use of android.support.v7.widget.AppCompatCheckBox in project Rashr by DsLNeXuS.
the class BackupActivity method createBackup.
public void createBackup(final boolean RecoveryBackup) {
String prefix;
String CurrentName;
String EXT;
if (RecoveryBackup) {
prefix = "recovery";
EXT = App.Device.getRecoveryExt();
CurrentName = App.Device.getRecoveryVersion();
} else {
prefix = "kernel";
EXT = App.Device.getKernelExt();
CurrentName = App.Device.getKernelVersion();
}
final AppCompatDialog dialog = new AppCompatDialog(mContext);
dialog.setTitle(R.string.setname);
dialog.setContentView(R.layout.dialog_input);
final AppCompatButton bGoBackup = dialog.findViewById(R.id.bGoBackup);
final AppCompatEditText etFileName = dialog.findViewById(R.id.etFileName);
final AppCompatCheckBox optName = dialog.findViewById(R.id.cbOptInput);
if (bGoBackup == null || etFileName == null || optName == null)
return;
final String NameHint = prefix + "-from-" + Calendar.getInstance().get(Calendar.DATE) + "-" + Calendar.getInstance().get(Calendar.MONTH) + "-" + Calendar.getInstance().get(Calendar.YEAR) + "-" + Calendar.getInstance().get(Calendar.HOUR_OF_DAY) + "-" + Calendar.getInstance().get(Calendar.MINUTE) + EXT;
optName.setText(CurrentName);
optName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
etFileName.setEnabled(!optName.isChecked());
}
});
etFileName.setHint(NameHint);
bGoBackup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String EXT;
File Path;
final int JOB;
if (RecoveryBackup) {
EXT = App.Device.getRecoveryExt();
Path = App.PathToRecoveryBackups;
JOB = FlashUtil.JOB_BACKUP_RECOVERY;
} else {
EXT = App.Device.getKernelExt();
Path = App.PathToKernelBackups;
JOB = FlashUtil.JOB_BACKUP_KERNEL;
}
String Name;
if (optName.isChecked()) {
// Using preset name as filename
Name = optName.getText() + EXT;
} else {
if (etFileName.getText() != null && !etFileName.getText().toString().equals("")) {
// Use edittext as name
Name = etFileName.getText().toString();
} else {
// Use hint as name
Name = String.valueOf(etFileName.getHint());
}
}
// Adding extension to chosen name
if (!Name.endsWith(EXT)) {
Name = Name + EXT;
}
final File fBACKUP = new File(Path, Name);
if (fBACKUP.exists()) {
// Backup exists already do not create new.
Toast.makeText(mActivity, R.string.backupalready, Toast.LENGTH_SHORT).show();
} else {
final FlashUtil BackupCreator = new FlashUtil(mActivity, fBACKUP, JOB);
BackupCreator.setOnFlashListener(new FlashUtil.OnFlashListener() {
@Override
public void onSuccess() {
mAdapter.loadBackups();
}
@Override
public void onFail(Exception e) {
String msg;
if (e != null) {
msg = e.toString();
} else {
msg = getString(R.string.bak_error);
}
Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
}
});
BackupCreator.execute();
}
dialog.dismiss();
}
});
dialog.show();
}
use of android.support.v7.widget.AppCompatCheckBox in project SearchView by lapism.
the class SearchView method setFilters.
public void setFilters(@Nullable List<SearchFilter> filters) {
mSearchFilters = filters;
mFiltersContainer.removeAllViews();
if (filters == null) {
mSearchFiltersStates = null;
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mFiltersContainer.getLayoutParams();
params.topMargin = 0;
params.bottomMargin = 0;
mFiltersContainer.setLayoutParams(params);
} else {
mSearchFiltersStates = new ArrayList<>();
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mFiltersContainer.getLayoutParams();
params.topMargin = mContext.getResources().getDimensionPixelSize(R.dimen.filter_margin_top);
params.bottomMargin = params.topMargin / 2;
mFiltersContainer.setLayoutParams(params);
for (SearchFilter filter : filters) {
AppCompatCheckBox checkBox = new AppCompatCheckBox(mContext);
checkBox.setText(filter.getTitle());
checkBox.setTextSize(12);
checkBox.setTextColor(mTextColor);
checkBox.setChecked(filter.isChecked());
FlowLayout.LayoutParams lp = new FlowLayout.LayoutParams(FlowLayout.LayoutParams.WRAP_CONTENT, FlowLayout.LayoutParams.WRAP_CONTENT);
checkBox.setLayoutParams(lp);
checkBox.setTag(filter.getTagId());
mFiltersContainer.addView(checkBox);
boolean isChecked = filter.isChecked();
mSearchFiltersStates.add(isChecked);
}
}
}
use of android.support.v7.widget.AppCompatCheckBox in project Rashr by DsLNeXuS.
the class ScriptManagerFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mRootView = inflater.inflate(R.layout.fragment_script_manager, container, false);
mFileNameAdapter = new ArrayAdapter<>(mContext, R.layout.custom_list_item);
mFileList = new ArrayList<>();
mQueue = (ListView) mRootView.findViewById(R.id.lvQueue);
mQueue.setAdapter(mFileNameAdapter);
mQueue.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mFileList.remove(position);
mFileNameAdapter.clear();
for (File i : mFileList) {
mFileNameAdapter.add(i.getName());
}
}
});
if (mStartFile != null) {
if (mStartFile.exists()) {
if (Common.stringEndsWithArray(mStartFile.getName(), mAllowedEXT)) {
addFileToQueue(mStartFile);
} else {
Toast.makeText(mContext, R.string.wrong_format, Toast.LENGTH_SHORT).show();
}
}
}
AppCompatButton AddZip = (AppCompatButton) mRootView.findViewById(R.id.addZip);
AddZip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mFileChooser = new FileChooserDialog(mContext);
File startFolder = Environment.getExternalStorageDirectory();
if (mFileList.size() > 0) {
startFolder = mFileList.get(mFileList.size() - 1);
if (startFolder.isFile()) {
startFolder = startFolder.getParentFile();
}
}
mFileChooser.setStartFolder(startFolder);
mFileChooser.setOnFileChooseListener(new FileChooserDialog.OnFileChooseListener() {
@Override
public void OnFileChoose(File file) {
addFileToQueue(file);
}
});
mFileChooser.setAllowedEXT(mAllowedEXT);
mFileChooser.setBrowseUpAllowed(true);
mFileChooser.setWarn(false);
mFileChooser.show();
}
});
AppCompatButton FlashZip = (AppCompatButton) mRootView.findViewById(R.id.bFlashZip);
FlashZip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AppCompatCheckBox cbBakSystem = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupSystem);
AppCompatCheckBox cbBakData = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupData);
AppCompatCheckBox cbBakCache = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupCache);
AppCompatCheckBox cbBakRecovery = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupRecovery);
AppCompatCheckBox cbBakBoot = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupBoot);
AppCompatCheckBox cbSkipMD5 = (AppCompatCheckBox) mRootView.findViewById(R.id.cbSkipMD5);
AppCompatEditText etBakName = (AppCompatEditText) mRootView.findViewById(R.id.etBackupName);
AppCompatCheckBox cbWipeCache = (AppCompatCheckBox) mRootView.findViewById(R.id.cbWipeCache);
AppCompatCheckBox cbWipeDalvik = (AppCompatCheckBox) mRootView.findViewById(R.id.cbWipeDalvik);
AppCompatCheckBox cbWipeData = (AppCompatCheckBox) mRootView.findViewById(R.id.cbWipeData);
final StringBuilder command = new StringBuilder();
command.append("echo #####Script created by Rashr#####;");
if (cbBakBoot.isChecked() || cbBakCache.isChecked() || cbBakData.isChecked() || cbBakRecovery.isChecked() || cbBakSystem.isChecked()) {
command.append("backup ");
if (cbBakBoot.isChecked())
command.append("B");
if (cbBakCache.isChecked())
command.append("C");
if (cbBakData.isChecked())
command.append("D");
if (cbBakRecovery.isChecked())
command.append("R");
if (cbBakSystem.isChecked())
command.append("S");
if (cbSkipMD5.isChecked())
command.append("M");
CharSequence BackupName = etBakName.getText();
if (BackupName != null && !BackupName.equals("")) {
command.append(" ");
command.append(BackupName);
}
command.append(CMD_END);
}
if (cbWipeCache.isChecked())
command.append("wipe cache;");
if (cbWipeDalvik.isChecked())
command.append("wipe dalvik;");
if (cbWipeData.isChecked())
command.append("wipe data;");
for (File i : mFileList) {
command.append("install ");
command.append(i.getAbsolutePath());
command.append(CMD_END);
}
if (!command.toString().equals("")) {
String commands = "";
int index = 0;
for (String i : command.toString().split(CMD_END)) {
if (!i.equals("")) {
if (index > 0) {
commands += index++ + ". " + i + "\n";
} else {
index++;
}
}
}
final AlertDialog.Builder CommandsPreview = new AlertDialog.Builder(mContext);
CommandsPreview.setTitle(R.string.recovery_script_review);
CommandsPreview.setPositiveButton(R.string.run, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
for (String split : command.toString().split(";")) {
if (!split.equals("")) {
RashrApp.SHELL.execCommand("echo " + split + " >> /cache/recovery/openrecoveryscript");
}
}
RashrApp.TOOLBOX.reboot(Toolbox.REBOOT_RECOVERY);
} catch (Exception e) {
e.printStackTrace();
}
}
});
CommandsPreview.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
CommandsPreview.setMessage(commands);
CommandsPreview.show();
} else {
Toast.makeText(mContext, "No job to do :)", Toast.LENGTH_LONG).show();
}
}
});
return mRootView;
}
Aggregations