This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For #1084 - Add Setting to enable/disable TP
- Loading branch information
1 parent
9b1c1b5
commit 068744e
Showing
10 changed files
with
129 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
app/src/main/java/org/mozilla/fenix/settings/TrackingProtectionFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* 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.Preference | ||
import androidx.preference.PreferenceFragmentCompat | ||
import org.mozilla.fenix.R | ||
import org.mozilla.fenix.ext.getPreferenceKey | ||
import org.mozilla.fenix.ext.requireComponents | ||
|
||
class TrackingProtectionFragment : PreferenceFragmentCompat() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
(activity as AppCompatActivity).title = getString(R.string.preferences_tracking_protection) | ||
(activity as AppCompatActivity).supportActionBar?.show() | ||
} | ||
|
||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { | ||
setPreferencesFromResource(R.xml.tracking_protection_preferences, rootKey) | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
// Tracking Protection Switch | ||
val trackingProtectionKey = | ||
context!!.getPreferenceKey(R.string.pref_key_tracking_protection) | ||
val preferenceTP = findPreference<Preference>(trackingProtectionKey) | ||
preferenceTP?.onPreferenceChangeListener = | ||
Preference.OnPreferenceChangeListener { _, newValue -> | ||
requireComponents.core.updateTrackingProtection(newValue as Boolean) | ||
true | ||
} | ||
|
||
// Exceptions | ||
val exceptions = | ||
context!!.getPreferenceKey(R.string.pref_key_tracking_protection_exceptions) | ||
val preferenceExceptions = findPreference<Preference>(exceptions) | ||
preferenceExceptions?.onPreferenceClickListener = getClickListenerForSignOut() | ||
} | ||
|
||
private fun getClickListenerForSignOut(): Preference.OnPreferenceClickListener { | ||
return Preference.OnPreferenceClickListener { | ||
// TODO go to Exceptions Fragment | ||
true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?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/. --> | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:fillColor="?attr/primaryTextColor" | ||
android:fillType="evenOdd" | ||
android:pathData="M20,6.047C19.9965,4.9927 19.2276,4.0971 18.186,3.934L12,2.912L5.816,3.933C4.7741,4.0968 4.0049,4.9923 4,6.047C4,7.729 4.012,9.954 4.111,11.005C4.411,14.205 5.033,15.96 6.56,17.954C7.8759,19.6329 9.7831,20.746 11.892,21.066L12,21.078L12.107,21.066C14.2159,20.746 16.1231,19.6329 17.439,17.954C18.967,15.96 19.584,14.206 19.888,11.005L19.888,11.005C19.993,9.891 20,7.421 20,6.047ZM17.9,10.815C17.63,13.659 17.152,15.043 15.855,16.739C14.8897,17.9499 13.5217,18.7739 12,19.061C10.4792,18.7737 9.1122,17.9496 8.148,16.739C6.848,15.039 6.372,13.659 6.103,10.816C6.031,10.059 6,8.367 6,6.054C6.0036,5.9768 6.0631,5.9138 6.14,5.906L12,4.939L17.861,5.907C17.9376,5.9135 17.9972,5.9762 18,6.053C18.005,8.328 17.968,10.064 17.9,10.815ZM8,7.626C8.015,9.593 8.066,10.365 8.091,10.626C8.347,13.326 8.785,14.282 9.733,15.526C10.3122,16.2484 11.1061,16.7677 12,17.009L12,6.967L8,7.626Z" /> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?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/. --> | ||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<SwitchPreference | ||
android:defaultValue="true" | ||
android:icon="@drawable/ic_tracking_protection" | ||
android:key="@string/pref_key_tracking_protection" | ||
android:summary="@string/preferences_tracking_protection_description" | ||
android:title="@string/preferences_tracking_protection" /> | ||
<Preference | ||
android:icon="@drawable/ic_internet" | ||
android:key="@string/pref_key_tracking_protection_exceptions" | ||
android:title="@string/preferences_tracking_protection_exceptions" /> | ||
</androidx.preference.PreferenceScreen> |