Example usage for android.app AlertDialog findViewById

List of usage examples for android.app AlertDialog findViewById

Introduction

In this page you can find the example usage for android.app AlertDialog findViewById.

Prototype

@Nullable
public <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID or null if the ID is invalid (< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via #show() or #create() ).

Usage

From source file:be.ppareit.swiftp.gui.PreferenceFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
    Resources resources = getResources();

    TwoStatePreference runningPref = findPref("running_switch");
    updateRunningState();/*from  w w w  . j a v a  2s  . c o  m*/
    runningPref.setOnPreferenceChangeListener((preference, newValue) -> {
        if ((Boolean) newValue) {
            startServer();
        } else {
            stopServer();
        }
        return true;
    });

    PreferenceScreen prefScreen = findPref("preference_screen");
    Preference marketVersionPref = findPref("market_version");
    marketVersionPref.setOnPreferenceClickListener(preference -> {
        // start the market at our application
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setData(Uri.parse("market://details?id=be.ppareit.swiftp"));
        try {
            // this can fail if there is no market installed
            startActivity(intent);
        } catch (Exception e) {
            Cat.e("Failed to launch the market.");
            e.printStackTrace();
        }
        return false;
    });
    if (!App.isFreeVersion()) {
        prefScreen.removePreference(marketVersionPref);
    }

    updateLoginInfo();

    EditTextPreference usernamePref = findPref("username");
    usernamePref.setOnPreferenceChangeListener((preference, newValue) -> {
        String newUsername = (String) newValue;
        if (preference.getSummary().equals(newUsername))
            return false;
        if (!newUsername.matches("[a-zA-Z0-9]+")) {
            Toast.makeText(getActivity(), R.string.username_validation_error, Toast.LENGTH_LONG).show();
            return false;
        }
        stopServer();
        return true;
    });

    mPassWordPref = findPref("password");
    mPassWordPref.setOnPreferenceChangeListener((preference, newValue) -> {
        stopServer();
        return true;
    });
    mAutoconnectListPref = findPref("autoconnect_preference");
    mAutoconnectListPref.setOnPopulateListener(pref -> {
        Cat.d("autoconnect populate listener");

        WifiManager wifiManager = (WifiManager) getActivity().getApplicationContext()
                .getSystemService(Context.WIFI_SERVICE);
        List<WifiConfiguration> configs = wifiManager.getConfiguredNetworks();
        if (configs == null) {
            Cat.e("Unable to receive wifi configurations, bark at user and bail");
            Toast.makeText(getActivity(), R.string.autoconnect_error_enable_wifi_for_access_points,
                    Toast.LENGTH_LONG).show();
            return;
        }
        CharSequence[] ssids = new CharSequence[configs.size()];
        CharSequence[] niceSsids = new CharSequence[configs.size()];
        for (int i = 0; i < configs.size(); ++i) {
            ssids[i] = configs.get(i).SSID;
            String ssid = configs.get(i).SSID;
            if (ssid.length() > 2 && ssid.startsWith("\"") && ssid.endsWith("\"")) {
                ssid = ssid.substring(1, ssid.length() - 1);
            }
            niceSsids[i] = ssid;
        }
        pref.setEntries(niceSsids);
        pref.setEntryValues(ssids);
    });
    mAutoconnectListPref.setOnPreferenceClickListener(preference -> {
        Cat.d("Clicked");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (ActivityCompat.checkSelfPermission(getContext(),
                    Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_DENIED) {
                if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(),
                        Manifest.permission.ACCESS_COARSE_LOCATION)) {
                    new AlertDialog.Builder(getContext()).setTitle(R.string.request_coarse_location_dlg_title)
                            .setMessage(R.string.request_coarse_location_dlg_message)
                            .setPositiveButton(android.R.string.ok, (dialog, which) -> {
                                requestPermissions(new String[] { Manifest.permission.ACCESS_COARSE_LOCATION },
                                        ACCESS_COARSE_LOCATION_REQUEST_CODE);
                            }).setOnCancelListener(dialog -> {
                                mAutoconnectListPref.getDialog().cancel();
                            }).create().show();
                } else {
                    requestPermissions(new String[] { Manifest.permission.ACCESS_COARSE_LOCATION },
                            ACCESS_COARSE_LOCATION_REQUEST_CODE);
                }
            }
        }
        return false;
    });

    EditTextPreference portnum_pref = findPref("portNum");
    portnum_pref.setSummary(sp.getString("portNum", resources.getString(R.string.portnumber_default)));
    portnum_pref.setOnPreferenceChangeListener((preference, newValue) -> {
        String newPortnumString = (String) newValue;
        if (preference.getSummary().equals(newPortnumString))
            return false;
        int portnum = 0;
        try {
            portnum = Integer.parseInt(newPortnumString);
        } catch (Exception e) {
            Cat.d("Error parsing port number! Moving on...");
        }
        if (portnum <= 0 || 65535 < portnum) {
            Toast.makeText(getActivity(), R.string.port_validation_error, Toast.LENGTH_LONG).show();
            return false;
        }
        preference.setSummary(newPortnumString);
        stopServer();
        return true;
    });

    Preference chroot_pref = findPref("chrootDir");
    chroot_pref.setSummary(FsSettings.getChrootDirAsString());
    chroot_pref.setOnPreferenceClickListener(preference -> {
        AlertDialog folderPicker = new FolderPickerDialogBuilder(getActivity(), FsSettings.getChrootDir())
                .setSelectedButton(R.string.select, path -> {
                    if (preference.getSummary().equals(path))
                        return;
                    if (!FsSettings.setChrootDir(path))
                        return;
                    // TODO: this is a hotfix, create correct resources, improve UI/UX
                    final File root = new File(path);
                    if (!root.canRead()) {
                        Toast.makeText(getActivity(), "Notice that we can't read/write in this folder.",
                                Toast.LENGTH_LONG).show();
                    } else if (!root.canWrite()) {
                        Toast.makeText(getActivity(),
                                "Notice that we can't write in this folder, reading will work. Writing in sub folders might work.",
                                Toast.LENGTH_LONG).show();
                    }

                    preference.setSummary(path);
                    stopServer();
                }).setNegativeButton(R.string.cancel, null).create();
        folderPicker.show();
        return true;
    });

    final CheckBoxPreference wakelock_pref = findPref("stayAwake");
    wakelock_pref.setOnPreferenceChangeListener((preference, newValue) -> {
        stopServer();
        return true;
    });

    final CheckBoxPreference writeExternalStorage_pref = findPref("writeExternalStorage");
    String externalStorageUri = FsSettings.getExternalStorageUri();
    if (externalStorageUri == null) {
        writeExternalStorage_pref.setChecked(false);
    }
    writeExternalStorage_pref.setOnPreferenceChangeListener((preference, newValue) -> {
        if ((boolean) newValue) {
            Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
            startActivityForResult(intent, ACTION_OPEN_DOCUMENT_TREE);
            return false;
        } else {
            FsSettings.setExternalStorageUri(null);
            return true;
        }
    });

    ListPreference theme = findPref("theme");
    theme.setSummary(theme.getEntry());
    theme.setOnPreferenceChangeListener((preference, newValue) -> {
        theme.setSummary(theme.getEntry());
        getActivity().recreate();
        return true;
    });

    Preference help = findPref("help");
    help.setOnPreferenceClickListener(preference -> {
        Cat.v("On preference help clicked");
        Context context = getActivity();
        AlertDialog ad = new AlertDialog.Builder(context).setTitle(R.string.help_dlg_title)
                .setMessage(R.string.help_dlg_message).setPositiveButton(android.R.string.ok, null).create();
        ad.show();
        Linkify.addLinks((TextView) ad.findViewById(android.R.id.message), Linkify.ALL);
        return true;
    });

    Preference about = findPref("about");
    about.setOnPreferenceClickListener(preference -> {
        startActivity(new Intent(getActivity(), AboutActivity.class));
        return true;
    });

}

