Search in sources :

Example 66 with ContextThemeWrapper

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ContextThemeWrapper(android.view.ContextThemeWrapper) DialogInterface(android.content.DialogInterface) AuthenticationActionBuilder(org.wordpress.android.fluxc.generated.AuthenticationActionBuilder)

Example 67 with ContextThemeWrapper

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ContextThemeWrapper(android.view.ContextThemeWrapper)

Example 68 with ContextThemeWrapper

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;
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper) LayoutInflater(android.view.LayoutInflater) View(android.view.View) ViewTreeObserver(android.view.ViewTreeObserver) Nullable(android.support.annotation.Nullable)

Example 69 with ContextThemeWrapper

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();
}
Also used : LinearLayout(android.widget.LinearLayout) Arrays(java.util.Arrays) Bundle(android.os.Bundle) ThemeHelper(org.schabi.newpipe.util.ThemeHelper) Icepick(icepick.Icepick) RadioButton(android.widget.RadioButton) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) SinglePlayQueue(org.schabi.newpipe.playlist.SinglePlayQueue) IntentService(android.app.IntentService) StreamInfo(org.schabi.newpipe.extractor.stream.StreamInfo) ThemeHelper.resolveResourceIdFromAttr(org.schabi.newpipe.util.ThemeHelper.resolveResourceIdFromAttr) ExtractorHelper(org.schabi.newpipe.util.ExtractorHelper) ContextThemeWrapper(android.view.ContextThemeWrapper) View(android.view.View) Button(android.widget.Button) Schedulers(io.reactivex.schedulers.Schedulers) PreferenceManager(android.preference.PreferenceManager) Collection(java.util.Collection) UserAction(org.schabi.newpipe.report.UserAction) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) Serializable(java.io.Serializable) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) PlaylistPlayQueue(org.schabi.newpipe.playlist.PlaylistPlayQueue) Nullable(android.support.annotation.Nullable) ChannelPlayQueue(org.schabi.newpipe.playlist.ChannelPlayQueue) StreamingService(org.schabi.newpipe.extractor.StreamingService) NewPipe(org.schabi.newpipe.extractor.NewPipe) NavigationHelper(org.schabi.newpipe.util.NavigationHelper) Intent(android.content.Intent) RadioGroup(android.widget.RadioGroup) Single(io.reactivex.Single) HashSet(java.util.HashSet) ServiceList(org.schabi.newpipe.extractor.ServiceList) Toast(android.widget.Toast) Observable(io.reactivex.Observable) State(icepick.State) PlaylistInfo(org.schabi.newpipe.extractor.playlist.PlaylistInfo) ExtractionException(org.schabi.newpipe.extractor.exceptions.ExtractionException) DialogInterface(android.content.DialogInterface) Info(org.schabi.newpipe.extractor.Info) PlayerHelper(org.schabi.newpipe.player.helper.PlayerHelper) LayoutInflater(android.view.LayoutInflater) LinkType(org.schabi.newpipe.extractor.StreamingService.LinkType) TextUtils(android.text.TextUtils) Consumer(io.reactivex.functions.Consumer) ChannelInfo(org.schabi.newpipe.extractor.channel.ChannelInfo) DrawableRes(android.support.annotation.DrawableRes) AlertDialog(android.support.v7.app.AlertDialog) SharedPreferences(android.content.SharedPreferences) NotificationCompat(android.support.v4.app.NotificationCompat) PlayQueue(org.schabi.newpipe.playlist.PlayQueue) PermissionHelper(org.schabi.newpipe.util.PermissionHelper) AlertDialog(android.support.v7.app.AlertDialog) RadioGroup(android.widget.RadioGroup) SharedPreferences(android.content.SharedPreferences) DialogInterface(android.content.DialogInterface) RadioButton(android.widget.RadioButton) View(android.view.View) ContextThemeWrapper(android.view.ContextThemeWrapper) LayoutInflater(android.view.LayoutInflater) LinearLayout(android.widget.LinearLayout)

Example 70 with ContextThemeWrapper

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;
}
Also used : ItemDecorationDivider(com.winsonchiu.reader.utils.ItemDecorationDivider) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) Page(com.winsonchiu.reader.data.Page) FragmentNewMessage(com.winsonchiu.reader.FragmentNewMessage) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) ContextThemeWrapper(android.view.ContextThemeWrapper) ThemeWrapper(com.winsonchiu.reader.theme.ThemeWrapper) AdapterCommentList(com.winsonchiu.reader.comments.AdapterCommentList) ScrollAwareFloatingActionButtonBehavior(com.winsonchiu.reader.utils.ScrollAwareFloatingActionButtonBehavior) AppBarLayout(android.support.design.widget.AppBarLayout) ScrollAwareFloatingActionButtonBehavior(com.winsonchiu.reader.utils.ScrollAwareFloatingActionButtonBehavior) Comment(com.winsonchiu.reader.data.reddit.Comment) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) AppCompatSpinner(android.support.v7.widget.AppCompatSpinner) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ContextThemeWrapper(android.view.ContextThemeWrapper) AdapterView(android.widget.AdapterView) Likes(com.winsonchiu.reader.data.reddit.Likes)

Aggregations

View (android.view.View)41 ContextThemeWrapper (android.support.v7.view.ContextThemeWrapper)38 ContextThemeWrapper (android.view.ContextThemeWrapper)35 DialogInterface (android.content.DialogInterface)26 Context (android.content.Context)25 AlertDialog (android.support.v7.app.AlertDialog)24 TextView (android.widget.TextView)23 RecyclerView (android.support.v7.widget.RecyclerView)21 ImageView (android.widget.ImageView)21 LayoutInflater (android.view.LayoutInflater)18 Intent (android.content.Intent)13 Nullable (android.support.annotation.Nullable)10 ColorPreferences (me.ccrama.redditslide.ColorPreferences)10 Drawable (android.graphics.drawable.Drawable)9 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9 EditText (android.widget.EditText)9 Bundle (android.os.Bundle)7 NonNull (android.support.annotation.NonNull)7 ArrayList (java.util.ArrayList)7 SuppressLint (android.annotation.SuppressLint)6