Example usage for android.widget EditText getText

List of usage examples for android.widget EditText getText

Introduction

In this page you can find the example usage for android.widget EditText getText.

Prototype

@Override
    public Editable getText() 

Source Link

Usage

From source file:com.BeatYourRecord.SubmitActivity.java

public String getDescriptionText() {
    EditText descriptionEdit = (EditText) findViewById(R.id.submitDescription);
    return sanitize(descriptionEdit.getText().toString());
}

From source file:ar.com.tristeslostrestigres.diasporanativewebapp.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.notifications) {

        if (Helpers.isOnline(MainActivity.this)) {

            //                webView.stopLoading();
            ////from w w w  .ja  va2  s .  c o  m
            //                WebView wvNotifications = new WebView(MainActivity.this);
            //                wvNotifications.loadUrl("https://" + podDomain + "/notifications");
            //
            //                final AlertDialog d = new AlertDialog.Builder(MainActivity.this).setView(wvNotifications)
            //                        .setPositiveButton("Close", new DialogInterface.OnClickListener() {
            //                            @TargetApi(11)
            //                            public void onClick(DialogInterface dialog, int id) {
            //                                dialog.cancel();
            //                            }
            //                        }).show();
            //
            ////                wvNotifications.setWebChromeClient(new WebChromeClient() {
            ////
            ////                   public void onProgressChanged(WebView view, int progress) {
            ////                       progressBar.setProgress(progress);
            //
            ////                       if (progress > 0 && progress <= 60) {
            ////                           view.loadUrl("javascript: ( function() {" +
            ////                                   "    if (document.getElementById('notification')) {" +
            ////                                   "       var count = document.getElementById('notification').innerHTML;" +
            ////                                   "       NotificationCounter.setNotificationCount(count.replace(/(\\r\\n|\\n|\\r)/gm, \"\"));" +
            ////                                   "    } else {" +
            ////                                   "       NotificationCounter.setNotificationCount('0');" +
            ////                                   "    }" +
            ////                                   "    if (document.getElementById('conversation')) {" +
            ////                                   "       var count = document.getElementById('conversation').innerHTML;" +
            ////                                   "       NotificationCounter.setConversationCount(count.replace(/(\\r\\n|\\n|\\r)/gm, \"\"));" +
            ////                                   "    } else {" +
            ////                                   "       NotificationCounter.setConversationCount('0');" +
            ////                                   "    }" +
            ////                                   "})();");
            ////                       }
            //
            ////                       if (progress > 60) {
            ////                           view.loadUrl("javascript: ( function() {" +
            ////                                   "    if(document.getElementById('main_nav')) {" +
            ////                                   "        document.getElementById('main_nav').parentNode.removeChild(" +
            ////                                   "        document.getElementById('main_nav'));" +
            ////                                   "    } else if (document.getElementById('main-nav')) {" +
            ////                                   "        document.getElementById('main-nav').parentNode.removeChild(" +
            ////                                   "        document.getElementById('main-nav'));" +
            ////                                   "    }" +
            ////                                   "})();");
            //////                           fab.setVisibility(View.VISIBLE);
            ////                       }
            //
            ////                       if (progress == 100) {
            ////                           fab.collapse();
            ////                           progressBar.setVisibility(View.GONE);
            ////                       } else {
            ////                           progressBar.setVisibility(View.VISIBLE);
            ////                       }
            ////                   }
            ////               });
            //
            //                        wvNotifications.setWebViewClient(new WebViewClient() {
            //                            @Override
            //                            public boolean shouldOverrideUrlLoading(WebView view, String url) {
            //                                if (!url.equals("https://" + podDomain + "/notifications")) {
            //                                    Intent urlIntent = new Intent(MainActivity.URL_MESSAGE);
            //                                    urlIntent.putExtra("url", url);
            //                                    sendBroadcast(urlIntent);
            //                                }
            //                                d.dismiss();
            //                                return true;
            //                            }
            //                        });

            webView.loadUrl("https://" + podDomain + "/notifications");
            return true;
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
            return false;
        }
    }

    if (id == R.id.conversations) {
        if (Helpers.isOnline(MainActivity.this)) {
            webView.loadUrl("https://" + podDomain + "/conversations");
            return true;
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
            return false;
        }
    }

    if (id == R.id.search) {
        fab.collapse();
        if (Helpers.isOnline(MainActivity.this)) {
            final AlertDialog.Builder alert = new AlertDialog.Builder(this);
            final EditText input = new EditText(this);
            alert.setView(input);
            alert.setTitle(R.string.search_alert_title);
            alert.setPositiveButton(R.string.search_alert_people, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    String inputTag = input.getText().toString().trim();
                    String cleanTag = inputTag.replaceAll("\\*", "");
                    // this validate the input data for tagfind
                    if (cleanTag.isEmpty()) {
                        dialog.cancel(); // if user dont have added a tag
                        Snackbar.make(getWindow().findViewById(R.id.drawer),
                                R.string.search_alert_bypeople_validate_needsomedata, Snackbar.LENGTH_LONG)
                                .show();
                    } else { // User have added a search tag
                        txtTitle.setText(R.string.fab1_title_person);
                        webView.loadUrl("https://" + podDomain + "/people.mobile?q=" + cleanTag);
                    }
                }
            }).setNegativeButton(R.string.search_alert_tag, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    String inputTag = input.getText().toString().trim();
                    String cleanTag = inputTag.replaceAll("\\#", "");
                    // this validate the input data for tagfind
                    if (cleanTag.isEmpty()) {
                        dialog.cancel(); // if user hasn't added a tag
                        Snackbar.make(getWindow().findViewById(R.id.drawer),
                                R.string.search_alert_bytags_validate_needsomedata, Snackbar.LENGTH_LONG)
                                .show();
                    } else { // User have added a search tag
                        txtTitle.setText(R.string.fab1_title_tag);
                        webView.loadUrl("https://" + podDomain + "/tags/" + cleanTag);
                    }
                }
            }).setNeutralButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    //
                }
            });
            alert.show();
        }
    }

    if (id == R.id.reload) {
        if (Helpers.isOnline(MainActivity.this)) {
            webView.reload();
            return true;
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
            return false;
        }
    }

    if (id == R.id.mobile) {
        if (Helpers.isOnline(MainActivity.this)) {
            webView.loadUrl("https://" + podDomain + "/mobile/toggle");
            return true;
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
            return false;
        }
    }

    if (id == R.id.loadImg) {
        if (Helpers.isOnline(MainActivity.this)) {
            wSettings.setLoadsImagesAutomatically(!pm.getLoadImages());
            pm.setLoadImages(!pm.getLoadImages());
            webView.loadUrl(webView.getUrl());
            return true;
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
            return false;
        }
    }

    if (id == R.id.fontSize) {
        if (Helpers.isOnline(MainActivity.this)) {
            alertFormElements();
            return true;
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
            return false;
        }
    }

    if (id == R.id.exit) {
        if (Helpers.isOnline(MainActivity.this)) {
            new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert)
                    .setMessage(getString(R.string.confirm_sign_out))
                    .setPositiveButton(getString(android.R.string.yes).toUpperCase(),
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    webView.clearCache(true);
                                    Intent i = new Intent(MainActivity.this, PodsActivity.class);
                                    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                                    startActivity(i);
                                    finish();
                                }
                            })
                    .setNegativeButton(getString(android.R.string.no).toUpperCase(), null).show();
            return true;
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
            return false;
        }
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.example.yudiandrean.socioblood.FeedActivity.java

