(fix) fix settings

Signed-off-by: androidacy-user <opensource@androidacy.com>
master
androidacy-user 1 year ago
parent 6a706b08d5
commit 2d201e2b64

@ -385,6 +385,23 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
}
ExternalHelper.INSTANCE.refreshHelper(this);
this.initMode = false;
// add preference listener to set isMatomoAllowed
SharedPreferences.OnSharedPreferenceChangeListener listener = (sharedPreferences, key) -> {
if (key.equals("pref_analytics_enabled")) {
MainApplication.getINSTANCE().isMatomoAllowed = sharedPreferences.getBoolean(key, false);
MainApplication.getINSTANCE().getTracker().setOptOut(MainApplication.getINSTANCE().isMatomoAllowed);
Timber.d("Matomo is allowed change: %s", MainApplication.getINSTANCE().isMatomoAllowed);
}
if (MainApplication.getINSTANCE().isMatomoAllowed) {
String value = sharedPreferences.getString(key, null);
// then log
if (value != null) {
TrackHelper.track().event("pref_changed", key + "=" + value).with(MainApplication.getINSTANCE().getTracker());
}
}
Timber.d("Preference changed: %s", key);
};
MainApplication.getPreferences("mmm").registerOnSharedPreferenceChangeListener(listener);
}
private void cardIconifyUpdate() {

@ -430,14 +430,6 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
// analytics
Timber.d("Initializing matomo");
isMatomoAllowed = isMatomoAllowed();
// add preference listener to set isMatomoAllowed
getPreferences("mmm").registerOnSharedPreferenceChangeListener((sharedPreferences, key) -> {
if (key.equals("pref_analytics_enabled")) {
isMatomoAllowed = sharedPreferences.getBoolean(key, false);
tracker.setOptOut(isMatomoAllowed);
Timber.d("Matomo is allowed change: %s", isMatomoAllowed);
}
});
getTracker();
if (!isMatomoAllowed) {
Timber.d("Matomo is not allowed");

@ -167,6 +167,8 @@ public class SetupActivity extends FoxActivity implements LanguageActivity {
Timber.d("Got editor: %s", editor);
// Set the Automatic update check pref
editor.putBoolean("pref_background_update_check", ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_background_update_check))).isChecked());
// require wifi pref
editor.putBoolean("pref_background_update_check_wifi", ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_background_update_check_require_wifi))).isChecked());
// Set the crash reporting pref
editor.putBoolean("pref_crash_reporting", ((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_crash_reporting))).isChecked());
// Set the crash reporting PII pref

@ -215,17 +215,6 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
assert preferenceManager != null;
setPreferencesFromResource(R.xml.root_preferences, rootKey);
applyMaterial3(getPreferenceScreen());
// track enabled prefs
dataStore.getSharedPreferences().registerOnSharedPreferenceChangeListener((sharedPreferences, key) -> {
// use trackHelper to log key and value
// get key and value first
String value = sharedPreferences.getString(key, null);
// then log
if (value != null) {
TrackHelper.track().event("pref_changed", key + "=" + value).with(MainApplication.getINSTANCE().getTracker());
}
});
// track all non empty values
SharedPreferences sharedPreferences = dataStore.getSharedPreferences();
// disabled until EncryptedSharedPreferences fixes getAll()

Loading…
Cancel
Save