mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2024-12-16 15:48:13 +08:00
Adding option to delete certificates.
This commit is contained in:
parent
ee0392e208
commit
abdfe8d9d1
@ -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;
|
||||
|
@ -33,7 +33,7 @@
|
||||
layout="@layout/layout_settings_fileview"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/translationDivider"
|
||||
android:id="@+id/certsDivider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginStart="44dp"
|
||||
@ -42,6 +42,20 @@
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_below="@id/fileViewLayout" />
|
||||
|
||||
<include
|
||||
android:id="@+id/certsLayout"
|
||||
layout="@layout/layout_settings_certs" />
|
||||
|
||||
<View
|
||||
android:id="@+id/translationDivider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginStart="44dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_below="@id/certsLayout" />
|
||||
|
||||
<include
|
||||
android:id="@+id/langLayout"
|
||||
layout="@layout/layout_settings_languages" />
|
||||
|
42
app/src/main/res/layout/layout_settings_certs.xml
Normal file
42
app/src/main/res/layout/layout_settings_certs.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/layoutSettingsCerts"
|
||||
android:orientation="vertical"
|
||||
android:layout_below="@+id/certsDivider"
|
||||
android:background="?attr/primaryBackgroundColor">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCert"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableStart="@drawable/ic_lock_open"
|
||||
android:drawablePadding="20dp"
|
||||
android:text="@string/settingsCertsHeader"
|
||||
android:textColor="@color/colorDarkGreen"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/certsFrame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCertHeader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="44dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:text="@string/settingsCertsSelectorHeader"
|
||||
android:textColor="?attr/primaryTextColor"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -246,6 +246,8 @@
|
||||
|
||||
<!-- settings -->
|
||||
<string name="settingsLanguageHeaderText">Translation</string>
|
||||
<string name="settingsCertsHeader">Certs</string>
|
||||
<string name="settingsCertsSelectorHeader">Delete certificates</string>
|
||||
<string name="settingsDateTimeHeaderText">Date & Time</string>
|
||||
<string name="settingsSave">Settings saved</string>
|
||||
<string name="settingsLanguageSelectorHeader">Language</string>
|
||||
|
Loading…
Reference in New Issue
Block a user