Adding option to delete certificates.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.mian.gitnex.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -101,7 +102,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
||||
|
||||
if(!tinyDb.getBoolean("loggedInMode")) {
|
||||
logout();
|
||||
logout(this, ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -354,7 +355,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
new SettingsFragment()).commit();
|
||||
break;
|
||||
case R.id.nav_logout:
|
||||
logout();
|
||||
logout(this, ctx);
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
break;
|
||||
case R.id.nav_about:
|
||||
@@ -392,15 +393,15 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
}
|
||||
}
|
||||
|
||||
public void logout() {
|
||||
public static void logout(Activity activity, Context ctx) {
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
TinyDB tinyDb = new TinyDB(ctx.getApplicationContext());
|
||||
tinyDb.putBoolean("loggedInMode", false);
|
||||
tinyDb.remove("basicAuthPassword");
|
||||
tinyDb.putBoolean("basicAuthFlag", false);
|
||||
//tinyDb.clear();
|
||||
finish();
|
||||
startActivity(new Intent(MainActivity.this, LoginActivity.class));
|
||||
activity.finish();
|
||||
ctx.startActivity(new Intent(ctx, LoginActivity.class));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,9 @@ import android.widget.LinearLayout;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.Objects;
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -67,6 +69,7 @@ public class SettingsFragment extends Fragment {
|
||||
LinearLayout homeScreenFrame = v.findViewById(R.id.homeScreenFrame);
|
||||
LinearLayout customFontFrame = v.findViewById(R.id.customFontFrame);
|
||||
LinearLayout themeFrame = v.findViewById(R.id.themeSelectionFrame);
|
||||
LinearLayout certsFrame = v.findViewById(R.id.certsFrame);
|
||||
|
||||
Switch issuesSwitch = v.findViewById(R.id.switchIssuesBadge);
|
||||
Switch pdfModeSwitch = v.findViewById(R.id.switchPdfMode);
|
||||
@@ -144,6 +147,32 @@ public class SettingsFragment extends Fragment {
|
||||
pdfModeSwitch.setChecked(false);
|
||||
}
|
||||
|
||||
// certs deletion
|
||||
certsFrame.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
||||
builder.setTitle("Delete trusted certificates?");
|
||||
builder.setMessage("Are you really sure to delete any manually trusted certificate?\n\nNotice: Your will be logged out too.");
|
||||
builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ctx.getSharedPreferences(MemorizingTrustManager.KEYSTORE_NAME, Context.MODE_PRIVATE)
|
||||
.edit()
|
||||
.remove(MemorizingTrustManager.KEYSTORE_KEY)
|
||||
.apply();
|
||||
|
||||
MainActivity.logout(Objects.requireNonNull(getActivity()), ctx);
|
||||
}
|
||||
});
|
||||
|
||||
builder.setNeutralButton("NO", (dialog, which) -> dialog.dismiss());
|
||||
builder.create().show();
|
||||
}
|
||||
});
|
||||
|
||||
// issues badge switcher
|
||||
issuesSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
|
||||
@@ -45,8 +45,8 @@ import javax.net.ssl.X509TrustManager;
|
||||
public class MemorizingTrustManager implements X509TrustManager {
|
||||
private final static int NOTIFICATION_ID = 100509;
|
||||
|
||||
private final static String KEYSTORE_NAME = "keystore";
|
||||
private final static String KEYSTORE_KEY = "keystore";
|
||||
public final static String KEYSTORE_NAME = "keystore";
|
||||
public final static String KEYSTORE_KEY = "keystore";
|
||||
|
||||
private Context context;
|
||||
private NotificationManager notificationManager;
|
||||
|
||||
Reference in New Issue
Block a user