Skip to content

Commit

Permalink
Gear: Move tile animation into qs tile customization section
Browse files Browse the repository at this point in the history
Also properly rename fragment
  • Loading branch information
travarilo committed Mar 1, 2024
1 parent 1dcd2a1 commit 8c404a4
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 74 deletions.
5 changes: 2 additions & 3 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -808,9 +808,8 @@
<string name="ambient_edge_light_width_title">Light width</string>

<!-- QS tiles layout -->
<string name="qs_tile_styles">QS tiles styles</string>
<string name="qs_tile_layout_title">Tiles layout</string>
<string name="qs_tile_layout_summary">Customize tiles layout in QS panel</string>
<string name="qs_tiles_customization">QS tiles customization</string>
<string name="qs_tiles_customization_summary">Style, layout, animation</string>
<string name="qs_tiles_layout_category">Tiles layout</string>
<string name="qs_rows_portrait_title">Rows (Portrait)</string>
<string name="qqs_rows_portrait_title">Rows (Quick QS portrait)</string>
Expand Down
45 changes: 11 additions & 34 deletions res/xml/bg_quicksettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,7 @@
</PreferenceCategory>

<PreferenceCategory
android:title="@string/qs_tile_styles">

<Preference
android:key="qs_tile_layout"
android:title="@string/qs_tile_layout_title"
android:summary="@string/qs_tile_layout_summary"
android:fragment="com.banana.settings.fragments.QsTileLayoutSettings" />
android:title="@string/interface_title">

<!-- QS Header image -->
<Preference
Expand All @@ -85,33 +79,11 @@
android:summary="@string/qs_header_image_summary"
android:fragment="com.banana.settings.fragments.qs.QsHeaderImageSettings" />

<com.banana.support.preferences.SystemSettingListPreference
android:key="qs_tile_animation_style"
android:title="@string/qs_tile_animation_style_title"
android:entries="@array/qs_tile_animation_style_entries"
android:entryValues="@array/qs_tile_animation_style_values"
android:defaultValue="0" />

<com.banana.support.preferences.SystemSettingSeekBarPreference
android:key="qs_tile_animation_duration"
android:title="@string/qs_tile_animation_duration_title"
android:defaultValue="1"
settings:interval="1"
settings:units="@string/unit_seconds"
android:max="5"
android:min="1" />

<com.banana.support.preferences.SystemSettingListPreference
android:key="qs_tile_animation_interpolator"
android:title="@string/qs_tile_animation_interpolator_title"
android:entries="@array/qs_tile_animation_interpolator_entries"
android:entryValues="@array/qs_tile_animation_interpolator_values"
android:defaultValue="0" />

</PreferenceCategory>

<PreferenceCategory
android:title="@string/other_category_title">
<Preference
android:key="qs_tile_customization"
android:title="@string/qs_tiles_customization"
android:summary="@string/qs_tiles_customization_summary"
android:fragment="com.banana.settings.fragments.QsTileCustomization" />

<com.banana.support.preferences.SystemSettingSwitchPreference
android:key="qs_dual_tone"
Expand All @@ -129,6 +101,11 @@
android:max="100"
android:min="1" />

</PreferenceCategory>

<PreferenceCategory
android:title="@string/other_category_title">

<com.banana.support.preferences.SystemSettingSwitchPreference
android:key="qs_footer_data_usage"
android:title="@string/qs_footer_datausage_title"
Expand Down
30 changes: 29 additions & 1 deletion res/xml/qs_tile_layout.xml → res/xml/qs_tile_customization.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:title="@string/qs_tile_layout_title">
android:title="@string/qs_tiles_customization">

<!-- QS styles -->
<com.banana.support.preferences.SystemSettingListPreference
Expand Down Expand Up @@ -90,4 +90,32 @@
settings:units="sp"
android:defaultValue="13" />

<PreferenceCategory
android:title="@string/qs_tile_animation_title">

<com.banana.support.preferences.SystemSettingListPreference
android:key="qs_tile_animation_style"
android:title="@string/qs_tile_animation_style_title"
android:entries="@array/qs_tile_animation_style_entries"
android:entryValues="@array/qs_tile_animation_style_values"
android:defaultValue="0" />

<com.banana.support.preferences.SystemSettingSeekBarPreference
android:key="qs_tile_animation_duration"
android:title="@string/qs_tile_animation_duration_title"
android:defaultValue="1"
settings:interval="1"
settings:units="@string/unit_seconds"
android:max="5"
android:min="1" />

<com.banana.support.preferences.SystemSettingListPreference
android:key="qs_tile_animation_interpolator"
android:title="@string/qs_tile_animation_interpolator_title"
android:entries="@array/qs_tile_animation_interpolator_entries"
android:entryValues="@array/qs_tile_animation_interpolator_values"
android:defaultValue="0" />

</PreferenceCategory>

</PreferenceScreen>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand All @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
33 changes: 0 additions & 33 deletions src/com/banana/settings/fragments/QuickSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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() {
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit 8c404a4

Please sign in to comment.