mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2023-12-13 20:50:18 +01:00
Port accept cert dialog to M3 (#1184)
Actually it is working, just need to restart the app. So closing #1119 and also porting the Alert dialogs for accepting the certificates and remove account to M3. Co-authored-by: M M Arif <mmarif@swatian.com> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1184
This commit is contained in:
parent
e4cd1e147b
commit
6326f5eba5
|
@ -2,7 +2,6 @@ package org.mian.gitnex.activities;
|
||||||
|
|
||||||
import android.app.KeyguardManager;
|
import android.app.KeyguardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -82,61 +81,53 @@ public class SettingsSecurityActivity extends BaseActivity {
|
||||||
// biometric switcher
|
// biometric switcher
|
||||||
switchBiometric.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
switchBiometric.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if(isChecked) {
|
||||||
|
|
||||||
if(isChecked) {
|
BiometricManager biometricManager = BiometricManager.from(ctx);
|
||||||
|
KeyguardManager keyguardManager = (KeyguardManager) ctx.getSystemService(Context.KEYGUARD_SERVICE);
|
||||||
|
|
||||||
BiometricManager biometricManager = BiometricManager.from(ctx);
|
if (!keyguardManager.isDeviceSecure()) {
|
||||||
KeyguardManager keyguardManager = (KeyguardManager) ctx.getSystemService(Context.KEYGUARD_SERVICE);
|
|
||||||
|
|
||||||
if (!keyguardManager.isDeviceSecure()) {
|
switch(biometricManager.canAuthenticate(BIOMETRIC_STRONG | DEVICE_CREDENTIAL)) {
|
||||||
|
|
||||||
switch(biometricManager.canAuthenticate(BIOMETRIC_STRONG | DEVICE_CREDENTIAL)) {
|
case BiometricManager.BIOMETRIC_SUCCESS:
|
||||||
|
|
||||||
case BiometricManager.BIOMETRIC_SUCCESS:
|
tinyDB.putBoolean("biometricStatus", true);
|
||||||
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
|
break;
|
||||||
|
case BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE:
|
||||||
|
case BiometricManager.BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED:
|
||||||
|
case BiometricManager.BIOMETRIC_ERROR_UNSUPPORTED:
|
||||||
|
case BiometricManager.BIOMETRIC_STATUS_UNKNOWN:
|
||||||
|
|
||||||
tinyDB.putBoolean("biometricStatus", true);
|
tinyDB.putBoolean("biometricStatus", false);
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
switchBiometric.setChecked(false);
|
||||||
break;
|
Toasty.error(appCtx, getResources().getString(R.string.biometricNotSupported));
|
||||||
case BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE:
|
break;
|
||||||
case BiometricManager.BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED:
|
case BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE:
|
||||||
case BiometricManager.BIOMETRIC_ERROR_UNSUPPORTED:
|
|
||||||
case BiometricManager.BIOMETRIC_STATUS_UNKNOWN:
|
|
||||||
|
|
||||||
tinyDB.putBoolean("biometricStatus", false);
|
tinyDB.putBoolean("biometricStatus", false);
|
||||||
switchBiometric.setChecked(false);
|
switchBiometric.setChecked(false);
|
||||||
Toasty.error(appCtx, getResources().getString(R.string.biometricNotSupported));
|
Toasty.error(appCtx, getResources().getString(R.string.biometricNotAvailable));
|
||||||
break;
|
break;
|
||||||
case BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE:
|
case BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED:
|
||||||
|
|
||||||
tinyDB.putBoolean("biometricStatus", false);
|
tinyDB.putBoolean("biometricStatus", false);
|
||||||
switchBiometric.setChecked(false);
|
switchBiometric.setChecked(false);
|
||||||
Toasty.error(appCtx, getResources().getString(R.string.biometricNotAvailable));
|
Toasty.info(appCtx, getResources().getString(R.string.enrollBiometric));
|
||||||
break;
|
break;
|
||||||
case BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED:
|
|
||||||
|
|
||||||
tinyDB.putBoolean("biometricStatus", false);
|
|
||||||
switchBiometric.setChecked(false);
|
|
||||||
Toasty.info(appCtx, getResources().getString(R.string.enrollBiometric));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
tinyDB.putBoolean("biometricStatus", true);
|
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
tinyDB.putBoolean("biometricStatus", false);
|
tinyDB.putBoolean("biometricStatus", true);
|
||||||
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
tinyDB.putBoolean("biometricStatus", false);
|
tinyDB.putBoolean("biometricStatus", false);
|
||||||
Toasty.warning(appCtx, getResources().getString(R.string.biometricNotSupported));
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,9 +12,8 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
import org.gitnex.tea4j.v2.models.NotificationCount;
|
import org.gitnex.tea4j.v2.models.NotificationCount;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.AddNewAccountActivity;
|
import org.mian.gitnex.activities.AddNewAccountActivity;
|
||||||
|
@ -66,18 +65,19 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
||||||
|
|
||||||
deleteAccount.setOnClickListener(itemDelete -> {
|
deleteAccount.setOnClickListener(itemDelete -> {
|
||||||
|
|
||||||
new AlertDialog.Builder(context)
|
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context)
|
||||||
.setIcon(AppCompatResources.getDrawable(context, R.drawable.ic_delete))
|
|
||||||
.setTitle(context.getResources().getString(R.string.removeAccountPopupTitle))
|
.setTitle(context.getResources().getString(R.string.removeAccountPopupTitle))
|
||||||
.setMessage(context.getResources().getString(R.string.removeAccountPopupMessage))
|
.setMessage(context.getResources().getString(R.string.removeAccountPopupMessage))
|
||||||
|
.setNeutralButton(context.getResources().getString(R.string.cancelButton), null)
|
||||||
.setPositiveButton(context.getResources().getString(R.string.removeButton), (dialog, which) -> {
|
.setPositiveButton(context.getResources().getString(R.string.removeButton), (dialog, which) -> {
|
||||||
|
|
||||||
updateLayoutByPosition(getBindingAdapterPosition());
|
updateLayoutByPosition(getBindingAdapterPosition());
|
||||||
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
|
||||||
assert userAccountsApi != null;
|
assert userAccountsApi != null;
|
||||||
userAccountsApi.deleteAccount(Integer.parseInt(String.valueOf(accountId)));
|
userAccountsApi.deleteAccount(Integer.parseInt(String.valueOf(accountId)));
|
||||||
}).setNeutralButton(context.getResources().getString(R.string.cancelButton), null)
|
});
|
||||||
.show();
|
|
||||||
|
materialAlertDialogBuilder.create().show();
|
||||||
});
|
});
|
||||||
|
|
||||||
itemView.setOnClickListener(switchAccount -> {
|
itemView.setOnClickListener(switchAccount -> {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.mian.gitnex.helpers.ssl;
|
package org.mian.gitnex.helpers.ssl;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
@ -10,6 +9,7 @@ import android.content.SharedPreferences;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.activities.BaseActivity;
|
import org.mian.gitnex.activities.BaseActivity;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
@ -562,15 +562,15 @@ public class MemorizingTrustManager implements X509TrustManager {
|
||||||
final int myId = createDecisionId(choice);
|
final int myId = createDecisionId(choice);
|
||||||
|
|
||||||
((BaseActivity) context).runOnUiThread(() -> {
|
((BaseActivity) context).runOnUiThread(() -> {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
||||||
builder.setTitle(titleId);
|
|
||||||
builder.setMessage(message);
|
|
||||||
|
|
||||||
builder.setPositiveButton(R.string.mtmDecisionAlways, (dialog, which) -> interactResult(myId, MTMDecision.DECISION_ALWAYS));
|
MaterialAlertDialogBuilder materialAlertDialogBuilder = new MaterialAlertDialogBuilder(context)
|
||||||
builder.setNeutralButton(R.string.mtmDecisionAbort, (dialog, which) -> interactResult(myId, MTMDecision.DECISION_ABORT));
|
.setTitle(titleId)
|
||||||
builder.setOnCancelListener(dialog -> interactResult(myId, MTMDecision.DECISION_ABORT));
|
.setMessage(message)
|
||||||
|
.setPositiveButton(R.string.mtmDecisionAlways, (dialog, which) -> interactResult(myId, MTMDecision.DECISION_ALWAYS))
|
||||||
|
.setNeutralButton(R.string.mtmDecisionAbort, (dialog, which) -> interactResult(myId, MTMDecision.DECISION_ABORT))
|
||||||
|
.setOnCancelListener(dialog -> interactResult(myId, MTMDecision.DECISION_ABORT));
|
||||||
|
|
||||||
builder.create().show();
|
materialAlertDialogBuilder.create().show();
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue