Example usage for android.view ContextThemeWrapper ContextThemeWrapper

List of usage examples for android.view ContextThemeWrapper ContextThemeWrapper

Introduction

In this page you can find the example usage for android.view ContextThemeWrapper ContextThemeWrapper.

Prototype

public ContextThemeWrapper(Context base, Resources.Theme theme) 

Source Link

Document

Creates a new context wrapper with the specified theme.

Usage

From source file:butter.droid.fragments.dialog.EpisodeDialogFragment.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override//from w w  w. ja  v a 2 s  .c  om
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = LayoutInflater.from(new ContextThemeWrapper(getActivity(), R.style.Theme_Butter))
            .inflate(R.layout.fragment_dialog_episode, container, false);
    ButterKnife.bind(this, v);

    if (!VersionUtils.isJellyBean()) {
        mPlayButton.setBackgroundDrawable(PixelUtils.changeDrawableColor(mPlayButton.getContext(),
                R.drawable.play_button_circle, mShow.color));
    } else {
        mPlayButton.setBackground(PixelUtils.changeDrawableColor(mPlayButton.getContext(),
                R.drawable.play_button_circle, mShow.color));
    }

    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mPlaceholder.getLayoutParams();
    layoutParams.height = PixelUtils.getScreenHeight(mActivity);
    mPlaceholder.setLayoutParams(layoutParams);

    return v;
}

