1
0
Fork 0

Closes #292: Adds placeholder advanced settings fragments (#638)

master
Sawyer Blatz 2019-02-25 14:05:19 -08:00 committed by GitHub
parent 5b8d40e6e0
commit 56dadad35a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 188 additions and 14 deletions

View File

@ -0,0 +1,23 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.settings
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceFragmentCompat
import org.mozilla.fenix.R
class AccessibilityFragment : PreferenceFragmentCompat() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activity as AppCompatActivity).title = getString(R.string.preferences_accessibility)
(activity as AppCompatActivity).supportActionBar?.show()
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.accessibility_preferences, rootKey)
}
}

View File

@ -0,0 +1,23 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.settings
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceFragmentCompat
import org.mozilla.fenix.R
class DataChoicesFragment : PreferenceFragmentCompat() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activity as AppCompatActivity).title = getString(R.string.preferences_data_choices)
(activity as AppCompatActivity).supportActionBar?.show()
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.data_choices_preferences, rootKey)
}
}

View File

@ -20,17 +20,26 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlin.coroutines.CoroutineContext
import java.io.File
import mozilla.components.support.ktx.android.graphics.toDataUri
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.FenixApplication
import org.mozilla.fenix.R
import org.mozilla.fenix.R.string.pref_key_leakcanary
import org.mozilla.fenix.R.string.pref_key_make_default_browser
import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.ext.requireComponents
import java.io.File
import kotlin.coroutines.CoroutineContext
import org.mozilla.fenix.R
import org.mozilla.fenix.R.string.pref_key_leakcanary
import org.mozilla.fenix.R.string.pref_key_feedback
import org.mozilla.fenix.R.string.pref_key_help
import org.mozilla.fenix.R.string.pref_key_make_default_browser
import org.mozilla.fenix.R.string.pref_key_rate
import org.mozilla.fenix.R.string.pref_key_site_permissions
import org.mozilla.fenix.R.string.pref_key_accessibility
import org.mozilla.fenix.R.string.pref_key_language
import org.mozilla.fenix.R.string.pref_key_data_choices
import org.mozilla.fenix.R.string.pref_key_about
@Suppress("TooManyFunctions")
class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope {
private lateinit var job: Job
@ -54,21 +63,34 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope {
setupPreferences()
}
@Suppress("ComplexMethod")
override fun onPreferenceTreeClick(preference: Preference): Boolean {
when (preference.key) {
resources.getString(R.string.pref_key_help) -> {
resources.getString(pref_key_site_permissions) -> {
navigateToSitePermissions()
}
resources.getString(pref_key_accessibility) -> {
navigateToAccessibility()
}
resources.getString(pref_key_language) -> {
// TODO open language switcher
}
resources.getString(pref_key_data_choices) -> {
navigateToDataChoices()
}
resources.getString(pref_key_help) -> {
requireComponents.useCases.tabsUseCases.addTab
.invoke(SupportUtils.getSumoURLForTopic(context!!, SupportUtils.SumoTopic.HELP))
navigateToSettingsArticle()
}
resources.getString(R.string.pref_key_rate) -> {
resources.getString(pref_key_rate) -> {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(SupportUtils.RATE_APP_URL)))
}
resources.getString(R.string.pref_key_feedback) -> {
resources.getString(pref_key_feedback) -> {
requireComponents.useCases.tabsUseCases.addTab.invoke(SupportUtils.FEEDBACK_URL)
navigateToSettingsArticle()
}
resources.getString(R.string.pref_key_about) -> {
resources.getString(pref_key_about) -> {
requireComponents.useCases.tabsUseCases.addTab.invoke(aboutURL, true)
navigateToSettingsArticle()
}
@ -144,11 +166,26 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope {
}
}
private fun navigateToSitePermissions() {
val directions = SettingsFragmentDirections.actionSettingsFragmentToSitePermissionsFragment()
Navigation.findNavController(view!!).navigate(directions)
}
private fun navigateToAccessibility() {
val directions = SettingsFragmentDirections.actionSettingsFragmentToAccessibilityFragment()
Navigation.findNavController(view!!).navigate(directions)
}
private fun navigateToDataChoices() {
val directions = SettingsFragmentDirections.actionSettingsFragmentToDataChoicesFragment()
Navigation.findNavController(view!!).navigate(directions)
}
private fun navigateToSettingsArticle() {
requireComponents.useCases.tabsUseCases.addTab.invoke(aboutURL, true)
val newSession = requireComponents.core.sessionManager.selectedSession?.id
view?.let {
Navigation.findNavController(it)
.navigate(SettingsFragmentDirections.actionGlobalBrowser(null))
.navigate(SettingsFragmentDirections.actionGlobalBrowser(newSession))
}
}

View File

@ -0,0 +1,23 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.settings
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceFragmentCompat
import org.mozilla.fenix.R
class SitePermissionsFragment : PreferenceFragmentCompat() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activity as AppCompatActivity).title = getString(R.string.preferences_site_permissions)
(activity as AppCompatActivity).supportActionBar?.show()
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.site_permissions_preferences, rootKey)
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

View File

@ -87,5 +87,23 @@
<fragment
android:id="@+id/settingsFragment"
android:name="org.mozilla.fenix.settings.SettingsFragment"
android:label="@string/settings_title" />
android:label="@string/settings_title" >
<action
android:id="@+id/action_settingsFragment_to_browserFragment"
app:destination="@id/browserFragment"
app:popUpTo="@+id/settingsFragment" />
<action android:id="@+id/action_settingsFragment_to_dataChoicesFragment"
app:destination="@id/dataChoicesFragment" app:popUpTo="@+id/settingsFragment"/>
<action android:id="@+id/action_settingsFragment_to_sitePermissionsFragment"
app:destination="@id/sitePermissionsFragment"/>
<action android:id="@+id/action_settingsFragment_to_accessibilityFragment"
app:destination="@id/accessibilityFragment"/>
</fragment>
<fragment android:id="@+id/dataChoicesFragment" android:name="org.mozilla.fenix.settings.DataChoicesFragment"
android:label="DataChoicesFragment"/>
<fragment android:id="@+id/sitePermissionsFragment"
android:name="org.mozilla.fenix.settings.SitePermissionsFragment"
android:label="SitePermissionsFragment"/>
<fragment android:id="@+id/accessibilityFragment" android:name="org.mozilla.fenix.settings.AccessibilityFragment"
android:label="AccessibilityFragment"/>
</navigation>

View File

@ -41,8 +41,7 @@ img#wordmark {
</style>
</head>
<html>
<body
class="about">
<body class="about">
<br>
<img src="%wordmark%" id="wordmark"/>
<br>

View File

@ -19,4 +19,12 @@
<string name="pref_key_private_mode" translatable="false">pref_key_private_mode</string>
<string name="pref_key_theme" translatable="false">pref_key_theme</string>
<string name="pref_key_leakcanary" translatable="false">pref_key_leakcanary</string>
<!-- Data Choices -->
<string name="pref_key_telemetry" translatable="false">pref_key_telemetry</string>
<string name="pref_key_crash_reporter" translatable="false">pref_key_crash_reporter</string>
<string name="pref_key_mozilla_location_service" translatable="false">pref_key_mozilla_location_service</string>
<string name="pref_key_fenix_health_report" translatable="false">pref_key_fenix_health_report</string>
</resources>

View File

@ -109,6 +109,16 @@
<!-- Preference for developers -->
<string name="preference_leakcanary">Leak Canary</string>
<!-- Advanced Preferences -->
<!-- Preference switch for Telemetry -->
<string name="preferences_telemetry">Telemetry</string>
<!-- Preference switch for crash reporter -->
<string name="preferences_crash_reporter">Crash reporter</string>
<!-- Preference switch for Mozilla location service -->
<string name="preferences_mozilla_location_service">Mozilla location service</string>
<!-- Preference switch for app health report. -->
<string name="preferences_fenix_health_report">Fenix health report</string>
<!-- Library -->
<!-- Option in Library to open Sessions page -->
<string name="library_sessions">Sessions</string>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
</PreferenceScreen>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.SwitchPreference
android:key="@string/pref_key_make_default_browser"
android:title="@string/preferences_telemetry" />
<androidx.preference.SwitchPreference
android:key="@string/pref_key_make_default_browser"
android:title="@string/preferences_crash_reporter" />
<androidx.preference.SwitchPreference
android:key="@string/pref_key_make_default_browser"
android:title="@string/preferences_mozilla_location_service" />
<androidx.preference.SwitchPreference
android:key="@string/pref_key_make_default_browser"
android:title="@string/preferences_fenix_health_report" />
</PreferenceScreen>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
</PreferenceScreen>