List of usage examples for android.view View inflate
public static View inflate(Context context, @LayoutRes int resource, ViewGroup root)
From source file:edu.mit.viral.shen.DroidFish.java
private final Dialog newNetworkEngineDialog() { View content = View.inflate(this, R.layout.create_network_engine, null); final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(content);/* w ww. j av a2s . c om*/ builder.setTitle(R.string.create_network_engine); final EditText engineNameView = (EditText) content.findViewById(R.id.create_network_engine); engineNameView.setText(""); final Runnable createEngine = new Runnable() { public void run() { String engineName = engineNameView.getText().toString(); String sep = File.separator; String pathName = Environment.getExternalStorageDirectory() + sep + engineDir + sep + engineName; File file = new File(pathName); boolean nameOk = true; int errMsg = -1; if (engineName.contains("/")) { nameOk = false; errMsg = R.string.slash_not_allowed; } else if (internalEngine(engineName) || file.exists()) { nameOk = false; errMsg = R.string.engine_name_in_use; } if (!nameOk) { Toast.makeText(getApplicationContext(), errMsg, Toast.LENGTH_LONG).show(); removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); return; } networkEngineToConfig = pathName; removeDialog(NETWORK_ENGINE_CONFIG_DIALOG); showDialog(NETWORK_ENGINE_CONFIG_DIALOG); } }; builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { createEngine.run(); } }); builder.setNegativeButton(R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); builder.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); final Dialog dialog = builder.create(); engineNameView.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { createEngine.run(); dialog.cancel(); return true; } return false; } }); return dialog; }
From source file:edu.mit.viral.shen.DroidFish.java
private final Dialog networkEngineConfigDialog() { View content = View.inflate(this, R.layout.network_engine_config, null); final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(content);//from w w w. ja v a 2 s .c om builder.setTitle(R.string.configure_network_engine); final EditText hostNameView = (EditText) content.findViewById(R.id.network_engine_host); final EditText portView = (EditText) content.findViewById(R.id.network_engine_port); String hostName = ""; String port = "0"; try { String[] lines = Util.readFile(networkEngineToConfig); if ((lines.length >= 1) && lines[0].equals("NETE")) { if (lines.length > 1) hostName = lines[1]; if (lines.length > 2) port = lines[2]; } } catch (IOException e1) { } hostNameView.setText(hostName); portView.setText(port); final Runnable writeConfig = new Runnable() { public void run() { String hostName = hostNameView.getText().toString(); String port = portView.getText().toString(); try { FileWriter fw = new FileWriter(new File(networkEngineToConfig), false); fw.write("NETE\n"); fw.write(hostName); fw.write("\n"); fw.write(port); fw.write("\n"); fw.close(); setEngineOptions(true); } catch (IOException e) { Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } }; builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { writeConfig.run(); removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); builder.setNegativeButton(R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); builder.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); } }); builder.setNeutralButton(R.string.delete, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { removeDialog(DELETE_NETWORK_ENGINE_DIALOG); showDialog(DELETE_NETWORK_ENGINE_DIALOG); } }); final Dialog dialog = builder.create(); portView.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { writeConfig.run(); dialog.cancel(); removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); return true; } return false; } }); return dialog; }
From source file:edu.cmu.cylab.starslinger.view.HomeActivity.java
private AlertDialog.Builder xshowManagePassphrases(final Activity act, Bundle args) { String msg = args.getString(extra.RESID_MSG); boolean allowDelete = args.getBoolean(extra.ALLOW_DELETE); AlertDialog.Builder ad = new AlertDialog.Builder(act); View layout;//w w w.j av a 2s . c o m if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { layout = View.inflate(new ContextThemeWrapper(act, R.style.Theme_AppCompat), R.layout.about, null); } else { LayoutInflater inflater = (LayoutInflater) act.getSystemService(Context.LAYOUT_INFLATER_SERVICE); layout = inflater.inflate(R.layout.about, null); } TextView textViewAbout = (TextView) layout.findViewById(R.id.TextViewAbout); ad.setTitle(R.string.menu_ManagePassphrases); textViewAbout.setText(msg); ad.setView(layout); ad.setCancelable(true); if (allowDelete) { // only have delete key when recent keys exist ad.setPositiveButton(R.string.btn_DeleteKeys, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); // delete all more recent keys for now... doRemoveMoreRecentKeys(); refreshView(); } }); } ad.setNegativeButton(R.string.btn_Cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); ad.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { dialog.dismiss(); } }); return ad; }
From source file:edu.cmu.cylab.starslinger.view.HomeActivity.java
private AlertDialog.Builder xshowIntroductionInvite(final Activity act, final Bundle args) { String exchName = args.getString(extra.EXCH_NAME); final String introName = args.getString(extra.INTRO_NAME); final byte[] introPhoto = args.getByteArray(extra.PHOTO); final byte[] introPush = args.getByteArray(extra.PUSH_REGISTRATION_ID); final byte[] introPubKey = args.getByteArray(extra.INTRO_PUBKEY); final long msgRowId = args.getLong(extra.MESSAGE_ROW_ID); AlertDialog.Builder ad = new AlertDialog.Builder(act); View layout;//from w w w .jav a 2 s .c o m if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { layout = View.inflate(new ContextThemeWrapper(act, R.style.Theme_AppCompat), R.layout.secureinvite, null); } else { LayoutInflater inflater = (LayoutInflater) act.getSystemService(Context.LAYOUT_INFLATER_SERVICE); layout = inflater.inflate(R.layout.secureinvite, null); } TextView textViewExchName = (TextView) layout.findViewById(R.id.textViewExchName); TextView textViewIntroName = (TextView) layout.findViewById(R.id.textViewIntroName); ImageView imageViewIntroPhoto = (ImageView) layout.findViewById(R.id.imageViewIntroPhoto); ad.setTitle(R.string.title_SecureIntroductionInvite); textViewExchName.setText(exchName); textViewIntroName.setText(introName); if (introPhoto != null) { try { Bitmap bm = BitmapFactory.decodeByteArray(introPhoto, 0, introPhoto.length, null); imageViewIntroPhoto.setImageBitmap(bm); } catch (OutOfMemoryError e) { imageViewIntroPhoto.setImageDrawable(getResources().getDrawable(R.drawable.ic_silhouette)); } } ad.setView(layout); ad.setCancelable(false); ad.setPositiveButton(getString(R.string.btn_Accept), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); // accept secure introduction? int selected = 0; args.putString(extra.NAME + selected, introName); args.putByteArray(extra.PHOTO + selected, introPhoto); args.putByteArray(SafeSlingerConfig.APP_KEY_PUBKEY + selected, introPubKey); args.putByteArray(SafeSlingerConfig.APP_KEY_PUSHTOKEN + selected, introPush); String contactLookupKey = getContactLookupKeyByName(introName); args.putString(extra.CONTACT_LOOKUP_KEY + selected, contactLookupKey); MessageRow inviteMsg = null; MessageDbAdapter dbMessage = MessageDbAdapter.openInstance(getApplicationContext()); Cursor c = dbMessage.fetchMessageSmall(msgRowId); if (c != null) { try { if (c.moveToFirst()) { inviteMsg = new MessageRow(c, false); } } finally { c.close(); } } if (inviteMsg == null) { showNote(R.string.error_InvalidIncomingMessage); return; } // import the new contacts args.putInt(extra.RECIP_SOURCE, RecipientDbAdapter.RECIP_SOURCE_INTRODUCTION); args.putString(extra.KEYID, inviteMsg.getKeyId()); ImportFromExchangeTask importFromExchange = new ImportFromExchangeTask(); importFromExchange.execute(args); setTab(Tabs.MESSAGE); refreshView(); } }); ad.setNegativeButton(getString(R.string.btn_Refuse), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); showNote(String.format(getString(R.string.state_SomeContactsImported), 0)); refreshView(); } }); return ad; }
From source file:com.android.vending.billing.InAppBillingService.LACK.listAppsFragment.java
public void changeDayOnUp() { AlertDlg localAlertDlg = new AlertDlg(frag.getContext()); localAlertDlg.setTitle(2131165404); LinearLayout localLinearLayout = (LinearLayout) View.inflate(frag.getContext(), 2130968597, null); final EditText localEditText = (EditText) localLinearLayout.findViewById(2131558503); localEditText.setText("" + getConfig().getInt("days_on_up", 1)); localAlertDlg.setView(localLinearLayout); localAlertDlg.setNegativeButton(2131165563, null) .setPositiveButton(2131165187, new DialogInterface.OnClickListener() { public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) { paramAnonymousDialogInterface = localEditText.getText(); if (listAppsFragment.this.numberCheck(paramAnonymousDialogInterface)) { listAppsFragment.getConfig().edit() .putInt("days_on_up", Integer.valueOf(paramAnonymousDialogInterface.toString()).intValue()) .commit(); listAppsFragment.getConfig().edit().putBoolean("settings_change", true).commit(); listAppsFragment.getConfig().edit().putBoolean("lang_change", true).commit(); listAppsFragment.runResume = true; }//from w ww. j a v a 2 s. com } }).create().show(); }
From source file:com.android.vending.billing.InAppBillingService.LACK.listAppsFragment.java
public void changeDefaultDir() { AlertDlg localAlertDlg = new AlertDlg(frag.getContext()); localAlertDlg.setTitle(2131165411); LinearLayout localLinearLayout = (LinearLayout) View.inflate(frag.getContext(), 2130968596, null); final EditText localEditText = (EditText) localLinearLayout.findViewById(2131558502); localEditText.setText(getConfig().getString("basepath", "/")); localAlertDlg.setView(localLinearLayout); localAlertDlg.setNegativeButton(2131165563, null) .setPositiveButton(2131165187, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) { paramAnonymousDialogInterface = localEditText.getText(); if ((paramAnonymousDialogInterface.toString().contains("/")) && (!paramAnonymousDialogInterface.toString().equals("/"))) { final Object localObject2 = paramAnonymousDialogInterface.toString().trim() .replaceAll("\\s+", ".").split("\\/+"); paramAnonymousDialogInterface = ""; int i = localObject2.length; paramAnonymousInt = 0; final Object localObject1; while (paramAnonymousInt < i) { String str = localObject2[paramAnonymousInt]; localObject1 = paramAnonymousDialogInterface; if (!str.equals("")) { localObject1 = paramAnonymousDialogInterface + "/" + str; }//from w ww . ja v a2 s .c om paramAnonymousInt += 1; paramAnonymousDialogInterface = (DialogInterface) localObject1; } if (!new File(paramAnonymousDialogInterface).exists()) { if ((listAppsFragment.this.testPath(true, paramAnonymousDialogInterface)) && (!paramAnonymousDialogInterface.startsWith(listAppsFragment.getInstance() .getDir("sdcard", 0).getAbsolutePath()))) { listAppsFragment.getConfig().edit() .putString("path", paramAnonymousDialogInterface).commit(); listAppsFragment.getConfig().edit().putBoolean("manual_path", true).commit(); listAppsFragment.getConfig().edit().putBoolean("path_changed", true).commit(); localObject1 = new File( listAppsFragment.getConfig().getString("basepath", "Noting")); localObject2 = new File(paramAnonymousDialogInterface); if (!((File) localObject1).exists()) { System.out.println("Directory does not exist."); } } else { return; } listAppsFragment.this.runWithWait(new Runnable() { public void run() { try { Utils.copyFolder(localObject1, localObject2); new Utils("").deleteFolder(localObject1); listAppsFragment.getConfig().edit() .putString("basepath", paramAnonymousDialogInterface).commit(); listAppsFragment.basepath = paramAnonymousDialogInterface; listAppsFragment.this.showMessage(Utils.getText(2131165748), Utils.getText(2131165553) + paramAnonymousDialogInterface); return; } catch (Exception localException) { localException.printStackTrace(); listAppsFragment.this.showMessage(Utils.getText(2131165748), Utils.getText(2131165569)); } } }); return; } listAppsFragment.this.showMessage(Utils.getText(2131165748), Utils.getText(2131165445)); return; } listAppsFragment.this.showMessage(Utils.getText(2131165748), Utils.getText(2131165444)); } }).create().show(); }
From source file:com.android.vending.billing.InAppBillingService.LACK.listAppsFragment.java
public void showAbout() { LinearLayout localLinearLayout = (LinearLayout) View.inflate(patchAct, 2130968576, null); Object localObject = (LinearLayout) localLinearLayout.findViewById(2131558401).findViewById(2131558403); String str1 = Utils.getText(2131165737) + version + "\n"; localObject = (TextView) ((LinearLayout) localObject).findViewById(2131558404); ((TextView) localObject).append(Utils.getColoredText(str1, "#ffffffff", "bold")); ((TextView) localObject)//from ww w .ja v a2 s . com .append(Utils.getColoredText("----------------------------------\n\n", "#ffffffff", "bold")); ((TextView) localObject).append( Utils.getColoredText(Utils.getText(2131165188) + " " + basepath + "\n\n", "#ffffffff", "bold")); ((TextView) localObject) .append(Utils.getColoredText(Utils.getText(2131165629) + "\n\n", "#ffff0000", "bold")); ((TextView) localObject) .append(Utils.getColoredText(Utils.getText(2131165189) + "\n", "#ffffff00", "bold")); ((TextView) localObject) .append(Utils.getColoredText("\n" + Utils.getText(2131165801) + "\n\n", "#ffffffff", "bold")); ((TextView) localObject).append(Utils.getColoredText( "\nThanks to:\nUsed source code: pyler, Mikanoshi@4pda.ru\nm0rpheus@TeamURET, Site WebIconSet.com - Smile icons\nslycog@XDA - Custom Patch Help translate\nIcons to menu - Sergey Kamashki\nTemplate for ADS - And123\n\nTranslation project:\nhttps://www.transifex.com/chelpus/luckypatcher/\nSupport by email: lp.chelpus@gmail.com\nGood Luck!\nChelpuS", "#ffffffff", "bold")); new AlertDlg(patchAct).setTitle(2131165191).setCancelable(true).setIcon(17301659) .setPositiveButton(Utils.getText(2131165587), null) .setNeutralButton("Changelog", new DialogInterface.OnClickListener() { public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) { if (new File(listAppsFragment.basepath + "/Changes/changelog.txt").exists()) { listAppsFragment.this.showMessage(Utils.getText(2131165251), Utils.read_from_file( new File(listAppsFragment.basepath + "/Changes/changelog.txt"))); return; } listAppsFragment.this.showMessage(Utils.getText(2131165251), Utils.getText(2131165577)); } }).setView(localLinearLayout).setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface paramAnonymousDialogInterface) { paramAnonymousDialogInterface.dismiss(); } }).create().show(); }