From source file:com.keylesspalace.tusky.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("lightTheme", false)) {
        setTheme(R.style.AppTheme_Light);
    }/* w  w w. ja v  a  2 s . co  m*/

    setContentView(R.layout.activity_login);
    ButterKnife.bind(this);

    if (savedInstanceState != null) {
        domain = savedInstanceState.getString("domain");
        clientId = savedInstanceState.getString("clientId");
        clientSecret = savedInstanceState.getString("clientSecret");
    } else {
        domain = null;
        clientId = null;
        clientSecret = null;
    }

    preferences = getSharedPreferences(getString(R.string.preferences_file_key), Context.MODE_PRIVATE);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onButtonClick(editText);
        }
    });

    final Context context = this;

    whatsAnInstance.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog dialog = new AlertDialog.Builder(context).setMessage(R.string.dialog_whats_an_instance)
                    .setPositiveButton(R.string.action_close, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    }).show();
            TextView textView = (TextView) dialog.findViewById(android.R.id.message);
            textView.setMovementMethod(LinkMovementMethod.getInstance());
        }
    });
}

From source file:com.fa.mastodon.activity.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("light")) {
        setTheme(R.style.AppTheme_Light);
    } else if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("black")) {
        setTheme(R.style.AppThemeAmoled);
    }//from  www  . java 2 s.com

    setContentView(R.layout.activity_login);
    ButterKnife.bind(this);

    if (savedInstanceState != null) {
        domain = savedInstanceState.getString("domain");
        clientId = savedInstanceState.getString("clientId");
        clientSecret = savedInstanceState.getString("clientSecret");
    } else {
        domain = null;
        clientId = null;
        clientSecret = null;
    }

    preferences = getSharedPreferences(getString(R.string.preferences_file_key), Context.MODE_PRIVATE);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onButtonClick(editText);
        }
    });

    final Context context = this;

    whatsAnInstance.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog dialog = new AlertDialog.Builder(context).setMessage(R.string.dialog_whats_an_instance)
                    .setPositiveButton(R.string.action_close, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    }).show();
            TextView textView = (TextView) dialog.findViewById(android.R.id.message);
            textView.setMovementMethod(LinkMovementMethod.getInstance());
        }
    });

    bp = new BillingProcessor(this, PublicValues.LICENSE_KEY, this);

    bp.loadOwnedPurchasesFromGoogle();
}

