Refactor settings screen, move drafts and crash to general section

This commit is contained in:
M M Arif 2023-04-11 21:04:40 +05:00
parent 0db3bed589
commit 9574692eae
10 changed files with 124 additions and 418 deletions

View File

@ -129,18 +129,12 @@
<activity
android:name=".activities.SettingsTranslationActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
<activity
android:name=".activities.SettingsReportsActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
<activity
android:name=".activities.AddNewTeamMemberActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
<activity
android:name=".activities.AddNewTeamRepoActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
<activity
android:name=".activities.SettingsDraftsActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>
<activity
android:name=".activities.RepoForksActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"/>

View File

@ -1,49 +0,0 @@
package org.mian.gitnex.activities;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import org.mian.gitnex.R;
import org.mian.gitnex.databinding.ActivitySettingsDraftsBinding;
import org.mian.gitnex.helpers.Toasty;
/**
* @author M M Arif
*/
public class SettingsDraftsActivity extends BaseActivity {
private View.OnClickListener onClickListener;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivitySettingsDraftsBinding activitySettingsDraftsBinding =
ActivitySettingsDraftsBinding.inflate(getLayoutInflater());
setContentView(activitySettingsDraftsBinding.getRoot());
ImageView closeActivity = activitySettingsDraftsBinding.close;
initCloseListener();
closeActivity.setOnClickListener(onClickListener);
activitySettingsDraftsBinding.commentsDeletionSwitch.setChecked(
tinyDB.getBoolean("draftsCommentsDeletionEnabled", true));
// delete comments on submit switcher
activitySettingsDraftsBinding.commentsDeletionSwitch.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
tinyDB.putBoolean("draftsCommentsDeletionEnabled", isChecked);
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
activitySettingsDraftsBinding.enableDraftsCommentsDeletion.setOnClickListener(
v ->
activitySettingsDraftsBinding.commentsDeletionSwitch.setChecked(
!activitySettingsDraftsBinding.commentsDeletionSwitch.isChecked()));
}
private void initCloseListener() {
onClickListener = view -> finish();
}
}

View File

@ -169,6 +169,34 @@ public class SettingsGeneralActivity extends BaseActivity {
viewBinding.customTabsFrame.setOnClickListener(
v -> viewBinding.switchTabs.setChecked(!viewBinding.switchTabs.isChecked()));
// custom tabs
// enable drafts deletion
viewBinding.commentsDeletionSwitch.setChecked(
tinyDB.getBoolean("draftsCommentsDeletionEnabled", true));
// delete comments on submit switcher
viewBinding.commentsDeletionSwitch.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
tinyDB.putBoolean("draftsCommentsDeletionEnabled", isChecked);
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
viewBinding.enableDraftsCommentsDeletion.setOnClickListener(
v ->
viewBinding.commentsDeletionSwitch.setChecked(
!viewBinding.commentsDeletionSwitch.isChecked()));
// enable drafts deletion
// crash reports switcher
viewBinding.crashReportsSwitch.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
tinyDB.putBoolean("crashReportingEnabled", isChecked);
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
viewBinding.enableSendReports.setOnClickListener(
v ->
viewBinding.crashReportsSwitch.setChecked(
!viewBinding.crashReportsSwitch.isChecked()));
// crash reports switcher
}
private void initCloseListener() {

View File

@ -1,49 +0,0 @@
package org.mian.gitnex.activities;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import org.mian.gitnex.R;
import org.mian.gitnex.databinding.ActivitySettingsReportsBinding;
import org.mian.gitnex.helpers.Toasty;
/**
* @author M M Arif
*/
public class SettingsReportsActivity extends BaseActivity {
private View.OnClickListener onClickListener;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivitySettingsReportsBinding activitySettingsReportsBinding =
ActivitySettingsReportsBinding.inflate(getLayoutInflater());
setContentView(activitySettingsReportsBinding.getRoot());
ImageView closeActivity = activitySettingsReportsBinding.close;
initCloseListener();
closeActivity.setOnClickListener(onClickListener);
activitySettingsReportsBinding.crashReportsSwitch.setChecked(
tinyDB.getBoolean("crashReportingEnabled", true));
// crash reports switcher
activitySettingsReportsBinding.crashReportsSwitch.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
tinyDB.putBoolean("crashReportingEnabled", isChecked);
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
});
activitySettingsReportsBinding.enableSendReports.setOnClickListener(
v ->
activitySettingsReportsBinding.crashReportsSwitch.setChecked(
!activitySettingsReportsBinding.crashReportsSwitch.isChecked()));
}
private void initCloseListener() {
onClickListener = view -> finish();
}
}

View File