From source file:pct.droid.dialogfragments.EpisodeDialogFragment.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override/* ww w . java  2 s .  c  o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = LayoutInflater.from(new ContextThemeWrapper(getActivity(), R.style.Theme_PopcornTime))
            .inflate(R.layout.fragment_dialog_episode, container, false);
    ButterKnife.inject(this, v);

    if (!VersionUtils.isJellyBean()) {
        mPlayButton.setBackgroundDrawable(PixelUtils.changeDrawableColor(mPlayButton.getContext(),
                R.drawable.play_button_circle, mShow.color));
    } else {
        mPlayButton.setBackground(PixelUtils.changeDrawableColor(mPlayButton.getContext(),
                R.drawable.play_button_circle, mShow.color));
    }

    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mPlaceholder.getLayoutParams();
    layoutParams.height = PixelUtils.getScreenHeight(mActivity);
    mPlaceholder.setLayoutParams(layoutParams);

    return v;
}

From source file:com.actionbarsherlock.internal.widget.IcsListPopupWindow.java

public IcsListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    mContext = context;//from   w  ww . j  a  va2  s  . com
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        Context wrapped = new ContextThemeWrapper(context, defStyleRes);
        mPopup = new PopupWindow(wrapped, attrs, defStyleAttr);
    } else {
        mPopup = new PopupWindow(context, attrs, defStyleAttr, defStyleRes);
    }
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
}

From source file:piuk.blockchain.android.ui.dialogs.RequestPasswordDialog.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final FragmentActivity activity = (FragmentActivity) getActivity();

    final WalletApplication application = (WalletApplication) activity.getApplication();

    final LayoutInflater inflater = LayoutInflater.from(activity);

    final Builder dialog = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.Theme_Dialog));

    if (passwordType == PasswordTypeSecond)
        dialog.setTitle(R.string.second_password_title);
    else if (passwordType == PasswordTypePrivateKey)
        dialog.setTitle(R.string.private_key_password_title);
    else// w  ww . j  a v  a2 s  .  c o  m
        dialog.setTitle(R.string.main_password_title);

    final View view = inflater.inflate(R.layout.password_dialog, null);

    dialog.setView(view);

    final TextView passwordField = (TextView) view.findViewById(R.id.password_field);

    final TextView titleTextView = (TextView) view.findViewById(R.id.title_text_view);

    if (passwordType == PasswordTypeSecond)
        titleTextView.setText(R.string.second_password_text);
    else if (passwordType == PasswordTypePrivateKey)
        titleTextView.setText(R.string.private_key_password_text);
    else
        titleTextView.setText(R.string.main_password_text);

    final Button continueButton = (Button) view.findViewById(R.id.password_continue);

    continueButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {

            try {
                if (passwordType == PasswordTypeSecond) {
                    if (passwordField.getText().toString().trim() == null
                            || passwordField.getText().toString().trim().length() < 1)
                        return;

                    MyRemoteWallet wallet = application.getRemoteWallet();

                    String secondPassword = passwordField.getText().toString().trim();

                    if (wallet == null) {
                        dismiss();

                        callback.onFail();
                    }
                    if (wallet.validateSecondPassword(secondPassword)) {
                        wallet.setTemporySecondPassword(secondPassword);

                        dismiss();

                        callback.onSuccess();
                    } else {
                        Toast.makeText(activity.getApplication(), R.string.password_incorrect,
                                Toast.LENGTH_SHORT).show();
                    }
                } else if (passwordType == PasswordTypeMain) {
                    if (passwordField.getText().toString().trim() == null
                            || passwordField.getText().toString().trim().length() < 1) {
                        callback.onFail();
                    }

                    String localWallet = application.readLocalWallet();
                    if (!application.decryptLocalWallet(localWallet,
                            passwordField.getText().toString().trim())) {
                        callback.onFail();
                        return;
                    }

                    String password = passwordField.getText().toString().trim();

                    application.checkIfWalletHasUpdatedAndFetchTransactions(password, new SuccessCallback() {
                        @Override
                        public void onSuccess() {
                            dismiss();
                            callback.onSuccess();
                        }

                        @Override
                        public void onFail() {
                            dismiss();
                            callback.onFail();
                        }
                    });
                } else {
                    if (passwordField.getText().toString().trim() == null
                            || passwordField.getText().toString().trim().length() < 1) {
                        callback.onFail();
                    }

                    String localWallet = application.readLocalWallet();
                    if (!application.decryptLocalWallet(localWallet,
                            passwordField.getText().toString().trim())) {
                        callback.onFail();
                        return;
                    }

                    passwordResult = passwordField.getText().toString().trim();

                    dismiss();

                    callback.onSuccess();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

    Dialog d = dialog.create();

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();

    lp.dimAmount = 0;
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
    //      lp.gravity = Gravity.BOTTOM;

    d.show();

    d.getWindow().setAttributes(lp);

    d.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return d;
}

From source file:com.binomed.showtime.android.screen.search.CineShowTimeSearchFragment.java

/** Called when the activity is first created. */
@Override/*from w  w w  .ja  v a 2s.  com*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // super.onCreate(savedInstanceState);
    tracker = fragmentInteraction.getTracker();

    // Bug fix do to pb of theme. Was forced to set manually the theme.
    SharedPreferences pref = PreferenceManager
            .getDefaultSharedPreferences(fragmentInteraction.getMainContext());
    String defaultTheme = fragmentInteraction.getMainContext().getResources()
            .getString(R.string.preference_gen_default_theme);
    String theme = pref.getString(
            fragmentInteraction.getMainContext().getResources().getString(R.string.preference_gen_key_theme),
            defaultTheme);
    int themeRessource = R.style.Theme_Dark_Night;
    if (!theme.equals(defaultTheme)) {
        themeRessource = R.style.Theme_Shine_the_lite;
    }

    LayoutInflater newInflater = inflater
            .cloneInContext(new ContextThemeWrapper(fragmentInteraction.getMainContext(), themeRessource));
    View mainView = newInflater.inflate(R.layout.fragment_search, container, false);

    getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    model = fragmentInteraction.getModelActivity();

    initViews(mainView);
    initDB();

    display();

    return mainView;
}

From source file:com.ayuget.redface.ui.fragment.TopicListFragment.java

protected void initializeAdapters() {
    subcategoriesAdapter = new SubcategoriesAdapter(getActivity(), topicFilter);
    subcategoriesAdapter.replaceWith(category);

    topicsAdapter = new TopicsAdapter(
            new ContextThemeWrapper(getActivity(), themeManager.getActiveThemeStyle()), themeManager,
            settings.isCompactModeEnabled());
    topicsAdapter.setOnTopicClickedListener(this);
    topicsAdapter.setOnTopicLongClickListener(this);
}

From source file:com.afwsamples.testdpc.SetupManagementFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        mLogoUri = (Uri) savedInstanceState.getParcelable(EXTRA_PROVISIONING_LOGO_URI);
        mCurrentColor = savedInstanceState.getInt(EXTRA_PROVISIONING_MAIN_COLOR);
    } else {//w  ww. j a  va  2 s .  co m
        mLogoUri = resourceToUri(getActivity(), R.drawable.ic_launcher);
        mCurrentColor = getResources().getColor(R.color.teal);
    }

    // Use setupwizard theme
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.SetupTheme);
    LayoutInflater themeInflater = inflater.cloneInContext(contextThemeWrapper);
    View view = themeInflater.inflate(R.layout.setup_management_fragment, container, false);
    SetupWizardLayout layout = (SetupWizardLayout) view.findViewById(R.id.setup_wizard_layout);
    NavigationBar navigationBar = layout.getNavigationBar();
    navigationBar.setNavigationBarListener(this);
    navigationBar.getBackButton().setText(R.string.exit);
    mNavigationNextButton = navigationBar.getNextButton();
    mNavigationNextButton.setText(R.string.setup_label);

    mSetupManagementMessage = (TextView) view.findViewById(R.id.setup_management_message_id);
    mSetupOptions = (RadioGroup) view.findViewById(R.id.setup_options);
    mSetupOptions.setOnCheckedChangeListener(this);
    mSkipUserConsent = (CheckBox) view.findViewById(R.id.skip_user_consent);
    mKeepAccountMigrated = (CheckBox) view.findViewById(R.id.keep_account_migrated);
    mSkipEncryption = (CheckBox) view.findViewById(R.id.skip_encryption);

    mParamsView = view.findViewById(R.id.params);
    mParamsIndicator = (ImageButton) view.findViewById(R.id.params_indicator);
    mParamsIndicator.setOnClickListener(this);

    view.findViewById(R.id.color_select_button).setOnClickListener(this);
    mColorValue = (TextView) view.findViewById(R.id.selected_color_value);
    mColorValue.setText(String.format(ColorPicker.COLOR_STRING_FORMATTER, mCurrentColor));
    mColorPreviewView = (ImageView) view.findViewById(R.id.preview_color);
    mColorPreviewView.setImageTintList(ColorStateList.valueOf(mCurrentColor));

    Intent launchIntent = getActivity().getIntent();
    if (LaunchIntentUtil.isSynchronousAuthLaunch(launchIntent)) {
        Account addedAccount = LaunchIntentUtil.getAddedAccount(launchIntent);
        if (addedAccount != null) {
            view.findViewById(R.id.managed_account_desc).setVisibility(View.VISIBLE);
            // Show the user which account needs management.
            TextView managedAccountName = (TextView) view.findViewById(R.id.managed_account_name);
            managedAccountName.setVisibility(View.VISIBLE);
            managedAccountName.setText(addedAccount.name);
        } else {
            // This is not an expected case, sync-auth is triggered by an account being added so
            // we expect to be told which account to migrate in the launch intent. We don't
            // finish() here as it's still technically feasible to continue.
            Toast.makeText(getActivity(), R.string.invalid_launch_intent_no_account, Toast.LENGTH_LONG).show();
        }
    }
    return view;
}

From source file:org.dmfs.tasks.InputTextDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final Context contextThemeWrapperLight = new ContextThemeWrapper(getActivity(),
            R.style.ThemeOverlay_AppCompat_Light);
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapperLight);

    View view = localInflater.inflate(R.layout.fragment_input_text_dialog, container);

    mEditText = (EditText) view.findViewById(android.R.id.input);
    mErrorText = (TextView) view.findViewById(R.id.error);
    if (savedInstanceState == null && mInitialText != null) {
        mEditText.setText(mInitialText);
    }/*www  .  j a  v  a  2s . com*/
    if (savedInstanceState == null && mHint != null) {
        mEditText.setHint(mHint);
    }
    if (mMessage != null) {
        TextView mMessageView = (TextView) view.findViewById(android.R.id.message);
        mMessageView.setText(mMessage);
        mMessageView.setVisibility(View.VISIBLE);
    }
    ((TextView) view.findViewById(android.R.id.title)).setText(mTitle);

    mEditText.requestFocus();
    getDialog().getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    mEditText.setOnEditorActionListener(this);

    view.findViewById(android.R.id.button1).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            handleSave();
        }
    });

    view.findViewById(android.R.id.button2).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            handleCancel();
        }
    });

    return view;
}

