Move settings data to db and other improvements (#1332)

Closes #1331

Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1332
Co-authored-by: M M Arif <mmarif@swatian.com>
Co-committed-by: M M Arif <mmarif@swatian.com>
This commit is contained in:
M M Arif 2024-03-18 05:12:24 +00:00 committed by M M Arif
parent 36e7cfeddb
commit e6365b9d74
69 changed files with 3604 additions and 1073 deletions

View File

@ -10,7 +10,7 @@ steps:
branch: main
push:
image: crowdin/cli:3.7.8
image: crowdin/cli:3.16.0
commands:
- crowdin push
when:
@ -19,7 +19,7 @@ steps:
path: [ app/src/main/res/values/strings.xml, fastlane/metadata/android/en-US/*.txt, fastlane/metadata/android/en-US/changelogs/*.txt ]
pull:
image: crowdin/cli:3.7.8
image: crowdin/cli:3.16.0
# we do not need to update the config file again since it persists
commands:
- crowdin pull

View File

@ -10,6 +10,7 @@ import java.util.Locale;
import java.util.concurrent.Executor;
import org.mian.gitnex.R;
import org.mian.gitnex.core.MainApplication;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.TimeHelper;
import org.mian.gitnex.helpers.TinyDB;
@ -34,7 +35,8 @@ public abstract class BaseActivity extends AppCompatActivity {
this.appCtx = getApplicationContext();
this.tinyDB = TinyDB.getInstance(appCtx);
switch (tinyDB.getInt("themeId", 6)) {
switch (Integer.parseInt(
AppDatabaseSettings.getSettingsValue(ctx, AppDatabaseSettings.APP_THEME_KEY))) {
case 0:
setTheme(R.style.AppTheme);
break;
@ -43,10 +45,18 @@ public abstract class BaseActivity extends AppCompatActivity {
break;
case 2:
if (TimeHelper.timeBetweenHours(
tinyDB.getInt("darkThemeTimeHour", 18),
tinyDB.getInt("lightThemeTimeHour", 6),
tinyDB.getInt("darkThemeTimeMinute", 0),
tinyDB.getInt("lightThemeTimeMinute", 0))) {
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_DARK_HOUR_KEY)),
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_LIGHT_HOUR_KEY)),
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_DARK_MIN_KEY)),
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_LIGHT_MIN_KEY)))) {
setTheme(R.style.AppTheme);
} else {
@ -59,10 +69,18 @@ public abstract class BaseActivity extends AppCompatActivity {
break;
case 4:
if (TimeHelper.timeBetweenHours(
tinyDB.getInt("darkThemeTimeHour", 18),
tinyDB.getInt("lightThemeTimeHour", 6),
tinyDB.getInt("darkThemeTimeMinute", 0),
tinyDB.getInt("lightThemeTimeMinute", 0))) {
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_DARK_HOUR_KEY)),
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_LIGHT_HOUR_KEY)),
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_DARK_MIN_KEY)),
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_LIGHT_MIN_KEY)))) {
setTheme(R.style.AppTheme);
} else {
@ -87,11 +105,14 @@ public abstract class BaseActivity extends AppCompatActivity {
break;
}
String locale = tinyDB.getString("locale");
if (locale.isEmpty()) {
String[] locale =
AppDatabaseSettings.getSettingsValue(ctx, AppDatabaseSettings.APP_LOCALE_KEY)
.split("\\|");
if (locale[0].equals("0")) {
AppUtil.setAppLocale(getResources(), Locale.getDefault().getLanguage());
} else {
AppUtil.setAppLocale(getResources(), locale);
AppUtil.setAppLocale(getResources(), locale[1]);
}
Notifications.startWorker(ctx);
@ -100,8 +121,12 @@ public abstract class BaseActivity extends AppCompatActivity {
public void onResume() {
super.onResume();
if (tinyDB.getBoolean("biometricStatus", false)
&& !tinyDB.getBoolean("biometricLifeCycle")) {
if (Boolean.parseBoolean(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_BIOMETRIC_KEY))
&& !Boolean.parseBoolean(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_BIOMETRIC_LIFE_CYCLE_KEY))) {
Executor executor = ContextCompat.getMainExecutor(this);
@ -126,7 +151,10 @@ public abstract class BaseActivity extends AppCompatActivity {
public void onAuthenticationSucceeded(
@NonNull BiometricPrompt.AuthenticationResult result) {
super.onAuthenticationSucceeded(result);
tinyDB.putBoolean("biometricLifeCycle", true);
AppDatabaseSettings.updateSettingsValue(
getApplicationContext(),
"true",
AppDatabaseSettings.APP_BIOMETRIC_LIFE_CYCLE_KEY);
}
// Authentication failed, close the app

View File

@ -13,6 +13,7 @@ import java.util.Map;
import org.mian.gitnex.R;
import org.mian.gitnex.core.MainGrammarLocator;
import org.mian.gitnex.databinding.ActivityCodeEditorBinding;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.codeeditor.CustomCodeViewAdapter;
import org.mian.gitnex.helpers.codeeditor.SourcePositionListener;
import org.mian.gitnex.helpers.codeeditor.languages.Language;
@ -73,9 +74,14 @@ public class CodeEditorActivity extends BaseActivity {
binding.codeView.setLineNumberTextSize(32f);
// Setup Auto indenting feature
if (tinyDB.getInt("ceIndentationId") == 0) {
if (Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_CE_INDENTATION_KEY))
== 0) {
binding.codeView.setEnableAutoIndentation(true);
switch (tinyDB.getInt("ceIndentationTabsId")) {
switch (Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_CE_TABS_WIDTH_KEY))) {
case 0:
binding.codeView.setTabLength(2);
break;

View File

@ -50,6 +50,7 @@ import org.mian.gitnex.databinding.CustomAssigneesSelectionDialogBinding;
import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding;
import org.mian.gitnex.fragments.IssuesFragment;
import org.mian.gitnex.helpers.AlertDialogs;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.Constants;
import org.mian.gitnex.helpers.Markdown;
import org.mian.gitnex.helpers.SnackBar;
@ -315,6 +316,10 @@ public class CreateIssueActivity extends BaseActivity
builder.setTitleText(R.string.newIssueDueDateTitle);
MaterialDatePicker<Long> materialDatePicker = builder.build();
String[] locale_ =
AppDatabaseSettings.getSettingsValue(ctx, AppDatabaseSettings.APP_LOCALE_KEY)
.split("\\|");
viewBinding.newIssueDueDate.setOnClickListener(
v -> materialDatePicker.show(getSupportFragmentManager(), "DATE_PICKER"));
@ -323,8 +328,7 @@ public class CreateIssueActivity extends BaseActivity
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
calendar.setTimeInMillis(selection);
SimpleDateFormat format =
new SimpleDateFormat(
"yyyy-MM-dd", new Locale(tinyDB.getString("locale")));
new SimpleDateFormat("yyyy-MM-dd", new Locale(locale_[1]));
String formattedDate = format.format(calendar.getTime());
viewBinding.newIssueDueDate.setText(formattedDate);
});

View File

@ -21,6 +21,7 @@ import org.mian.gitnex.R;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.databinding.ActivityCreateMilestoneBinding;
import org.mian.gitnex.helpers.AlertDialogs;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.Markdown;
import org.mian.gitnex.helpers.SnackBar;
import org.mian.gitnex.helpers.contexts.RepositoryContext;
@ -109,6 +110,10 @@ public class CreateMilestoneActivity extends BaseActivity {
builder.setTitleText(R.string.newIssueDueDateTitle);
MaterialDatePicker<Long> materialDatePicker = builder.build();
String[] locale_ =
AppDatabaseSettings.getSettingsValue(ctx, AppDatabaseSettings.APP_LOCALE_KEY)
.split("\\|");
binding.milestoneDueDate.setOnClickListener(
v -> materialDatePicker.show(getSupportFragmentManager(), "DATE_PICKER"));
@ -117,8 +122,7 @@ public class CreateMilestoneActivity extends BaseActivity {
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
calendar.setTimeInMillis(selection);
SimpleDateFormat format =
new SimpleDateFormat(
"yyyy-MM-dd", new Locale(tinyDB.getString("locale")));
new SimpleDateFormat("yyyy-MM-dd", new Locale(locale_[1]));
String formattedDate = format.format(calendar.getTime());
binding.milestoneDueDate.setText(formattedDate);
});

View File

@ -47,6 +47,7 @@ import org.mian.gitnex.databinding.BottomSheetAttachmentsBinding;
import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding;
import org.mian.gitnex.fragments.PullRequestsFragment;
import org.mian.gitnex.helpers.AlertDialogs;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.Constants;
import org.mian.gitnex.helpers.Markdown;
import org.mian.gitnex.helpers.SnackBar;
@ -429,6 +430,10 @@ public class CreatePullRequestActivity extends BaseActivity
builder.setTitleText(R.string.newIssueDueDateTitle);
MaterialDatePicker<Long> materialDatePicker = builder.build();
String[] locale_ =
AppDatabaseSettings.getSettingsValue(ctx, AppDatabaseSettings.APP_LOCALE_KEY)
.split("\\|");
viewBinding.prDueDate.setOnClickListener(
v -> materialDatePicker.show(getSupportFragmentManager(), "DATE_PICKER"));
@ -437,8 +442,7 @@ public class CreatePullRequestActivity extends BaseActivity
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
calendar.setTimeInMillis(selection);
SimpleDateFormat format =
new SimpleDateFormat(
"yyyy-MM-dd", new Locale(tinyDB.getString("locale")));
new SimpleDateFormat("yyyy-MM-dd", new Locale(locale_[1]));
String formattedDate = format.format(calendar.getTime());
viewBinding.prDueDate.setText(formattedDate);
});

View File

@ -23,6 +23,7 @@ import org.mian.gitnex.database.api.BaseApi;
import org.mian.gitnex.database.api.UserAccountsApi;
import org.mian.gitnex.database.models.UserAccount;
import org.mian.gitnex.databinding.ActivityDeeplinksBinding;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.contexts.IssueContext;
import org.mian.gitnex.helpers.contexts.RepositoryContext;
@ -675,7 +676,9 @@ public class DeepLinksActivity extends BaseActivity {
private void showNoActionButtons() {
viewBinding.progressBar.setVisibility(View.GONE);
switch (tinyDB.getInt("defaultScreenId")) {
switch (Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_LINK_HANDLER_KEY))) {
case 1: // repos
mainIntent.putExtra("launchFragmentByLinkHandler", "repos");
ctx.startActivity(mainIntent);
@ -708,7 +711,10 @@ public class DeepLinksActivity extends BaseActivity {
viewBinding.repository.setOnClickListener(
repository -> {
tinyDB.putInt("defaultScreenId", 1);
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(1),
AppDatabaseSettings.APP_LINK_HANDLER_KEY);
mainIntent.putExtra("launchFragmentByLinkHandler", "repos");
ctx.startActivity(mainIntent);
finish();
@ -716,7 +722,10 @@ public class DeepLinksActivity extends BaseActivity {
viewBinding.organization.setOnClickListener(
organization -> {
tinyDB.putInt("defaultScreenId", 2);
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(2),
AppDatabaseSettings.APP_LINK_HANDLER_KEY);
mainIntent.putExtra("launchFragmentByLinkHandler", "org");
ctx.startActivity(mainIntent);
finish();
@ -724,7 +733,10 @@ public class DeepLinksActivity extends BaseActivity {
viewBinding.notification.setOnClickListener(
notification -> {
tinyDB.putInt("defaultScreenId", 3);
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(3),
AppDatabaseSettings.APP_LINK_HANDLER_KEY);
mainIntent.putExtra("launchFragmentByLinkHandler", "notification");
ctx.startActivity(mainIntent);
finish();
@ -732,7 +744,10 @@ public class DeepLinksActivity extends BaseActivity {
viewBinding.explore.setOnClickListener(
explore -> {
tinyDB.putInt("defaultScreenId", 4);
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(4),
AppDatabaseSettings.APP_LINK_HANDLER_KEY);
mainIntent.putExtra("launchFragmentByLinkHandler", "explore");
ctx.startActivity(mainIntent);
finish();
@ -740,7 +755,10 @@ public class DeepLinksActivity extends BaseActivity {
viewBinding.launchApp2.setOnClickListener(
launchApp2 -> {
tinyDB.putInt("defaultScreenId", 0);
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(0),
AppDatabaseSettings.APP_LINK_HANDLER_KEY);
ctx.startActivity(mainIntent);
finish();
});

View File

@ -33,6 +33,7 @@ import org.mian.gitnex.databinding.ActivityEditIssueBinding;
import org.mian.gitnex.fragments.IssuesFragment;
import org.mian.gitnex.fragments.PullRequestsFragment;
import org.mian.gitnex.helpers.AlertDialogs;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.Constants;
import org.mian.gitnex.helpers.Markdown;
import org.mian.gitnex.helpers.SnackBar;
@ -247,6 +248,10 @@ public class EditIssueActivity extends BaseActivity {
builder.setTitleText(R.string.newIssueDueDateTitle);
MaterialDatePicker<Long> materialDatePicker = builder.build();
String[] locale_ =
AppDatabaseSettings.getSettingsValue(ctx, AppDatabaseSettings.APP_LOCALE_KEY)
.split("\\|");
binding.editIssueDueDate.setOnClickListener(
v -> materialDatePicker.show(getSupportFragmentManager(), "DATE_PICKER"));
@ -255,8 +260,7 @@ public class EditIssueActivity extends BaseActivity {
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
calendar.setTimeInMillis(selection);
SimpleDateFormat format =
new SimpleDateFormat(
"yyyy-MM-dd", new Locale(tinyDB.getString("locale")));
new SimpleDateFormat("yyyy-MM-dd", new Locale(locale_[1]));
String formattedDate = format.format(calendar.getTime());
binding.editIssueDueDate.setText(formattedDate);
});

View File

@ -73,6 +73,7 @@ import org.mian.gitnex.fragments.BottomSheetReplyFragment;
import org.mian.gitnex.fragments.BottomSheetSingleIssueFragment;
import org.mian.gitnex.fragments.IssuesFragment;
import org.mian.gitnex.helpers.AlertDialogs;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.ClickListener;
import org.mian.gitnex.helpers.ColorInverter;
@ -857,18 +858,34 @@ public class IssueDetailActivity extends BaseActivity
} else { // open
viewBinding.issuePrState.setImageResource(R.drawable.ic_pull_request);
if (tinyDB.getInt("themeId") == 3) {
if (Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_KEY))
== 3) {
ImageViewCompat.setImageTintList(
viewBinding.issuePrState,
ColorStateList.valueOf(
ctx.getResources()
.getColor(R.color.retroThemeColorPrimary, null)));
} else if (tinyDB.getInt("themeId") == 4) {
} else if (Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_KEY))
== 4) {
if (TimeHelper.timeBetweenHours(
tinyDB.getInt("darkThemeTimeHour", 18),
tinyDB.getInt("lightThemeTimeHour", 6),
tinyDB.getInt("darkThemeTimeMinute", 0),
tinyDB.getInt("lightThemeTimeMinute", 0))) {
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_DARK_HOUR_KEY)),
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx,
AppDatabaseSettings.APP_THEME_AUTO_LIGHT_HOUR_KEY)),
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_DARK_MIN_KEY)),
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx,
AppDatabaseSettings.APP_THEME_AUTO_LIGHT_MIN_KEY)))) {
ImageViewCompat.setImageTintList(
viewBinding.issuePrState,
ColorStateList.valueOf(
@ -880,7 +897,10 @@ public class IssueDetailActivity extends BaseActivity
ctx.getResources()
.getColor(R.color.retroThemeColorPrimary, null)));
}
} else if (tinyDB.getInt("themeId") == 8) {
} else if (Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_KEY))
== 8) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
ImageViewCompat.setImageTintList(
viewBinding.issuePrState,
@ -908,17 +928,31 @@ public class IssueDetailActivity extends BaseActivity
loadingFinishedPr = true;
updateMenuState();
viewBinding.issuePrState.setImageResource(R.drawable.ic_issue);
if (tinyDB.getInt("themeId") == 3) {
if (Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_KEY))
== 3) {
ImageViewCompat.setImageTintList(
viewBinding.issuePrState,
ColorStateList.valueOf(
ctx.getResources().getColor(R.color.retroThemeColorPrimary, null)));
} else if (tinyDB.getInt("themeId") == 4) {
} else if (Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_KEY))
== 4) {
if (TimeHelper.timeBetweenHours(
tinyDB.getInt("darkThemeTimeHour", 18),
tinyDB.getInt("lightThemeTimeHour", 6),
tinyDB.getInt("darkThemeTimeMinute", 0),
tinyDB.getInt("lightThemeTimeMinute", 0))) {
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_DARK_HOUR_KEY)),
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_LIGHT_HOUR_KEY)),
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_DARK_MIN_KEY)),
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_LIGHT_MIN_KEY)))) {
ImageViewCompat.setImageTintList(
viewBinding.issuePrState,
ColorStateList.valueOf(
@ -930,7 +964,10 @@ public class IssueDetailActivity extends BaseActivity
ctx.getResources()
.getColor(R.color.retroThemeColorPrimary, null)));
}
} else if (tinyDB.getInt("themeId") == 8) {
} else if (Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_KEY))
== 8) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
ImageViewCompat.setImageTintList(
viewBinding.issuePrState,

View File

@ -10,6 +10,7 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
@ -54,6 +55,7 @@ import org.mian.gitnex.fragments.SettingsFragment;
import org.mian.gitnex.fragments.StarredRepositoriesFragment;
import org.mian.gitnex.fragments.WatchedRepositoriesFragment;
import org.mian.gitnex.helpers.AlertDialogs;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.ChangeLog;
import org.mian.gitnex.helpers.RoundedTransformation;
@ -228,7 +230,7 @@ public class MainActivity extends BaseActivity
.observe(
(AppCompatActivity) ctx,
userAccounts -> {
if (userAccounts.size() > 0) {
if (!userAccounts.isEmpty()) {
userAccountsList.clear();
userAccountsList.addAll(userAccounts);
navRecyclerViewUserAccounts.setAdapter(
@ -246,15 +248,15 @@ public class MainActivity extends BaseActivity
String userFullNameNav = getAccount().getFullName();
String userAvatarNav = getAccount().getUserInfo().getAvatarUrl();
if (!userEmailNav.equals("")) {
if (!userEmailNav.isEmpty()) {
userEmail.setText(userEmailNav);
}
if (!userFullNameNav.equals("")) {
if (!userFullNameNav.isEmpty()) {
userFullName.setText(Html.fromHtml(userFullNameNav));
}
if (!userAvatarNav.equals("")) {
if (!userAvatarNav.isEmpty()) {
int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 60);
@ -400,13 +402,9 @@ public class MainActivity extends BaseActivity
if (savedInstanceState == null) {
if (!getAccount().requiresVersion("1.12.3")) {
if (tinyDB.getInt("homeScreenId", 0) == 7) {
tinyDB.putInt("homeScreenId", 0);
}
}
switch (tinyDB.getInt("homeScreenId", 0)) {
switch (Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_HOME_SCREEN_KEY))) {
case 1:
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
getSupportFragmentManager()
@ -566,6 +564,17 @@ public class MainActivity extends BaseActivity
ChangeLog changelogDialog = new ChangeLog(this);
changelogDialog.showDialog();
}
OnBackPressedCallback onBackPressedCallback =
new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
}
}
};
getOnBackPressedDispatcher().addCallback(this, onBackPressedCallback);
}
@Override
@ -639,18 +648,6 @@ public class MainActivity extends BaseActivity
}
}
@Override
public void onBackPressed() {
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {

View File

@ -28,6 +28,7 @@ import org.mian.gitnex.fragments.OrganizationLabelsFragment;
import org.mian.gitnex.fragments.OrganizationMembersFragment;
import org.mian.gitnex.fragments.OrganizationRepositoriesFragment;
import org.mian.gitnex.fragments.OrganizationTeamsFragment;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.ViewPager2Transformers;
import org.mian.gitnex.structs.BottomSheetListener;
@ -129,7 +130,10 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
viewPager.setAdapter(new OrganizationDetailActivity.ViewPagerAdapter(this));
ViewPager2Transformers.returnSelectedTransformer(
viewPager, tinyDB.getInt("fragmentTabsAnimationId", 0));
viewPager,
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_TABS_ANIMATION_KEY)));
List<String> tabsList = new ArrayList<>();
tabsList.add(getResources().getString(R.string.tabTextInfo));

View File

@ -14,6 +14,7 @@ import org.mian.gitnex.databinding.ActivityOrgTeamInfoBinding;
import org.mian.gitnex.fragments.OrganizationTeamInfoMembersFragment;
import org.mian.gitnex.fragments.OrganizationTeamInfoPermissionsFragment;
import org.mian.gitnex.fragments.OrganizationTeamInfoReposFragment;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.ViewPager2Transformers;
/**
@ -37,6 +38,7 @@ public class OrganizationTeamInfoActivity extends BaseActivity {
team = (Team) getIntent().getSerializableExtra("team");
assert team != null;
if (team.getName() != null && !team.getName().isEmpty()) {
binding.toolbarTitle.setText(team.getName());
} else {
@ -68,7 +70,10 @@ public class OrganizationTeamInfoActivity extends BaseActivity {
});
ViewPager2Transformers.returnSelectedTransformer(
binding.pager, tinyDB.getInt("fragmentTabsAnimationId", 0));
binding.pager,
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_TABS_ANIMATION_KEY)));
new TabLayoutMediator(
binding.tabs,

View File

@ -26,6 +26,7 @@ import org.mian.gitnex.fragments.profile.FollowingFragment;
import org.mian.gitnex.fragments.profile.OrganizationsFragment;
import org.mian.gitnex.fragments.profile.RepositoriesFragment;
import org.mian.gitnex.fragments.profile.StarredRepositoriesFragment;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.Toasty;
import org.mian.gitnex.helpers.ViewPager2Transformers;
@ -76,7 +77,10 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
viewPager.setAdapter(new ViewPagerAdapter(this));
ViewPager2Transformers.returnSelectedTransformer(
viewPager, tinyDB.getInt("fragmentTabsAnimationId", 0));
viewPager,
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_TABS_ANIMATION_KEY)));
String[] tabTitles = {
ctx.getResources().getString(R.string.tabTextInfo),

View File

@ -50,6 +50,7 @@ import org.mian.gitnex.fragments.PullRequestsFragment;
import org.mian.gitnex.fragments.ReleasesFragment;
import org.mian.gitnex.fragments.RepoInfoFragment;
import org.mian.gitnex.fragments.WikiFragment;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.Toasty;
import org.mian.gitnex.helpers.ViewPager2Transformers;
@ -539,7 +540,10 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
viewPager.setAdapter(new ViewPagerAdapter(this));
ViewPager2Transformers.returnSelectedTransformer(
viewPager, tinyDB.getInt("fragmentTabsAnimationId", 0));
viewPager,
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_TABS_ANIMATION_KEY)));
String[] tabTitles = {
ctx.getResources().getString(R.string.tabTextInfo),
@ -578,7 +582,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
}
}
if (tinyDB.getBoolean("enableCounterBadges", true)) {
if (Boolean.parseBoolean(
AppDatabaseSettings.getSettingsValue(ctx, AppDatabaseSettings.APP_COUNTER_KEY))) {
@SuppressLint("InflateParams")
View tabHeader2 = LayoutInflater.from(ctx).inflate(R.layout.badge_issue, null);
if (textViewBadgeIssue == null) {

View File

@ -2,6 +2,7 @@ package org.mian.gitnex.activities;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.timepicker.MaterialTimePicker;
@ -10,10 +11,10 @@ import java.util.Locale;
import org.mian.gitnex.R;
import org.mian.gitnex.databinding.ActivitySettingsAppearanceBinding;
import org.mian.gitnex.fragments.SettingsFragment;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.FontsOverride;
import org.mian.gitnex.helpers.SnackBar;
import org.mian.gitnex.helpers.TinyDB;
/**
* @author M M Arif
@ -21,12 +22,12 @@ import org.mian.gitnex.helpers.TinyDB;
public class SettingsAppearanceActivity extends BaseActivity {
private static String[] customFontList;
private static int customFontSelectedChoice = 0;
private static int customFontSelectedChoice;
private static String[] themeList;
private static int themeSelectedChoice = 0;
private static int langSelectedChoice = 0;
private static int themeSelectedChoice;
private static int langSelectedChoice;
private static String[] fragmentTabsAnimationList;
private static int fragmentTabsAnimationSelectedChoice = 0;
private static int fragmentTabsAnimationSelectedChoice;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -38,7 +39,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
setContentView(activitySettingsAppearanceBinding.getRoot());
LinkedHashMap<String, String> lang = new LinkedHashMap<>();
lang.put("", getString(R.string.settingsLanguageSystem));
lang.put("sys", getString(R.string.settingsLanguageSystem));
for (String langCode : getResources().getStringArray(R.array.languages)) {
lang.put(langCode, getLanguageDisplayName(langCode));
}
@ -55,8 +56,14 @@ public class SettingsAppearanceActivity extends BaseActivity {
activitySettingsAppearanceBinding.topAppBar.setNavigationOnClickListener(v -> finish());
String lightMinute = String.valueOf(tinyDB.getInt("lightThemeTimeMinute"));
String lightHour = String.valueOf(tinyDB.getInt("lightThemeTimeHour"));
String lightMinute =
String.valueOf(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_LIGHT_MIN_KEY));
String lightHour =
String.valueOf(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_LIGHT_HOUR_KEY));
if (lightMinute.length() == 1) {
lightMinute = "0" + lightMinute;
}
@ -64,8 +71,14 @@ public class SettingsAppearanceActivity extends BaseActivity {
lightHour = "0" + lightHour;
}
String darkMinute = String.valueOf(tinyDB.getInt("darkThemeTimeMinute"));
String darkHour = String.valueOf(tinyDB.getInt("darkThemeTimeHour"));
String darkMinute =
String.valueOf(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_DARK_MIN_KEY));
String darkHour =
String.valueOf(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_DARK_HOUR_KEY));
if (darkMinute.length() == 1) {
darkMinute = "0" + darkMinute;
}
@ -73,9 +86,18 @@ public class SettingsAppearanceActivity extends BaseActivity {
darkHour = "0" + darkHour;
}
fragmentTabsAnimationSelectedChoice = tinyDB.getInt("fragmentTabsAnimationId", 0);
customFontSelectedChoice = tinyDB.getInt("customFontId", 1);
themeSelectedChoice = tinyDB.getInt("themeId", 6); // use system theme as default
fragmentTabsAnimationSelectedChoice =
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_TABS_ANIMATION_KEY));
customFontSelectedChoice =
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_FONT_KEY));
themeSelectedChoice =
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_KEY));
activitySettingsAppearanceBinding.lightThemeSelectedTime.setText(
ctx.getResources()
@ -100,12 +122,15 @@ public class SettingsAppearanceActivity extends BaseActivity {
}
activitySettingsAppearanceBinding.switchCounterBadge.setChecked(
tinyDB.getBoolean("enableCounterBadges", true));
Boolean.parseBoolean(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_COUNTER_KEY)));
// counter badge switcher
activitySettingsAppearanceBinding.switchCounterBadge.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
tinyDB.putBoolean("enableCounterBadges", isChecked);
AppDatabaseSettings.updateSettingsValue(
ctx, String.valueOf(isChecked), AppDatabaseSettings.APP_COUNTER_KEY);
SnackBar.success(
ctx,
findViewById(android.R.id.content),
@ -118,11 +143,16 @@ public class SettingsAppearanceActivity extends BaseActivity {
// show labels in lists(issues, pr) - default is color dots
activitySettingsAppearanceBinding.switchLabelsInListBadge.setChecked(
tinyDB.getBoolean("showLabelsInList", false));
Boolean.parseBoolean(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_LABELS_IN_LIST_KEY)));
activitySettingsAppearanceBinding.switchLabelsInListBadge.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
tinyDB.putBoolean("showLabelsInList", isChecked);
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(isChecked),
AppDatabaseSettings.APP_LABELS_IN_LIST_KEY);
SnackBar.success(
ctx,
findViewById(android.R.id.content),
@ -147,7 +177,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
themeSelectedChoice = i;
activitySettingsAppearanceBinding.themeSelected
.setText(themeList[i]);
tinyDB.putInt("themeId", i);
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(i),
AppDatabaseSettings.APP_THEME_KEY);
SettingsFragment.refreshParent = true;
this.recreate();
@ -182,13 +215,26 @@ public class SettingsAppearanceActivity extends BaseActivity {
customFontSelectedChoice = i;
activitySettingsAppearanceBinding.customFontSelected
.setText(customFontList[i]);
tinyDB.putInt("customFontId", i);
AppUtil.typeface = null; // reset typeface
FontsOverride.setDefaultFont(this);
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(i),
AppDatabaseSettings.APP_FONT_KEY);
new Handler()
.postDelayed(
() -> {
AppUtil.typeface =
null; // reset typeface
FontsOverride.setDefaultFont(
this);
SettingsFragment.refreshParent =
true;
this.recreate();
this.overridePendingTransition(
0, 0);
},
1000);
SettingsFragment.refreshParent = true;
this.recreate();
this.overridePendingTransition(0, 0);
dialogInterfaceCustomFont.dismiss();
SnackBar.success(
ctx,
@ -209,19 +255,20 @@ public class SettingsAppearanceActivity extends BaseActivity {
.setSingleChoiceItems(
fragmentTabsAnimationList,
fragmentTabsAnimationSelectedChoice,
(dialogInterfaceCustomFont, i) -> {
(dialogInterfaceTabsAnimation, i) -> {
fragmentTabsAnimationSelectedChoice = i;
activitySettingsAppearanceBinding
.fragmentTabsAnimationFrameSelected.setText(
fragmentTabsAnimationList[i]);
tinyDB.putInt("fragmentTabsAnimationId", i);
AppUtil.typeface = null; // reset typeface
FontsOverride.setDefaultFont(this);
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(i),
AppDatabaseSettings.APP_TABS_ANIMATION_KEY);
SettingsFragment.refreshParent = true;
this.recreate();
this.overridePendingTransition(0, 0);
dialogInterfaceCustomFont.dismiss();
dialogInterfaceTabsAnimation.dismiss();
SnackBar.success(
ctx,
findViewById(android.R.id.content),
@ -237,7 +284,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
AppUtil.openUrlInBrowser(
this, getResources().getString(R.string.crowdInLink)));
langSelectedChoice = tinyDB.getInt("langId");
String[] locale =
AppDatabaseSettings.getSettingsValue(ctx, AppDatabaseSettings.APP_LOCALE_KEY)
.split("\\|");
langSelectedChoice = Integer.parseInt(locale[0]);
activitySettingsAppearanceBinding.tvLanguageSelected.setText(
lang.get(lang.keySet().toArray(new String[0])[langSelectedChoice]));
@ -255,8 +305,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
(dialogInterface, i) -> {
String selectedLanguage =
lang.keySet().toArray(new String[0])[i];
tinyDB.putInt("langId", i);
tinyDB.putString("locale", selectedLanguage);
AppDatabaseSettings.updateSettingsValue(
ctx,
i + "|" + selectedLanguage,
AppDatabaseSettings.APP_LOCALE_KEY);
SettingsFragment.refreshParent = true;
this.overridePendingTransition(0, 0);
@ -274,18 +326,28 @@ public class SettingsAppearanceActivity extends BaseActivity {
public void lightTimePicker() {
TinyDB db = TinyDB.getInstance(ctx);
int hour = db.getInt("lightThemeTimeHour");
int minute = db.getInt("lightThemeTimeMinute");
int hour =
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_LIGHT_HOUR_KEY));
int minute =
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_LIGHT_MIN_KEY));
MaterialTimePicker materialTimePicker =
new MaterialTimePicker.Builder().setHour(hour).setMinute(minute).build();
materialTimePicker.addOnPositiveButtonClickListener(
selection -> {
db.putInt("lightThemeTimeHour", materialTimePicker.getHour());
db.putInt("lightThemeTimeMinute", materialTimePicker.getMinute());
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(materialTimePicker.getHour()),
AppDatabaseSettings.APP_THEME_AUTO_LIGHT_HOUR_KEY);
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(materialTimePicker.getMinute()),
AppDatabaseSettings.APP_THEME_AUTO_LIGHT_MIN_KEY);
SettingsFragment.refreshParent = true;
overridePendingTransition(0, 0);
SnackBar.success(
@ -300,18 +362,28 @@ public class SettingsAppearanceActivity extends BaseActivity {
public void darkTimePicker() {
TinyDB db = TinyDB.getInstance(ctx);
int hour = db.getInt("darkThemeTimeHour");
int minute = db.getInt("darkThemeTimeMinute");
int hour =
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_DARK_HOUR_KEY));
int minute =
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_THEME_AUTO_DARK_MIN_KEY));
MaterialTimePicker materialTimePicker =
new MaterialTimePicker.Builder().setHour(hour).setMinute(minute).build();
materialTimePicker.addOnPositiveButtonClickListener(
selection -> {
db.putInt("darkThemeTimeHour", materialTimePicker.getHour());
db.putInt("darkThemeTimeMinute", materialTimePicker.getMinute());
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(materialTimePicker.getHour()),
AppDatabaseSettings.APP_THEME_AUTO_DARK_HOUR_KEY);
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(materialTimePicker.getMinute()),
AppDatabaseSettings.APP_THEME_AUTO_DARK_MIN_KEY);
SettingsFragment.refreshParent = true;
overridePendingTransition(0, 0);
SnackBar.success(
@ -326,7 +398,17 @@ public class SettingsAppearanceActivity extends BaseActivity {
private static String getLanguageDisplayName(String langCode) {
Locale english = new Locale("en");
Locale translated = new Locale(langCode);
String[] multiCodeLang = langCode.split("-");
String countryCode;
if (langCode.contains("-")) {
langCode = multiCodeLang[0];
countryCode = multiCodeLang[1];
} else {
countryCode = "";
}
Locale translated = new Locale(langCode, countryCode);
return String.format(
"%s (%s)",
translated.getDisplayName(translated), translated.getDisplayName(english));

View File

@ -6,6 +6,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import org.mian.gitnex.R;
import org.mian.gitnex.databinding.ActivitySettingsCodeEditorBinding;
import org.mian.gitnex.fragments.SettingsFragment;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.SnackBar;
/**
@ -14,11 +15,11 @@ import org.mian.gitnex.helpers.SnackBar;
public class SettingsCodeEditorActivity extends BaseActivity {
private static String[] colorList;
private static int colorSelectedChoice = 0;
private static int colorSelectedChoice;
private static String[] indentationList;
private static int indentationSelectedChoice = 0;
private static int indentationSelectedChoice;
private static String[] indentationTabsList;
private static int indentationTabsSelectedChoice = 0;
private static int indentationTabsSelectedChoice;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -33,7 +34,10 @@ public class SettingsCodeEditorActivity extends BaseActivity {
// color selector dialog
colorList = getResources().getStringArray(R.array.ceColors);
colorSelectedChoice = tinyDB.getInt("ceColorId");
colorSelectedChoice =
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_CE_SYNTAX_HIGHLIGHT_KEY));
activitySettingsCodeEditorBinding.ceColorSelected.setText(colorList[colorSelectedChoice]);
activitySettingsCodeEditorBinding.ceColorSelectionFrame.setOnClickListener(
@ -48,7 +52,11 @@ public class SettingsCodeEditorActivity extends BaseActivity {
colorSelectedChoice = i;
activitySettingsCodeEditorBinding.ceColorSelected
.setText(colorList[i]);
tinyDB.putInt("ceColorId", i);
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(i),
AppDatabaseSettings
.APP_CE_SYNTAX_HIGHLIGHT_KEY);
SettingsFragment.refreshParent = true;
this.recreate();
@ -65,7 +73,10 @@ public class SettingsCodeEditorActivity extends BaseActivity {
// indentation selector dialog
indentationList = getResources().getStringArray(R.array.ceIndentation);
indentationSelectedChoice = tinyDB.getInt("ceIndentationId");
indentationSelectedChoice =
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_CE_INDENTATION_KEY));
activitySettingsCodeEditorBinding.indentationSelected.setText(
indentationList[indentationSelectedChoice]);
@ -82,7 +93,10 @@ public class SettingsCodeEditorActivity extends BaseActivity {
activitySettingsCodeEditorBinding
.indentationSelected.setText(
indentationList[i]);
tinyDB.putInt("ceIndentationId", i);
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(i),
AppDatabaseSettings.APP_CE_INDENTATION_KEY);
SettingsFragment.refreshParent = true;
this.recreate();
@ -107,7 +121,10 @@ public class SettingsCodeEditorActivity extends BaseActivity {
}
indentationTabsList = getResources().getStringArray(R.array.ceIndentationTabsWidth);
indentationTabsSelectedChoice = tinyDB.getInt("ceIndentationTabsId");
indentationTabsSelectedChoice =
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_CE_TABS_WIDTH_KEY));
activitySettingsCodeEditorBinding.indentationTabsSelected.setText(
indentationTabsList[indentationTabsSelectedChoice]);
@ -124,7 +141,10 @@ public class SettingsCodeEditorActivity extends BaseActivity {
activitySettingsCodeEditorBinding
.indentationTabsSelected.setText(
indentationTabsList[i]);
tinyDB.putInt("ceIndentationTabsId", i);
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(i),
AppDatabaseSettings.APP_CE_TABS_WIDTH_KEY);
SettingsFragment.refreshParent = true;
this.recreate();

View File

@ -7,6 +7,7 @@ import java.util.Arrays;
import java.util.List;
import org.mian.gitnex.R;
import org.mian.gitnex.databinding.ActivitySettingsGeneralBinding;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.SnackBar;
/**
@ -14,11 +15,9 @@ import org.mian.gitnex.helpers.SnackBar;
*/
public class SettingsGeneralActivity extends BaseActivity {
private static int homeScreenSelectedChoice = 0;
private static int defaultLinkHandlerScreenSelectedChoice = 0;
private static int homeScreenSelectedChoice;
private static int defaultLinkHandlerScreenSelectedChoice;
private ActivitySettingsGeneralBinding viewBinding;
private List<String> homeScreenList;
private List<String> linkHandlerDefaultScreen;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -31,73 +30,15 @@ public class SettingsGeneralActivity extends BaseActivity {
viewBinding.topAppBar.setNavigationOnClickListener(v -> finish());
// home screen
String[] appHomeDefaultScreen = getResources().getStringArray(R.array.appDefaultHomeScreen);
String[] appHomeDefaultScreenNew =
String[] appHomeDefaultScreen =
getResources().getStringArray(R.array.appDefaultHomeScreenNew);
if (getAccount().requiresVersion("1.12.3")) {
homeScreenSelectedChoice =
Integer.parseInt(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_HOME_SCREEN_KEY));
appHomeDefaultScreen = appHomeDefaultScreenNew;
}
homeScreenList = new ArrayList<>(Arrays.asList(appHomeDefaultScreen));
if (!getAccount().requiresVersion("1.14.0")) {
homeScreenList.remove(8);
}
String[] homeScreenArray = new String[homeScreenList.size()];
homeScreenList.toArray(homeScreenArray);
if (homeScreenSelectedChoice == 0) {
homeScreenSelectedChoice = tinyDB.getInt("homeScreenId", 0);
viewBinding.homeScreenSelected.setText(getResources().getString(R.string.navMyRepos));
}
if (homeScreenSelectedChoice == 1) {