mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-20 20:58:54 +01:00
Fix background color animation
This commit is contained in:
@@ -39,7 +39,8 @@ public abstract class LiveViewManager {
|
|||||||
* A list of preferences to be excluded from LiveView refreshing when the preference changes
|
* A list of preferences to be excluded from LiveView refreshing when the preference changes
|
||||||
*/
|
*/
|
||||||
private static final HashSet<String> sExcludedPrefs = new HashSet<>(Arrays.asList(
|
private static final HashSet<String> sExcludedPrefs = new HashSet<>(Arrays.asList(
|
||||||
QKPreference.THEME.getKey()
|
QKPreference.THEME.getKey(),
|
||||||
|
QKPreference.BACKGROUND.getKey()
|
||||||
));
|
));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import android.os.Build;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
|
||||||
import android.view.animation.DecelerateInterpolator;
|
import android.view.animation.DecelerateInterpolator;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import com.moez.QKSMS.R;
|
import com.moez.QKSMS.R;
|
||||||
@@ -248,47 +247,27 @@ public class ThemeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setTheme(Theme theme) {
|
public static void setTheme(Theme theme) {
|
||||||
int startColor = mBackgroundColor;
|
final int startColor = mBackgroundColor;
|
||||||
initializeTheme(theme);
|
initializeTheme(theme);
|
||||||
int endColor = mBackgroundColor;
|
final int endColor = mBackgroundColor;
|
||||||
|
|
||||||
if (mContext instanceof MainActivity) {
|
if (startColor != endColor) {
|
||||||
final View background = ((MainActivity) mContext).findViewById(R.id.menu_frame).getRootView();
|
ValueAnimator backgroundAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), startColor, endColor);
|
||||||
final View menu = ((MainActivity) mContext).findViewById(R.id.menu_frame);
|
backgroundAnimation.setDuration(TRANSITION_LENGTH);
|
||||||
final View content = ((MainActivity) mContext).findViewById(R.id.content_frame);
|
backgroundAnimation.addUpdateListener(animation -> {
|
||||||
final View fragment = ((MainActivity) mContext).getContent().getView();
|
mBackgroundColor = (Integer) animation.getAnimatedValue();
|
||||||
|
|
||||||
if (startColor != endColor) {
|
|
||||||
ValueAnimator backgroundAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), startColor, endColor);
|
|
||||||
backgroundAnimation.setDuration(TRANSITION_LENGTH);
|
|
||||||
backgroundAnimation.addUpdateListener(animation -> {
|
|
||||||
int color = (Integer) animation.getAnimatedValue();
|
|
||||||
if (fragment != null) {
|
|
||||||
fragment.setBackgroundColor(color);
|
|
||||||
}
|
|
||||||
background.setBackgroundColor(color);
|
|
||||||
menu.setBackgroundColor(color);
|
|
||||||
content.setBackgroundColor(color);
|
|
||||||
});
|
|
||||||
backgroundAnimation.addListener(new AnimatorListenerAdapter() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
// This updates the colors and fonts of all the views.
|
|
||||||
LiveViewManager.refreshViews(QKPreference.BACKGROUND);
|
|
||||||
WidgetProvider.notifyThemeChanged(mContext);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
backgroundAnimation.start();
|
|
||||||
} else {
|
|
||||||
// This updates the colors and fonts of all the views.
|
|
||||||
LiveViewManager.refreshViews(QKPreference.BACKGROUND);
|
LiveViewManager.refreshViews(QKPreference.BACKGROUND);
|
||||||
background.setBackgroundColor(endColor);
|
});
|
||||||
menu.setBackgroundColor(endColor);
|
backgroundAnimation.addListener(new AnimatorListenerAdapter() {
|
||||||
content.setBackgroundColor(endColor);
|
@Override
|
||||||
WidgetProvider.notifyThemeChanged(mContext);
|
public void onAnimationEnd(Animator animation) {
|
||||||
}
|
mBackgroundColor = endColor;
|
||||||
|
LiveViewManager.refreshViews(QKPreference.BACKGROUND);
|
||||||
|
WidgetProvider.notifyThemeChanged(mContext);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
backgroundAnimation.start();
|
||||||
} else {
|
} else {
|
||||||
// This updates the colors and fonts of all the views.
|
|
||||||
LiveViewManager.refreshViews(QKPreference.BACKGROUND);
|
LiveViewManager.refreshViews(QKPreference.BACKGROUND);
|
||||||
WidgetProvider.notifyThemeChanged(mContext);
|
WidgetProvider.notifyThemeChanged(mContext);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user