Search in sources :

Example 1 with AppCompatButton

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();
        }
    });
}
Also used : View(android.view.View) AppCompatButton(androidx.appcompat.widget.AppCompatButton)

Example 2 with AppCompatButton

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;
}
Also used : Context(android.content.Context) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) URLSpan(android.text.style.URLSpan) SpannableStringBuilder(android.text.SpannableStringBuilder) AppCompatButton(androidx.appcompat.widget.AppCompatButton)

Example 3 with AppCompatButton

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();
    });
}
Also used : SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) CommentOverflow(me.ccrama.redditslide.Views.CommentOverflow) TitleTextView(me.ccrama.redditslide.Views.TitleTextView) AppCompatButton(androidx.appcompat.widget.AppCompatButton)

Example 4 with AppCompatButton

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());
}
Also used : AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) EditText(android.widget.EditText) Context(android.content.Context) KITKAT(android.os.Build.VERSION_CODES.KITKAT) JELLY_BEAN(android.os.Build.VERSION_CODES.JELLY_BEAN) P(android.os.Build.VERSION_CODES.P) Robolectric(org.robolectric.Robolectric) RunWith(org.junit.runner.RunWith) Config(org.robolectric.annotation.Config) Assert.assertTrue(org.junit.Assert.assertTrue) AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) Test(org.junit.Test) AppCompatButton(androidx.appcompat.widget.AppCompatButton) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) ApplicationProvider(androidx.test.core.app.ApplicationProvider) Assert.assertNull(org.junit.Assert.assertNull) Assert.assertFalse(org.junit.Assert.assertFalse) Button(android.widget.Button) R(com.amaze.filemanager.R) Assert.assertEquals(org.junit.Assert.assertEquals) EditText(android.widget.EditText) Before(org.junit.Before) AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) AppCompatButton(androidx.appcompat.widget.AppCompatButton) Button(android.widget.Button) AppCompatButton(androidx.appcompat.widget.AppCompatButton) Test(org.junit.Test)

