diff --git a/res/values/strings.xml b/res/values/strings.xml index e0d22960..7a228fad 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -808,9 +808,8 @@ Light width - QS tiles styles - Tiles layout - Customize tiles layout in QS panel + QS tiles customization + Style, layout, animation Tiles layout Rows (Portrait) Rows (Quick QS portrait) diff --git a/res/xml/bg_quicksettings.xml b/res/xml/bg_quicksettings.xml index 57db94fe..9b583365 100644 --- a/res/xml/bg_quicksettings.xml +++ b/res/xml/bg_quicksettings.xml @@ -70,13 +70,7 @@ - - + android:title="@string/interface_title"> - - - - - - - - - + + + + + + android:title="@string/qs_tiles_customization"> + + + + + + + + + + diff --git a/src/com/banana/settings/fragments/QsTileLayoutSettings.java b/src/com/banana/settings/fragments/QsTileCustomization.java similarity index 85% rename from src/com/banana/settings/fragments/QsTileLayoutSettings.java rename to src/com/banana/settings/fragments/QsTileCustomization.java index d3e3627c..8d4fb559 100644 --- a/src/com/banana/settings/fragments/QsTileLayoutSettings.java +++ b/src/com/banana/settings/fragments/QsTileCustomization.java @@ -26,7 +26,7 @@ import android.widget.Button; import android.widget.Toast; -import androidx.preference.Preference; +import androidx.preference.*; import com.android.internal.logging.nano.MetricsProto; import com.android.internal.util.banana.ThemeUtils; @@ -37,12 +37,13 @@ import com.android.settingslib.widget.LayoutPreference; +import com.banana.support.preferences.CustomSeekBarPreference; import com.banana.support.preferences.ProperSeekBarPreference; import com.banana.support.preferences.SystemSettingListPreference; import com.banana.support.preferences.SystemSettingSeekBarPreference; import com.banana.support.preferences.SystemSettingSwitchPreference; -public class QsTileLayoutSettings extends SettingsPreferenceFragment +public class QsTileCustomization extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener { private static final String KEY_QS_HIDE_LABEL = "qs_tile_label_hide"; @@ -56,6 +57,9 @@ public class QsTileLayoutSettings extends SettingsPreferenceFragment private static final String overlayThemeTarget = "com.android.systemui"; private static final String KEY_QS_LABEL_SIZE = "qs_tile_label_size"; private static final String KEY_QS_SECONDARY_LABEL_SIZE = "qs_tile_secondary_label_size"; + private static final String KEY_PREF_TILE_ANIM_STYLE = "qs_tile_animation_style"; + private static final String KEY_PREF_TILE_ANIM_DURATION = "qs_tile_animation_duration"; + private static final String KEY_PREF_TILE_ANIM_INTERPOLATOR = "qs_tile_animation_interpolator"; private Context mContext; @@ -78,15 +82,32 @@ public class QsTileLayoutSettings extends SettingsPreferenceFragment private SystemSettingSeekBarPreference mSize; private SystemSettingSeekBarPreference mSizeSec; + private ListPreference mTileAnimationStyle; + private CustomSeekBarPreference mTileAnimationDuration; + private ListPreference mTileAnimationInterpolator; + @Override public void onCreate(Bundle savedInstance) { super.onCreate(savedInstance); - addPreferencesFromResource(R.xml.qs_tile_layout); + addPreferencesFromResource(R.xml.qs_tile_customization); + + final Context mContext = getActivity().getApplicationContext(); + final ContentResolver resolver = mContext.getContentResolver(); mThemeUtils = new ThemeUtils(getActivity()); mQsStyle = (SystemSettingListPreference) findPreference(KEY_QS_PANEL_STYLE); mQsUI = (SystemSettingListPreference) findPreference(KEY_QS_UI_STYLE); mCustomSettingsObserver.observe(); + + mTileAnimationStyle = (ListPreference) findPreference(KEY_PREF_TILE_ANIM_STYLE); + mTileAnimationDuration = (CustomSeekBarPreference) findPreference(KEY_PREF_TILE_ANIM_DURATION); + mTileAnimationInterpolator = (ListPreference) findPreference(KEY_PREF_TILE_ANIM_INTERPOLATOR); + + mTileAnimationStyle.setOnPreferenceChangeListener(this); + + int tileAnimationStyle = Settings.System.getIntForUser(resolver, + Settings.System.QS_TILE_ANIMATION_STYLE, 0, UserHandle.USER_CURRENT); + updateAnimTileStyle(tileAnimationStyle); } @Override @@ -185,6 +206,10 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { return true; } else if (preference == mQsUI) { mCustomSettingsObserver.observe(); + } else if (preference == mTileAnimationStyle) { + int value = Integer.parseInt((String) newValue); + updateAnimTileStyle(value); + return true; } return true; } @@ -279,6 +304,11 @@ public void setQsStyle(String overlayName, String category) { mThemeUtils.setOverlayEnabled(category, overlayName, overlayThemeTarget); } + private void updateAnimTileStyle(int tileAnimationStyle) { + mTileAnimationDuration.setEnabled(tileAnimationStyle != 0); + mTileAnimationInterpolator.setEnabled(tileAnimationStyle != 0); + } + @Override public int getMetricsCategory() { return MetricsProto.MetricsEvent.BANANADROID; diff --git a/src/com/banana/settings/fragments/QuickSettings.java b/src/com/banana/settings/fragments/QuickSettings.java index cc09aa09..28215e86 100644 --- a/src/com/banana/settings/fragments/QuickSettings.java +++ b/src/com/banana/settings/fragments/QuickSettings.java @@ -31,8 +31,6 @@ import com.android.settingslib.search.Indexable; import com.android.settingslib.search.SearchIndexable; -import com.banana.support.preferences.CustomSeekBarPreference; - import java.util.ArrayList; import java.util.List; @@ -46,17 +44,11 @@ public class QuickSettings extends DashboardFragment implements private static final String KEY_BRIGHTNESS_SLIDER_POSITION = "qs_brightness_slider_position"; private static final String KEY_BRIGHTNESS_SLIDER_HAPTIC = "qs_brightness_slider_haptic"; private static final String KEY_SHOW_AUTO_BRIGHTNESS = "qs_show_auto_brightness"; - private static final String KEY_PREF_TILE_ANIM_STYLE = "qs_tile_animation_style"; - private static final String KEY_PREF_TILE_ANIM_DURATION = "qs_tile_animation_duration"; - private static final String KEY_PREF_TILE_ANIM_INTERPOLATOR = "qs_tile_animation_interpolator"; private ListPreference mShowBrightnessSlider; private ListPreference mBrightnessSliderPosition; private SwitchPreference mBrightnessSliderHaptic; private SwitchPreference mShowAutoBrightness; - private ListPreference mTileAnimationStyle; - private CustomSeekBarPreference mTileAnimationDuration; - private ListPreference mTileAnimationInterpolator; @Override protected int getPreferenceScreenResId() { @@ -90,16 +82,6 @@ public void onCreate(Bundle icicle) { } else { prefScreen.removePreference(mShowAutoBrightness); } - - mTileAnimationStyle = (ListPreference) findPreference(KEY_PREF_TILE_ANIM_STYLE); - mTileAnimationDuration = (CustomSeekBarPreference) findPreference(KEY_PREF_TILE_ANIM_DURATION); - mTileAnimationInterpolator = (ListPreference) findPreference(KEY_PREF_TILE_ANIM_INTERPOLATOR); - - mTileAnimationStyle.setOnPreferenceChangeListener(this); - - int tileAnimationStyle = Settings.System.getIntForUser(resolver, - Settings.System.QS_TILE_ANIMATION_STYLE, 0, UserHandle.USER_CURRENT); - updateAnimTileStyle(tileAnimationStyle); } public boolean onPreferenceChange(Preference preference, Object newValue) { @@ -110,10 +92,6 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { if (mShowAutoBrightness != null) mShowAutoBrightness.setEnabled(value > 0); return true; - } else if (preference == mTileAnimationStyle) { - int value = Integer.parseInt((String) newValue); - updateAnimTileStyle(value); - return true; } return false; } @@ -130,23 +108,12 @@ public static void reset(Context mContext) { Settings.System.QS_FOOTER_DATA_USAGE, 0, UserHandle.USER_CURRENT); Settings.System.putIntForUser(resolver, Settings.System.QS_TRANSPARENCY, 100, UserHandle.USER_CURRENT); - Settings.System.putIntForUser(resolver, - Settings.System.QS_TILE_ANIMATION_STYLE, 0, UserHandle.USER_CURRENT); - Settings.System.putIntForUser(resolver, - Settings.System.QS_TILE_ANIMATION_DURATION, 1, UserHandle.USER_CURRENT); - Settings.System.putIntForUser(resolver, - Settings.System.QS_TILE_ANIMATION_INTERPOLATOR, 0, UserHandle.USER_CURRENT); Settings.System.putIntForUser(resolver, Settings.System.QS_BRIGHTNESS_SLIDER_HAPTIC, 0, UserHandle.USER_CURRENT); Settings.System.putIntForUser(resolver, Settings.System.QS_DUAL_TONE, 1, UserHandle.USER_CURRENT); } - private void updateAnimTileStyle(int tileAnimationStyle) { - mTileAnimationDuration.setEnabled(tileAnimationStyle != 0); - mTileAnimationInterpolator.setEnabled(tileAnimationStyle != 0); - } - @Override public int getMetricsCategory() { return MetricsProto.MetricsEvent.BANANADROID;