@SuppressLint("NewApi")
@Override// w  ww . jav a 2  s  . c  o  m
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    final Dialog d = new Dialog(context);
    setContentView(R.layout.feed_activity);
    postrequest = (TextView) findViewById(R.id.editText);

    WindowManager manager = (WindowManager) getSystemService(Activity.WINDOW_SERVICE);
    final int width, height;
    ActionBar.LayoutParams params;

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) {
        width = manager.getDefaultDisplay().getWidth();
        height = manager.getDefaultDisplay().getHeight();
    } else {
        Point point = new Point();
        manager.getDefaultDisplay().getSize(point);
        width = point.x;
        height = point.y;
    }

    session = new SessionManager(getApplicationContext());

    // Check if user is already logged in or not
    if (!session.isLoggedIn()) {
        // User is already logged in. Take him to main activity
        Intent intent = new Intent(FeedActivity.this, LoginActivity.class);
        startActivity(intent);
        finish();
    }

    listView = (ListView) findViewById(R.id.list);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeContainer);
    feedItems = new ArrayList<FeedItem>();

    listAdapter = new FeedListAdapter(this, feedItems);
    listView.setAdapter(listAdapter);

    swipeRefreshLayout.setOnRefreshListener(this);

    // add button listener
    postrequest.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {

            try {
                d.requestWindowFeature(Window.FEATURE_NO_TITLE);
                d.setContentView(R.layout.post_request);
                WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
                lp.copyFrom(d.getWindow().getAttributes());
                lp.width = width;
                lp.height = height;
                d.getWindow().setAttributes(lp);
            } catch (AndroidRuntimeException e) {
            } catch (Exception e) {
            }

            final Spinner rhesusspinner = (Spinner) d.findViewById(R.id.rhesus_spinner);
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(FeedActivity.this,
                    android.R.layout.simple_spinner_dropdown_item) {

                @Override
                public View getView(int position, View convertView, ViewGroup parent) {

                    View v = super.getView(position, convertView, parent);
                    if (position == getCount()) {
                        ((TextView) v.findViewById(android.R.id.text1)).setText("");
                        ((TextView) v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed"
                    }

                    return v;
                }

                @Override
                public int getCount() {
                    return super.getCount() - 1; // you dont display last item. It is used as hint.
                }

            };

            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            adapter.add("+");
            adapter.add("-");
            adapter.add("Rhesus");

            rhesusspinner.setAdapter(adapter);
            rhesusspinner.setSelection(adapter.getCount()); //display hint

            final Spinner bloodspinner = (Spinner) d.findViewById(R.id.bloodtype_spinner);
            ArrayAdapter<String> bloodadapter = new ArrayAdapter<String>(FeedActivity.this,
                    android.R.layout.simple_spinner_dropdown_item) {

                @Override
                public View getView(int position, View convertView, ViewGroup parent) {

                    View v = super.getView(position, convertView, parent);
                    if (position == getCount()) {
                        ((TextView) v.findViewById(android.R.id.text1)).setText("");
                        ((TextView) v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed"
                    }

                    return v;
                }

                @Override
                public int getCount() {
                    return super.getCount() - 1; // you dont display last item. It is used as hint.
                }

            };

            bloodadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            bloodadapter.add("O");
            bloodadapter.add("A");
            bloodadapter.add("B");
            bloodadapter.add("AB");
            bloodadapter.add("Desired Type");

            bloodspinner.setAdapter(bloodadapter);
            bloodspinner.setSelection(bloodadapter.getCount()); //display hint

            //Buttons-Editexts
            Button btnpost = (Button) d.findViewById(R.id.post);
            final EditText userInput = (EditText) d.findViewById(R.id.editTextDialogUserInput);

            d.show();

            btnpost.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (bloodspinner.getSelectedItem().toString().equals("Desired Type")) {
                        Toast.makeText(getApplicationContext(), "Input Blood Type!", Toast.LENGTH_SHORT).show();
                    } else if (rhesusspinner.getSelectedItem().toString().equals("Rhesus")) {
                        Toast.makeText(getApplicationContext(), "Input Rhesus!", Toast.LENGTH_SHORT).show();
                    } else if (userInput.getText().toString().equals("")) {
                        Toast.makeText(getApplicationContext(), "Input your request message!",
                                Toast.LENGTH_SHORT).show();
                    } else {

                        int uid = session.currentUID();

                        String message = userInput.getText().toString();
                        String post_bloodtype = bloodspinner.getSelectedItem().toString();
                        String post_rhesus = rhesusspinner.getSelectedItem().toString();

                        NetAsync(d, view, uid, message, post_bloodtype, post_rhesus);

                    }
                }
            });

        }
    });

    //        // We first check for cached request
    //        Cache cache = FeedController.getInstance().getRequestQueue().getCache();
    //        Entry entry = cache.get(URL_FEED);
    //        if (entry != null) {
    //            // fetch the data from cache
    //            try {
    //                String data = new String(entry.data, "UTF-8");
    //                try {
    //                    parseJsonFeed(new JSONObject(data));
    //                } catch (JSONException e) {
    //                    e.printStackTrace();
    //                }
    //            } catch (UnsupportedEncodingException e) {
    //                e.printStackTrace();
    //            }
    //
    //        } else {
    // making fresh volley request and getting json

    /**
     * Showing Swipe Refresh animation on activity create
     * As animation won't start on onCreate, post runnable is used
     */
    swipeRefreshLayout.post(new Runnable() {
        @Override
        public void run() {
            swipeRefreshLayout.setRefreshing(true);
            getTimelineAsync();
        }
    });

}