Example 5 with AppCompatButton

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);
    */
}
Also used : RequiresApi(androidx.annotation.RequiresApi) LinearLayout(android.widget.LinearLayout) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) MainFragment(com.amaze.filemanager.ui.fragments.MainFragment) FileProperties(com.amaze.filemanager.filesystem.FileProperties) MainActivity(com.amaze.filemanager.ui.activities.MainActivity) SortHandler(com.amaze.filemanager.database.SortHandler) MDButton(com.afollestad.materialdialogs.internal.MDButton) CompressedHelper(com.amaze.filemanager.filesystem.compressed.CompressedHelper) GeneralSecurityException(java.security.GeneralSecurityException) RootHelper(com.amaze.filemanager.filesystem.RootHelper) CheckBox(android.widget.CheckBox) View(android.view.View) Button(android.widget.Button) DialogSigninWithGoogleBinding(com.amaze.filemanager.databinding.DialogSigninWithGoogleBinding) PieChart(com.github.mikephil.charting.charts.PieChart) Log(android.util.Log) PieData(com.github.mikephil.charting.data.PieData) LoadFolderSpaceDataTask(com.amaze.filemanager.asynchronous.asynctasks.LoadFolderSpaceDataTask) M(android.os.Build.VERSION_CODES.M) LayoutElementParcelable(com.amaze.filemanager.adapters.data.LayoutElementParcelable) AsyncTask(android.os.AsyncTask) Entry(com.github.mikephil.charting.data.Entry) Set(java.util.Set) InputType(android.text.InputType) ExtensionsKt(com.amaze.filemanager.ui.ExtensionsKt) FingerprintManager(android.hardware.fingerprint.FingerprintManager) FileUtils(com.amaze.filemanager.filesystem.files.FileUtils) AppCompatButton(androidx.appcompat.widget.AppCompatButton) Executors(java.util.concurrent.Executors) EncryptDecryptUtils(com.amaze.filemanager.filesystem.files.EncryptDecryptUtils) Objects(java.util.Objects) FileUtils.toHybridFileArrayList(com.amaze.filemanager.filesystem.files.FileUtils.toHybridFileArrayList) List(java.util.List) StringRes(androidx.annotation.StringRes) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) HiddenAdapter(com.amaze.filemanager.adapters.HiddenAdapter) PREFERENCE_SORTBY_ONLY_THIS(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_SORTBY_ONLY_THIS) R(com.amaze.filemanager.R) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) CountItemsOrAndSizeTask(com.amaze.filemanager.asynchronous.asynctasks.CountItemsOrAndSizeTask) AppTheme(com.amaze.filemanager.ui.theme.AppTheme) AppConfig(com.amaze.filemanager.application.AppConfig) SimpleTextWatcher(com.amaze.filemanager.utils.SimpleTextWatcher) Legend(com.github.mikephil.charting.components.Legend) TextWatcher(android.text.TextWatcher) Typeface(android.graphics.Typeface) Context(android.content.Context) TextInputEditText(com.google.android.material.textfield.TextInputEditText) IValueFormatter(com.github.mikephil.charting.formatter.IValueFormatter) HybridFile(com.amaze.filemanager.filesystem.HybridFile) FingerprintHandler(com.amaze.filemanager.utils.FingerprintHandler) Intent(android.content.Intent) OpenMode(com.amaze.filemanager.file_operations.filesystem.OpenMode) Sort(com.amaze.filemanager.database.models.explorer.Sort) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) WarnableTextInputLayout(com.amaze.filemanager.ui.views.WarnableTextInputLayout) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) PieDataSet(com.github.mikephil.charting.data.PieDataSet) ShellNotRunningException(com.amaze.filemanager.file_operations.exceptions.ShellNotRunningException) PreferencesConstants(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants) DataUtils(com.amaze.filemanager.utils.DataUtils) Toast(android.widget.Toast) Build(android.os.Build) ExecutorService(java.util.concurrent.ExecutorService) Formatter(android.text.format.Formatter) GenerateHashesTask(com.amaze.filemanager.asynchronous.asynctasks.GenerateHashesTask) SpannableString(android.text.SpannableString) LayoutInflater(android.view.LayoutInflater) IOException(java.io.IOException) DialogAction(com.afollestad.materialdialogs.DialogAction) TextUtils(android.text.TextUtils) ChangeFilePermissionsCommand(com.amaze.filemanager.filesystem.root.ChangeFilePermissionsCommand) WarnableTextInputValidator(com.amaze.filemanager.ui.views.WarnableTextInputValidator) File(java.io.File) Theme(com.afollestad.materialdialogs.Theme) Color(android.graphics.Color) Utils(com.amaze.filemanager.utils.Utils) SharedPreferences(android.content.SharedPreferences) CryptUtil(com.amaze.filemanager.filesystem.files.CryptUtil) ViewPortHandler(com.github.mikephil.charting.utils.ViewPortHandler) EncryptService(com.amaze.filemanager.asynchronous.services.EncryptService) ThemedActivity(com.amaze.filemanager.ui.activities.superclasses.ThemedActivity) PreferenceManager(androidx.preference.PreferenceManager) PieEntry(com.github.mikephil.charting.data.PieEntry) Collections(java.util.Collections) EditText(android.widget.EditText) PieEntry(com.github.mikephil.charting.data.PieEntry) SpannableString(android.text.SpannableString) PieChart(com.github.mikephil.charting.charts.PieChart) PieDataSet(com.github.mikephil.charting.data.PieDataSet) TextView(android.widget.TextView) FileUtils.toHybridFileArrayList(com.amaze.filemanager.filesystem.files.FileUtils.toHybridFileArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Context(android.content.Context) GenerateHashesTask(com.amaze.filemanager.asynchronous.asynctasks.GenerateHashesTask) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) IOException(java.io.IOException) View(android.view.View) TextView(android.widget.TextView) CountItemsOrAndSizeTask(com.amaze.filemanager.asynchronous.asynctasks.CountItemsOrAndSizeTask) AppCompatButton(androidx.appcompat.widget.AppCompatButton) SpannableString(android.text.SpannableString) LoadFolderSpaceDataTask(com.amaze.filemanager.asynchronous.asynctasks.LoadFolderSpaceDataTask) CheckBox(android.widget.CheckBox) ExecutorService(java.util.concurrent.ExecutorService) PieData(com.github.mikephil.charting.data.PieData) HybridFile(com.amaze.filemanager.filesystem.HybridFile) File(java.io.File) LinearLayout(android.widget.LinearLayout)

Aggregations

AppCompatButton (androidx.appcompat.widget.AppCompatButton)7 Context (android.content.Context)4 View (android.view.View)4 Uri (android.net.Uri)2 LayoutInflater (android.view.LayoutInflater)2 Button (android.widget.Button)2 EditText (android.widget.EditText)2 TextView (android.widget.TextView)2 Nullable (androidx.annotation.Nullable)2 R (com.amaze.filemanager.R)2 Account (android.accounts.Account)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 DataSetObserver (android.database.DataSetObserver)1 Bitmap (android.graphics.Bitmap)1 Color (android.graphics.Color)1 Typeface (android.graphics.Typeface)1 FingerprintManager (android.hardware.fingerprint.FingerprintManager)1 AsyncTask (android.os.AsyncTask)1