Cherish: Add interpolators to qs tiles animation [2/2]

Change-Id: I702fdb87ed821290b5a895381f7b987e3a36a58d
Signed-off-by: mydongistiny <jaysonedson@gmail.com>
Signed-off-by: Arghya Chanda <arghyac35@gmail.com>
Signed-off-by: SagarMakhar <sagarmakhar@gmail.com>
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Nico60
2016-05-29 13:04:12 +02:00
committed by Hưng Phan
parent f802e64457
commit 382eeb9172
4 changed files with 76 additions and 13 deletions

View File

@@ -235,5 +235,28 @@
<item>2000</item> <item>2000</item>
<item>1500</item> <item>1500</item>
</string-array> </string-array>
<!-- Tiles animation interpolator -->
<string-array name="qs_tile_animation_interpolator_entries" translatable="false">
<item>@string/qs_tile_animation_interpolator_linearInterpolator</item>
<item>@string/qs_tile_animation_interpolator_accelerateInterpolator</item>
<item>@string/qs_tile_animation_interpolator_decelerateInterpolator</item>
<item>@string/qs_tile_animation_interpolator_accelerateDecelerateInterpolator</item>
<item>@string/qs_tile_animation_interpolator_bounceInterpolator</item>
<item>@string/qs_tile_animation_interpolator_overshootInterpolator</item>
<item>@string/qs_tile_animation_interpolator_anticipateInterpolator</item>
<item>@string/qs_tile_animation_interpolator_anticipateOvershootInterpolator</item>
</string-array>
<string-array name="qs_tile_animation_interpolator_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
</string-array>
</resources> </resources>

View File

@@ -351,12 +351,22 @@
<string name="qs_tile_animation_title">Animations</string> <string name="qs_tile_animation_title">Animations</string>
<string name="qs_tile_animation_style_title">Animation style</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_duration_title">Animation duration</string>
<string name="qs_tile_animation_style_off">no animation</string> <string name="qs_tile_animation_interpolator_title">Tiles animation interpolator</string>
<string name="qs_tile_animation_style_flip">flip</string> <string name="qs_tile_animation_style_off">No animation</string>
<string name="qs_tile_animation_style_rotate">rotate</string> <string name="qs_tile_animation_style_flip">Flip</string>
<string name="qs_tile_animation_duration_low">low</string> <string name="qs_tile_animation_style_rotate">Rotate</string>
<string name="qs_tile_animation_duration_default">default</string> <string name="qs_tile_animation_duration_low">Low</string>
<string name="qs_tile_animation_duration_fast">fast</string> <string name="qs_tile_animation_duration_default">Default</string>
<string name="qs_set_animation_style">Animation is set to %1$s</string> <string name="qs_tile_animation_duration_fast">Fast</string>
<string name="qs_set_animation_duration">Animation duration is set to %1$s</string> <string name="qs_tile_animation_interpolator_linearInterpolator">Linear</string>
<string name="qs_tile_animation_interpolator_accelerateInterpolator">Accelerate</string>
<string name="qs_tile_animation_interpolator_decelerateInterpolator">Decelerate</string>
<string name="qs_tile_animation_interpolator_accelerateDecelerateInterpolator">Accelerate decelerate</string>
<string name="qs_tile_animation_interpolator_bounceInterpolator">Bounce</string>
<string name="qs_tile_animation_interpolator_overshootInterpolator">Overshoot</string>
<string name="qs_tile_animation_interpolator_anticipateInterpolator">Anticipate</string>
<string name="qs_tile_animation_interpolator_anticipateOvershootInterpolator">Anticipate overshoot</string>
<string name="qs_set_animation_style">%1$s</string>
<string name="qs_set_animation_duration">%1$s</string>
<string name="qs_set_animation_interpolator">%1$s</string>
</resources> </resources>

View File

