public static ColorStateList getTextColor(Context context, int type) { // Colors and font weight switch (type) { case FontManager.TEXT_TYPE_PRIMARY: boolean isNight = ThemeManager.getTheme() == ThemeManager.Theme.GREY || ThemeManager.getTheme() == ThemeManager.Theme.BLACK; int id = isNight ? R.color.text_primary_dark : R.color.text_primary_light; return context.getResources().getColorStateList(id); case FontManager.TEXT_TYPE_SECONDARY: return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary()); case FontManager.TEXT_TYPE_TERTIARY: return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary()); case FontManager.TEXT_TYPE_CATEGORY: return ColorStateList.valueOf(ThemeManager.getColor()); case FontManager.TEXT_TYPE_DIALOG_TITLE: return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundPrimary()); case FontManager.TEXT_TYPE_DIALOG_MESSAGE: return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary()); case FontManager.TEXT_TYPE_DIALOG_BUTTON: return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundPrimary()); case FontManager.TEXT_TYPE_TOOLBAR: return ColorStateList.valueOf(ThemeManager.getTextOnColorPrimary()); } return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundPrimary()); }
private void updateDelayButton() { mDelay.setColorFilter( mDelayedMessagingEnabled ? ThemeManager.getTextOnColorPrimary() : ThemeManager.getTextOnColorSecondary(), PorterDuff.Mode.SRC_ATOP); }
@Override public void refresh() { if (mFab != null) { mFab.setColorNormal(ThemeManager.getColor()); mFab.setColorPressed(ColorUtils.lighten(ThemeManager.getColor())); mFab.getDrawable() .setColorFilter( new PorterDuffColorFilter( ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.MULTIPLY)); } // TODO ListviewHelper.applyCustomScrollbar(mContext, mListView); }
/** Update the widget appWidgetId */ private static void updateWidget(Context context, int appWidgetId) { Log.v(TAG, "updateWidget appWidgetId: " + appWidgetId); RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); PendingIntent clickIntent; // Launch an intent to avoid ANRs final Intent intent = new Intent(context, WidgetService.class); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); remoteViews.setRemoteAdapter(appWidgetId, R.id.conversation_list, intent); remoteViews.setTextViewText( R.id.widget_label, context.getString(R.string.title_conversation_list)); remoteViews.setTextColor(R.id.widget_label, ThemeManager.getTextOnColorPrimary()); remoteViews.setInt( R.id.conversation_list_background, "setColorFilter", ThemeManager.getBackgroundColor()); remoteViews.setInt(R.id.header_background, "setColorFilter", ThemeManager.getColor()); // Open Mms's app conversation list when click on header final Intent convIntent = new Intent(context, MainActivity.class); clickIntent = PendingIntent.getActivity(context, 0, convIntent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.widget_header, clickIntent); // On click intent for Compose final Intent composeIntent = new Intent(context, QKComposeActivity.class); clickIntent = PendingIntent.getActivity(context, 0, composeIntent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.widget_compose, clickIntent); // On click intent for Conversation Intent startActivityIntent = new Intent(context, MainActivity.class); PendingIntent startActivityPendingIntent = PendingIntent.getActivity( context, 0, startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setPendingIntentTemplate(R.id.conversation_list, startActivityPendingIntent); AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, remoteViews); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_conversations, null); mRecyclerView = (RecyclerView) view.findViewById(R.id.conversations_list); mRecyclerView.setHasFixedSize(true); mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerView.setAdapter(mAdapter); // TODO ListviewHelper.applyCustomScrollbar(mContext, mRecyclerView); mFab = (FloatingActionButton) view.findViewById(R.id.fab); mFab.setColorNormal(ThemeManager.getColor()); mFab.setColorPressed(ColorUtils.lighten(ThemeManager.getColor())); mFab.attachToRecyclerView(mRecyclerView); mFab.getDrawable() .setColorFilter( new PorterDuffColorFilter( ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.MULTIPLY)); mFab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // Show the compose fragment, showing the keyboard and focusing on the recipients // edittext. Bundle args = new Bundle(); args.putBoolean(ComposeFragment.ARG_SHOW_KEYBOARD, true); args.putString(ComposeFragment.ARG_FOCUS, ComposeFragment.FOCUS_RECIPIENTS); Fragment content = getFragmentManager().findFragmentById(R.id.content_frame); switchFragment(ComposeFragment.getInstance(args, content)); } }); initLoaderManager(); return view; }
@Override public void onFinishInflate() { super.onFinishInflate(); // Get references to the views mReplyText = (QKEditText) findViewById(R.id.compose_reply_text); mButton = (FrameLayout) findViewById(R.id.compose_button); mProgress = (DonutProgress) findViewById(R.id.progress); mButtonBackground = (ImageView) findViewById(R.id.compose_button_background); mButtonBar1 = (ImageView) findViewById(R.id.compose_button_bar_1); mButtonBar2 = (ImageView) findViewById(R.id.compose_button_bar_2); mAttachmentPanel = findViewById(R.id.attachment_panel); mAttach = (ImageButton) findViewById(R.id.attach); mCamera = (ImageButton) findViewById(R.id.camera); mDelay = (ImageButton) findViewById(R.id.delay); mLetterCount = (QKTextView) findViewById(R.id.compose_letter_count); mAttachmentLayout = (FrameLayout) findViewById(R.id.attachment); mAttachment = (AttachmentImageView) findViewById(R.id.compose_attachment); mCancel = (ImageButton) findViewById(R.id.cancel); mButton.setOnClickListener(this); mAttach.setOnClickListener(this); mCamera.setOnClickListener(this); mCancel.setOnClickListener(this); mDelay.setOnClickListener(this); LiveViewManager.registerView( QKPreference.THEME, this, key -> { mButtonBackground.setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP); mButtonBar1.setColorFilter( ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mButtonBar2.setColorFilter( ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mAttachmentPanel.setBackgroundColor(ThemeManager.getColor()); mAttach.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mCamera.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); updateDelayButton(); mProgress.setUnfinishedStrokeColor(ThemeManager.getTextOnColorSecondary()); mProgress.setFinishedStrokeColor(ThemeManager.getTextOnColorPrimary()); if (ThemeManager.getSentBubbleRes() != 0) mReplyText.setBackgroundResource(ThemeManager.getSentBubbleRes()); }); LiveViewManager.registerView( QKPreference.BACKGROUND, this, key -> { mReplyText .getBackground() .setColorFilter(ThemeManager.getNeutralBubbleColor(), PorterDuff.Mode.SRC_ATOP); getBackground() .setColorFilter(ThemeManager.getBackgroundColor(), PorterDuff.Mode.SRC_ATOP); }); // There is an option for using the return button instead of the emoticon button in the // keyboard; set that up here. switch (Integer.parseInt(mPrefs.getString(SettingsFragment.ENTER_BUTTON, "0"))) { case 0: // emoji break; case 1: // new line mReplyText.setInputType( InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE); mReplyText.setSingleLine(false); break; case 2: // send mReplyText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); mReplyText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); mReplyText.setSingleLine(false); mReplyText.setOnKeyListener( new OnKeyListener() { // Workaround because ACTION_SEND does not support multiline mode @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == 66) { sendSms(); return true; } return false; } }); break; } mReplyText.setTextChangedListener( new QKEditText.TextChangedListener() { @Override public void onTextChanged(CharSequence s) { int length = s.length(); updateButtonState(length); // If the reply is within 10 characters of the SMS limit (160), it will start counting // down // If the reply exceeds the SMS limit, it will count down until an extra message will // have to be sent, and shows how many messages will currently be sent if (length < 150) { mLetterCount.setText(""); } else if (150 <= length && length <= 160) { mLetterCount.setText("" + (160 - length)); } else if (160 < length) { mLetterCount.setText((160 - length % 160) + "/" + (length / 160 + 1)); } } }); mProgressAnimator = new ValueAnimator(); mProgressAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); mProgressAnimator.setDuration(mDelayDuration); mProgressAnimator.setIntValues(0, 360); mProgressAnimator.addUpdateListener( new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mProgress.setProgress((int) animation.getAnimatedValue()); } }); mProgressAnimator.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mProgress.setVisibility(INVISIBLE); mProgress.setProgress(0); if (!mSendingCancelled) { sendSms(); // In case they only enabled it for a particular message, let's set it back to the // pref value mDelayedMessagingEnabled = mPrefs.getBoolean(SettingsFragment.DELAYED, false); updateDelayButton(); } else { mSendingCancelled = false; updateButtonState(); } } }); }