com.grarak.kerneladiutor.utils.tools.Initd Java Examples
The following examples show how to use
com.grarak.kerneladiutor.utils.tools.Initd.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InitdFragment.java From KA27 with Apache License 2.0 | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (data != null) { String name = data.getExtras().getString("name"); String text = data.getExtras().getString("text"); if (text != null) { RootFile file = Initd.delete(name); RootUtils.mountSystem(true); for (String line: text.split("\\r?\\n")) file.write(line, true); RootUtils.mountSystem(false); } if (requestCode == 0) getHandler().post(new Runnable() { @Override public void run() { refresh(); } }); } }
Example #2
Source File: InitdFragment.java From kernel_adiutor with Apache License 2.0 | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (data != null) { String name = data.getExtras().getString("name"); String text = data.getExtras().getString("text"); if (text != null) { RootFile file = Initd.delete(name); RootUtils.mount(true, "/system"); for (String line : text.split("\\r?\\n")) file.write(line, true); } if (requestCode == 0) getHandler().post(new Runnable() { @Override public void run() { refresh(); } }); } }
Example #3
Source File: InitdFragment.java From KernelAdiutor with GNU General Public License v3.0 | 6 votes |
private void showCreateDialog() { mShowCreateNameDialog = true; ViewUtils.dialogEditText(null, (dialogInterface, i) -> { }, text -> { if (text.isEmpty()) { Utils.toast(R.string.name_empty, getActivity()); return; } if (Initd.list().indexOf(text) > -1) { Utils.toast(getString(R.string.already_exists, text), getActivity()); return; } mCreateName = text; Intent intent = new Intent(getActivity(), EditorActivity.class); intent.putExtra(EditorActivity.TITLE_INTENT, mCreateName); intent.putExtra(EditorActivity.TEXT_INTENT, "#!/system/bin/sh\n\n"); startActivityForResult(intent, 1); }, getActivity()).setTitle(getString(R.string.name)) .setOnDismissListener( dialogInterface -> mShowCreateNameDialog = false).show(); }
Example #4
Source File: InitdFragment.java From KernelAdiutor with GNU General Public License v3.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (data == null) return; if (requestCode == 0) { Initd.write(mEditInitd, data.getCharSequenceExtra(EditorActivity.TEXT_INTENT).toString()); reload(); } else if (requestCode == 1) { Initd.write(mCreateName, data.getCharSequenceExtra(EditorActivity.TEXT_INTENT).toString()); mCreateName = null; reload(); } }
Example #5
Source File: InitdFragment.java From KA27 with Apache License 2.0 | 4 votes |
private void refresh() { removeAllViews(); final InformationCardView.DInformationCard mInformationCard = new InformationCardView.DInformationCard(); mInformationCard.setText(getString(R.string.emulate_initd_summary)); addView(mInformationCard); for (final String file: Initd.getInitds()) { if (file == null || file.isEmpty()) return; final CardViewItem.DCardView mInitdCard = new CardViewItem.DCardView(); mInitdCard.setDescription(file); mInitdCard.setOnDCardListener(new CardViewItem.DCardView.OnDCardListener() { @Override public void onClick(CardViewItem.DCardView dCardView) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), (Utils.DARKTHEME ? R.style.AlertDialogStyleDark : R.style.AlertDialogStyleLight)); builder.setTitle(file); builder.setItems(R.array.initd_menu, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: new AlertDialog.Builder(getActivity()).setMessage(Initd.getInitd(file)).show(); break; case 1: new AsyncTask < Void, Void, String > () { private MaterialDialog progressDialog; @Override protected void onPreExecute() { super.onPreExecute(); progressDialog = new MaterialDialog.Builder(getActivity()) .content(getString(R.string.executing)) .progress(true, 0) .canceledOnTouchOutside(false) .show(); } @Override protected String doInBackground(Void...params) { return Initd.execute(file); } @Override protected void onPostExecute(String s) { super.onPostExecute(s); progressDialog.dismiss(); if (!s.isEmpty()) try { new AlertDialog.Builder(getActivity()).setMessage(s).show(); } catch (NullPointerException ignored) {} } }.execute(); break; case 2: Intent i = new Intent(getActivity(), EditTextActivity.class); Bundle args = new Bundle(); args.putString(EditTextActivity.NAME_ARG, file); args.putString(EditTextActivity.TEXT_ARG, Initd.getInitd(file)); i.putExtras(args); startActivityForResult(i, 1); break; case 3: Initd.delete(file); removeView(mInitdCard); resetTranslations(); break; } } }).show(); } }); addView(mInitdCard); } }
Example #6
Source File: InitdFragment.java From KernelAdiutor with GNU General Public License v3.0 | 4 votes |
@Override protected void load(List<RecyclerViewItem> items) { super.load(items); for (final String initd : Initd.list()) { CardView cardView = new CardView(); cardView.setOnMenuListener((cardView1, popupMenu) -> { Menu menu = popupMenu.getMenu(); menu.add(Menu.NONE, 0, Menu.NONE, getString(R.string.edit)); menu.add(Menu.NONE, 1, Menu.NONE, getString(R.string.delete)); popupMenu.setOnMenuItemClickListener(item -> { switch (item.getItemId()) { case 0: mEditInitd = initd; Intent intent = new Intent(getActivity(), EditorActivity.class); intent.putExtra(EditorActivity.TITLE_INTENT, initd); intent.putExtra(EditorActivity.TEXT_INTENT, Initd.read(initd)); startActivityForResult(intent, 0); break; case 1: mDeleteDialog = ViewUtils.dialogBuilder(getString(R.string.sure_question), (dialogInterface, i) -> { }, (dialogInterface, i) -> { Initd.delete(initd); reload(); }, dialogInterface -> mDeleteDialog = null, getActivity()); mDeleteDialog.show(); break; } return false; }); }); DescriptionView descriptionView = new DescriptionView(); descriptionView.setSummary(initd); descriptionView.setOnItemClickListener(item -> { mExecuteDialog = ViewUtils.dialogBuilder(getString(R.string.exceute_question, initd), (dialogInterface, i) -> { }, (dialogInterface, i) -> execute(initd), dialogInterface -> mExecuteDialog = null, getActivity()); mExecuteDialog.show(); }); cardView.addItem(descriptionView); items.add(cardView); } }
Example #7
Source File: InitdFragment.java From KernelAdiutor with GNU General Public License v3.0 | 4 votes |
@Override public Void doInBackground(InitdFragment fragment) { mResult = Initd.execute(mInitd); return null; }