Search in sources :

Example 1 with AppCompatDialog

use of android.support.v7.app.AppCompatDialog in project mosby by sockeqwe.

the class StatisticsDialog method onCreateDialog.

//
// End delegates
//
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AppCompatDialog dialog = new AppCompatDialog(getActivity(), getTheme());
    dialog.setTitle(R.string.menu_statistics);
    return dialog;
}
Also used : AppCompatDialog(android.support.v7.app.AppCompatDialog) NonNull(android.support.annotation.NonNull)

Example 2 with AppCompatDialog

use of android.support.v7.app.AppCompatDialog in project Rashr by DsLNeXuS.

the class BackupRestoreFragment method createBackup.

public void createBackup(final boolean RecoveryBackup) {
    String prefix;
    String CurrentName;
    String EXT;
    if (RecoveryBackup) {
        prefix = "recovery";
        EXT = RashrApp.DEVICE.getRecoveryExt();
        CurrentName = RashrApp.DEVICE.getRecoveryVersion();
    } else {
        prefix = "kernel";
        EXT = RashrApp.DEVICE.getKernelExt();
        CurrentName = RashrApp.DEVICE.getKernelVersion();
    }
    final AppCompatDialog dialog = new AppCompatDialog(mContext);
    dialog.setTitle(R.string.setname);
    dialog.setContentView(R.layout.dialog_input);
    final AppCompatButton bGoBackup = (AppCompatButton) dialog.findViewById(R.id.bGoBackup);
    final AppCompatEditText etFileName = (AppCompatEditText) dialog.findViewById(R.id.etFileName);
    final AppCompatCheckBox optName = (AppCompatCheckBox) dialog.findViewById(R.id.cbOptInput);
    if (bGoBackup == null || etFileName == null || optName == null)
        return;
    final String NameHint = prefix + "-from-" + Calendar.getInstance().get(Calendar.DATE) + "-" + Calendar.getInstance().get(Calendar.MONTH) + "-" + Calendar.getInstance().get(Calendar.YEAR) + "-" + Calendar.getInstance().get(Calendar.HOUR) + "-" + Calendar.getInstance().get(Calendar.MINUTE) + EXT;
    optName.setText(CurrentName);
    optName.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            etFileName.setEnabled(!optName.isChecked());
        }
    });
    etFileName.setHint(NameHint);
    bGoBackup.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String EXT;
            File Path;
            final int JOB;
            if (RecoveryBackup) {
                EXT = RashrApp.DEVICE.getRecoveryExt();
                Path = Const.PathToRecoveryBackups;
                JOB = FlashUtil.JOB_BACKUP_RECOVERY;
            } else {
                EXT = RashrApp.DEVICE.getKernelExt();
                Path = Const.PathToKernelBackups;
                JOB = FlashUtil.JOB_BACKUP_KERNEL;
            }
            CharSequence Name = "";
            if (optName.isChecked()) {
                Name = optName.getText() + EXT;
            } else {
                if (etFileName.getText() != null && !etFileName.getText().toString().equals("")) {
                    Name = etFileName.getText().toString();
                }
                if (Name.equals("")) {
                    Name = String.valueOf(etFileName.getHint());
                }
                if (!Name.toString().endsWith(EXT)) {
                    Name = Name + EXT;
                }
            }
            final File fBACKUP = new File(Path, Name.toString());
            if (fBACKUP.exists()) {
                Toast.makeText(mActivity, R.string.backupalready, Toast.LENGTH_SHORT).show();
            } else {
                final FlashUtil BackupCreator = new FlashUtil(mActivity, fBACKUP, JOB);
                BackupCreator.setOnTaskDoneListener(new FlashUtil.OnTaskDoneListener() {

                    @Override
                    public void onSuccess() {
                        mAdapter.reload();
                    }

                    @Override
                    public void onFail(Exception e) {
                        String msg;
                        if (e != null) {
                            msg = e.toString();
                        } else {
                            msg = getString(R.string.bak_error);
                        }
                        Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
                    }
                });
                BackupCreator.execute();
            }
            dialog.dismiss();
        }
    });
    dialog.show();
}
Also used : View(android.view.View) AdapterView(android.widget.AdapterView) AppCompatTextView(android.support.v7.widget.AppCompatTextView) ListView(android.widget.ListView) AppCompatButton(android.support.v7.widget.AppCompatButton) AppCompatCheckBox(android.support.v7.widget.AppCompatCheckBox) AppCompatEditText(android.support.v7.widget.AppCompatEditText) AppCompatDialog(android.support.v7.app.AppCompatDialog) File(java.io.File)

Example 3 with AppCompatDialog

use of android.support.v7.app.AppCompatDialog in project Rashr by DsLNeXuS.

the class FlashFragment method showUnifiedBuildsDialog.

/**
     * Check if Device uses a Unified base like some Galaxy S4: htle, htltespr htltexx uses the same
     * sources so they can use the unified kernels and recoveries. Let the User choice which one is
     * the correct for him. PLEASE BE CAREFUL!
     */