From source file:ee.ria.DigiDoc.fragment.ContainerDetailsFragment.java

private void startMobileSign() {
    View view = LayoutInflater.from(getActivity()).inflate(R.layout.mobile_id_dialogue, null);
    final EditText mobileNr = findById(view, R.id.mobile_nr);
    final EditText personalCode = findById(view, R.id.personal_code);
    final CheckBox rememberMe = findById(view, R.id.remember_me);

    final AppPreferences preferences = AppPreferences.get(getContext());
    mobileNr.setText(preferences.getMobileNumber());
    personalCode.setText(preferences.getPersonalCode());

    final AlertDialog.Builder builder = new AlertDialog.Builder(getContext())
            .setPositiveButton(R.string.sign_button, new DialogInterface.OnClickListener() {
                @Override/* ww w.  j  av  a  2 s.  c om*/
                public void onClick(DialogInterface dialog, int which) {
                    refreshContainerFacade();
                    String phone = mobileNr.getText().toString();
                    String pCode = personalCode.getText().toString();
                    if (rememberMe.isChecked()) {
                        preferences.updateMobileNumber(phone);
                        preferences.updatePersonalCode(pCode);
                    }
                    String message = getResources().getString(R.string.action_sign) + " "
                            + containerFacade.getName();
                    MobileCreateSignatureRequest request = CreateSignatureRequestBuilder
                            .aCreateSignatureRequest().withContainer(containerFacade).withIdCode(pCode)
                            .withPhoneNr(phone).withDesiredMessageToDisplay(message)
                            .withLocale(Locale.getDefault())
                            .withLocalSigningProfile(getFutureSignatureProfile()).build();
                    Intent mobileSignIntent = new Intent(getActivity(), MobileSignService.class);
                    mobileSignIntent.putExtra(CREATE_SIGNATURE_REQUEST, toJson(request));
                    mobileSignIntent.putExtra(ACCESS_TOKEN_PASS, Conf.instance().PKCS12Pass());
                    mobileSignIntent.putExtra(ACCESS_TOKEN_PATH,
                            new File(FileUtils.getSchemaCacheDirectory(getContext()), "878252.p12")
                                    .getAbsolutePath());
                    getActivity().startService(mobileSignIntent);
                    disableSigning();
                }
            }).setNegativeButton(R.string.cancel, null).setView(view);
    notificationUtil.clearMessages();
    builder.show();
}

