comment #702 - Separated settings
This commit is contained in:
parent
9466a76071
commit
2164c2fe91
|
@ -392,8 +392,8 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
boolean confirmFav = sharedpreferences.getBoolean(context.getString(R.string.SET_NOTIF_VALIDATION_FAV), false);
|
||||
boolean confirmBoost = sharedpreferences.getBoolean(context.getString(R.string.SET_NOTIF_VALIDATION), true);
|
||||
boolean fullAttachement = sharedpreferences.getBoolean(context.getString(R.string.SET_FULL_PREVIEW), false);
|
||||
boolean displayBookmark = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_BOOKMARK), true);
|
||||
boolean displayTranslate = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_TRANSLATE), false);
|
||||
boolean displayBookmark = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_BOOKMARK) + MainActivity.currentUserID + MainActivity.currentInstance, true);
|
||||
boolean displayTranslate = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_TRANSLATE) + MainActivity.currentUserID + MainActivity.currentInstance, false);
|
||||
boolean displayCounters = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_COUNTER_FAV_BOOST), false);
|
||||
boolean removeLeftMargin = sharedpreferences.getBoolean(context.getString(R.string.SET_REMOVE_LEFT_MARGIN), false);
|
||||
boolean extraFeatures = sharedpreferences.getBoolean(context.getString(R.string.SET_EXTAND_EXTRA_FEATURES) + MainActivity.currentUserID + MainActivity.currentInstance, false);
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
package app.fedilab.android.ui.fragment.settings;
|
||||
/* Copyright 2022 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Fedilab
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreferenceCompat;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
|
||||
public class FragmentExtraFeaturesSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.pref_extra_features);
|
||||
createPref();
|
||||
}
|
||||
|
||||
private void createPref() {
|
||||
|
||||
getPreferenceScreen().removeAll();
|
||||
addPreferencesFromResource(R.xml.pref_extra_features);
|
||||
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||
SwitchPreferenceCompat SET_EXTAND_EXTRA_FEATURES = findPreference(getString(R.string.SET_EXTAND_EXTRA_FEATURES));
|
||||
if (SET_EXTAND_EXTRA_FEATURES != null) {
|
||||
boolean checked = sharedpreferences.getBoolean(getString(R.string.SET_EXTAND_EXTRA_FEATURES) + MainActivity.currentUserID + MainActivity.currentInstance, false);
|
||||
SET_EXTAND_EXTRA_FEATURES.setChecked(checked);
|
||||
}
|
||||
SwitchPreferenceCompat SET_DISPLAY_BOOKMARK = findPreference(getString(R.string.SET_DISPLAY_BOOKMARK));
|
||||
if (SET_DISPLAY_BOOKMARK != null) {
|
||||
boolean checked = sharedpreferences.getBoolean(getString(R.string.SET_DISPLAY_BOOKMARK) + MainActivity.currentUserID + MainActivity.currentInstance, true);
|
||||
SET_DISPLAY_BOOKMARK.setChecked(checked);
|
||||
}
|
||||
SwitchPreferenceCompat SET_DISPLAY_TRANSLATE = findPreference(getString(R.string.SET_DISPLAY_TRANSLATE));
|
||||
if (SET_DISPLAY_TRANSLATE != null) {
|
||||
boolean checked = sharedpreferences.getBoolean(getString(R.string.SET_DISPLAY_TRANSLATE) + MainActivity.currentUserID + MainActivity.currentInstance, false);
|
||||
SET_DISPLAY_TRANSLATE.setChecked(checked);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (getActivity() != null) {
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
if (key.compareToIgnoreCase(getString(R.string.SET_EXTAND_EXTRA_FEATURES)) == 0) {
|
||||
SwitchPreferenceCompat SET_EXTAND_EXTRA_FEATURES = findPreference(getString(R.string.SET_EXTAND_EXTRA_FEATURES));
|
||||
if (SET_EXTAND_EXTRA_FEATURES != null) {
|
||||
editor.putBoolean(getString(R.string.SET_EXTAND_EXTRA_FEATURES) + MainActivity.currentUserID + MainActivity.currentInstance, SET_EXTAND_EXTRA_FEATURES.isChecked());
|
||||
}
|
||||
}
|
||||
if (key.compareToIgnoreCase(getString(R.string.SET_DISPLAY_BOOKMARK)) == 0) {
|
||||
SwitchPreferenceCompat SET_DISPLAY_BOOKMARK = findPreference(getString(R.string.SET_DISPLAY_BOOKMARK));
|
||||
if (SET_DISPLAY_BOOKMARK != null) {
|
||||
editor.putBoolean(getString(R.string.SET_DISPLAY_BOOKMARK) + MainActivity.currentUserID + MainActivity.currentInstance, SET_DISPLAY_BOOKMARK.isChecked());
|
||||
}
|
||||
}
|
||||
if (key.compareToIgnoreCase(getString(R.string.SET_DISPLAY_TRANSLATE)) == 0) {
|
||||
SwitchPreferenceCompat SET_DISPLAY_TRANSLATE = findPreference(getString(R.string.SET_DISPLAY_TRANSLATE));
|
||||
if (SET_DISPLAY_TRANSLATE != null) {
|
||||
editor.putBoolean(getString(R.string.SET_DISPLAY_TRANSLATE) + MainActivity.currentUserID + MainActivity.currentInstance, SET_DISPLAY_TRANSLATE.isChecked());
|
||||
}
|
||||
}
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
getPreferenceScreen().getSharedPreferences()
|
||||
.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
getPreferenceScreen().getSharedPreferences()
|
||||
.unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -108,6 +108,7 @@ public class FragmentInterfaceSettings extends PreferenceFragmentCompat implemen
|
|||
if (SET_EXTAND_EXTRA_FEATURES != null) {
|
||||
editor.putBoolean(getString(R.string.SET_EXTAND_EXTRA_FEATURES) + MainActivity.currentUserID + MainActivity.currentInstance, SET_EXTAND_EXTRA_FEATURES.isChecked());
|
||||
}
|
||||
recreate = true;
|
||||
}
|
||||
if (key.compareToIgnoreCase(getString(R.string.SET_LOGO_LAUNCHER)) == 0) {
|
||||
ListPreference SET_LOGO_LAUNCHER = findPreference(getString(R.string.SET_LOGO_LAUNCHER));
|
||||
|
|
|
@ -121,6 +121,16 @@ public class FragmentSettingsCategories extends PreferenceFragmentCompat {
|
|||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
Preference pref_category_key_extra_features = findPreference(getString(R.string.pref_category_key_extra_features));
|
||||
if (pref_category_key_extra_features != null) {
|
||||
pref_category_key_extra_features.setOnPreferenceClickListener(preference -> {
|
||||
NavController navController = Navigation.findNavController(requireActivity(), R.id.fragment_container);
|
||||
navController.navigate(FragmentSettingsCategoriesDirections.Companion.categoriesToExtraFeatures());
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
ActivityResultLauncher<String> permissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> {
|
||||
if (isGranted) {
|
||||
try {
|
||||
|
|
|
@ -22,8 +22,10 @@ import androidx.preference.ListPreference;
|
|||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreferenceCompat;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
|
||||
public class FragmentTimelinesSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
@ -37,6 +39,7 @@ public class FragmentTimelinesSettings extends PreferenceFragmentCompat implemen
|
|||
private void createPref() {
|
||||
|
||||
getPreferenceScreen().removeAll();
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||
addPreferencesFromResource(R.xml.pref_timelines);
|
||||
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||
ListPreference SET_LOAD_MEDIA_TYPE = findPreference(getString(R.string.SET_LOAD_MEDIA_TYPE));
|
||||
|
@ -60,6 +63,16 @@ public class FragmentTimelinesSettings extends PreferenceFragmentCompat implemen
|
|||
preferenceScreen.removePreferenceRecursively("SET_TRANSLATOR_VERSION");
|
||||
}
|
||||
}
|
||||
SwitchPreferenceCompat SET_DISPLAY_BOOKMARK = findPreference(getString(R.string.SET_DISPLAY_BOOKMARK));
|
||||
if (SET_DISPLAY_BOOKMARK != null) {
|
||||
boolean checked = sharedpreferences.getBoolean(getString(R.string.SET_DISPLAY_BOOKMARK) + MainActivity.currentUserID + MainActivity.currentInstance, true);
|
||||
SET_DISPLAY_BOOKMARK.setChecked(checked);
|
||||
}
|
||||
SwitchPreferenceCompat SET_DISPLAY_TRANSLATE = findPreference(getString(R.string.SET_DISPLAY_TRANSLATE));
|
||||
if (SET_DISPLAY_TRANSLATE != null) {
|
||||
boolean checked = sharedpreferences.getBoolean(getString(R.string.SET_DISPLAY_TRANSLATE) + MainActivity.currentUserID + MainActivity.currentInstance, false);
|
||||
SET_DISPLAY_TRANSLATE.setChecked(checked);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,10 +80,22 @@ public class FragmentTimelinesSettings extends PreferenceFragmentCompat implemen
|
|||
if (getActivity() != null) {
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.apply();
|
||||
if (key.compareToIgnoreCase(getString(R.string.SET_TRANSLATOR)) == 0) {
|
||||
createPref();
|
||||
}
|
||||
if (key.compareToIgnoreCase(getString(R.string.SET_DISPLAY_BOOKMARK)) == 0) {
|
||||
SwitchPreferenceCompat SET_DISPLAY_BOOKMARK = findPreference(getString(R.string.SET_DISPLAY_BOOKMARK));
|
||||
if (SET_DISPLAY_BOOKMARK != null) {
|
||||
editor.putBoolean(getString(R.string.SET_DISPLAY_BOOKMARK) + MainActivity.currentUserID + MainActivity.currentInstance, SET_DISPLAY_BOOKMARK.isChecked());
|
||||
}
|
||||
}
|
||||
if (key.compareToIgnoreCase(getString(R.string.SET_DISPLAY_TRANSLATE)) == 0) {
|
||||
SwitchPreferenceCompat SET_DISPLAY_TRANSLATE = findPreference(getString(R.string.SET_DISPLAY_TRANSLATE));
|
||||
if (SET_DISPLAY_TRANSLATE != null) {
|
||||
editor.putBoolean(getString(R.string.SET_DISPLAY_TRANSLATE) + MainActivity.currentUserID + MainActivity.currentInstance, SET_DISPLAY_TRANSLATE.isChecked());
|
||||
}
|
||||
}
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/black"
|
||||
android:pathData="M20.5,11H19V7c0,-1.1 -0.9,-2 -2,-2h-4V3.5C13,2.12 11.88,1 10.5,1S8,2.12 8,3.5V5H4c-1.1,0 -1.99,0.9 -1.99,2v3.8H3.5c1.49,0 2.7,1.21 2.7,2.7s-1.21,2.7 -2.7,2.7H2V20c0,1.1 0.9,2 2,2h3.8v-1.5c0,-1.49 1.21,-2.7 2.7,-2.7 1.49,0 2.7,1.21 2.7,2.7V22H17c1.1,0 2,-0.9 2,-2v-4h1.5c1.38,0 2.5,-1.12 2.5,-2.5S21.88,11 20.5,11z" />
|
||||
</vector>
|
|
@ -68,6 +68,14 @@
|
|||
app:exitAnim="@anim/exit"
|
||||
app:popEnterAnim="@anim/pop_enter"
|
||||
app:popExitAnim="@anim/pop_exit" />
|
||||
|
||||
<action
|
||||
android:id="@+id/categories_to_extra_features"
|
||||
app:destination="@id/FragmentExtraFeaturesSettings"
|
||||
app:enterAnim="@anim/enter"
|
||||
app:exitAnim="@anim/exit"
|
||||
app:popEnterAnim="@anim/pop_enter"
|
||||
app:popExitAnim="@anim/pop_exit" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
|
@ -105,6 +113,11 @@
|
|||
android:name="app.fedilab.android.ui.fragment.settings.FragmentLanguageSettings"
|
||||
android:label="@string/languages" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/FragmentExtraFeaturesSettings"
|
||||
android:name="app.fedilab.android.ui.fragment.settings.FragmentExtraFeaturesSettings"
|
||||
android:label="@string/set_extand_extra_features_title" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/FragmentCustomLightSettings"
|
||||
android:name="app.fedilab.android.ui.fragment.settings.FragmentCustomLightSettings"
|
||||
|
|
|
@ -1956,6 +1956,8 @@
|
|||
<string name="pref_category_key_theming" translatable="false">pref_category_theming</string>
|
||||
<string name="pref_category_key_administration" translatable="false">pref_category_administration</string>
|
||||
<string name="pref_category_key_languages" translatable="false">pref_category_languages</string>
|
||||
<string name="pref_category_key_extra_features" translatable="false">pref_category_key_extra_features</string>
|
||||
|
||||
<string name="pref_export_settings" translatable="false">pref_export_settings</string>
|
||||
<string name="pref_import_settings" translatable="false">pref_import_settings</string>
|
||||
<string name="export_settings">Export settings</string>
|
||||
|
@ -2150,4 +2152,6 @@
|
|||
<string name="set_translator_version">Translator version</string>
|
||||
<string name="set_extand_extra_features_title">Extra features</string>
|
||||
<string name="set_extand_extra_features">By enabling that option the app will display extra features. This feature is done for social softwares like Pleroma, Akkoma or Glitch Social</string>
|
||||
<string name="icons_visibility">Icons visibility</string>
|
||||
<string name="icons_visibility_summary">You can safely hide these icons at the bottom to have more space. They are also in the submenu.</string>
|
||||
</resources>
|
|
@ -70,6 +70,13 @@
|
|||
app:key="@string/pref_category_key_languages" />
|
||||
|
||||
|
||||
<Preference
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:title="@string/set_extand_extra_features_title"
|
||||
app:icon="@drawable/ic_baseline_extension_24"
|
||||
app:key="@string/pref_category_key_extra_features" />
|
||||
|
||||
<Preference
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="false"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="@string/SET_EXTAND_EXTRA_FEATURES"
|
||||
app:singleLineTitle="false"
|
||||
app:summary="@string/set_extand_extra_features"
|
||||
app:title="@string/set_extand_extra_features_title" />
|
||||
<app.fedilab.android.helper.settings.LongSummaryPreferenceCategory
|
||||
app:dependency="@string/SET_EXTAND_EXTRA_FEATURES"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="bottom_icon"
|
||||
app:summary="@string/icons_visibility_summary"
|
||||
app:title="@string/icons_visibility">
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="@string/SET_DISPLAY_BOOKMARK"
|
||||
app:singleLineTitle="false"
|
||||
app:title="@string/set_display_bookmark_indication" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="@string/SET_DISPLAY_TRANSLATE"
|
||||
app:singleLineTitle="false"
|
||||
app:title="@string/set_display_translate_indication" />
|
||||
</app.fedilab.android.helper.settings.LongSummaryPreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
|
@ -28,14 +28,6 @@
|
|||
app:summary="@string/set_remove_left_margin"
|
||||
app:title="@string/set_remove_left_margin_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="false"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="@string/SET_EXTAND_EXTRA_FEATURES"
|
||||
app:singleLineTitle="false"
|
||||
app:summary="@string/set_extand_extra_features"
|
||||
app:title="@string/set_extand_extra_features_title" />
|
||||
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="true"
|
||||
|
|
Loading…
Reference in New Issue