From source file:org.rm3l.ddwrt.tiles.status.wireless.WirelessIfaceTile.java

@Override
public boolean onMenuItemClick(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.tile_status_wireless_iface_qrcode:
        if (wifiEncryptionType == null || (isNullOrEmpty(wifiSsid) && isNullOrEmpty(wifiPassword))) {
            //menu item should have been disabled, but anyways, you never know :)
            Toast.makeText(mParentFragmentActivity, "Missing parameters to generate QR-Code - try again later",
                    Toast.LENGTH_SHORT).show();
            return true;
        }/*from w  w  w.j  a v a 2s .c  o m*/
        //https://github.com/zxing/zxing/wiki/Barcode-Contents
        //noinspection ConstantConditions
        final String wifiSsidNullToEmpty = nullToEmpty(wifiSsid);
        final String wifiQrCodeString = String.format("WIFI:S:%s;T:%s;P:%s;%s;",
                escapeString(wifiSsidNullToEmpty), wifiEncryptionType.toString(),
                escapeString(nullToEmpty(wifiPassword)), wifiSsidNullToEmpty.isEmpty() ? "H:true" : "");

        final String routerUuid = mRouter.getUuid();
        final Class<?> activityClass = Utils.isThemeLight(mParentFragmentActivity, routerUuid)
                ? WirelessIfaceQrCodeActivityLight.class
                : WirelessIfaceQrCodeActivity.class;

        final Intent intent = new Intent(mParentFragmentActivity, activityClass);
        intent.putExtra(RouterManagementActivity.ROUTER_SELECTED, routerUuid);
        intent.putExtra(WirelessIfaceQrCodeActivity.SSID, wifiSsidNullToEmpty);
        intent.putExtra(WirelessIfaceQrCodeActivity.WIFI_QR_CODE, wifiQrCodeString);

        final AlertDialog alertDialog = Utils.buildAlertDialog(mParentFragmentActivity, null,
                String.format("Generating QR Code for '%s'", wifiSsidNullToEmpty), false, false);
        alertDialog.show();
        ((TextView) alertDialog.findViewById(android.R.id.message)).setGravity(Gravity.CENTER_HORIZONTAL);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                mParentFragmentActivity.startActivity(intent);
                alertDialog.cancel();
            }
        }, 2500);

        return true;
    default:
        break;
    }
    return false;
}