From source file:com.balakrish.gpstracker.WaypointsListActivity.java

/**
 * Export waypoints to external file//from  w w  w .  j  av  a 2  s .co m
 */
private void exportWaypoints() {

    Context mContext = this;

    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.filename_dialog,
            (ViewGroup) findViewById(R.id.filename_dialog_layout_root));

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);

    builder.setTitle(R.string.export_waypoints);
    builder.setView(layout);

    // final String defaultFilename = "wp_" + (new SimpleDateFormat("yyyy-MM-dd", Locale.US)).format((new
    // Date()).getTime());
    final String defaultFilename = "wp_" + (DateFormat.format("yyyy-MM-dd", (new Date()).getTime()));

    // creating references to input fields in order to use them in
    // onClick handler
    final EditText filenameEditText = (EditText) layout.findViewById(R.id.filenameInputText);
    filenameEditText.setText(defaultFilename);

    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {

            // waypoint title from input dialog
            String filenameStr = filenameEditText.getText().toString().trim();

            if (filenameStr.equals("")) {
                filenameStr = defaultFilename;
            }

            waypointToGpx = new WaypointGpxExportTask(WaypointsListActivity.this, filenameStr);
            waypointToGpx.setApp(app);
            waypointToGpx.execute(0L);

            dialog.dismiss();

        }
    });

    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            // dialog.dismiss();
        }
    });

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

}

From source file:com.gimranov.zandy.app.ItemActivity.java

protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_NEW:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getResources().getString(R.string.item_type))
                // XXX i18n
                .setItems(Item.ITEM_TYPES_EN, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int pos) {
                        Item item = new Item(getBaseContext(), Item.ITEM_TYPES[pos]);
                        item.dirty = APIRequest.API_DIRTY;
                        item.save(db);/*  ww w  . j  av a2s.c  om*/
                        if (collectionKey != null) {
                            ItemCollection coll = ItemCollection.load(collectionKey, db);
                            if (coll != null) {
                                coll.loadChildren(db);
                                coll.add(item);
                                coll.saveChildren(db);
                            }
                        }
                        Log.d(TAG, "Loading item data with key: " + item.getKey());
                        // We create and issue a specified intent with the necessary data
                        Intent i = new Intent(getBaseContext(), ItemDataActivity.class);
                        i.putExtra("com.gimranov.zandy.app.itemKey", item.getKey());
                        startActivity(i);
                    }
                });
        AlertDialog dialog = builder.create();
        return dialog;
    case DIALOG_SORT:

        // We generate the sort name list for our current locale
        String[] sorts = new String[SORT_NAMES.length];
        for (int j = 0; j < SORT_NAMES.length; j++) {
            sorts[j] = getResources().getString(SORT_NAMES[j]);
        }

        AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
        builder2.setTitle(getResources().getString(R.string.set_sort_order)).setItems(sorts,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int pos) {
                        Cursor cursor;
                        setSortBy(SORTS[pos]);
                        ItemCollection collection;
                        if (collectionKey != null
                                && (collection = ItemCollection.load(collectionKey, db)) != null) {
                            cursor = getCursor(collection);
                        } else {
                            if (query != null) {
                                cursor = getCursor(query);
                            } else {
                                cursor = getCursor();
                            }
                        }
                        ItemAdapter adapter = (ItemAdapter) getListAdapter();
                        adapter.changeCursor(cursor);
                        Log.d(TAG, "Re-sorting by: " + SORTS[pos]);

                        Persistence.write(SORT_CHOICE, SORTS[pos]);
                    }
                });
        AlertDialog dialog2 = builder2.create();
        return dialog2;
    case DIALOG_PROGRESS:
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressDialog.setIndeterminate(true);
        mProgressDialog.setMessage(getResources().getString(R.string.identifier_looking_up));
        return mProgressDialog;
    case DIALOG_IDENTIFIER:
        final EditText input = new EditText(this);
        input.setHint(getResources().getString(R.string.identifier_hint));

        final ItemActivity current = this;

        dialog = new AlertDialog.Builder(this).setTitle(getResources().getString(R.string.identifier_message))
                .setView(input).setPositiveButton(getResources().getString(R.string.menu_search),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                Editable value = input.getText();
                                // run search
                                Bundle c = new Bundle();
                                c.putString("mode", "isbn");
                                c.putString("identifier", value.toString());
                                removeDialog(DIALOG_PROGRESS);
                                ItemActivity.this.b = c;
                                showDialog(DIALOG_PROGRESS);
                            }
                        })
                .setNeutralButton(getResources().getString(R.string.scan),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                // If we're about to download from Google play, cancel that dialog
                                // and prompt from Amazon if we're on an Amazon device
                                IntentIntegrator integrator = new IntentIntegrator(current);
                                @Nullable
                                AlertDialog producedDialog = integrator.initiateScan();
                                if (producedDialog != null && "amazon".equals(BuildConfig.FLAVOR)) {
                                    producedDialog.dismiss();
                                    AmazonZxingGlue.showDownloadDialog(current);
                                }
                            }
                        })
                .setNegativeButton(getResources().getString(R.string.cancel),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                // do nothing
                            }
                        })
                .create();
        return dialog;
    default:
        return null;
    }
}

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