public void showUnifiedBuildsDialog() {
    final AppCompatDialog UnifiedBuildsDialog = new AppCompatDialog(mContext);
    UnifiedBuildsDialog.setTitle(R.string.make_choice);
    final ArrayList<String> DevName = new ArrayList<>();
    ArrayList<String> DevNamesCarriers = new ArrayList<>();
    UnifiedBuildsDialog.setContentView(R.layout.dialog_unified_build);
    ListView UnifiedList = (ListView) UnifiedBuildsDialog.findViewById(R.id.lvUnifiedList);
    ArrayAdapter<String> UnifiedAdapter = new ArrayAdapter<>(mContext, android.R.layout.simple_list_item_1, DevNamesCarriers);
    if (UnifiedList != null) {
        UnifiedList.setAdapter(UnifiedAdapter);
        UnifiedList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
                UnifiedBuildsDialog.dismiss();
                final ProgressDialog reloading = new ProgressDialog(mContext);
                reloading.setMessage(mContext.getString(R.string.reloading));
                reloading.setCancelable(false);
                reloading.show();
                new Thread(new Runnable() {

                    @Override
                    public void run() {
                        Common.setBooleanPref(mContext, Const.PREF_NAME, Const.PREF_KEY_SHOW_UNIFIED, false);
                        RashrApp.DEVICE.setName(DevName.get(position));
                        RashrApp.DEVICE.loadRecoveryList();
                        mActivity.runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                reloading.dismiss();
                                mActivity.switchTo(FlashFragment.newInstance(mActivity));
                            }
                        });
                    }
                }).start();
            }
        });
    }
    if (RashrApp.DEVICE.getManufacture().equals("samsung")) {
        String[] unifiedGalaxyS3 = { "d2lte", "d2att", "d2cri", "d2mtr", "d2spr", "d2tmo", "d2usc", "d2vzw" };
        String[] unifiedGalaxyNote3 = { "hlte", "hltespr", "hltetmo", "hltevzw", "htlexx" };
        String[] unifiedGalaxyS4 = { "jflte", "jflteatt", "jfltecan", "jfltecri", "jfltecsp", "jfltespr", "jfltetmo", "jflteusc", "jfltevzw", "jfltexx", "jgedlte" };
        String[] unifiedGalaxyNote4 = { "trlte", "trltecan", "trltedt", "trltexx", "trltespr", "trltetmo", "trltevzw", "trlteusc" };
        if (Common.stringEndsWithArray(RashrApp.DEVICE.getName(), unifiedGalaxyS3)) {
            DevName.addAll(Arrays.asList(unifiedGalaxyS3));
        } else if (Common.stringEndsWithArray(RashrApp.DEVICE.getName(), unifiedGalaxyS3)) {
            DevName.addAll(Arrays.asList(unifiedGalaxyNote3));
        } else if (Common.stringEndsWithArray(RashrApp.DEVICE.getName(), unifiedGalaxyS4)) {
            DevName.addAll(Arrays.asList(unifiedGalaxyS4));
        } else if (Common.stringEndsWithArray(RashrApp.DEVICE.getName(), unifiedGalaxyNote4)) {
            DevName.addAll(Arrays.asList(unifiedGalaxyNote4));
        }
    }
    if (RashrApp.DEVICE.getManufacture().equals("motorola")) {
        String[] unifiedMsm8960 = { "moto_msm8960" };
        if (RashrApp.DEVICE.getBOARD().equals("msm8960")) {
            DevName.addAll(Arrays.asList(unifiedMsm8960));
        }
    }
    for (String i : DevName) {
        if (i.contains("att")) {
            DevNamesCarriers.add(i + " (AT&T Mobility)");
        } else if (i.contains("can")) {
            DevNamesCarriers.add(i + " (Canada)");
        } else if (i.contains("cri")) {
            DevNamesCarriers.add(i + " (Cricket Wireless)");
        } else if (i.contains("csp")) {
            DevNamesCarriers.add(i + " (C Spire Wireless)");
        } else if (i.contains("mtr")) {
            DevNamesCarriers.add(i + " (MetroPCS)");
        } else if (i.contains("spr")) {
            DevNamesCarriers.add(i + " (Sprint Corporation)");
        } else if (i.contains("tmo")) {
            DevNamesCarriers.add(i + " (T-Mobile US)");
        } else if (i.contains("usc")) {
            DevNamesCarriers.add(i + " (U.S. Cellular)");
        } else if (i.contains("vzw")) {
            DevNamesCarriers.add(i + " (Verizon Wireless)");
        } else if (i.contains("xx")) {
            DevNamesCarriers.add(i + " (International)");
        } else if (i.contains("ged")) {
            DevNamesCarriers.add(i + " (Google Play Edition)");
        } else if (i.contains("dt")) {
            DevNamesCarriers.add(i + " (India)");
        } else {
            DevNamesCarriers.add(i + " (Unified)");
        }
    }
    AppCompatButton KeepCurrent = (AppCompatButton) UnifiedBuildsDialog.findViewById(R.id.bKeepCurrent);
    if (KeepCurrent != null) {
        KeepCurrent.setText(String.format(getString(R.string.keep_current_name), RashrApp.DEVICE.getName()));
        KeepCurrent.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Common.setBooleanPref(mContext, Const.PREF_NAME, Const.PREF_KEY_SHOW_UNIFIED, false);
                UnifiedBuildsDialog.dismiss();
            }
        });
    }
    if (DevName.size() > 0) {
        UnifiedBuildsDialog.show();
        UnifiedBuildsDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                Common.setBooleanPref(mContext, Const.PREF_NAME, Const.PREF_KEY_SHOW_UNIFIED, false);
            }
        });
    }
}
Also used : DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) ProgressDialog(android.app.ProgressDialog) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) AppCompatButton(android.support.v7.widget.AppCompatButton) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) AppCompatDialog(android.support.v7.app.AppCompatDialog) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 4 with AppCompatDialog