From source file:net.bytten.comicviewer.ComicViewerActivity.java

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    // Determine the type of dialog based on the integer passed. These are defined in constants
    // at the top of the class.
    switch (id) {
    case DIALOG_SHOW_HOVER_TEXT:
        //Get an alertdialog so we can edit it.
        AlertDialog adh = (AlertDialog) dialog;
        adh.setMessage(comicInfo.getAlt());

        adh.getButton(AlertDialog.BUTTON_POSITIVE)
                .setVisibility(comicInfo.getLink() != null ? Button.VISIBLE : Button.GONE);

        break;//from ww  w  .  j a  v a  2 s. com
    case DIALOG_FAILED:
        //Get the alertdialog for the failedDialog
        AlertDialog adf = (AlertDialog) dialog;

        adf.setMessage(errors);
        //Set failedDialog to our dialog so we can dismiss
        //it manually
        failedDialog = adf;
        break;
    case DIALOG_SEARCH_BY_TITLE:
        // Clear the text box
        AlertDialog ads = (AlertDialog) dialog;
        ((EditText) ads.findViewById(R.id.search_dlg_edit_box)).setText("");
        break;
    default:
        break;
    }
    super.onPrepareDialog(id, dialog);
}

From source file:org.alfresco.mobile.android.application.extension.samsung.pen.SNoteEditorActivity.java

public void requestSave() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.editor_save_request);
    builder.setCancelable(false);/*ww  w .  ja  v  a 2 s  . c  o m*/
    builder.setMessage(Html.fromHtml(getString(R.string.editor_save_description)));
    builder.setIcon(R.drawable.ic_save);
    builder.setPositiveButton(R.string.editor_save, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            save(true);
            dialog.dismiss();
        }
    });
    builder.setNegativeButton(R.string.editor_discard, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            dialog.dismiss();
            finish();
        }
    });
    builder.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            dialog.dismiss();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
    TextView messageText = (TextView) alert.findViewById(android.R.id.message);
    messageText.setGravity(Gravity.CENTER);
}

From source file:org.rm3l.ddwrt.tiles.status.wan.WANMonthlyTrafficTile.java

