mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-01-31 00:45:00 +01:00
restarts activity when some theme preference changed
This commit is contained in:
parent
f9e45f968f
commit
c5ec57652f
@ -214,6 +214,7 @@ public interface IntentConstants {
|
|||||||
public static final String EXTRA_EXTRAS = "extras";
|
public static final String EXTRA_EXTRAS = "extras";
|
||||||
public static final String EXTRA_MY_FOLLOWING_ONLY = "my_following_only";
|
public static final String EXTRA_MY_FOLLOWING_ONLY = "my_following_only";
|
||||||
public static final String EXTRA_CHANGED = "changed";
|
public static final String EXTRA_CHANGED = "changed";
|
||||||
|
public static final String EXTRA_NOTIFY_CHANGE = "notify_change";
|
||||||
public static final String EXTRA_FROM_USER = "from_user";
|
public static final String EXTRA_FROM_USER = "from_user";
|
||||||
public static final String EXTRA_SHOW_MEDIA_PREVIEW = "show_media_preview";
|
public static final String EXTRA_SHOW_MEDIA_PREVIEW = "show_media_preview";
|
||||||
public static final String EXTRA_SHOW_EXTRA_TYPE = "show_extra_type";
|
public static final String EXTRA_SHOW_EXTRA_TYPE = "show_extra_type";
|
||||||
|
@ -21,26 +21,30 @@ package org.mariotaku.twidere.fragment;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import org.mariotaku.twidere.activity.SettingsActivity;
|
||||||
import org.mariotaku.twidere.util.Utils;
|
import org.mariotaku.twidere.util.Utils;
|
||||||
|
|
||||||
public class SettingsDetailsFragment extends BasePreferenceFragment {
|
public class SettingsDetailsFragment extends BasePreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(final Bundle savedInstanceState) {
|
public void onActivityCreated(final Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
final PreferenceManager preferenceManager = getPreferenceManager();
|
||||||
final PreferenceScreen defaultScreen = getPreferenceScreen();
|
final PreferenceScreen defaultScreen = getPreferenceScreen();
|
||||||
final PreferenceScreen preferenceScreen;
|
final PreferenceScreen preferenceScreen;
|
||||||
if (defaultScreen != null) {
|
if (defaultScreen != null) {
|
||||||
defaultScreen.removeAll();
|
defaultScreen.removeAll();
|
||||||
preferenceScreen = defaultScreen;
|
preferenceScreen = defaultScreen;
|
||||||
} else {
|
} else {
|
||||||
preferenceScreen = getPreferenceManager().createPreferenceScreen(getActivity());
|
preferenceScreen = preferenceManager.createPreferenceScreen(getActivity());
|
||||||
}
|
}
|
||||||
setPreferenceScreen(preferenceScreen);
|
setPreferenceScreen(preferenceScreen);
|
||||||
final Bundle args = getArguments();
|
final Bundle args = getArguments();
|
||||||
@ -72,4 +76,27 @@ public class SettingsDetailsFragment extends BasePreferenceFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
final SharedPreferences preferences = getPreferenceManager().getSharedPreferences();
|
||||||
|
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
final SharedPreferences preferences = getPreferenceManager().getSharedPreferences();
|
||||||
|
preferences.unregisterOnSharedPreferenceChangeListener(this);
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
|
final Preference preference = findPreference(key);
|
||||||
|
if (preference == null) return;
|
||||||
|
final Bundle extras = preference.getExtras();
|
||||||
|
if (extras != null && extras.containsKey(EXTRA_NOTIFY_CHANGE)) {
|
||||||
|
SettingsActivity.setShouldNotifyChange(getActivity());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,88 +1,118 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:title="@string/cards">
|
android:title="@string/cards">
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="cat_card_preview"
|
android:key="cat_card_preview"
|
||||||
android:order="11"
|
android:order="11"
|
||||||
android:title="@string/preview">
|
android:title="@string/preview">
|
||||||
<org.mariotaku.twidere.preference.CardPreviewPreference android:key="card_preview"/>
|
<org.mariotaku.twidere.preference.CardPreviewPreference android:key="card_preview" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="name_first"
|
android:key="name_first"
|
||||||
android:order="22"
|
android:order="22"
|
||||||
android:title="@string/name_first"/>
|
android:title="@string/name_first">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
|
||||||
|
|
||||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="display_profile_image"
|
android:key="display_profile_image"
|
||||||
android:order="23"
|
android:order="23"
|
||||||
android:title="@string/profile_image"/>
|
android:title="@string/profile_image">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
|
||||||
<org.mariotaku.twidere.preference.SummaryListPreference
|
<org.mariotaku.twidere.preference.SummaryListPreference
|
||||||
android:defaultValue="@string/default_profile_image_style"
|
android:defaultValue="@string/default_profile_image_style"
|
||||||
android:entries="@array/entries_profile_image_style"
|
android:entries="@array/entries_profile_image_style"
|
||||||
android:entryValues="@array/values_profile_image_style"
|
android:entryValues="@array/values_profile_image_style"
|
||||||
android:key="profile_image_style"
|
android:key="profile_image_style"
|
||||||
android:order="24"
|
android:order="24"
|
||||||
android:title="@string/profile_image_style"/>
|
android:title="@string/profile_image_style">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.SummaryListPreference>
|
||||||
|
|
||||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="media_preview"
|
android:key="media_preview"
|
||||||
android:order="25"
|
android:order="25"
|
||||||
android:title="@string/media_preview"/>
|
android:title="@string/media_preview">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
|
||||||
<org.mariotaku.twidere.preference.SummaryListPreference
|
<org.mariotaku.twidere.preference.SummaryListPreference
|
||||||
android:defaultValue="crop"
|
android:defaultValue="crop"
|
||||||
android:entries="@array/entries_media_preview_style"
|
android:entries="@array/entries_media_preview_style"
|
||||||
android:entryValues="@array/values_media_preview_style"
|
android:entryValues="@array/values_media_preview_style"
|
||||||
android:key="media_preview_style"
|
android:key="media_preview_style"
|
||||||
android:order="26"
|
android:order="26"
|
||||||
android:title="@string/media_preview_style"/>
|
android:title="@string/media_preview_style">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.SummaryListPreference>
|
||||||
|
|
||||||
<org.mariotaku.twidere.preference.LinkHighlightPreference
|
<org.mariotaku.twidere.preference.LinkHighlightPreference
|
||||||
android:defaultValue="none"
|
android:defaultValue="none"
|
||||||
android:key="link_highlight_option"
|
android:key="link_highlight_option"
|
||||||
android:order="27"
|
android:order="27"
|
||||||
android:title="@string/link_highlight_option"/>
|
android:title="@string/link_highlight_option">
|
||||||
|
<extra
|
||||||
<!--<org.mariotaku.twidere.preference.AutoInvalidateListPreference-->
|
android:name="notify_change"
|
||||||
<!--android:defaultValue="background"-->
|
android:value="true" />
|
||||||
<!--android:entries="@array/entries_card_highlight_option"-->
|
</org.mariotaku.twidere.preference.LinkHighlightPreference>
|
||||||
<!--android:entryValues="@array/values_card_highlight_option"-->
|
|
||||||
<!--android:key="card_highlight_option"-->
|
|
||||||
<!--android:order="28"-->
|
|
||||||
<!--android:summary="%s"-->
|
|
||||||
<!--android:title="@string/card_highlight_option"/>-->
|
|
||||||
|
|
||||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="indicate_my_status"
|
android:key="indicate_my_status"
|
||||||
android:order="29"
|
android:order="29"
|
||||||
android:title="@string/indicate_your_status"/>
|
android:title="@string/indicate_your_status" />
|
||||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="show_absolute_time"
|
android:key="show_absolute_time"
|
||||||
android:order="30"
|
android:order="30"
|
||||||
android:summary="@string/show_absolute_time_summary"
|
android:summary="@string/show_absolute_time_summary"
|
||||||
android:title="@string/show_absolute_time"/>
|
android:title="@string/show_absolute_time">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
|
||||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="card_animation"
|
android:key="card_animation"
|
||||||
android:order="31"
|
android:order="31"
|
||||||
android:title="@string/card_animation"/>
|
android:title="@string/card_animation">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
|
||||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="compact_cards"
|
android:key="compact_cards"
|
||||||
android:order="32"
|
android:order="32"
|
||||||
android:summary="@string/compact_cards_summary"
|
android:summary="@string/compact_cards_summary"
|
||||||
android:title="@string/compact_cards"/>
|
android:title="@string/compact_cards">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
|
||||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="hide_card_actions"
|
android:key="hide_card_actions"
|
||||||
android:order="33"
|
android:order="33"
|
||||||
android:title="@string/hide_card_actions"/>
|
android:title="@string/hide_card_actions">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:title="@string/settings_interface">
|
android:title="@string/settings_interface">
|
||||||
|
|
||||||
@ -10,7 +9,11 @@
|
|||||||
android:defaultValue="sans-serif-light"
|
android:defaultValue="sans-serif-light"
|
||||||
android:enabled="@bool/has_font_family"
|
android:enabled="@bool/has_font_family"
|
||||||
android:key="theme_font_family"
|
android:key="theme_font_family"
|
||||||
android:title="@string/style"/>
|
android:title="@string/style">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.ThemeFontFamilyPreference>
|
||||||
|
|
||||||
<org.mariotaku.twidere.preference.SeekBarDialogPreference
|
<org.mariotaku.twidere.preference.SeekBarDialogPreference
|
||||||
android:defaultValue="@integer/default_text_size"
|
android:defaultValue="@integer/default_text_size"
|
||||||
@ -19,31 +22,39 @@
|
|||||||
android:title="@string/size"
|
android:title="@string/size"
|
||||||
app:max="24"
|
app:max="24"
|
||||||
app:min="12"
|
app:min="12"
|
||||||
app:progressTextSuffix="sp"/>
|
app:progressTextSuffix="sp">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.SeekBarDialogPreference>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="unread_count"
|
android:key="unread_count"
|
||||||
android:title="@string/unread_count"/>
|
android:title="@string/unread_count">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
|
||||||
|
|
||||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="leftside_compose_button"
|
android:key="leftside_compose_button"
|
||||||
android:summary="@string/leftside_compose_button_summary"
|
android:summary="@string/leftside_compose_button_summary"
|
||||||
android:title="@string/leftside_compose_button"/>
|
android:title="@string/leftside_compose_button" />
|
||||||
|
|
||||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
<!--<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference-->
|
||||||
android:defaultValue="false"
|
<!--android:defaultValue="false"-->
|
||||||
android:key="fast_scroll_thumb"
|
<!--android:key="fast_scroll_thumb"-->
|
||||||
android:title="@string/fast_scroll_thumb"/>
|
<!--android:title="@string/fast_scroll_thumb" />-->
|
||||||
|
|
||||||
<org.mariotaku.twidere.preference.SummaryListPreference
|
<org.mariotaku.twidere.preference.SummaryListPreference
|
||||||
android:defaultValue="@string/default_tab_display_option"
|
android:defaultValue="@string/default_tab_display_option"
|
||||||
android:entries="@array/entries_tab_display_option"
|
android:entries="@array/entries_tab_display_option"
|
||||||
android:entryValues="@array/values_tab_display_option"
|
android:entryValues="@array/values_tab_display_option"
|
||||||
android:key="tab_display_option"
|
android:key="tab_display_option"
|
||||||
android:title="@string/tab_display_option"/>
|
android:title="@string/tab_display_option" />
|
||||||
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:title="@string/theme">
|
android:title="@string/theme">
|
||||||
|
|
||||||
@ -8,8 +7,7 @@
|
|||||||
android:key="cat_theme_preview"
|
android:key="cat_theme_preview"
|
||||||
android:order="11"
|
android:order="11"
|
||||||
android:title="@string/preview">
|
android:title="@string/preview">
|
||||||
<org.mariotaku.twidere.preference.ThemePreviewPreference
|
<org.mariotaku.twidere.preference.ThemePreviewPreference android:key="theme_preview" />
|
||||||
android:key="theme_preview"/>
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<org.mariotaku.twidere.preference.SummaryListPreference
|
<org.mariotaku.twidere.preference.SummaryListPreference
|
||||||
@ -18,18 +16,30 @@
|
|||||||
android:entryValues="@array/values_theme"
|
android:entryValues="@array/values_theme"
|
||||||
android:key="theme"
|
android:key="theme"
|
||||||
android:order="21"
|
android:order="21"
|
||||||
android:title="@string/style"/>
|
android:title="@string/style">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.SummaryListPreference>
|
||||||
|
|
||||||
<org.mariotaku.twidere.preference.ThemeBackgroundPreference
|
<org.mariotaku.twidere.preference.ThemeBackgroundPreference
|
||||||
android:defaultValue="default"
|
android:defaultValue="default"
|
||||||
android:order="22"
|
android:order="22"
|
||||||
android:title="@string/background"/>
|
android:title="@string/background">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.ThemeBackgroundPreference>
|
||||||
|
|
||||||
<org.mariotaku.twidere.preference.ColorPickerPreference
|
<org.mariotaku.twidere.preference.ColorPickerPreference
|
||||||
android:key="theme_color"
|
android:key="theme_color"
|
||||||
android:order="25"
|
android:order="25"
|
||||||
android:title="@string/color"
|
android:title="@string/color"
|
||||||
app:defaultColor="@color/branding_color"/>
|
app:defaultColor="@color/branding_color">
|
||||||
|
<extra
|
||||||
|
android:name="notify_change"
|
||||||
|
android:value="true" />
|
||||||
|
</org.mariotaku.twidere.preference.ColorPickerPreference>
|
||||||
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
x
Reference in New Issue
Block a user