use of android.support.v7.view.ContextThemeWrapper in project WordPress-Login-Flow-Android by wordpress-mobile.
the class SignupMagicLinkFragment method showErrorDialog.
protected void showErrorDialog(String message) {
DialogInterface.OnClickListener dialogListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
case DialogInterface.BUTTON_POSITIVE:
sendMagicLinkEmail();
break;
}
}
};
AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme)).setMessage(message).setNegativeButton(R.string.signup_magic_link_error_button_negative, dialogListener).setPositiveButton(R.string.signup_magic_link_error_button_positive, dialogListener).create();
dialog.show();
}
use of android.support.v7.view.ContextThemeWrapper in project WordPress-Login-Flow-Android by wordpress-mobile.
the class Login2FaFragment method showErrorDialog.
private void showErrorDialog(String message) {
AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme)).setMessage(message).setPositiveButton(R.string.login_error_button, null).create();
dialog.show();
}
use of android.support.v7.view.ContextThemeWrapper in project FastHub by k0shk0sh.
the class BaseBottomSheetDialog method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final Context contextThemeWrapper = new ContextThemeWrapper(getContext(), getContext().getTheme());
LayoutInflater themeAwareInflater = inflater.cloneInContext(contextThemeWrapper);
View view = themeAwareInflater.inflate(layoutRes(), container, false);
unbinder = ButterKnife.bind(this, view);
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
View parent = getDialog().findViewById(R.id.design_bottom_sheet);
if (parent != null) {
bottomSheetBehavior = BottomSheetBehavior.from(parent);
if (bottomSheetBehavior != null) {
bottomSheetBehavior.setBottomSheetCallback(bottomSheetCallback);
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
}
}
});
return view;
}
use of android.support.v7.view.ContextThemeWrapper in project NewPipe by TeamNewPipe.
the class RouterActivity method showDialog.
private void showDialog() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final ContextThemeWrapper themeWrapper = new ContextThemeWrapper(this, ThemeHelper.isLightThemeSelected(this) ? R.style.LightTheme : R.style.DarkTheme);
LayoutInflater inflater = LayoutInflater.from(themeWrapper);
final LinearLayout rootLayout = (LinearLayout) inflater.inflate(R.layout.preferred_player_dialog_view, null, false);
final RadioGroup radioGroup = rootLayout.findViewById(android.R.id.list);
final AdapterChoiceItem[] choices = { new AdapterChoiceItem(getString(R.string.show_info_key), getString(R.string.show_info), resolveResourceIdFromAttr(themeWrapper, R.attr.info)), new AdapterChoiceItem(getString(R.string.video_player_key), getString(R.string.video_player), resolveResourceIdFromAttr(themeWrapper, R.attr.play)), new AdapterChoiceItem(getString(R.string.background_player_key), getString(R.string.background_player), resolveResourceIdFromAttr(themeWrapper, R.attr.audio)), new AdapterChoiceItem(getString(R.string.popup_player_key), getString(R.string.popup_player), resolveResourceIdFromAttr(themeWrapper, R.attr.popup)) };
final DialogInterface.OnClickListener dialogButtonsClickListener = (dialog, which) -> {
final int indexOfChild = radioGroup.indexOfChild(radioGroup.findViewById(radioGroup.getCheckedRadioButtonId()));
final AdapterChoiceItem choice = choices[indexOfChild];
handleChoice(choice.key);
if (which == DialogInterface.BUTTON_POSITIVE) {
preferences.edit().putString(getString(R.string.preferred_open_action_key), choice.key).apply();
}
};
final AlertDialog alertDialog = new AlertDialog.Builder(themeWrapper).setTitle(R.string.preferred_player_share_menu_title).setView(radioGroup).setCancelable(true).setNegativeButton(R.string.just_once, dialogButtonsClickListener).setPositiveButton(R.string.always, dialogButtonsClickListener).setOnDismissListener((dialog) -> finish()).create();
alertDialog.setOnShowListener(dialog -> {
setDialogButtonsState(alertDialog, radioGroup.getCheckedRadioButtonId() != -1);
});
radioGroup.setOnCheckedChangeListener((group, checkedId) -> setDialogButtonsState(alertDialog, true));
final View.OnClickListener radioButtonsClickListener = v -> {
final int indexOfChild = radioGroup.indexOfChild(v);
if (indexOfChild == -1)
return;
selectedPreviously = selectedRadioPosition;
selectedRadioPosition = indexOfChild;
if (selectedPreviously == selectedRadioPosition) {
handleChoice(choices[selectedRadioPosition].key);
}
};
int id = 12345;
for (AdapterChoiceItem item : choices) {
final RadioButton radioButton = (RadioButton) inflater.inflate(R.layout.list_radio_icon_item, null);
radioButton.setText(item.description);
radioButton.setCompoundDrawablesWithIntrinsicBounds(item.icon, 0, 0, 0);
radioButton.setChecked(false);
radioButton.setId(id++);
radioButton.setLayoutParams(new RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
radioButton.setOnClickListener(radioButtonsClickListener);
radioGroup.addView(radioButton);
}
if (selectedRadioPosition == -1) {
final String lastSelectedPlayer = preferences.getString(getString(R.string.preferred_open_action_last_selected_key), null);
if (!TextUtils.isEmpty(lastSelectedPlayer)) {
for (int i = 0; i < choices.length; i++) {
AdapterChoiceItem c = choices[i];
if (lastSelectedPlayer.equals(c.key)) {
selectedRadioPosition = i;
break;
}
}
}
}
selectedRadioPosition = Math.min(Math.max(-1, selectedRadioPosition), choices.length - 1);
if (selectedRadioPosition != -1) {
((RadioButton) radioGroup.getChildAt(selectedRadioPosition)).setChecked(true);
}
selectedPreviously = selectedRadioPosition;
alertDialog.show();
}
use of android.support.v7.view.ContextThemeWrapper in project Reader by TheKeeperOfPie.
the class FragmentInbox method onCreateView.
@SuppressWarnings("ResourceType")
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_inbox, container, false);
listener = new ControllerInbox.Listener() {
@Override
public void setPage(Page page) {
spinnerPage.setSelection(adapterInboxPage.getPages().indexOf(page));
}
@Override
public RecyclerView.Adapter getAdapter() {
return adapterInbox;
}
@Override
public void setToolbarTitle(CharSequence title) {
toolbar.setTitle(title);
}
@Override
public void setRefreshing(boolean refreshing) {
swipeRefreshInbox.setRefreshing(refreshing);
}
@Override
public void post(Runnable runnable) {
recyclerInbox.post(runnable);
}
};
layoutCoordinator = (CoordinatorLayout) view.findViewById(R.id.layout_coordinator);
layoutAppBar = (AppBarLayout) view.findViewById(R.id.layout_app_bar);
int styleColorBackground = AppSettings.THEME_DARK.equals(mListener.getThemeBackground()) ? R.style.MenuDark : R.style.MenuLight;
ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(new ThemeWrapper(activity, UtilsColor.getThemeForColor(getResources(), themer.getColorPrimary(), mListener)), styleColorBackground);
toolbar = (Toolbar) activity.getLayoutInflater().cloneInContext(contextThemeWrapper).inflate(R.layout.toolbar, layoutAppBar, false);
layoutAppBar.addView(toolbar);
((AppBarLayout.LayoutParams) toolbar.getLayoutParams()).setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
toolbar.setTitleTextColor(themer.getColorFilterPrimary().getColor());
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
toolbar.getNavigationIcon().mutate().setColorFilter(themer.getColorFilterPrimary());
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListener.openDrawer();
}
});
setUpOptionsMenu();
floatingActionButtonNewMessage = (FloatingActionButton) view.findViewById(R.id.fab_new_message);
floatingActionButtonNewMessage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentNewMessage fragmentNewMessage = FragmentNewMessage.newInstance();
getFragmentManager().beginTransaction().hide(FragmentInbox.this).add(R.id.frame_fragment, fragmentNewMessage, FragmentNewMessage.TAG).addToBackStack(null).commit();
}
});
floatingActionButtonNewMessage.setColorFilter(themer.getColorFilterAccent());
behaviorFloatingActionButton = new ScrollAwareFloatingActionButtonBehavior(activity, null, new ScrollAwareFloatingActionButtonBehavior.OnVisibilityChangeListener() {
@Override
public void onStartHideFromScroll() {
}
@Override
public void onEndHideFromScroll() {
}
});
((CoordinatorLayout.LayoutParams) floatingActionButtonNewMessage.getLayoutParams()).setBehavior(behaviorFloatingActionButton);
adapterInboxPage = new AdapterInboxPage(activity);
spinnerPage = new AppCompatSpinner(contextThemeWrapper);
toolbar.addView(spinnerPage);
((Toolbar.LayoutParams) spinnerPage.getLayoutParams()).setMarginEnd((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()));
spinnerPage.setAdapter(adapterInboxPage);
spinnerPage.setSelection(adapterInboxPage.getPages().indexOf(controllerInbox.getPage()));
spinnerPage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
controllerInbox.setPage(adapterInboxPage.getItem(position));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
swipeRefreshInbox = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_inbox);
swipeRefreshInbox.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
controllerInbox.reload();
}
});
linearLayoutManager = new LinearLayoutManager(activity);
recyclerInbox = (RecyclerView) view.findViewById(R.id.recycler_inbox);
recyclerInbox.setHasFixedSize(true);
recyclerInbox.setItemAnimator(new DefaultItemAnimator());
recyclerInbox.getItemAnimator().setRemoveDuration(UtilsAnimation.EXPAND_ACTION_DURATION);
recyclerInbox.setLayoutManager(linearLayoutManager);
recyclerInbox.addItemDecoration(new ItemDecorationDivider(activity, ItemDecorationDivider.VERTICAL_LIST));
AdapterListener adapterListener = new AdapterListener() {
@Override
public void scrollAndCenter(int position, int height) {
linearLayoutManager.scrollToPositionWithOffset(position, 0);
}
@Override
public void hideToolbar() {
AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
}
@Override
public void clearDecoration() {
behaviorFloatingActionButton.animateOut(floatingActionButtonNewMessage);
AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
}
@Override
public void requestMore() {
controllerInbox.loadMore();
}
@Override
public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
recyclerInbox.requestDisallowInterceptTouchEvent(disallow);
swipeRefreshInbox.requestDisallowInterceptTouchEvent(disallow);
}
@Override
public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
}
};
AdapterCommentList.ViewHolderComment.Listener listenerComments = new AdapterCommentList.ViewHolderComment.Listener() {
@Override
public void onToggleComment(Comment comment) {
}
@Override
public void onShowReplyEditor(Comment comment) {
}
@Override
public void onEditComment(Comment comment, String text) {
}
@Override
public void onSendComment(Comment comment, String text) {
}
@Override
public void onMarkRead(Comment comment) {
}
@Override
public void onLoadNestedComments(Comment comment) {
}
@Override
public void onJumpToParent(Comment comment) {
}
@Override
public void onViewProfile(Comment comment) {
}
@Override
public void onCopyText(Comment comment) {
}
@Override
public void onDeleteComment(Comment comment) {
}
@Override
public void onReport(Comment comment) {
}
@Override
public void onVoteComment(Comment comment, AdapterCommentList.ViewHolderComment viewHolderComment, Likes vote) {
}
@Override
public void onSave(Comment comment) {
}
};
if (adapterInbox == null) {
adapterInbox = new AdapterInbox(controllerInbox, controllerUser, adapterListener, listenerComments, mListener.getEventListenerBase());
}
recyclerInbox.setAdapter(adapterInbox);
return view;
}
Aggregations