use of android.support.v7.widget.AppCompatButton in project ToolBarLib by jjhesk.
the class CandyBar method init.
private void init() {
actionbar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
View t;
if (this.toolbar_resid != 0) {
t = ToolbarHelper.renewView(activity, toolbar, this.toolbar_resid);
} else
t = ToolbarHelper.renewView(activity, toolbar, mainPreset);
if (burger != 0)
toolbar.setNavigationIcon(burger);
FrameLayout dynamic_button_frame = (FrameLayout) t.findViewById(R.id.liveicon_counterpanel);
ImageView k3 = (ImageView) t.findViewById(R.id.liveiconloc);
prepareNotificationCustomization(t);
invalidateNotificationBox();
logoview = (ImageView) t.findViewById(R.id.logo_k);
if (logo != 0)
logoview.setImageResource(logo);
AppCompatButton k2 = (AppCompatButton) t.findViewById(R.id.i_kr2);
final int[] overrides = mb.getOverrideIcons_i_t_ii();
if (mainPreset == LayoutAsset.i_logo_ir) {
AppCompatButton k1 = (AppCompatButton) t.findViewById(R.id.i_kl1);
if (overrides[0] != 0)
k1.setBackgroundResource(overrides[0]);
k1.setOnClickListener(this);
if (overrides[1] != 0)
k2.setBackgroundResource(overrides[1]);
if (overrides[2] != 0)
k3.setImageResource(overrides[2]);
}
if (mainPreset == LayoutAsset.i_logo_ir2) {
if (overrides[0] != 0)
k2.setBackgroundResource(overrides[0]);
if (overrides[1] != 0)
k3.setImageResource(overrides[1]);
}
titlebar = (TextView) t.findViewById(R.id.i_text_wide);
k2.setOnClickListener(this);
dynamic_button_frame.setOnClickListener(this);
}
use of android.support.v7.widget.AppCompatButton 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;
}
use of android.support.v7.widget.AppCompatButton in project Rashr by DsLNeXuS.
the class BackupRestoreFragment method showPopup.
public void showPopup(final View v) {
PopupMenu popup = new PopupMenu(mActivity, v);
popup.getMenuInflater().inflate(R.menu.bakmgr_menu, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(final MenuItem menuItem) {
final CharSequence text = ((AppCompatTextView) v).getText();
final String FileName = text.toString();
final AppCompatDialog dialog = new AppCompatDialog(mActivity);
dialog.setTitle(R.string.setname);
dialog.setContentView(R.layout.dialog_input);
final AppCompatButton bGo = (AppCompatButton) dialog.findViewById(R.id.bGoBackup);
final AppCompatEditText etFileName = (AppCompatEditText) dialog.findViewById(R.id.etFileName);
if (bGo == null || etFileName == null)
return false;
//If current item is 0 (first item) a recovery backup will be edited or created
final File path = mPager.getCurrentItem() == 0 ? Const.PathToRecoveryBackups : Const.PathToKernelBackups;
try {
switch(menuItem.getItemId()) {
case R.id.iRestore:
File backup = new File(path, FileName);
FlashUtil RestoreUtil = new FlashUtil(mActivity, backup, mPager.getCurrentItem() == 0 ? FlashUtil.JOB_RESTORE_RECOVERY : FlashUtil.JOB_RESTORE_KERNEL);
RestoreUtil.execute();
return true;
case R.id.iRename:
etFileName.setHint(FileName);
bGo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String Name;
if (etFileName.getText() != null && etFileName.isEnabled() && !etFileName.getText().toString().equals("")) {
//User has defined a name for the backup. Use it.
Name = etFileName.getText().toString();
} else {
//Use hint as backup name. Normally the correct version
//and Recovery System (if Rashr could read it out of
//"/cache/recovery/last_log"
Name = String.valueOf(etFileName.getHint());
}
if (!Name.endsWith(RashrApp.DEVICE.getRecoveryExt())) {
//Append extension
Name += RashrApp.DEVICE.getRecoveryExt();
}
File renamedBackup = new File(path, Name);
if (renamedBackup.exists()) {
Toast.makeText(mActivity, R.string.backupalready, Toast.LENGTH_SHORT).show();
// if backup already exists, let the user chose a new name
onMenuItemClick(menuItem);
} else {
File Backup = new File(path, FileName);
if (Backup.renameTo(renamedBackup)) {
mAdapter.reload();
} else {
Toast.makeText(mActivity, R.string.rename_failed, Toast.LENGTH_SHORT).show();
}
}
dialog.dismiss();
}
});
dialog.show();
return true;
case R.id.iDeleteBackup:
backup = new File(path, text.toString());
if (backup.delete()) {
Toast.makeText(mActivity, mContext.getString(R.string.bak_deleted), Toast.LENGTH_SHORT).show();
}
mAdapter.reload();
return true;
default:
return false;
}
} catch (Exception e) {
if (e.getMessage().contains("EINVAL") && text.toString().contains(":")) {
AlertDialog.Builder adialog = new AlertDialog.Builder(mContext);
adialog.setMessage(R.string.check_name);
adialog.setMessage(R.string.ok);
adialog.show();
}
RashrApp.ERRORS.add(Const.RASHR_TAG + " " + e);
return false;
}
}
});
popup.show();
}
use of android.support.v7.widget.AppCompatButton in project Rashr by DsLNeXuS.
the class FlashAsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View fragment = inflater.inflate(R.layout.fragment_flash_as, container, false);
AppCompatTextView tvFlashAs = (AppCompatTextView) fragment.findViewById(R.id.tvFlashAs);
tvFlashAs.setText(String.format(getString(R.string.flash_as), mImg.getName()));
mOptAsRecovery = (RadioButton) fragment.findViewById(R.id.optAsRecovery);
mOptAsKernel = (RadioButton) fragment.findViewById(R.id.optAsKernel);
mButFlashAs = (AppCompatButton) fragment.findViewById(R.id.bFlashAs);
final AppCompatButton ButCancel = (AppCompatButton) fragment.findViewById(R.id.bCancel);
ButCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!mCloseApp) {
new AlertDialog.Builder(mContext).setTitle(R.string.exit_app).setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mActivity.finish();
}
}).setNegativeButton(R.string.negative, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mActivity.switchTo(FlashFragment.newInstance(mActivity));
}
}).setCancelable(false).show();
} else {
mActivity.finish();
}
}
});
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View view) {
if (view.getTag().toString().equals("recovery")) {
mOptAsKernel.setChecked(false);
} else {
mOptAsRecovery.setChecked(false);
}
mButFlashAs.setEnabled(true);
}
};
mButFlashAs.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mImg.exists()) {
int job = mOptAsRecovery.isChecked() ? FlashUtil.JOB_FLASH_RECOVERY : FlashUtil.JOB_FLASH_KERNEL;
final FlashUtil flashUtil = new FlashUtil(mActivity, mImg, job);
flashUtil.setOnTaskDoneListener(new FlashUtil.OnTaskDoneListener() {
@Override
public void onSuccess() {
flashUtil.showRebootDialog();
}
@Override
public void onFail(Exception e) {
}
});
flashUtil.execute();
} else {
mActivity.finish();
}
}
});
mOptAsRecovery.setOnClickListener(listener);
mOptAsKernel.setOnClickListener(listener);
ViewGroup parent;
if (!RashrApp.DEVICE.isRecoverySupported()) {
if ((parent = (ViewGroup) mOptAsRecovery.getParent()) != null) {
parent.removeView(mOptAsRecovery);
mOptAsKernel.setChecked(true);
}
}
if (!RashrApp.DEVICE.isKernelSupported()) {
if ((parent = (ViewGroup) mOptAsKernel.getParent()) != null) {
parent.removeView(mOptAsKernel);
}
}
return fragment;
}
use of android.support.v7.widget.AppCompatButton in project WordPress-Android by wordpress-mobile.
the class EditPostSettingsFragment method populateSelectedCategories.
private void populateSelectedCategories() {
// Remove previous category buttons if any + select category button
List<View> viewsToRemove = new ArrayList<>();
for (int i = 0; i < mSectionCategories.getChildCount(); i++) {
View v = mSectionCategories.getChildAt(i);
if (v == null)
return;
Object tag = v.getTag();
if (tag != null && tag.getClass() == String.class && (((String) tag).startsWith(CATEGORY_PREFIX_TAG) || tag.equals("select-category"))) {
viewsToRemove.add(v);
}
}
for (View viewToRemove : viewsToRemove) {
mSectionCategories.removeView(viewToRemove);
}
viewsToRemove.clear();
// New category buttons
LayoutInflater layoutInflater = getActivity().getLayoutInflater();
if (mCategories != null) {
for (TermModel category : mCategories) {
AppCompatButton buttonCategory = (AppCompatButton) layoutInflater.inflate(R.layout.category_button, null);
if (category != null && category.getName() != null && buttonCategory != null) {
buttonCategory.setText(Html.fromHtml(category.getName()));
buttonCategory.setTag(CATEGORY_PREFIX_TAG + category.getName());
buttonCategory.setOnClickListener(this);
mSectionCategories.addView(buttonCategory);
}
}
}
// Add select category button once the category list has been initialized
Button selectCategory = (Button) layoutInflater.inflate(R.layout.category_select_button, null);
if (selectCategory != null && mCategories != null) {
selectCategory.setOnClickListener(this);
mSectionCategories.addView(selectCategory);
}
}
Aggregations