public ThemedTextView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); if (!isInEditMode()) { setLinkTextColor(ThemeUtils.getUserLinkTextColor(context)); setHighlightColor(ThemeUtils.getUserHighlightColor(context)); setTypeface(ThemeUtils.getUserTypeface(context, getTypeface())); } }
@Override public void onViewCreated(final Activity activity, final View headerView) { super.onViewCreated(activity, headerView); setProgressBarStyle(PROGRESS_BAR_STYLE_INSIDE); if (ThemeUtils.isColoredActionBar(activity)) { setProgressBarColor(Color.WHITE); } else { setProgressBarColor(ThemeUtils.getUserThemeColor(activity)); } }
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final View view = getView(); assert view != null; final Context context = view.getContext(); final boolean compact = Utils.isCompactCards(context); final int backgroundColor = ThemeUtils.getThemeBackgroundColor(context); final int colorRes = TwidereColorUtils.getContrastYIQ( backgroundColor, R.color.bg_refresh_progress_color_light, R.color.bg_refresh_progress_color_dark); mSwipeRefreshLayout.setOnRefreshListener(this); mSwipeRefreshLayout.setProgressBackgroundColorSchemeResource(colorRes); mAdapter = onCreateAdapter(context, compact); mListView.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { updateRefreshProgressOffset(); } return false; } }); mListView.setAdapter(mAdapter); }
@NonNull @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity()); final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped); builder.setNegativeButton(android.R.string.cancel, null); builder.setPositiveButton(android.R.string.ok, this); builder.setTitle(R.string.account_delete_confirm_title); builder.setMessage(R.string.account_delete_confirm_message); return builder.create(); }
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity()); final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped); final ParcelableUser user = getUser(); if (user != null) { final String display_name = Utils.getDisplayName(wrapped, user.id, user.name, user.screen_name); builder.setTitle(getString(R.string.block_user, display_name)); builder.setMessage(getString(R.string.block_user_confirm_message, display_name)); } builder.setPositiveButton(android.R.string.ok, this); builder.setNegativeButton(android.R.string.cancel, null); return builder.create(); }
@NonNull @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final FragmentActivity activity = getActivity(); final Context wrapped = ThemeUtils.getDialogThemedContext(activity); final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped); final ParcelableUser user = getUser(); if (user != null) { final boolean nameFirst = mPreferences.getBoolean(KEY_NAME_FIRST); final String displayName = mUserColorNameManager.getDisplayName(user, nameFirst, false); builder.setTitle(getString(R.string.report_user, displayName)); builder.setMessage(getString(R.string.report_user_confirm_message, displayName)); } builder.setPositiveButton(android.R.string.ok, this); builder.setNegativeButton(android.R.string.cancel, null); return builder.create(); }
@NonNull @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final FragmentActivity activity = getActivity(); final Context wrapped = ThemeUtils.getDialogThemedContext(activity); final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped); buildDialog(builder); builder.setView(R.layout.dialog_auto_complete_textview); builder.setTitle(R.string.add_rule); builder.setPositiveButton(android.R.string.ok, this); builder.setNegativeButton(android.R.string.cancel, this); final AlertDialog dialog = builder.create(); dialog.setOnShowListener( new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { AlertDialog alertDialog = (AlertDialog) dialog; final AutoCompleteTextView editText = (AutoCompleteTextView) alertDialog.findViewById(R.id.edit_text); final Bundle args = getArguments(); final int autoCompleteType; autoCompleteType = args.getInt(EXTRA_AUTO_COMPLETE_TYPE, 0); if (autoCompleteType != 0) { SimpleCursorAdapter mUserAutoCompleteAdapter; if (autoCompleteType == AUTO_COMPLETE_TYPE_SOURCES) { mUserAutoCompleteAdapter = new SourceAutoCompleteAdapter(activity); } else { final ComposeAutoCompleteAdapter adapter = new ComposeAutoCompleteAdapter(activity); adapter.setAccountId(Utils.getDefaultAccountId(activity)); mUserAutoCompleteAdapter = adapter; } editText.setAdapter(mUserAutoCompleteAdapter); editText.setThreshold(1); } } }); return dialog; }
@Override public int getThemeResourceId() { return ThemeUtils.getQuickSearchBarThemeResource(this); }
@Override public int getThemeColor() { return ThemeUtils.getUserAccentColor(this); }
public FilesAdapter(final Context context) { super(context, android.R.layout.simple_list_item_1); mResources = context.getResources(); mActionIconColor = ThemeUtils.isDarkTheme(context) ? 0xffffffff : 0xc0333333; mPadding = (int) (4 * mResources.getDisplayMetrics().density); }
@NonNull @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity()); final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped); final Context context = builder.getContext(); mValidator = new TwidereValidator(context); final LayoutInflater inflater = LayoutInflater.from(context); @SuppressLint("InflateParams") final View view = inflater.inflate(R.layout.dialog_status_quote_retweet, null); final DummyStatusHolderAdapter adapter = new DummyStatusHolderAdapter(context); adapter.setShouldShowAccountsColor(true); final IStatusViewHolder holder = new StatusViewHolder(adapter, view.findViewById(R.id.item_content)); final ParcelableStatus status = getStatus(); assert status != null; builder.setView(view); builder.setTitle(R.string.retweet_quote_confirm_title); if (isMyRetweet(status)) { builder.setPositiveButton(R.string.cancel_retweet, this); } else if (!status.user_is_protected) { builder.setPositiveButton(R.string.retweet, this); } builder.setNeutralButton(R.string.quote, this); builder.setNegativeButton(android.R.string.cancel, null); holder.displayStatus(status, null, false, true); view.findViewById(R.id.item_menu).setVisibility(View.GONE); view.findViewById(R.id.action_buttons).setVisibility(View.GONE); view.findViewById(R.id.item_content).setFocusable(false); view.findViewById(R.id.comment_container) .setVisibility(status.user_is_protected ? View.GONE : View.VISIBLE); final ComposeMaterialEditText mEditComment = (ComposeMaterialEditText) view.findViewById(R.id.edit_comment); mEditComment.setAccountId(status.account_id); final boolean sendByEnter = mPreferences.getBoolean(KEY_QUICK_SEND); final EditTextEnterHandler enterHandler = EditTextEnterHandler.attach( mEditComment, new EditTextEnterHandler.EnterListener() { @Override public boolean shouldCallListener() { return true; } @Override public boolean onHitEnter() { final AsyncTwitterWrapper twitter = mTwitterWrapper; final ParcelableStatus status = getStatus(); if (twitter == null || status == null) return false; retweetOrQuote(twitter, status); dismiss(); return true; } }, sendByEnter); enterHandler.addTextChangedListener( new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) { updateTextCount(getDialog(), s, status); } @Override public void afterTextChanged(Editable s) {} }); final View commentMenu = view.findViewById(R.id.comment_menu); mPopupMenu = new PopupMenu(context, commentMenu, Gravity.NO_GRAVITY, R.attr.actionOverflowMenuStyle, 0); commentMenu.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mPopupMenu.show(); } }); commentMenu.setOnTouchListener(mPopupMenu.getDragToOpenListener()); mPopupMenu.inflate(R.menu.menu_dialog_comment); final Menu menu = mPopupMenu.getMenu(); MenuUtils.setMenuItemAvailability( menu, R.id.quote_original_status, status.retweet_id > 0 || status.quoted_id > 0); mPopupMenu.setOnMenuItemClickListener( new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item.isCheckable()) { item.setChecked(!item.isChecked()); return true; } return false; } }); final Dialog dialog = builder.create(); dialog.setOnShowListener( new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { updateTextCount(dialog, mEditComment.getText(), status); } }); return dialog; }
@Override protected Drawable getActionBarBackground(final Context context) { return ThemeUtils.getActionBarBackground(context, false); }
@Override public int getThemeResourceId() { return ThemeUtils.getDialogThemeResource(this); }