Search in sources :

Example 61 with ContextThemeWrapper

use of android.support.v7.view.ContextThemeWrapper in project fdroidclient by f-droid.

the class ErrorDialogActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Intent intent = getIntent();
    final String title = intent.getStringExtra(EXTRA_TITLE);
    final String message = intent.getStringExtra(EXTRA_MESSAGE);
    // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());
    final AlertDialog.Builder builder = new AlertDialog.Builder(theme);
    builder.setTitle(title);
    builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            setResult(Activity.RESULT_OK);
            finish();
        }
    });
    builder.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            setResult(Activity.RESULT_CANCELED);
            finish();
        }
    });
    builder.setMessage(message);
    builder.create().show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ContextThemeWrapper(android.view.ContextThemeWrapper) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent)

Example 62 with ContextThemeWrapper

use of android.support.v7.view.ContextThemeWrapper in project fdroidclient by f-droid.

the class FileInstallerActivity method showDialog.

private void showDialog() {
    // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());
    final AlertDialog.Builder builder = new AlertDialog.Builder(theme);
    builder.setMessage(R.string.app_permission_storage).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            ActivityCompat.requestPermissions(activity, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, MY_PERMISSIONS_REQUEST_STORAGE);
        }
    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            if (act == 1) {
                installer.sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_INTERRUPTED);
            } else if (act == 2) {
                installer.sendBroadcastUninstall(Installer.ACTION_UNINSTALL_INTERRUPTED);
            }
            finish();
        }
    }).create().show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ContextThemeWrapper(android.view.ContextThemeWrapper) DialogInterface(android.content.DialogInterface)

Example 63 with ContextThemeWrapper

use of android.support.v7.view.ContextThemeWrapper in project fdroidclient by f-droid.

the class UninstallDialogActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Intent intent = getIntent();
    final Apk apk = intent.getParcelableExtra(Installer.EXTRA_APK);
    PackageManager pm = getPackageManager();
    ApplicationInfo appInfo;
    try {
        // noinspection WrongConstant (lint is actually wrong here!)
        appInfo = pm.getApplicationInfo(apk.packageName, PackageManager.GET_UNINSTALLED_PACKAGES);
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException("Failed to get ApplicationInfo for uninstalling");
    }
    final boolean isSystem = (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
    final boolean isUpdate = (appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
    if (isSystem && !isUpdate) {
        // Cannot remove system apps unless we're uninstalling updates
        throw new RuntimeException("Cannot remove system apps unless we're uninstalling updates");
    }
    int messageId;
    if (isUpdate) {
        messageId = R.string.uninstall_update_confirm;
    } else {
        messageId = R.string.uninstall_confirm;
    }
    // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());
    final AlertDialog.Builder builder = new AlertDialog.Builder(theme);
    builder.setTitle(appInfo.loadLabel(pm));
    builder.setIcon(appInfo.loadIcon(pm));
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent data = new Intent();
            data.putExtra(Installer.EXTRA_APK, apk);
            setResult(Activity.RESULT_OK, intent);
            finish();
        }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            setResult(Activity.RESULT_CANCELED);
            finish();
        }
    });
    builder.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            setResult(Activity.RESULT_CANCELED);
            finish();
        }
    });
    builder.setMessage(messageId);
    builder.create().show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ApplicationInfo(android.content.pm.ApplicationInfo) Intent(android.content.Intent) PackageManager(android.content.pm.PackageManager) ContextThemeWrapper(android.view.ContextThemeWrapper) Apk(org.fdroid.fdroid.data.Apk)

Example 64 with ContextThemeWrapper

use of android.support.v7.view.ContextThemeWrapper in project fdroidclient by f-droid.

the class InstallExtensionDialogActivity method uninstall.

private void uninstall() {
    // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());
    final boolean isInstalled = PrivilegedInstaller.isExtensionInstalled(this);
    if (isInstalled) {
        String message = InstallExtension.create(getApplicationContext()).getWarningString();
        AlertDialog.Builder builder = new AlertDialog.Builder(theme).setTitle(R.string.system_uninstall).setMessage(Html.fromHtml(message)).setPositiveButton(R.string.system_uninstall_button, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                checkRootTask.execute();
            }
        }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                InstallExtensionDialogActivity.this.setResult(Activity.RESULT_CANCELED);
                InstallExtensionDialogActivity.this.finish();
            }
        });
        builder.create().show();
    } else {
        throw new RuntimeException("Uninstall invoked, but extension is not installed!");
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ContextThemeWrapper(android.view.ContextThemeWrapper) DialogInterface(android.content.DialogInterface)

Example 65 with ContextThemeWrapper

use of android.support.v7.view.ContextThemeWrapper in project WordPress-Login-Flow-Android by wordpress-mobile.

the class SignupEmailFragment method showErrorDialog.

protected void showErrorDialog(String message) {
    AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme)).setMessage(message).setPositiveButton(R.string.login_error_button, null).create();
    dialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ContextThemeWrapper(android.view.ContextThemeWrapper)

Aggregations

View (android.view.View)41 ContextThemeWrapper (android.support.v7.view.ContextThemeWrapper)38 ContextThemeWrapper (android.view.ContextThemeWrapper)35 DialogInterface (android.content.DialogInterface)26 Context (android.content.Context)25 AlertDialog (android.support.v7.app.AlertDialog)24 TextView (android.widget.TextView)23 RecyclerView (android.support.v7.widget.RecyclerView)21 ImageView (android.widget.ImageView)21 LayoutInflater (android.view.LayoutInflater)18 Intent (android.content.Intent)13 Nullable (android.support.annotation.Nullable)10 ColorPreferences (me.ccrama.redditslide.ColorPreferences)10 Drawable (android.graphics.drawable.Drawable)9 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9 EditText (android.widget.EditText)9 Bundle (android.os.Bundle)7 NonNull (android.support.annotation.NonNull)7 ArrayList (java.util.ArrayList)7 SuppressLint (android.annotation.SuppressLint)6