@Override
public void onLoadFinished(Loader<NVRAMInfo> loader, NVRAMInfo data) {
    Log.d(LOG_TAG, "onLoadFinished: loader=" + loader + " / data=" + data + " / traffData=" + traffData);

    setLoadingViewVisibility(View.GONE);

    Exception preliminaryCheckException = null;
    if (data == null) {
        preliminaryCheckException = new DDWRTNoDataException("No Data!");
    } else //noinspection ThrowableResultOfMethodCallIgnored
    if (data.getException() == null) {
        if (!"1".equals(data.getProperty(NVRAMInfo.TTRAFF_ENABLE))) {
            preliminaryCheckException = new IllegalStateException("Traffic monitoring disabled!");
        } else if (traffData == null || traffData.isEmpty()) {
            preliminaryCheckException = new DDWRTNoDataException("No Traffic Data!");
        }//  www. j  av a 2s  . co m
    }

    if (preliminaryCheckException != null) {
        data = new NVRAMInfo().setException(preliminaryCheckException);
    }

    @NotNull
    final TextView errorPlaceHolderView = (TextView) this.layout
            .findViewById(R.id.tile_status_wan_monthly_traffic_error);

    @Nullable
    final Exception exception = data.getException();

    final View displayButton = this.layout
            .findViewById(R.id.tile_status_wan_monthly_traffic_graph_placeholder_display_button);
    final View currentButton = this.layout
            .findViewById(R.id.tile_status_wan_monthly_traffic_graph_placeholder_current);
    final View previousButton = this.layout
            .findViewById(R.id.tile_status_wan_monthly_traffic_graph_placeholder_previous);
    final View nextButton = this.layout
            .findViewById(R.id.tile_status_wan_monthly_traffic_graph_placeholder_next);
    final TextView monthYearDisplayed = (TextView) this.layout
            .findViewById(R.id.tile_status_wan_monthly_month_displayed);

    final View[] ctrlViews = new View[] { monthYearDisplayed, displayButton, currentButton, previousButton,
            nextButton };

    if (exception == null) {
        errorPlaceHolderView.setVisibility(View.GONE);

        final String currentMonthYearAlreadyDisplayed = monthYearDisplayed.getText().toString();

        final Date currentDate = new Date();
        final String currentMonthYear = (isNullOrEmpty(currentMonthYearAlreadyDisplayed)
                ? SIMPLE_DATE_FORMAT.format(currentDate)
                : currentMonthYearAlreadyDisplayed);

        //TODO Load last value from preferences
        monthYearDisplayed.setText(currentMonthYear);

        displayButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final Intent intent = WANMonthlyTrafficTile.this
                        .renderTraffDateForMonth(monthYearDisplayed.getText().toString());
                if (intent == null) {
                    Toast.makeText(WANMonthlyTrafficTile.this.mParentFragmentActivity,
                            String.format("No traffic data for '%s'", monthYearDisplayed.getText()),
                            Toast.LENGTH_SHORT).show();
                } else {
                    final AlertDialog alertDialog = Utils.buildAlertDialog(mParentFragmentActivity, null,
                            String.format("Loading traffic data for '%s'", monthYearDisplayed.getText()), false,
                            false);
                    alertDialog.show();
                    ((TextView) alertDialog.findViewById(android.R.id.message))
                            .setGravity(Gravity.CENTER_HORIZONTAL);
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            WANMonthlyTrafficTile.this.mParentFragmentActivity.startActivity(intent);
                            alertDialog.cancel();
                        }
                    }, 2500);
                }
            }
        });

        currentButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                monthYearDisplayed.setText(SIMPLE_DATE_FORMAT.format(currentDate));
            }
        });

        previousButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final int[] currentYearMonth = getCurrentYearAndMonth(currentDate,
                        monthYearDisplayed.getText().toString());
                if (currentYearMonth.length < 2) {
                    return;
                }

                final int currentMonth = currentYearMonth[1];
                final int currentYear = currentYearMonth[0];

                final int previousMonth = currentMonth - 1;
                final String previousMonthYear = ((previousMonth <= 0) ? ("12-" + (currentYear - 1))
                        : (((previousMonth <= 9) ? ("0" + previousMonth) : previousMonth) + "-" + currentYear));

                monthYearDisplayed.setText(previousMonthYear);
            }
        });

        nextButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                final int[] currentYearMonth = getCurrentYearAndMonth(currentDate,
                        monthYearDisplayed.getText().toString());
                if (currentYearMonth.length < 2) {
                    return;
                }

                final int currentMonth = currentYearMonth[1];
                final int currentYear = currentYearMonth[0];
                final int nextMonth = currentMonth + 1;
                final String nextMonthYear = ((nextMonth >= 13) ? ("01-" + (currentYear + 1))
                        : (((nextMonth <= 9) ? ("0" + nextMonth) : nextMonth) + "-" + currentYear));

                monthYearDisplayed.setText(nextMonthYear);
            }
        });

        setVisibility(ctrlViews, View.VISIBLE);
    }

    if (exception != null && !(exception instanceof DDWRTTileAutoRefreshNotAllowedException)) {
        //noinspection ThrowableResultOfMethodCallIgnored
        final Throwable rootCause = Throwables.getRootCause(exception);
        errorPlaceHolderView.setText("Error: " + (rootCause != null ? rootCause.getMessage() : "null"));
        final Context parentContext = this.mParentFragmentActivity;
        errorPlaceHolderView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                //noinspection ThrowableResultOfMethodCallIgnored
                if (rootCause != null) {
                    Toast.makeText(parentContext, rootCause.getMessage(), Toast.LENGTH_LONG).show();
                }
            }
        });
        errorPlaceHolderView.setVisibility(View.VISIBLE);
        setVisibility(ctrlViews, View.GONE);
    } else {
        if (traffData == null || traffData.isEmpty()) {
            errorPlaceHolderView.setText("Error: No Data!");
            errorPlaceHolderView.setVisibility(View.VISIBLE);
            setVisibility(ctrlViews, View.GONE);
        }
    }

    doneWithLoaderInstance(this, loader, R.id.tile_status_wan_monthly_traffic_togglebutton_title,
            R.id.tile_status_wan_monthly_traffic_togglebutton_separator);

    Log.d(LOG_TAG, "onLoadFinished(): done loading!");

}

