2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/982 - Opens privacy policy in a custom tab

This commit is contained in:
Jeff Boek 2019-05-20 15:05:10 -07:00
parent b19827859d
commit c0e9d4b0a1
4 changed files with 32 additions and 2 deletions

View File

@ -6,14 +6,29 @@ package org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding
import android.view.View import android.view.View
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.onboarding_theme_picker.view.* import kotlinx.android.synthetic.main.onboarding_privacy_notice.view.*
import kotlinx.android.synthetic.main.onboarding_privacy_notice.view.description_text
import kotlinx.android.synthetic.main.onboarding_privacy_notice.view.header_text
import org.jetbrains.anko.dimen
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.settings.SupportUtils
class OnboardingPrivacyNoticeViewHolder(view: View) : RecyclerView.ViewHolder(view) { class OnboardingPrivacyNoticeViewHolder(view: View) : RecyclerView.ViewHolder(view) {
init { init {
val icon = view.context.getDrawable(R.drawable.ic_onboarding_privacy_notice)
val size = view.context.dimen(R.dimen.onboarding_privacy_notice_icon_height_width)
icon?.setBounds(0, 0, size, size)
view.header_text.setCompoundDrawables(icon, null, null, null)
val appName = view.context.getString(R.string.app_name) val appName = view.context.getString(R.string.app_name)
view.description_text.text = view.context.getString(R.string.onboarding_privacy_notice_description, appName) view.description_text.text = view.context.getString(R.string.onboarding_privacy_notice_description, appName)
view.read_button.setOnClickListener {
val intent = SupportUtils.createCustomTabIntent(view.context, SupportUtils.PRIVACY_NOTICE_URL)
view.context.startActivity(intent)
}
} }
companion object { companion object {

View File

@ -5,8 +5,11 @@
package org.mozilla.fenix.settings package org.mozilla.fenix.settings
import android.content.Context import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.net.Uri
import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.IntentReceiverActivity
import java.io.UnsupportedEncodingException import java.io.UnsupportedEncodingException
import java.net.URLEncoder import java.net.URLEncoder
import java.util.Locale import java.util.Locale
@ -15,6 +18,8 @@ object SupportUtils {
const val FEEDBACK_URL = "https://input.mozilla.org" const val FEEDBACK_URL = "https://input.mozilla.org"
const val RATE_APP_URL = "market://details?id=" + BuildConfig.APPLICATION_ID const val RATE_APP_URL = "market://details?id=" + BuildConfig.APPLICATION_ID
const val MOZILLA_MANIFESTO_URL = "https://www.mozilla.org/en-GB/about/manifesto/" const val MOZILLA_MANIFESTO_URL = "https://www.mozilla.org/en-GB/about/manifesto/"
val PRIVACY_NOTICE_URL: String
get() = "https://www.mozilla.org/${getLanguageTag(Locale.getDefault())}/privacy/firefox/"
enum class SumoTopic( enum class SumoTopic(
internal val topicStr: String internal val topicStr: String
@ -38,6 +43,14 @@ object SupportUtils {
return "https://support.mozilla.org/$langTag/kb/$escapedTopic" return "https://support.mozilla.org/$langTag/kb/$escapedTopic"
} }
fun createCustomTabIntent(context: Context, url: String) = Intent(Intent.ACTION_VIEW).apply {
putExtra("android.support.customtabs.extra.SESSION", true)
setClassName(context.applicationContext, IntentReceiverActivity::class.java.name)
data = Uri.parse(url)
setPackage(context.packageName)
}
private fun getEncodedTopicUTF8(topic: String): String { private fun getEncodedTopicUTF8(topic: String): String {
try { try {
return URLEncoder.encode(topic, "UTF-8") return URLEncoder.encode(topic, "UTF-8")

View File

@ -30,7 +30,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:background="@drawable/button_background" android:background="@drawable/button_background"
android:backgroundTint="?shadow" android:backgroundTint="?neutralFaded"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:foreground="?android:attr/selectableItemBackground" android:foreground="?android:attr/selectableItemBackground"

View File

@ -33,4 +33,6 @@
<!--Quick Settings--> <!--Quick Settings-->
<dimen name="quicksettings_item_height">46dp</dimen> <dimen name="quicksettings_item_height">46dp</dimen>
<dimen name="onboarding_privacy_notice_icon_height_width">32dp</dimen>
</resources> </resources>