private Dialog createRestoreWalletDialog() {
    final View view = getLayoutInflater().inflate(R.layout.restore_wallet_dialog, null);
    final Spinner fileView = (Spinner) view.findViewById(R.id.import_keys_from_storage_file);
    final EditText passwordView = (EditText) view.findViewById(R.id.import_keys_from_storage_password);

    final DialogBuilder dialog = new DialogBuilder(this);
    dialog.setTitle(R.string.import_keys_dialog_title);
    dialog.setView(view);/*from w ww . j  a  v  a2s  . c om*/
    dialog.setPositiveButton(R.string.import_keys_dialog_button_import, new OnClickListener() {
        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            final File file = (File) fileView.getSelectedItem();
            final String password = passwordView.getText().toString().trim();
            passwordView.setText(null); // get rid of it asap

            if (WalletUtils.BACKUP_FILE_FILTER.accept(file))
                restoreWalletFromProtobuf(file, CloseAction.CLOSE_RECREATE);
            else if (WalletUtils.KEYS_FILE_FILTER.accept(file))
                restorePrivateKeysFromBase58(file, CloseAction.CLOSE_RECREATE);
            else if (Crypto.OPENSSL_FILE_FILTER.accept(file))
                restoreWalletFromEncrypted(file, password, CloseAction.CLOSE_RECREATE);
        }
    });
    dialog.setNegativeButton(R.string.button_cancel, new OnClickListener() {
        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            passwordView.setText(null); // get rid of it asap
        }
    });
    dialog.setOnCancelListener(new OnCancelListener() {
        @Override
        public void onCancel(final DialogInterface dialog) {
            passwordView.setText(null); // get rid of it asap
        }
    });

    final FileAdapter adapter = new FileAdapter(this) {
        @Override
        public View getDropDownView(final int position, View row, final ViewGroup parent) {
            final File file = getItem(position);
            final boolean isExternal = Constants.Files.EXTERNAL_WALLET_BACKUP_DIR.equals(file.getParentFile());
            final boolean isEncrypted = Crypto.OPENSSL_FILE_FILTER.accept(file);

            if (row == null)
                row = inflater.inflate(R.layout.restore_wallet_file_row, null);

            final TextView filenameView = (TextView) row
                    .findViewById(R.id.wallet_import_keys_file_row_filename);
            filenameView.setText(file.getName());

            final TextView securityView = (TextView) row
                    .findViewById(R.id.wallet_import_keys_file_row_security);
            final String encryptedStr = context
                    .getString(isEncrypted ? R.string.import_keys_dialog_file_security_encrypted
                            : R.string.import_keys_dialog_file_security_unencrypted);
            final String storageStr = context
                    .getString(isExternal ? R.string.import_keys_dialog_file_security_external
                            : R.string.import_keys_dialog_file_security_internal);
            securityView.setText(encryptedStr + ", " + storageStr);

            final TextView createdView = (TextView) row.findViewById(R.id.wallet_import_keys_file_row_created);
            createdView.setText(context.getString(
                    isExternal ? R.string.import_keys_dialog_file_created_manual
                            : R.string.import_keys_dialog_file_created_automatic,
                    DateUtils.getRelativeTimeSpanString(context, file.lastModified(), true)));

            return row;
        }
    };

    fileView.setAdapter(adapter);

    return dialog.create();
}

From source file:com.hivewallet.androidclient.wallet.ui.WalletActivity.java

private Dialog createExportKeysDialog() {
    final View view = getLayoutInflater().inflate(R.layout.export_keys_dialog, null);
    final EditText passwordView = (EditText) view.findViewById(R.id.export_keys_dialog_password);

    final DialogBuilder dialog = new DialogBuilder(this);
    dialog.setTitle(R.string.export_keys_dialog_title);
    dialog.setView(view);/*from w  w w . jav  a  2 s .  co m*/
    dialog.setPositiveButton(R.string.export_keys_dialog_button_export, new OnClickListener() {
        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            final String password = passwordView.getText().toString().trim();
            passwordView.setText(null); // get rid of it asap

            backupWallet(password);

            config.disarmBackupReminder();
        }
    });
    dialog.setNegativeButton(R.string.button_cancel, new OnClickListener() {
        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            passwordView.setText(null); // get rid of it asap
        }
    });
    dialog.setOnCancelListener(new OnCancelListener() {
        @Override
        public void onCancel(final DialogInterface dialog) {
            passwordView.setText(null); // get rid of it asap
        }
    });
    return dialog.create();
}

From source file:com.BeatYourRecord.SubmitActivity.java