use of android.support.v7.app.AppCompatDialog in project Douya by DreaminginCodeZH.

the class BroadcastActivityDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AppCompatDialog dialog = (AppCompatDialog) super.onCreateDialog(savedInstanceState);
    // We are using a custom title, as in AlertDialog.
    dialog.supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    return dialog;
}
Also used : AppCompatDialog(android.support.v7.app.AppCompatDialog) NonNull(android.support.annotation.NonNull)

Example 5 with AppCompatDialog

use of android.support.v7.app.AppCompatDialog in project wire-android by wireapp.

the class AssetDialogUtils method showFileActionSheet.

public static void showFileActionSheet(final Context context, final Asset asset, final Uri uri, boolean fileCanBeOpened, final AssetDialogCallback callback) {
    final AppCompatDialog fileActionSheetDialog = new AppCompatDialog(context);
    fileActionSheetDialog.setTitle(asset.getName());
    fileActionSheetDialog.setContentView(R.layout.file_action_sheet_dialog);
    TextView title = ViewUtils.getView(fileActionSheetDialog, R.id.title);
    title.setEllipsize(TextUtils.TruncateAt.MIDDLE);
    title.setTypeface(TypefaceUtils.getTypeface(context.getResources().getString(R.string.wire__typeface__medium)));
    title.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimensionPixelSize(R.dimen.wire__text_size__regular));
    title.setGravity(Gravity.CENTER);
    TextView openButton = ViewUtils.getView(fileActionSheetDialog, R.id.ttv__file_action_dialog__open);
    View noAppFoundLabel = ViewUtils.getView(fileActionSheetDialog, R.id.ttv__file_action_dialog__open__no_app_found);
    View saveButton = ViewUtils.getView(fileActionSheetDialog, R.id.ttv__file_action_dialog__save);
    // Opening file
    if (fileCanBeOpened) {
        noAppFoundLabel.setVisibility(View.GONE);
        openButton.setAlpha(1f);
        openButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                callback.onOpenedFile(uri);
                fileActionSheetDialog.dismiss();
            }
        });
    } else {
        noAppFoundLabel.setVisibility(View.VISIBLE);
        float disabledAlpha = ResourceUtils.getResourceFloat(context.getResources(), R.dimen.button__disabled_state__alpha);
        openButton.setAlpha(disabledAlpha);
    }
    // Saving file
    final Asset.LoadCallback<Uri> saveFileLoadCallback = new Asset.LoadCallback<Uri>() {

        @Override
        public void onLoaded(Uri uri) {
            callback.onSavedFile(uri);
        }

        @Override
        public void onLoadFailed() {
        }
    };
    saveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            fileActionSheetDialog.dismiss();
            asset.saveToDownloads(saveFileLoadCallback);
        }
    });
    fileActionSheetDialog.show();
}
Also used : AppCompatDialog(android.support.v7.app.AppCompatDialog) Asset(com.waz.api.Asset) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) Uri(android.net.Uri)

Aggregations

AppCompatDialog (android.support.v7.app.AppCompatDialog)6 View (android.view.View)4 AppCompatButton (android.support.v7.widget.AppCompatButton)3 AdapterView (android.widget.AdapterView)3 ListView (android.widget.ListView)3 NonNull (android.support.annotation.NonNull)2 AppCompatEditText (android.support.v7.widget.AppCompatEditText)2 AppCompatTextView (android.support.v7.widget.AppCompatTextView)2 File (java.io.File)2 SuppressLint (android.annotation.SuppressLint)1 ProgressDialog (android.app.ProgressDialog)1 DialogInterface (android.content.DialogInterface)1 Uri (android.net.Uri)1 AlertDialog (android.support.v7.app.AlertDialog)1 AppCompatCheckBox (android.support.v7.widget.AppCompatCheckBox)1 PopupMenu (android.support.v7.widget.PopupMenu)1 MenuItem (android.view.MenuItem)1 AbsListView (android.widget.AbsListView)1 ArrayAdapter (android.widget.ArrayAdapter)1 TextView (android.widget.TextView)1