use of androidx.appcompat.widget.AppCompatButton in project simperium-android by Simperium.
the class AuthenticationActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.setTheme(R.style.Simperium);
setContentView(R.layout.activity_authentication);
AppCompatButton buttonLogin = findViewById(R.id.button_login);
buttonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
buttonLoginClicked();
}
});
AppCompatButton buttonSignup = findViewById(R.id.button_signup);
buttonSignup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
buttonSignupClicked();
}
});
}
use of androidx.appcompat.widget.AppCompatButton in project J2ME-Loader by nikita36078.
the class StringItem method getItemContentView.
@Override
public View getItemContentView() {
if (textview == null) {
Context context = getOwnerForm().getParentActivity();
if (appearanceMode == BUTTON) {
textview = new AppCompatButton(context);
} else {
textview = new AppCompatTextView(context);
}
textview.setTextAppearance(context, android.R.style.TextAppearance_Small);
if (appearanceMode == HYPERLINK && text != null) {
SpannableStringBuilder s = new SpannableStringBuilder(text);
s.setSpan(new URLSpan(text), 0, s.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
textview.setText(s);
} else {
textview.setText(text);
}
textview.setOnClickListener(v -> fireDefaultCommandAction());
}
return textview;
}
use of androidx.appcompat.widget.AppCompatButton in project Slide by ccrama.
the class Announcement method onCreate.
@Override
public void onCreate(Bundle savedInstance) {
overridePendingTransition(R.anim.fade_in_real, 0);
disableSwipeBackLayout();
applyColorTheme();
setTheme(R.style.popup);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setBackgroundDrawableResource(android.R.color.transparent);
super.onCreate(savedInstance);
setContentView(R.layout.submission_dialog);
SpoilerRobotoTextView spoilerRobotoTextView = (SpoilerRobotoTextView) findViewById(R.id.submission_dialog_firstTextView);
CommentOverflow commentOverflow = (CommentOverflow) findViewById(R.id.submission_dialog_commentOverflow);
TitleTextView titleTextView = (TitleTextView) findViewById(R.id.submission_dialog_title);
AppCompatButton okBtn = (AppCompatButton) findViewById(R.id.submission_dialog_ok);
AppCompatButton commentsBtn = (AppCompatButton) findViewById(R.id.submission_dialog_comments);
setViews(Reddit.appRestart.getString("page", ""), "NO SUB", spoilerRobotoTextView, commentOverflow);
titleTextView.setText(Reddit.appRestart.getString("title", ""));
okBtn.setOnClickListener(v -> finish());
commentsBtn.setOnClickListener(v -> {
OpenRedditLink.openUrl(Announcement.this, Reddit.appRestart.getString("url", ""), true);
finish();
});
}
use of androidx.appcompat.widget.AppCompatButton in project AmazeFileManager by TeamAmaze.
the class WarnableTextInputValidatorTest method testValidate.
@Test
public void testValidate() {
EditText textfield = new AppCompatEditText(context);
WarnableTextInputLayout layout = new WarnableTextInputLayout(context, Robolectric.buildAttributeSet().build());
Button button = new AppCompatButton(context);
WarnableTextInputValidator.OnTextValidate validator = text -> ("Pass".equals(text)) ? new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_NORMAL, R.string.ok) : new WarnableTextInputValidator.ReturnState(WarnableTextInputValidator.ReturnState.STATE_ERROR, R.string.error);
WarnableTextInputValidator target = new WarnableTextInputValidator(ApplicationProvider.getApplicationContext(), textfield, layout, button, validator);
textfield.setText("");
target.performClick();
assertFalse(button.isEnabled());
assertEquals(context.getString(R.string.error), layout.getError());
textfield.setText("pass");
target.performClick();
assertFalse(button.isEnabled());
assertEquals(context.getString(R.string.error), layout.getError());
textfield.setText("Pass");
target.performClick();
assertTrue(button.isEnabled());
assertNull(layout.getError());
}
use of androidx.appcompat.widget.AppCompatButton in project AmazeFileManager by TeamAmaze.
the class GeneralDialogCreation method showPropertiesDialog.
private static void showPropertiesDialog(@NonNull final HybridFileParcelable baseFile, @NonNull ThemedActivity themedActivity, @Nullable MainFragment mainFragment, @Nullable final String permissions, boolean isRoot, @NonNull AppTheme appTheme, boolean forStorage) {
final ExecutorService executor = Executors.newFixedThreadPool(3);
final Context c = themedActivity.getApplicationContext();
int accentColor = themedActivity.getAccent();
long last = baseFile.getDate();
final String date = Utils.getDate(themedActivity, last), items = c.getString(R.string.calculating), name = baseFile.getName(c), parent = baseFile.getReadablePath(baseFile.getParent(c));
File nomediaFile = baseFile.isDirectory() ? new File(baseFile.getPath() + "/" + FileUtils.NOMEDIA_FILE) : null;
MaterialDialog.Builder builder = new MaterialDialog.Builder(themedActivity);
builder.title(c.getString(R.string.properties));
builder.theme(appTheme.getMaterialDialogTheme());
View v = themedActivity.getLayoutInflater().inflate(R.layout.properties_dialog, null);
TextView itemsText = v.findViewById(R.id.t7);
CheckBox nomediaCheckBox = v.findViewById(R.id.nomediacheckbox);
/*View setup*/
{
TextView mNameTitle = v.findViewById(R.id.title_name);
mNameTitle.setTextColor(accentColor);
TextView mDateTitle = v.findViewById(R.id.title_date);
mDateTitle.setTextColor(accentColor);
TextView mSizeTitle = v.findViewById(R.id.title_size);
mSizeTitle.setTextColor(accentColor);
TextView mLocationTitle = v.findViewById(R.id.title_location);
mLocationTitle.setTextColor(accentColor);
TextView md5Title = v.findViewById(R.id.title_md5);
md5Title.setTextColor(accentColor);
TextView sha256Title = v.findViewById(R.id.title_sha256);
sha256Title.setTextColor(accentColor);
((TextView) v.findViewById(R.id.t5)).setText(name);
((TextView) v.findViewById(R.id.t6)).setText(parent);
itemsText.setText(items);
((TextView) v.findViewById(R.id.t8)).setText(date);
if (baseFile.isDirectory() && baseFile.isLocal()) {
nomediaCheckBox.setVisibility(View.VISIBLE);
if (nomediaFile != null) {
nomediaCheckBox.setChecked(nomediaFile.exists());
}
}
LinearLayout mNameLinearLayout = v.findViewById(R.id.properties_dialog_name);
LinearLayout mLocationLinearLayout = v.findViewById(R.id.properties_dialog_location);
LinearLayout mSizeLinearLayout = v.findViewById(R.id.properties_dialog_size);
LinearLayout mDateLinearLayout = v.findViewById(R.id.properties_dialog_date);
// setting click listeners for long press
mNameLinearLayout.setOnLongClickListener(v1 -> {
FileUtils.copyToClipboard(c, name);
Toast.makeText(c, c.getString(R.string.name) + " " + c.getString(R.string.properties_copied_clipboard), Toast.LENGTH_SHORT).show();
return false;
});
mLocationLinearLayout.setOnLongClickListener(v12 -> {
FileUtils.copyToClipboard(c, parent);
Toast.makeText(c, c.getString(R.string.location) + " " + c.getString(R.string.properties_copied_clipboard), Toast.LENGTH_SHORT).show();
return false;
});
mSizeLinearLayout.setOnLongClickListener(v13 -> {
FileUtils.copyToClipboard(c, items);
Toast.makeText(c, c.getString(R.string.size) + " " + c.getString(R.string.properties_copied_clipboard), Toast.LENGTH_SHORT).show();
return false;
});
mDateLinearLayout.setOnLongClickListener(v14 -> {
FileUtils.copyToClipboard(c, date);
Toast.makeText(c, c.getString(R.string.date) + " " + c.getString(R.string.properties_copied_clipboard), Toast.LENGTH_SHORT).show();
return false;
});
}
CountItemsOrAndSizeTask countItemsOrAndSizeTask = new CountItemsOrAndSizeTask(c, itemsText, baseFile, forStorage);
countItemsOrAndSizeTask.executeOnExecutor(executor);
GenerateHashesTask hashGen = new GenerateHashesTask(baseFile, c, v);
hashGen.executeOnExecutor(executor);
/*Chart creation and data loading*/
{
boolean isRightToLeft = c.getResources().getBoolean(R.bool.is_right_to_left);
boolean isDarkTheme = appTheme.getMaterialDialogTheme() == Theme.DARK;
PieChart chart = v.findViewById(R.id.chart);
chart.setTouchEnabled(false);
chart.setDrawEntryLabels(false);
chart.setDescription(null);
chart.setNoDataText(c.getString(R.string.loading));
chart.setRotationAngle(!isRightToLeft ? 0f : 180f);
chart.setHoleColor(Color.TRANSPARENT);
chart.setCenterTextColor(isDarkTheme ? Color.WHITE : Color.BLACK);
chart.getLegend().setEnabled(true);
chart.getLegend().setForm(Legend.LegendForm.CIRCLE);
chart.getLegend().setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
chart.getLegend().setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
chart.getLegend().setTextColor(isDarkTheme ? Color.WHITE : Color.BLACK);
chart.animateY(1000);
if (forStorage) {
final String[] LEGENDS = new String[] { c.getString(R.string.used), c.getString(R.string.free) };
final int[] COLORS = { Utils.getColor(c, R.color.piechart_red), Utils.getColor(c, R.color.piechart_green) };
long totalSpace = baseFile.getTotal(c), freeSpace = baseFile.getUsableSpace(), usedSpace = totalSpace - freeSpace;
List<PieEntry> entries = new ArrayList<>();
entries.add(new PieEntry(usedSpace, LEGENDS[0]));
entries.add(new PieEntry(freeSpace, LEGENDS[1]));
PieDataSet set = new PieDataSet(entries, null);
set.setColors(COLORS);
set.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
set.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
set.setSliceSpace(5f);
set.setAutomaticallyDisableSliceSpacing(true);
set.setValueLinePart2Length(1.05f);
set.setSelectionShift(0f);
PieData pieData = new PieData(set);
pieData.setValueFormatter(new SizeFormatter(c));
pieData.setValueTextColor(isDarkTheme ? Color.WHITE : Color.BLACK);
String totalSpaceFormatted = Formatter.formatFileSize(c, totalSpace);
chart.setCenterText(new SpannableString(c.getString(R.string.total) + "\n" + totalSpaceFormatted));
chart.setData(pieData);
} else {
LoadFolderSpaceDataTask loadFolderSpaceDataTask = new LoadFolderSpaceDataTask(c, appTheme, chart, baseFile);
loadFolderSpaceDataTask.executeOnExecutor(executor);
}
chart.invalidate();
}
if (!forStorage && permissions != null && mainFragment != null) {
AppCompatButton appCompatButton = v.findViewById(R.id.permissionsButton);
appCompatButton.setAllCaps(true);
final View permissionsTable = v.findViewById(R.id.permtable);
final View button = v.findViewById(R.id.set);
if (isRoot && permissions.length() > 6) {
appCompatButton.setVisibility(View.VISIBLE);
appCompatButton.setOnClickListener(v15 -> {
if (permissionsTable.getVisibility() == View.GONE) {
permissionsTable.setVisibility(View.VISIBLE);
button.setVisibility(View.VISIBLE);
setPermissionsDialog(permissionsTable, button, baseFile, permissions, c, mainFragment);
} else {
button.setVisibility(View.GONE);
permissionsTable.setVisibility(View.GONE);
}
});
}
}
builder.customView(v, true);
builder.positiveText(themedActivity.getString(R.string.ok));
builder.positiveColor(accentColor);
builder.dismissListener(dialog -> executor.shutdown());
builder.onPositive((dialog, which) -> {
if (baseFile.isDirectory() && nomediaFile != null) {
if (nomediaCheckBox.isChecked()) {
// checkbox is checked, create .nomedia
try {
if (!nomediaFile.createNewFile()) {
// failed operation
Log.w(TAG, "'.nomedia' file creation in " + baseFile.getPath() + " failed!");
}
} catch (IOException e) {
Log.e(TAG, "Error creating file", e);
}
} else {
// checkbox is unchecked, delete .nomedia
if (!nomediaFile.delete()) {
// failed operation
Log.w(TAG, "'.nomedia' file deletion in " + baseFile.getPath() + " failed!");
}
}
}
});
MaterialDialog materialDialog = builder.build();
materialDialog.show();
materialDialog.getActionButton(DialogAction.NEGATIVE).setEnabled(false);
/*
View bottomSheet = c.findViewById(R.id.design_bottom_sheet);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
bottomSheetBehavior.setPeekHeight(BottomSheetBehavior.STATE_DRAGGING);
*/
}
Aggregations