From source file:com.prof.rssparser.example.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();

    if (id == R.id.action_settings) {
        android.support.v7.app.AlertDialog alertDialog = new android.support.v7.app.AlertDialog.Builder(
                MainActivity.this).create();
        alertDialog.setTitle(R.string.app_name);
        alertDialog.setMessage(Html.fromHtml(MainActivity.this.getString(R.string.info_text)
                + " <a href='http://github.com/prof18/RSS-Parser'>GitHub.</a>"
                + MainActivity.this.getString(R.string.author)));
        alertDialog.setButton(android.support.v7.app.AlertDialog.BUTTON_NEUTRAL, "OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }//from   w w w . j  av a 2  s  . c o  m
                });
        alertDialog.show();

        ((TextView) alertDialog.findViewById(android.R.id.message))
                .setMovementMethod(LinkMovementMethod.getInstance());
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.matthewmitchell.peercoin_android_wallet.ui.WalletActivity.java

private void prepareBackupWalletDialog(final Dialog dialog) {
    final AlertDialog alertDialog = (AlertDialog) dialog;

    final EditText passwordView = (EditText) alertDialog.findViewById(R.id.export_keys_dialog_password);
    passwordView.setText(null);//from   w w w. ja v a2s.c  o m

    final ImportDialogButtonEnablerListener dialogButtonEnabler = new ImportDialogButtonEnablerListener(
            passwordView, alertDialog);
    passwordView.addTextChangedListener(dialogButtonEnabler);

    final CheckBox showView = (CheckBox) alertDialog.findViewById(R.id.export_keys_dialog_show);
    showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(passwordView));

    final TextView warningView = (TextView) alertDialog
            .findViewById(R.id.backup_wallet_dialog_warning_encrypted);
    Wallet wallet = application.getWallet();

    if (wallet == null) {
        warningView.setVisibility(View.GONE);
        runAfterLoad(new Runnable() {

            @Override
            public void run() {
                warningView.setVisibility(application.getWallet().isEncrypted() ? View.VISIBLE : View.GONE);
            }

        });
    } else
        warningView.setVisibility(wallet.isEncrypted() ? View.VISIBLE : View.GONE);
}

From source file:com.bluros.updater.UpdatesSettings.java

private void showSysInfo() {
    // Build the message
    Date lastCheck = new Date(mPrefs.getLong(Constants.LAST_UPDATE_CHECK_PREF, 0));
    String date = DateFormat.getLongDateFormat(this).format(lastCheck);
    String time = DateFormat.getTimeFormat(this).format(lastCheck);

    String cmReleaseType = Constants.CM_RELEASETYPE_NIGHTLY;
    int updateType = Utils.getUpdateType();
    if (updateType == Constants.UPDATE_TYPE_SNAPSHOT) {
        cmReleaseType = Constants.CM_RELEASETYPE_SNAPSHOT;
    }// w  w  w  . java2  s.co  m

    String message = getString(R.string.sysinfo_device) + " " + Utils.getDeviceType() + "\n\n"
            + getString(R.string.sysinfo_running) + " " + Utils.getInstalledVersion() + "\n\n"
            + getString(R.string.sysinfo_update_channel) + " " + cmReleaseType + "\n\n"
            + getString(R.string.sysinfo_last_check) + " " + date + " " + time;

    AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle(R.string.menu_system_info)
            .setMessage(message).setPositiveButton(R.string.dialog_ok, null);

    AlertDialog dialog = builder.create();
    dialog.show();

    TextView messageView = (TextView) dialog.findViewById(android.R.id.message);
    messageView.setTextAppearance(this, android.R.style.TextAppearance_DeviceDefault_Small);
}