Search in sources :

Example 1 with CIELChEvaluator

use of com.moez.QKSMS.common.CIELChEvaluator in project qksms by moezbhatti.

the class MessageListFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments() != null) {
        Bundle args = getArguments();
        mThreadId = args.getLong(MessageListActivity.ARG_THREAD_ID, -1);
        mRowId = args.getLong(MessageListActivity.ARG_ROW_ID, -1);
        mHighlight = args.getString(MessageListActivity.ARG_HIGHLIGHT, null);
        mShowImmediate = args.getBoolean(MessageListActivity.ARG_SHOW_IMMEDIATE, false);
    } else if (savedInstanceState != null) {
        mThreadId = savedInstanceState.getLong(MessageListActivity.ARG_THREAD_ID, -1);
        mRowId = savedInstanceState.getLong(MessageListActivity.ARG_ROW_ID, -1);
        mHighlight = savedInstanceState.getString(MessageListActivity.ARG_HIGHLIGHT, null);
        mShowImmediate = savedInstanceState.getBoolean(MessageListActivity.ARG_SHOW_IMMEDIATE, false);
    }
    mConversationPrefs = new ConversationPrefsHelper(mContext, mThreadId);
    mIsSmsEnabled = MmsConfig.isSmsEnabled(mContext);
    mConversationDetailsDialog = new ConversationDetailsDialog(mContext, getFragmentManager());
    onOpenConversation();
    setHasOptionsMenu(true);
    LiveViewManager.registerView(QKPreference.CONVERSATION_THEME, this, key -> {
        mCIELChEvaluator = new CIELChEvaluator(mConversationPrefs.getColor(), ThemeManager.getThemeColor());
    });
    mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
    mProxSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
    if (QKPreferences.getBoolean(QKPreference.PROXIMITY_SENSOR)) {
        mSensorManager.registerListener(this, mProxSensor, SensorManager.SENSOR_DELAY_NORMAL);
    }
    mBackgroundQueryHandler = new BackgroundQueryHandler(mContext.getContentResolver());
}
Also used : CIELChEvaluator(com.moez.QKSMS.common.CIELChEvaluator) Bundle(android.os.Bundle) ConversationDetailsDialog(com.moez.QKSMS.ui.dialog.conversationdetails.ConversationDetailsDialog) ConversationPrefsHelper(com.moez.QKSMS.common.ConversationPrefsHelper)

Example 2 with CIELChEvaluator

use of com.moez.QKSMS.common.CIELChEvaluator in project qksms by moezbhatti.

the class ThemeManager method setColor.

public static void setColor(QKActivity activity, int color) {
    AnalyticsManager.getInstance().sendEvent(AnalyticsManager.CATEGORY_PREFERENCE_CHANGE, SettingsFragment.CATEGORY_THEME, getColorString(color));
    int colorFrom = mActiveColor;
    mColor = color;
    mActiveColor = color;
    mPrefs.edit().putString(SettingsFragment.THEME, "" + color).apply();
    setSentBubbleColored(mPrefs.getBoolean(SettingsFragment.COLOR_SENT, true));
    setReceivedBubbleColored(mPrefs.getBoolean(SettingsFragment.COLOR_RECEIVED, false));
    mTextOnColorPrimary = mResources.getColor(isColorDarkEnough(mColor) ? R.color.theme_dark_text_primary : R.color.theme_light_text_primary);
    mTextOnColorSecondary = mResources.getColor(isColorDarkEnough(mColor) ? R.color.theme_dark_text_secondary : R.color.theme_light_text_secondary);
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new CIELChEvaluator(colorFrom, color), 0);
    colorAnimation.setDuration(TRANSITION_LENGTH);
    colorAnimation.setInterpolator(new DecelerateInterpolator());
    colorAnimation.addUpdateListener(animation -> {
        setActiveColor((Integer) animation.getAnimatedValue());
    });
    colorAnimation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            WidgetProvider.notifyThemeChanged(mContext);
        }
    });
    colorAnimation.start();
    if (activity.findViewById(R.id.toolbar_title) != null) {
        //final Toolbar toolbar = (Toolbar) mActivity.findViewById(R.id.title);
        final QKTextView title = (QKTextView) activity.findViewById(R.id.toolbar_title);
        if (title.getCurrentTextColor() != mTextOnColorPrimary) {
            ValueAnimator titleColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), title.getCurrentTextColor(), mTextOnColorPrimary);
            titleColorAnimation.setDuration(TRANSITION_LENGTH);
            titleColorAnimation.setInterpolator(new DecelerateInterpolator());
            titleColorAnimation.addUpdateListener(animation -> {
                int color1 = (Integer) animation.getAnimatedValue();
                title.setTextColor(color1);
                activity.colorMenuIcons(activity.getMenu(), color1);
            });
            titleColorAnimation.start();
        }
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) CIELChEvaluator(com.moez.QKSMS.common.CIELChEvaluator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator) QKTextView(com.moez.QKSMS.ui.view.QKTextView)

Aggregations

CIELChEvaluator (com.moez.QKSMS.common.CIELChEvaluator)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ArgbEvaluator (android.animation.ArgbEvaluator)1 ValueAnimator (android.animation.ValueAnimator)1 Bundle (android.os.Bundle)1 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)1 ConversationPrefsHelper (com.moez.QKSMS.common.ConversationPrefsHelper)1 ConversationDetailsDialog (com.moez.QKSMS.ui.dialog.conversationdetails.ConversationDetailsDialog)1 QKTextView (com.moez.QKSMS.ui.view.QKTextView)1