Search in sources :

Example 11 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project android by nextcloud.

the class SyncFileNotEnoughSpaceDialogFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    AlertDialog alertDialog = (AlertDialog) getDialog();
    if (alertDialog != null) {
        ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE), alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL), alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE));
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog)

Example 12 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project android by nextcloud.

the class SyncedFoldersActivity method showBatteryOptimizationInfo.

private void showBatteryOptimizationInfo() {
    if (powerManagementService.isPowerSavingExclusionAvailable() || checkIfBatteryOptimizationEnabled()) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this, R.style.Theme_ownCloud_Dialog).setTitle(getString(R.string.battery_optimization_title)).setMessage(getString(R.string.battery_optimization_message)).setPositiveButton(getString(R.string.battery_optimization_disable), (dialog, which) -> {
            // show instant upload
            @SuppressLint("BatteryLife") Intent intent = new Intent(ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, Uri.parse("package:" + BuildConfig.APPLICATION_ID));
            if (intent.resolveActivity(getPackageManager()) != null) {
                startActivity(intent);
            }
        }).setNeutralButton(getString(R.string.battery_optimization_close), (dialog, which) -> dialog.dismiss()).setIcon(R.drawable.ic_battery_alert);
        if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
            AlertDialog alertDialog = alertDialogBuilder.show();
            ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE), alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
        }
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) User(com.nextcloud.client.account.User) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) UNPERSISTED_ID(com.owncloud.android.datamodel.SyncedFolderDisplayItem.UNPERSISTED_ID) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) OCFile(com.owncloud.android.datamodel.OCFile) Clock(com.nextcloud.client.core.Clock) SyncedFolderDisplayItem(com.owncloud.android.datamodel.SyncedFolderDisplayItem) PowerManager(android.os.PowerManager) Locale(java.util.Locale) Map(java.util.Map) View(android.view.View) ThemeUtils(com.owncloud.android.utils.theme.ThemeUtils) BuildConfig(com.owncloud.android.BuildConfig) Log(android.util.Log) MediaFolder(com.owncloud.android.datamodel.MediaFolder) MediaFoldersDetectionWork(com.nextcloud.client.jobs.MediaFoldersDetectionWork) SyncedFoldersLayoutBinding(com.owncloud.android.databinding.SyncedFoldersLayoutBinding) NotificationManager(android.app.NotificationManager) AppPreferences(com.nextcloud.client.preferences.AppPreferences) FragmentTransaction(androidx.fragment.app.FragmentTransaction) ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS(android.provider.Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS) List(java.util.List) NotificationWork(com.nextcloud.client.jobs.NotificationWork) MainApp(com.owncloud.android.MainApp) FileUploader(com.owncloud.android.files.services.FileUploader) SyncedFolder(com.owncloud.android.datamodel.SyncedFolder) R(com.owncloud.android.R) ThemeButtonUtils(com.owncloud.android.utils.theme.ThemeButtonUtils) Context(android.content.Context) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) PermissionUtil(com.owncloud.android.utils.PermissionUtil) AlertDialog(androidx.appcompat.app.AlertDialog) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) ArbitraryDataProvider(com.owncloud.android.datamodel.ArbitraryDataProvider) Intent(android.content.Intent) HashMap(java.util.HashMap) MediaFolderType(com.owncloud.android.datamodel.MediaFolderType) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Lifecycle(androidx.lifecycle.Lifecycle) SuppressLint(android.annotation.SuppressLint) SyncedFolderProvider(com.owncloud.android.datamodel.SyncedFolderProvider) MenuInflater(android.view.MenuInflater) Menu(android.view.Menu) PowerManagementService(com.nextcloud.client.device.PowerManagementService) SyncedFolderAdapter(com.owncloud.android.ui.adapter.SyncedFolderAdapter) SyncedFolderUtils(com.owncloud.android.utils.SyncedFolderUtils) MediaGridItemDecoration(com.owncloud.android.ui.decoration.MediaGridItemDecoration) MediaProvider(com.owncloud.android.datamodel.MediaProvider) SyncedFolderParcelable(com.owncloud.android.ui.dialog.parcel.SyncedFolderParcelable) FragmentManager(androidx.fragment.app.FragmentManager) NameCollisionPolicy(com.owncloud.android.files.services.NameCollisionPolicy) Optional(com.nextcloud.java.util.Optional) TextUtils(android.text.TextUtils) File(java.io.File) BackgroundJobManager(com.nextcloud.client.jobs.BackgroundJobManager) Injectable(com.nextcloud.client.di.Injectable) Activity(android.app.Activity) Collections(java.util.Collections) SyncedFolderPreferencesDialogFragment(com.owncloud.android.ui.dialog.SyncedFolderPreferencesDialogFragment) SuppressLint(android.annotation.SuppressLint) Intent(android.content.Intent)

Example 13 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project WordPress-Login-Flow-Android by wordpress-mobile.

