Cherish: Add animations to quick settings tiles [2/2]
Change-Id: I2e4009027d35a519a8e8b3b17e41b4dcd829c307 Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -210,4 +210,30 @@
|
|||||||
<item>9</item>
|
<item>9</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Tiles animation style -->
|
||||||
|
<string-array name="qs_tile_animation_style_entries" translatable="false">
|
||||||
|
<item>@string/qs_tile_animation_style_off</item>
|
||||||
|
<item>@string/qs_tile_animation_style_flip</item>
|
||||||
|
<item>@string/qs_tile_animation_style_rotate</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="qs_tile_animation_style_values" translatable="false">
|
||||||
|
<item>0</item>
|
||||||
|
<item>1</item>
|
||||||
|
<item>2</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Tiles animation duration -->
|
||||||
|
<string-array name="qs_tile_animation_duration_entries" translatable="false">
|
||||||
|
<item>@string/qs_tile_animation_duration_low</item>
|
||||||
|
<item>@string/qs_tile_animation_duration_default</item>
|
||||||
|
<item>@string/qs_tile_animation_duration_fast</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="qs_tile_animation_duration_values" translatable="false">
|
||||||
|
<item>2500</item>
|
||||||
|
<item>2000</item>
|
||||||
|
<item>1500</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -347,4 +347,16 @@
|
|||||||
<string name="charging_animation_title">Charging animation</string>
|
<string name="charging_animation_title">Charging animation</string>
|
||||||
<string name="charging_animation_summary">Display an animation when the device is plugged in</string>
|
<string name="charging_animation_summary">Display an animation when the device is plugged in</string>
|
||||||
|
|
||||||
|
<!-- Tiles animation style -->
|
||||||
|
<string name="qs_tile_animation_title">Animations</string>
|
||||||
|
<string name="qs_tile_animation_style_title">Animation style</string>
|
||||||
|
<string name="qs_tile_animation_duration_title">Animation duration</string>
|
||||||
|
<string name="qs_tile_animation_style_off">no animation</string>
|
||||||
|
<string name="qs_tile_animation_style_flip">flip</string>
|
||||||
|
<string name="qs_tile_animation_style_rotate">rotate</string>
|
||||||
|
<string name="qs_tile_animation_duration_low">low</string>
|
||||||
|
<string name="qs_tile_animation_duration_default">default</string>
|
||||||
|
<string name="qs_tile_animation_duration_fast">fast</string>
|
||||||
|
<string name="qs_set_animation_style">Animation is set to %1$s</string>
|
||||||
|
<string name="qs_set_animation_duration">Animation duration is set to %1$s</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -20,4 +20,23 @@
|
|||||||
android:title="@string/animations_title"
|
android:title="@string/animations_title"
|
||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings" >
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings" >
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="quick_settings_animations"
|
||||||
|
android:title="@string/qs_tile_animation_title"/>
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
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:persistent="false" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:key="qs_tile_animation_duration"
|
||||||
|
android:title="@string/qs_tile_animation_duration_title"
|
||||||
|
android:entries="@array/qs_tile_animation_duration_entries"
|
||||||
|
android:entryValues="@array/qs_tile_animation_duration_values"
|
||||||
|
android:persistent="false" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
@@ -55,6 +55,12 @@ import java.util.List;
|
|||||||
public class AnimationsSettings extends SettingsPreferenceFragment
|
public class AnimationsSettings extends SettingsPreferenceFragment
|
||||||
implements OnPreferenceChangeListener {
|
implements OnPreferenceChangeListener {
|
||||||
|
|
||||||
|
private static final String PREF_TILE_ANIM_STYLE = "qs_tile_animation_style";
|
||||||
|
private static final String PREF_TILE_ANIM_DURATION = "qs_tile_animation_duration";
|
||||||
|
|
||||||
|
private ListPreference mTileAnimationStyle;
|
||||||
|
private ListPreference mTileAnimationDuration;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsEvent.CHERISH_SETTINGS;
|
return MetricsEvent.CHERISH_SETTINGS;
|
||||||
@@ -66,6 +72,22 @@ public class AnimationsSettings extends SettingsPreferenceFragment
|
|||||||
addPreferencesFromResource(R.xml.cherish_settings_animations);
|
addPreferencesFromResource(R.xml.cherish_settings_animations);
|
||||||
ContentResolver resolver = getActivity().getContentResolver();
|
ContentResolver resolver = getActivity().getContentResolver();
|
||||||
PreferenceScreen prefs = getPreferenceScreen();
|
PreferenceScreen prefs = getPreferenceScreen();
|
||||||
|
|
||||||
|
// QS animation
|
||||||
|
mTileAnimationStyle = (ListPreference) findPreference(PREF_TILE_ANIM_STYLE);
|
||||||
|
int tileAnimationStyle = Settings.System.getIntForUser(resolver,
|
||||||
|
Settings.System.ANIM_TILE_STYLE, 0, UserHandle.USER_CURRENT);
|
||||||
|
mTileAnimationStyle.setValue(String.valueOf(tileAnimationStyle));
|
||||||
|
updateTileAnimationStyleSummary(tileAnimationStyle);
|
||||||
|
updateAnimTileDuration(tileAnimationStyle);
|
||||||
|
mTileAnimationStyle.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
mTileAnimationDuration = (ListPreference) findPreference(PREF_TILE_ANIM_DURATION);
|
||||||
|
int tileAnimationDuration = Settings.System.getIntForUser(resolver,
|
||||||
|
Settings.System.ANIM_TILE_DURATION, 2000, UserHandle.USER_CURRENT);
|
||||||
|
mTileAnimationDuration.setValue(String.valueOf(tileAnimationDuration));
|
||||||
|
updateTileAnimationDurationSummary(tileAnimationDuration);
|
||||||
|
mTileAnimationDuration.setOnPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,9 +98,43 @@ public class AnimationsSettings extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
ContentResolver resolver = getActivity().getContentResolver();
|
ContentResolver resolver = getActivity().getContentResolver();
|
||||||
return false;
|
if (preference == mTileAnimationStyle) {
|
||||||
}
|
int tileAnimationStyle = Integer.valueOf((String) newValue);
|
||||||
|
Settings.System.putIntForUser(resolver, Settings.System.ANIM_TILE_STYLE,
|
||||||
|
tileAnimationStyle, UserHandle.USER_CURRENT);
|
||||||
|
updateTileAnimationStyleSummary(tileAnimationStyle);
|
||||||
|
updateAnimTileDuration(tileAnimationStyle);
|
||||||
|
return true;
|
||||||
|
} else if (preference == mTileAnimationDuration) {
|
||||||
|
int tileAnimationDuration = Integer.valueOf((String) newValue);
|
||||||
|
Settings.System.putIntForUser(resolver, Settings.System.ANIM_TILE_DURATION,
|
||||||
|
tileAnimationDuration, UserHandle.USER_CURRENT);
|
||||||
|
updateTileAnimationDurationSummary(tileAnimationDuration);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTileAnimationStyleSummary(int tileAnimationStyle) {
|
||||||
|
String prefix = (String) mTileAnimationStyle.getEntries()[mTileAnimationStyle.findIndexOfValue(String
|
||||||
|
.valueOf(tileAnimationStyle))];
|
||||||
|
mTileAnimationStyle.setSummary(getResources().getString(R.string.qs_set_animation_style, prefix));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTileAnimationDurationSummary(int tileAnimationDuration) {
|
||||||
|
String prefix = (String) mTileAnimationDuration.getEntries()[mTileAnimationDuration.findIndexOfValue(String
|
||||||
|
.valueOf(tileAnimationDuration))];
|
||||||
|
mTileAnimationDuration.setSummary(getResources().getString(R.string.qs_set_animation_duration, prefix));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateAnimTileDuration(int tileAnimationStyle) {
|
||||||
|
if (mTileAnimationDuration != null) {
|
||||||
|
if (tileAnimationStyle == 0) {
|
||||||
|
mTileAnimationDuration.setSelectable(false);
|
||||||
|
} else {
|
||||||
|
mTileAnimationDuration.setSelectable(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* For Search.
|
* For Search.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user