@@ -22,7 +22,7 @@
<PreferenceCategory <PreferenceCategory
android:key="quick_settings_animations" android:key="quick_settings_animations"
android:title="@string/qs_tile_animation_title"/> android:title="@string/qs_tile_animation_title">
<ListPreference <ListPreference
android:key="qs_tile_animation_style" android:key="qs_tile_animation_style"
@@ -37,6 +37,12 @@
android:entries="@array/qs_tile_animation_duration_entries" android:entries="@array/qs_tile_animation_duration_entries"
android:entryValues="@array/qs_tile_animation_duration_values" android:entryValues="@array/qs_tile_animation_duration_values"
android:persistent="false" /> android:persistent="false" />
</PreferenceCategory>
<ListPreference
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:persistent="false" />
</PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -57,9 +57,11 @@ public class AnimationsSettings extends SettingsPreferenceFragment
private static final String PREF_TILE_ANIM_STYLE = "qs_tile_animation_style"; 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 static final String PREF_TILE_ANIM_DURATION = "qs_tile_animation_duration";
private static final String PREF_TILE_ANIM_INTERPOLATOR = "qs_tile_animation_interpolator";
private ListPreference mTileAnimationStyle; private ListPreference mTileAnimationStyle;
private ListPreference mTileAnimationDuration; private ListPreference mTileAnimationDuration;
private ListPreference mTileAnimationInterpolator;
@Override @Override
public int getMetricsCategory() { public int getMetricsCategory() {
@@ -79,7 +81,7 @@ public class AnimationsSettings extends SettingsPreferenceFragment
Settings.System.ANIM_TILE_STYLE, 0, UserHandle.USER_CURRENT); Settings.System.ANIM_TILE_STYLE, 0, UserHandle.USER_CURRENT);
mTileAnimationStyle.setValue(String.valueOf(tileAnimationStyle)); mTileAnimationStyle.setValue(String.valueOf(tileAnimationStyle));
updateTileAnimationStyleSummary(tileAnimationStyle); updateTileAnimationStyleSummary(tileAnimationStyle);
updateAnimTileDuration(tileAnimationStyle); updateAnimTileStyle(tileAnimationStyle);
mTileAnimationStyle.setOnPreferenceChangeListener(this); mTileAnimationStyle.setOnPreferenceChangeListener(this);
mTileAnimationDuration = (ListPreference) findPreference(PREF_TILE_ANIM_DURATION); mTileAnimationDuration = (ListPreference) findPreference(PREF_TILE_ANIM_DURATION);
@@ -88,6 +90,13 @@ public class AnimationsSettings extends SettingsPreferenceFragment
mTileAnimationDuration.setValue(String.valueOf(tileAnimationDuration)); mTileAnimationDuration.setValue(String.valueOf(tileAnimationDuration));
updateTileAnimationDurationSummary(tileAnimationDuration); updateTileAnimationDurationSummary(tileAnimationDuration);
mTileAnimationDuration.setOnPreferenceChangeListener(this); mTileAnimationDuration.setOnPreferenceChangeListener(this);
mTileAnimationInterpolator = (ListPreference) findPreference(PREF_TILE_ANIM_INTERPOLATOR);
int tileAnimationInterpolator = Settings.System.getIntForUser(getContentResolver(),
Settings.System.ANIM_TILE_INTERPOLATOR, 0, UserHandle.USER_CURRENT);
mTileAnimationInterpolator.setValue(String.valueOf(tileAnimationInterpolator));
updateTileAnimationInterpolatorSummary(tileAnimationInterpolator);
mTileAnimationInterpolator.setOnPreferenceChangeListener(this);
} }
@Override @Override
@@ -103,7 +112,7 @@ public class AnimationsSettings extends SettingsPreferenceFragment
Settings.System.putIntForUser(resolver, Settings.System.ANIM_TILE_STYLE, Settings.System.putIntForUser(resolver, Settings.System.ANIM_TILE_STYLE,
tileAnimationStyle, UserHandle.USER_CURRENT); tileAnimationStyle, UserHandle.USER_CURRENT);
updateTileAnimationStyleSummary(tileAnimationStyle); updateTileAnimationStyleSummary(tileAnimationStyle);
updateAnimTileDuration(tileAnimationStyle); updateAnimTileStyle(tileAnimationStyle);
return true; return true;
} else if (preference == mTileAnimationDuration) { } else if (preference == mTileAnimationDuration) {
int tileAnimationDuration = Integer.valueOf((String) newValue); int tileAnimationDuration = Integer.valueOf((String) newValue);
@@ -111,6 +120,12 @@ public class AnimationsSettings extends SettingsPreferenceFragment
tileAnimationDuration, UserHandle.USER_CURRENT); tileAnimationDuration, UserHandle.USER_CURRENT);
updateTileAnimationDurationSummary(tileAnimationDuration); updateTileAnimationDurationSummary(tileAnimationDuration);
return true; return true;
} else if (preference == mTileAnimationInterpolator) {
int tileAnimationInterpolator = Integer.valueOf((String) newValue);
Settings.System.putIntForUser(resolver, Settings.System.ANIM_TILE_INTERPOLATOR,
tileAnimationInterpolator, UserHandle.USER_CURRENT);
updateTileAnimationInterpolatorSummary(tileAnimationInterpolator);
return true;
} }
return false; return false;
} }
@@ -127,14 +142,23 @@ public class AnimationsSettings extends SettingsPreferenceFragment
mTileAnimationDuration.setSummary(getResources().getString(R.string.qs_set_animation_duration, prefix)); mTileAnimationDuration.setSummary(getResources().getString(R.string.qs_set_animation_duration, prefix));
} }
private void updateAnimTileDuration(int tileAnimationStyle) { private void updateTileAnimationInterpolatorSummary(int tileAnimationInterpolator) {
String prefix = (String) mTileAnimationInterpolator.getEntries()[mTileAnimationInterpolator.findIndexOfValue(String
.valueOf(tileAnimationInterpolator))];
mTileAnimationInterpolator.setSummary(getResources().getString(R.string.qs_set_animation_interpolator, prefix));
}
private void updateAnimTileStyle(int tileAnimationStyle) {
if (mTileAnimationDuration != null) { if (mTileAnimationDuration != null) {
if (tileAnimationStyle == 0) { if (tileAnimationStyle == 0) {
mTileAnimationDuration.setSelectable(false); mTileAnimationDuration.setSelectable(false);
mTileAnimationInterpolator.setSelectable(false);
} else { } else {
mTileAnimationDuration.setSelectable(true); mTileAnimationDuration.setSelectable(true);
mTileAnimationInterpolator.setSelectable(true);
} }
} }
}
/** /**
* For Search. * For Search.
*/ */