the class LoginHttpAuthDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder alert = new MaterialAlertDialogBuilder(getActivity());
    alert.setTitle(R.string.http_authorization_required);
    if (!TextUtils.isEmpty(mMessage))
        alert.setMessage(mMessage);
    // noinspection InflateParams
    View httpAuth = getActivity().getLayoutInflater().inflate(R.layout.login_alert_http_auth, null);
    alert.setView(httpAuth);
    final EditText usernameEditText = (EditText) httpAuth.findViewById(R.id.login_http_username);
    final EditText passwordEditText = (EditText) httpAuth.findViewById(R.id.login_http_password);
    passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            String username = EditTextUtils.getText(usernameEditText);
            String password = EditTextUtils.getText(passwordEditText);
            sendResult(username, password);
            dismiss();
            return true;
        }
    });
    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dismiss();
        }
    });
    alert.setPositiveButton(R.string.next, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String username = EditTextUtils.getText(usernameEditText);
            String password = EditTextUtils.getText(passwordEditText);
            sendResult(username, password);
        }
    });
    final AlertDialog alertDialog = alert.create();
    // update the Next button when username edit box changes
    usernameEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            updateButton(alertDialog, usernameEditText);
        }
    });
    // update the Next button on first appearance
    alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            updateButton(alertDialog, usernameEditText);
        }
    });
    return alertDialog;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) TextView(android.widget.TextView) View(android.view.View) KeyEvent(android.view.KeyEvent) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) NonNull(androidx.annotation.NonNull)

Example 14 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project WordPress-Login-Flow-Android by wordpress-mobile.

the class LoginEmailFragment method showErrorDialog.

private void showErrorDialog(String message) {
    AlertDialog dialog = new MaterialAlertDialogBuilder(getActivity()).setMessage(message).setPositiveButton(R.string.login_error_button, null).create();
    dialog.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 15 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project CustomActivityOnCrash by Ereza.

the class DefaultErrorActivity method onCreate.

@SuppressLint("PrivateResource")
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // This is needed to avoid a crash if the developer has not specified
    // an app-level theme that extends Theme.AppCompat
    TypedArray a = obtainStyledAttributes(R.styleable.AppCompatTheme);
    if (!a.hasValue(R.styleable.AppCompatTheme_windowActionBar)) {
        setTheme(R.style.Theme_AppCompat_Light_DarkActionBar);
    }
    a.recycle();
    setContentView(R.layout.customactivityoncrash_default_error_activity);
    // Close/restart button logic:
    // If a class if set, use restart.
    // Else, use close and just finish the app.
    // It is recommended that you follow this logic if implementing a custom error activity.
    Button restartButton = findViewById(R.id.customactivityoncrash_error_activity_restart_button);
    final CaocConfig config = CustomActivityOnCrash.getConfigFromIntent(getIntent());
    if (config == null) {
        // This should never happen - Just finish the activity to avoid a recursive crash.
        finish();
        return;
    }
    if (config.isShowRestartButton() && config.getRestartActivityClass() != null) {
        restartButton.setText(R.string.customactivityoncrash_error_activity_restart_app);
        restartButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                CustomActivityOnCrash.restartApplication(DefaultErrorActivity.this, config);
            }
        });
    } else {
        restartButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                CustomActivityOnCrash.closeApplication(DefaultErrorActivity.this, config);
            }
        });
    }
    Button moreInfoButton = findViewById(R.id.customactivityoncrash_error_activity_more_info_button);
    if (config.isShowErrorDetails()) {
        moreInfoButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // We retrieve all the error data and show it
                AlertDialog dialog = new AlertDialog.Builder(DefaultErrorActivity.this).setTitle(R.string.customactivityoncrash_error_activity_error_details_title).setMessage(CustomActivityOnCrash.getAllErrorDetailsFromIntent(DefaultErrorActivity.this, getIntent())).setPositiveButton(R.string.customactivityoncrash_error_activity_error_details_close, null).setNeutralButton(R.string.customactivityoncrash_error_activity_error_details_copy, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        copyErrorToClipboard();
                    }
                }).show();
                TextView textView = dialog.findViewById(android.R.id.message);
                if (textView != null) {
                    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.customactivityoncrash_error_activity_error_details_text_size));
                }
            }
        });
    } else {
        moreInfoButton.setVisibility(View.GONE);
    }
    Integer defaultErrorActivityDrawableId = config.getErrorDrawable();
    ImageView errorImageView = findViewById(R.id.customactivityoncrash_error_activity_image);
    if (defaultErrorActivityDrawableId != null) {
        errorImageView.setImageDrawable(ResourcesCompat.getDrawable(getResources(), defaultErrorActivityDrawableId, getTheme()));
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) CaocConfig(cat.ereza.customactivityoncrash.config.CaocConfig) DialogInterface(android.content.DialogInterface) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) SuppressLint(android.annotation.SuppressLint) Button(android.widget.Button) TypedArray(android.content.res.TypedArray) TextView(android.widget.TextView) ImageView(android.widget.ImageView) SuppressLint(android.annotation.SuppressLint)

Aggregations

AlertDialog (androidx.appcompat.app.AlertDialog)261 Test (org.junit.Test)89 View (android.view.View)49 DialogInterface (android.content.DialogInterface)42 TextView (android.widget.TextView)40 Button (android.widget.Button)39 Intent (android.content.Intent)30 ShadowAlertDialogCompat (com.android.settings.testutils.shadow.ShadowAlertDialogCompat)30 NonNull (androidx.annotation.NonNull)28 Context (android.content.Context)26 Bundle (android.os.Bundle)20 EditText (android.widget.EditText)18 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)18 SuppressLint (android.annotation.SuppressLint)17 ArrayList (java.util.ArrayList)17 List (java.util.List)12 Activity (android.app.Activity)11 Uri (android.net.Uri)11 LayoutInflater (android.view.LayoutInflater)11 ListView (android.widget.ListView)10