From source file:com.andrewshu.android.reddit.mail.InboxActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog;/*from  w ww. j  av a 2  s . c  o m*/
    ProgressDialog pdialog;
    AlertDialog.Builder builder;
    LayoutInflater inflater;
    View layout; // used for inflated views for AlertDialog.Builder.setView()

    switch (id) {
    case Constants.DIALOG_COMPOSE:
        inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        layout = inflater.inflate(R.layout.compose_dialog, null);
        dialog = builder.setView(layout).create();
        final Dialog composeDialog = dialog;

        Common.setTextColorFromTheme(mSettings.getTheme(), getResources(),
                (TextView) layout.findViewById(R.id.compose_destination_textview),
                (TextView) layout.findViewById(R.id.compose_subject_textview),
                (TextView) layout.findViewById(R.id.compose_message_textview),
                (TextView) layout.findViewById(R.id.compose_captcha_textview),
                (TextView) layout.findViewById(R.id.compose_captcha_loading));

        final EditText composeDestination = (EditText) layout.findViewById(R.id.compose_destination_input);
        final EditText composeSubject = (EditText) layout.findViewById(R.id.compose_subject_input);
        final EditText composeText = (EditText) layout.findViewById(R.id.compose_text_input);
        final Button composeSendButton = (Button) layout.findViewById(R.id.compose_send_button);
        final Button composeCancelButton = (Button) layout.findViewById(R.id.compose_cancel_button);
        final EditText composeCaptcha = (EditText) layout.findViewById(R.id.compose_captcha_input);
        composeSendButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                ThingInfo thingInfo = new ThingInfo();

                if (!FormValidation.validateComposeMessageInputFields(InboxActivity.this, composeDestination,
                        composeSubject, composeText, composeCaptcha))
                    return;

                thingInfo.setDest(composeDestination.getText().toString().trim());
                thingInfo.setSubject(composeSubject.getText().toString().trim());
                new MyMessageComposeTask(composeDialog, thingInfo, composeCaptcha.getText().toString().trim(),
                        mCaptchaIden, mSettings, mClient, InboxActivity.this)
                                .execute(composeText.getText().toString().trim());
                removeDialog(Constants.DIALOG_COMPOSE);
            }
        });
        composeCancelButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                removeDialog(Constants.DIALOG_COMPOSE);
            }
        });
        break;

    case Constants.DIALOG_COMPOSING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Composing message...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    default:
        throw new IllegalArgumentException("Unexpected dialog id " + id);
    }
    return dialog;
}

