use of android.support.v7.view.ContextThemeWrapper in project MTweaks-KernelAdiutorMOD by morogoku.
the class SecurityActivity method loadFingerprint.
private void loadFingerprint() {
try {
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
KeyGenerator keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");
mCipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7);
keyStore.load(null);
keyGenerator.init(new KeyGenParameterSpec.Builder(KEY_NAME, KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT).setBlockModes(KeyProperties.BLOCK_MODE_CBC).setUserAuthenticationRequired(true).setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7).build());
keyGenerator.generateKey();
SecretKey key = (SecretKey) keyStore.getKey(KEY_NAME, null);
mCipher.init(Cipher.ENCRYPT_MODE, key);
} catch (KeyStoreException | NoSuchProviderException | NoSuchAlgorithmException | NoSuchPaddingException | UnrecoverableKeyException | InvalidKeyException | CertificateException | InvalidAlgorithmParameterException | IOException e) {
return;
}
mCryptoObject = new FingerprintManagerCompat.CryptoObject(mCipher);
FrameLayout fingerprintParent = (FrameLayout) findViewById(R.id.fingerprint_parent);
final SwirlView swirlView = new SwirlView(new ContextThemeWrapper(this, R.style.Swirl));
swirlView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
fingerprintParent.addView(swirlView);
fingerprintParent.setVisibility(View.VISIBLE);
mFingerprintUiHelper = new FingerprintUiHelper.FingerprintUiHelperBuilder(mFingerprintManagerCompat).build(swirlView, new FingerprintUiHelper.Callback() {
@Override
public void onAuthenticated() {
try {
mCipher.doFinal(SECRET_MESSAGE.getBytes());
mPasswordWrong.setVisibility(View.GONE);
setResult(1);
finish();
} catch (IllegalBlockSizeException | BadPaddingException e) {
e.printStackTrace();
swirlView.setState(SwirlView.State.ERROR);
}
}
@Override
public void onError() {
}
});
mFingerprintUiHelper.startListening(mCryptoObject);
}
use of android.support.v7.view.ContextThemeWrapper in project fdroidclient by f-droid.
the class InstallExtensionDialogActivity method askBeforeInstall.
private void askBeforeInstall() {
// hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());
// not support on Android >= 5.1
if (android.os.Build.VERSION.SDK_INT >= 22) {
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(theme);
alertBuilder.setMessage(R.string.system_install_not_supported);
alertBuilder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
InstallExtensionDialogActivity.this.setResult(Activity.RESULT_CANCELED);
InstallExtensionDialogActivity.this.finish();
}
});
alertBuilder.create().show();
return;
}
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(theme);
alertBuilder.setTitle(R.string.system_install_question);
String message = InstallExtension.create(getApplicationContext()).getWarningString();
alertBuilder.setMessage(Html.fromHtml(message));
alertBuilder.setPositiveButton(R.string.system_install_button_install, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
checkRootTask.execute();
}
});
alertBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
InstallExtensionDialogActivity.this.setResult(Activity.RESULT_CANCELED);
InstallExtensionDialogActivity.this.finish();
}
});
alertBuilder.create().show();
}
use of android.support.v7.view.ContextThemeWrapper in project fdroidclient by f-droid.
the class InstallExtensionDialogActivity method postInstall.
/**
* 3. Verify that install worked
*/
private void postInstall() {
int isInstalledCorrectly = PrivilegedInstaller.isExtensionInstalledCorrectly(this);
String title;
String message;
final int result;
switch(isInstalledCorrectly) {
case PrivilegedInstaller.IS_EXTENSION_INSTALLED_YES:
title = getString(R.string.system_install_post_success);
message = getString(R.string.system_install_post_success_message);
result = Activity.RESULT_OK;
break;
case PrivilegedInstaller.IS_EXTENSION_INSTALLED_NO:
title = getString(R.string.system_install_post_fail);
message = getString(R.string.system_install_post_fail_message);
result = Activity.RESULT_CANCELED;
break;
case PrivilegedInstaller.IS_EXTENSION_INSTALLED_SIGNATURE_PROBLEM:
title = getString(R.string.system_install_post_fail);
message = getString(R.string.system_install_post_fail_message) + "\n\n" + getString(R.string.system_install_denied_signature);
result = Activity.RESULT_CANCELED;
break;
default:
throw new RuntimeException("unhandled return");
}
// hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());
AlertDialog.Builder builder = new AlertDialog.Builder(theme).setTitle(title).setMessage(message).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
InstallExtensionDialogActivity.this.setResult(result);
InstallExtensionDialogActivity.this.finish();
startActivity(new Intent(InstallExtensionDialogActivity.this, MainActivity.class));
}
}).setCancelable(false);
builder.create().show();
}
use of android.support.v7.view.ContextThemeWrapper in project xDrip-plus by jamorham.
the class JoH method show_ok_dialog.
public static void show_ok_dialog(final Activity activity, String title, String message, final Runnable runnable) {
try {
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.AppTheme));
builder.setTitle(title);
builder.setMessage(message);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
try {
dialog.dismiss();
} catch (Exception e) {
//
}
if (runnable != null) {
runOnUiThreadDelayed(runnable, 10);
}
}
});
builder.create().show();
} catch (Exception e) {
Log.wtf(TAG, "show_dialog exception: " + e);
static_toast_long(message);
}
}
use of android.support.v7.view.ContextThemeWrapper in project openhab-android by openhab.
the class WidgetAdapterTest method testColorMappingDarkTheme.
@Test
public void testColorMappingDarkTheme() {
ColorMapper colorMapper = new ColorMapper(new ContextThemeWrapper(context, R.style.HABDroid_Basic_ui_dark));
assertEquals("Map #ffffff", Integer.valueOf(0xffffffff), colorMapper.mapColor("#ffffff"));
assertEquals("Must return \"null\" for invalid colors", null, colorMapper.mapColor("#fffzzz"));
assertEquals("Map white => #ffffff in dark themes", Integer.valueOf(0xffffffff), colorMapper.mapColor("white"));
assertEquals("Map red => #ff0000 in dark themes", Integer.valueOf(0xffff0000), colorMapper.mapColor("red"));
assertEquals("Map yellow => #ffff00 in dark themes", Integer.valueOf(0xffffff00), colorMapper.mapColor("yellow"));
}
Aggregations