public void iregistered() {
    EditText e2 = (EditText) findViewById(R.id.editText9);
    String str = e2.getText().toString();
    //log.v("Value1",str);
    EditText e3 = (EditText) findViewById(R.id.editText8);
    String str1 = e3.getText().toString();
    //log.v("Value1",str1);
    EditText e4 = (EditText) findViewById(R.id.editText0);
    String str2 = e4.getText().toString();
    EditText e5 = (EditText) findViewById(R.id.editText14);
    String str3 = e5.getText().toString();
    //log.v("Value1",str2);

    DefaultHttpClient client = new DefaultHttpClient();
    //log.v("here12","here");
    HttpPost post = new HttpPost(
            "http://ec2-54-212-221-3.us-west-2.compute.amazonaws.com/api/v3/registrations/");
    JSONObject holder = new JSONObject();
    JSONObject userObj = new JSONObject();
    JSONObject userObj1 = new JSONObject();
    JSONObject userObj2 = new JSONObject();
    JSONObject userObj4 = new JSONObject();

    String response = null;//from w w w .  j a  va 2s.com
    JSONObject json = new JSONObject();

    try {
        try {
            // setup the returned values in case
            // something goes wrong
            json.put("success", false);
            json.put("info", "Something went wrong. Retry!");
            // add the user email and password to
            // the params
            String k = "";
            String k1 = "";
            String k2 = "";
            SharedPreferences pref6 = getApplicationContext().getSharedPreferences("TourPref", 0); // 0 - for private mode
            Editor editor6 = pref6.edit();
            editor6.putString("Username", str3);
            editor6.commit();
            userObj.put("email", str);
            k = userObj.toString();
            k = k.substring(0, k.length() - 1);
            k += ",";
            userObj4.put("username", str3);
            k1 = userObj4.toString();
            k1 = k1.substring(1, k1.length() - 1);
            k1 += ",";
            k += k1;
            userObj1.put("password", str1);
            k1 = userObj1.toString();
            k1 = k1.substring(1, k1.length() - 1);
            k1 += ",";
            k += k1;
            userObj2.put("password_confirmation", str2);
            k1 = userObj2.toString();
            k1 = k1.substring(1, k1.length());
            k += k1;
            //log.v("holder",k);
            StringEntity se = new StringEntity(k);
            post.setEntity(se);

            // setup the request headers
            post.setHeader("Content-Type", "application/json");
            post.setHeader("Accept", "application/json");
            //  post.setHeader("Content-Type", "application/json");

            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            response = client.execute(post, responseHandler);
            json = new JSONObject(response);
            String test = json.getJSONObject("data").getString("auth_token");
            SharedPreferences pref = getApplicationContext().getSharedPreferences("Tester15", 0); // 0 - for private mode
            Editor editor = pref.edit();
            editor.putString("BYR_session", test); // Storing string
            auth = test;
            editor.commit();
            Log.v("test1authinsub", test);

        } catch (HttpResponseException e) {
            e.printStackTrace();
            Log.e("ClientProtocol", "" + e);
            json.put("info", "Email and/or password are invalid. Retry!");
        } catch (IOException e) {
            e.printStackTrace();
            Log.e("IO", "" + e);
        }
    } catch (JSONException e) {
        e.printStackTrace();
        Log.e("JSON", "" + e);
    }
}

From source file:com.timemachine.controller.ControllerActivity.java

private void createConnectDialog() {
    // Load saved IP address
    String serverIP = prefs.getString("serverIP", "");
    // Instantiate an AlertDialog.Builder with its constructor
    AlertDialog.Builder connectDialogBuilder = new AlertDialog.Builder(ControllerActivity.this);
    // Get the layout inflater
    LayoutInflater inflater = ControllerActivity.this.getLayoutInflater();
    // Inflate the custom view
    final View connectDialogLayout = inflater.inflate(R.layout.connect_dialog, null);
    // Get the text box
    final EditText ipTextbox = (EditText) connectDialogLayout.findViewById(R.id.ipAddress);
    // Restore previous IP
    ipTextbox.setText(serverIP);//from  w w  w .j ava 2 s .  c o m
    // Set layout and title
    connectDialogBuilder.setView(connectDialogLayout);
    connectDialogBuilder.setTitle(connectDialogTitle);
    // Prevent the dialog from canceling when users click outside the dialog
    connectDialogBuilder.setCancelable(false);
    // Add actionButtons
    connectDialogBuilder.setPositiveButton(R.string.connect, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            showProcessDialog("Connecting to server...");
            // Get the text written in IP address section
            ipText = ipTextbox.getText().toString();
            // Save IP address
            SharedPreferences.Editor editor = prefs.edit();
            editor.putString("serverIP", ipText);
            editor.commit();
            // Connect Websocket
            setupSocketConnection(ipText);
        }
    });
    buildDisconnectDialog();
    // Create the AlertDialog
    connectDialog = connectDialogBuilder.create();
    connectDialog.setOwnerActivity(ControllerActivity.this);
    connectDialog.show();
}