@ -16,10 +16,8 @@ import org.mian.gitnex.R;
import org.mian.gitnex.activities.BaseActivity;
import org.mian.gitnex.activities.MainActivity;
import org.mian.gitnex.activities.SettingsAppearanceActivity;
import org.mian.gitnex.activities.SettingsDraftsActivity;
import org.mian.gitnex.activities.SettingsGeneralActivity;
import org.mian.gitnex.activities.SettingsNotificationsActivity;
import org.mian.gitnex.activities.SettingsReportsActivity;
import org.mian.gitnex.activities.SettingsSecurityActivity;
import org.mian.gitnex.activities.SettingsTranslationActivity;
import org.mian.gitnex.databinding.CustomAboutDialogBinding;
@ -64,10 +62,7 @@ public class SettingsFragment extends Fragment {
v1 -> startActivity(new Intent(ctx, SettingsAppearanceActivity.class)));
fragmentSettingsBinding.codeEditorFrame.setOnClickListener(
v1 -> startActivity(new Intent(ctx, SettingsReportsActivity.class)));
fragmentSettingsBinding.draftsFrame.setOnClickListener(
v1 -> startActivity(new Intent(ctx, SettingsDraftsActivity.class)));
v1 -> startActivity(new Intent(ctx, SettingsAppearanceActivity.class)));
fragmentSettingsBinding.securityFrame.setOnClickListener(
v1 -> startActivity(new Intent(ctx, SettingsSecurityActivity.class)));
@ -78,9 +73,6 @@ public class SettingsFragment extends Fragment {
fragmentSettingsBinding.languagesFrame.setOnClickListener(
v1 -> startActivity(new Intent(ctx, SettingsTranslationActivity.class)));
fragmentSettingsBinding.reportsFrame.setOnClickListener(
v1 -> startActivity(new Intent(ctx, SettingsReportsActivity.class)));
fragmentSettingsBinding.rateAppFrame.setOnClickListener(rateApp -> rateThisApp());
fragmentSettingsBinding.aboutAppFrame.setOnClickListener(aboutApp -> showAboutAppDialog());

View File

@ -1,106 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/primaryBackgroundColor"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dimen10dp"
android:theme="@style/Widget.AppCompat.SearchView"
app:elevation="@dimen/dimen0dp">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/primaryBackgroundColor"
android:theme="@style/AppTheme.AppBarOverlay">
<ImageView
android:id="@+id/close"
android:layout_width="@dimen/dimen26dp"
android:layout_height="@dimen/dimen26dp"
android:layout_marginStart="@dimen/dimen16dp"
android:layout_marginEnd="@dimen/dimen16dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:contentDescription="@string/close"
android:focusable="true"
android:gravity="center_vertical"
android:src="@drawable/ic_close" />
<TextView
android:id="@+id/toolbarTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="1"
android:text="@string/draftsHeader"
android:textColor="?attr/primaryTextColor"
android:textSize="@dimen/dimen20sp" />
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:id="@+id/enableDraftsCommentsDeletion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dimen6dp"
android:background="?android:attr/selectableItemBackground"
android:orientation="horizontal"
android:padding="@dimen/dimen16dp">
<LinearLayout
android:id="@+id/enableCommentsDeletionHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="90"
android:layout_marginStart="@dimen/dimen24dp"
android:text="@string/settingsEnableCommentsDeletionText"
android:textColor="?attr/primaryTextColor"
android:textSize="@dimen/dimen18sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="10"
android:gravity="center_vertical|end"
android:orientation="horizontal">
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/commentsDeletionSwitch"
android:layout_width="wrap_content"
android:layout_height="@dimen/dimen32dp"
android:paddingStart="@dimen/dimen24dp"
android:paddingEnd="@dimen/dimen24dp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/enableCommentsDeletionHeader"
android:layout_marginStart="@dimen/dimen24dp"
android:layout_marginEnd="@dimen/dimen72dp"
android:text="@string/settingsEnableCommentsDeletionHintText"
android:textColor="?attr/hintColor"
android:textSize="@dimen/dimen12sp" />
</RelativeLayout>
</LinearLayout>

View File

@ -65,6 +65,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dimen24dp"
android:layout_marginEnd="@dimen/dimen24dp"
android:layout_marginBottom="@dimen/dimen6dp"
android:text="@string/generalDeepLinkDefaultScreen"
android:textColor="?attr/primaryTextColor"
android:textSize="@dimen/dimen18sp"/>
@ -155,4 +156,97 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/enableDraftsCommentsDeletion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dimen6dp"
android:background="?android:attr/selectableItemBackground"
android:orientation="horizontal"
android:padding="@dimen/dimen16dp">
<LinearLayout
android:id="@+id/enableCommentsDeletionHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="90"
android:layout_marginStart="@dimen/dimen24dp"
android:text="@string/settingsEnableCommentsDeletionText"
android:textColor="?attr/primaryTextColor"
android:textSize="@dimen/dimen18sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="10"
android:gravity="center_vertical|end"
android:orientation="horizontal">
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/commentsDeletionSwitch"
android:layout_width="wrap_content"
android:layout_height="@dimen/dimen32dp"
android:paddingStart="@dimen/dimen24dp"
android:paddingEnd="@dimen/dimen24dp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/enableCommentsDeletionHeader"
android:layout_marginStart="@dimen/dimen24dp"
android:layout_marginEnd="@dimen/dimen72dp"
android:text="@string/settingsEnableCommentsDeletionHintText"
android:textColor="?attr/hintColor"
android:textSize="@dimen/dimen12sp" />
</RelativeLayout>
<LinearLayout
android:id="@+id/enableSendReports"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dimen6dp"
android:background="?android:attr/selectableItemBackground"
android:orientation="horizontal"
android:weightSum="100"
android:padding="@dimen/dimen16dp">
<TextView
android:id="@+id/enableReportsHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="90"
android:layout_marginStart="@dimen/dimen24dp"
android:text="@string/settingsEnableReportsText"
android:textColor="?attr/primaryTextColor"
android:textSize="@dimen/dimen18sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="10"
android:gravity="center_vertical|end"
android:orientation="horizontal">
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/crashReportsSwitch"
android:layout_width="wrap_content"
android:layout_height="@dimen/dimen32dp"
android:paddingStart="@dimen/dimen24dp"
android:paddingEnd="@dimen/dimen24dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -1,88 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/primaryBackgroundColor"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dimen10dp"
android:theme="@style/Widget.AppCompat.SearchView"
app:elevation="@dimen/dimen0dp">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/primaryBackgroundColor">
<ImageView
android:id="@+id/close"
android:layout_width="@dimen/dimen26dp"
android:layout_height="@dimen/dimen26dp"
android:layout_marginStart="@dimen/dimen16dp"
android:layout_marginEnd="@dimen/dimen16dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:contentDescription="@string/close"
android:focusable="true"
android:gravity="center_vertical"
android:src="@drawable/ic_close" />
<TextView
android:id="@+id/toolbar_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="1"
android:text="@string/reportViewerHeader"
android:textColor="?attr/primaryTextColor"
android:textSize="@dimen/dimen20sp" />
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:id="@+id/enableSendReports"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dimen6dp"
android:background="?android:attr/selectableItemBackground"
android:orientation="horizontal"
android:weightSum="100"
android:padding="@dimen/dimen16dp">
<TextView
android:id="@+id/enableReportsHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="90"
android:layout_marginStart="@dimen/dimen24dp"
android:text="@string/settingsEnableReportsText"
android:textColor="?attr/primaryTextColor"
android:textSize="@dimen/dimen18sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="10"
android:gravity="center_vertical|end"
android:orientation="horizontal">
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/crashReportsSwitch"
android:layout_width="wrap_content"
android:layout_height="@dimen/dimen32dp"
android:paddingStart="@dimen/dimen24dp"
android:paddingEnd="@dimen/dimen24dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -183,61 +183,6 @@
</LinearLayout>
<LinearLayout
android:id="@+id/draftsFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="15dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_drafts"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/draftsHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:text="@string/draftsHeader"
android:textColor="?attr/primaryTextColor"
android:textSize="18sp"/>
<TextView
android:id="@+id/draftsHintText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:text="@string/draftsHintText"
android:textColor="?attr/primaryTextColor"
android:textSize="12sp"/>
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_chevron_right"/>
</LinearLayout>
<LinearLayout
android:id="@+id/securityFrame"
android:layout_width="match_parent"
@ -403,61 +348,6 @@
</LinearLayout>
<LinearLayout
android:id="@+id/reportsFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="15dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_bug_report"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/appReports"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:text="@string/reportViewerHeader"
android:textColor="?attr/primaryTextColor"
android:textSize="18sp"/>
<TextView
android:id="@+id/reportsHintText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:text="@string/reportsHintText"
android:textColor="?attr/primaryTextColor"
android:textSize="12sp"/>
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_chevron_right"/>
</LinearLayout>
<LinearLayout
android:id="@+id/rateAppFrame"
android:layout_width="match_parent"

View File

@ -242,7 +242,7 @@
<string name="settingsEnableCommentsDeletionText">Enable Drafts Deletion</string>
<string name="settingsEnableCommentsDeletionHintText">Delete comment draft when comment is posted</string>
<string name="settingsGeneralHeader">General</string>
<string name="generalHintText">Home screen, default link handler</string>
<string name="generalHintText">Home screen, drafts, crash reports</string>
<string name="generalDeepLinkDefaultScreen">Default Link Handler</string>
<string name="generalDeepLinkDefaultScreenHintText">Choose what screen should be loaded if the app cannot handle external links. It will redirect you automatically.</string>
<string name="generalDeepLinkSelectedText">N/A</string>