mirror of https://codeberg.org/gitnex/GitNex.git
Adding option to delete certificates.
This commit is contained in:
parent
ee0392e208
commit
abdfe8d9d1
|
@ -1,5 +1,6 @@
|
||||||
package org.mian.gitnex.activities;
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -101,7 +102,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||||
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
||||||
|
|
||||||
if(!tinyDb.getBoolean("loggedInMode")) {
|
if(!tinyDb.getBoolean("loggedInMode")) {
|
||||||
logout();
|
logout(this, ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +355,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||||
new SettingsFragment()).commit();
|
new SettingsFragment()).commit();
|
||||||
break;
|
break;
|
||||||
case R.id.nav_logout:
|
case R.id.nav_logout:
|
||||||
logout();
|
logout(this, ctx);
|
||||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||||
break;
|
break;
|
||||||
case R.id.nav_about:
|
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.putBoolean("loggedInMode", false);
|
||||||
tinyDb.remove("basicAuthPassword");
|
tinyDb.remove("basicAuthPassword");
|
||||||
tinyDb.putBoolean("basicAuthFlag", false);
|
tinyDb.putBoolean("basicAuthFlag", false);
|
||||||
//tinyDb.clear();
|
//tinyDb.clear();
|
||||||
finish();
|
activity.finish();
|
||||||
startActivity(new Intent(MainActivity.this, LoginActivity.class));
|
ctx.startActivity(new Intent(ctx, LoginActivity.class));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,9 @@ import android.widget.LinearLayout;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.activities.MainActivity;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.mian.gitnex.helpers.ssl.MemorizingTrustManager;
|
||||||
import org.mian.gitnex.util.TinyDB;
|
import org.mian.gitnex.util.TinyDB;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -67,6 +69,7 @@ public class SettingsFragment extends Fragment {
|
||||||
LinearLayout homeScreenFrame = v.findViewById(R.id.homeScreenFrame);
|
LinearLayout homeScreenFrame = v.findViewById(R.id.homeScreenFrame);
|
||||||
LinearLayout customFontFrame = v.findViewById(R.id.customFontFrame);
|
LinearLayout customFontFrame = v.findViewById(R.id.customFontFrame);
|
||||||
LinearLayout themeFrame = v.findViewById(R.id.themeSelectionFrame);
|
LinearLayout themeFrame = v.findViewById(R.id.themeSelectionFrame);
|
||||||
|
LinearLayout certsFrame = v.findViewById(R.id.certsFrame);
|
||||||
|
|
||||||
Switch issuesSwitch = v.findViewById(R.id.switchIssuesBadge);
|
Switch issuesSwitch = v.findViewById(R.id.switchIssuesBadge);
|
||||||
Switch pdfModeSwitch = v.findViewById(R.id.switchPdfMode);
|
Switch pdfModeSwitch = v.findViewById(R.id.switchPdfMode);
|
||||||
|
@ -144,6 +147,32 @@ public class SettingsFragment extends Fragment {
|
||||||
pdfModeSwitch.setChecked(false);
|
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
|
// issues badge switcher
|
||||||
issuesSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
issuesSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
|
|
@ -45,8 +45,8 @@ import javax.net.ssl.X509TrustManager;
|
||||||
public class MemorizingTrustManager implements X509TrustManager {
|
public class MemorizingTrustManager implements X509TrustManager {
|
||||||
private final static int NOTIFICATION_ID = 100509;
|
private final static int NOTIFICATION_ID = 100509;
|
||||||
|
|
||||||
private final static String KEYSTORE_NAME = "keystore";
|
public final static String KEYSTORE_NAME = "keystore";
|
||||||
private final static String KEYSTORE_KEY = "keystore";
|
public final static String KEYSTORE_KEY = "keystore";
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
private NotificationManager notificationManager;
|
private NotificationManager notificationManager;
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
layout="@layout/layout_settings_fileview"/>
|
layout="@layout/layout_settings_fileview"/>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/translationDivider"
|
android:id="@+id/certsDivider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginStart="44dp"
|
android:layout_marginStart="44dp"
|
||||||
|
@ -42,6 +42,20 @@
|
||||||
android:layout_marginBottom="20dp"
|
android:layout_marginBottom="20dp"
|
||||||
android:layout_below="@id/fileViewLayout" />
|
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
|
<include
|
||||||
android:id="@+id/langLayout"
|
android:id="@+id/langLayout"
|
||||||
layout="@layout/layout_settings_languages" />
|
layout="@layout/layout_settings_languages" />
|
||||||
|
|
|
@ -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 -->
|
<!-- settings -->
|
||||||
<string name="settingsLanguageHeaderText">Translation</string>
|
<string name="settingsLanguageHeaderText">Translation</string>
|
||||||
|
<string name="settingsCertsHeader">Certs</string>
|
||||||
|
<string name="settingsCertsSelectorHeader">Delete certificates</string>
|
||||||
<string name="settingsDateTimeHeaderText">Date & Time</string>
|
<string name="settingsDateTimeHeaderText">Date & Time</string>
|
||||||
<string name="settingsSave">Settings saved</string>
|
<string name="settingsSave">Settings saved</string>
|
||||||
<string name="settingsLanguageSelectorHeader">Language</string>
|
<string name="settingsLanguageSelectorHeader">Language</string>
|
||||||
|
|
Loading…
Reference in New Issue