From source file:nya.miku.wishmaster.http.cloudflare.CloudflareUIHandler.java

/**
 *  ?-?  Cloudflare.// w  w  w  .j  ava 2  s.  c o m
 *    
 * @param e ? {@link CloudflareException}
 * @param chan  
 * @param activity ?,    ?  ( ?  ? ),
 *   ?   ? WebView ? Anti DDOS  ? javascript.
 * ???  ?  UI  ({@link Activity#runOnUiThread(Runnable)})
 * @param cfTask ?? 
 * @param callback ? {@link Callback}
 */
static void handleCloudflare(final CloudflareException e, final HttpChanModule chan, final Activity activity,
        final CancellableTask cfTask, final InteractiveException.Callback callback) {
    if (cfTask.isCancelled())
        return;

    if (!e.isRecaptcha()) { // ? anti DDOS 
        if (!CloudflareChecker.getInstance().isAvaibleAntiDDOS()) {
            //?  ?   ??  ,   ?  ? ?
            // ?, ?      ChanModule,    
            //  ?  ?  () cloudflare  ? ?
            //  ?  ? ? ?   ? CloudflareChecker
            while (!CloudflareChecker.getInstance().isAvaibleAntiDDOS())
                Thread.yield();
            if (!cfTask.isCancelled())
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        callback.onSuccess();
                    }
                });
            return;
        }

        Cookie cfCookie = CloudflareChecker.getInstance().checkAntiDDOS(e, chan.getHttpClient(), cfTask,
                activity);
        if (cfCookie != null) {
            chan.saveCookie(cfCookie);
            if (!cfTask.isCancelled()) {
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        callback.onSuccess();
                    }
                });
            }
        } else if (!cfTask.isCancelled()) {
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    callback.onError(activity.getString(R.string.error_cloudflare_antiddos));
                }
            });
        }
    } else { //  ? 
        final Recaptcha recaptcha;
        try {
            recaptcha = CloudflareChecker.getInstance().getRecaptcha(e, chan.getHttpClient(), cfTask);
        } catch (RecaptchaException recaptchaException) {
            if (!cfTask.isCancelled())
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        callback.onError(activity.getString(R.string.error_cloudflare_get_captcha));
                    }
                });
            return;
        }

        if (!cfTask.isCancelled())
            activity.runOnUiThread(new Runnable() {
                @SuppressLint("InflateParams")
                @Override
                public void run() {
                    Context dialogContext = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
                            ? new ContextThemeWrapper(activity, R.style.Neutron_Medium)
                            : activity;
                    View view = LayoutInflater.from(dialogContext).inflate(R.layout.dialog_cloudflare_captcha,
                            null);
                    ImageView captchaView = (ImageView) view.findViewById(R.id.dialog_captcha_view);
                    final EditText captchaField = (EditText) view.findViewById(R.id.dialog_captcha_field);
                    captchaView.setImageBitmap(recaptcha.bitmap);

                    DialogInterface.OnClickListener process = new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            if (cfTask.isCancelled())
                                return;
                            PriorityThreadFactory.LOW_PRIORITY_FACTORY.newThread(new Runnable() {
                                @Override
                                public void run() {
                                    String answer = captchaField.getText().toString();
                                    Cookie cfCookie = CloudflareChecker.getInstance().checkRecaptcha(e,
                                            (ExtendedHttpClient) chan.getHttpClient(), cfTask,
                                            recaptcha.challenge, answer);
                                    if (cfCookie != null) {
                                        chan.saveCookie(cfCookie);
                                        if (!cfTask.isCancelled()) {
                                            activity.runOnUiThread(new Runnable() {
                                                @Override
                                                public void run() {
                                                    callback.onSuccess();
                                                }
                                            });
                                        }
                                    } else {
                                        //   (?,  ,    )
                                        handleCloudflare(e, chan, activity, cfTask, callback);
                                    }
                                }
                            }).start();
                        }
                    };

                    DialogInterface.OnCancelListener onCancel = new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialog) {
                            callback.onError(activity.getString(R.string.error_cloudflare_cancelled));
                        }
                    };

                    if (cfTask.isCancelled())
                        return;

                    final AlertDialog recaptchaDialog = new AlertDialog.Builder(dialogContext).setView(view)
                            .setPositiveButton(R.string.dialog_cloudflare_captcha_check, process)
                            .setOnCancelListener(onCancel).create();
                    recaptchaDialog.getWindow()
                            .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
                    recaptchaDialog.setCanceledOnTouchOutside(false);
                    recaptchaDialog.show();

                    captchaView.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            recaptchaDialog.dismiss();
                            if (cfTask.isCancelled())
                                return;
                            PriorityThreadFactory.LOW_PRIORITY_FACTORY.newThread(new Runnable() {
                                @Override
                                public void run() {
                                    handleCloudflare(e, chan, activity, cfTask, callback);
                                }
                            }).start();
                        }
                    });
                }
            });
    }
}