mirror of https://codeberg.org/gitnex/GitNex.git
Move settings arrays to resources (#924)
### Describe what your pull request does and which issue you’re targeting <!-- Create a new issue, if it doesn't exist yet --> Closes #920 <br><br> <!-- Make sure you are targeting the "main" branch, pull requests on release branches are only allowed for bug fixes. --> - [X] I carefully read the [contribution guidelines](https://codeberg.org/GitNex/GitNex/src/branch/main/CONTRIBUTING.md). - [X] I'm following the code standards as defined [here](https://codeberg.org/gitnex/GitNex/wiki/Code-Standards). - [X] By submitting this pull request, I permit GitNex to license my work under the [GNU General Public License v3](https://codeberg.org/GitNex/GitNex/src/branch/main/LICENSE). Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/924 Reviewed-by: opyale <opyale@noreply.codeberg.org> Reviewed-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
parent
d458d60122
commit
b97fa45b18
|
@ -19,13 +19,13 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
|
||||
private View.OnClickListener onClickListener;
|
||||
|
||||
private static final String[] timeList = {"Pretty", "Normal"};
|
||||
private static String[] timeList;
|
||||
private static int timeSelectedChoice = 0;
|
||||
|
||||
private static final String[] customFontList = {"Roboto", "Manrope", "Source Code Pro"};
|
||||
private static String[] customFontList;
|
||||
private static int customFontSelectedChoice = 0;
|
||||
|
||||
private static final String[] themeList = {"Dark", "Light", "Auto (Light / Dark)", "Retro", "Auto (Retro / Dark)", "Pitch Black"};
|
||||
private static String[] themeList;
|
||||
private static int themeSelectedChoice = 0;
|
||||
|
||||
@Override
|
||||
|
@ -48,6 +48,10 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
|
||||
SwitchMaterial counterBadgesSwitch = activitySettingsAppearanceBinding.switchCounterBadge;
|
||||
|
||||
timeList = getResources().getStringArray(R.array.timeFormats);
|
||||
customFontList = getResources().getStringArray(R.array.fonts);
|
||||
themeList = getResources().getStringArray(R.array.themes);
|
||||
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
|
@ -157,13 +161,13 @@ public class SettingsAppearanceActivity extends BaseActivity {
|
|||
tinyDB.putString("timeStr", timeList[i]);
|
||||
tinyDB.putInt("timeId", i);
|
||||
|
||||
if("Normal".equals(timeList[i])) {
|
||||
|
||||
tinyDB.putString("dateFormat", "normal");
|
||||
}
|
||||
else {
|
||||
|
||||
tinyDB.putString("dateFormat", "pretty");
|
||||
switch(i) {
|
||||
case 0:
|
||||
tinyDB.putString("dateFormat", "pretty");
|
||||
break;
|
||||
case 1:
|
||||
tinyDB.putString("dateFormat", "normal");
|
||||
break;
|
||||
}
|
||||
|
||||
dialogInterfaceTime.dismiss();
|
||||
|
|
|
@ -23,7 +23,7 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||
private List<String> homeScreenList;
|
||||
private static int homeScreenSelectedChoice = 0;
|
||||
|
||||
private List<String> defaultScreen;
|
||||
private List<String> linkHandlerDefaultScreen;
|
||||
private static int defaultLinkHandlerScreenSelectedChoice = 0;
|
||||
|
||||
@Override
|
||||
|
@ -38,20 +38,16 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||
viewBinding.close.setOnClickListener(onClickListener);
|
||||
|
||||
// home screen
|
||||
String[] homeDefaultScreen_ = {getResources().getString(R.string.pageTitleMyRepos), getResources().getString(R.string.pageTitleStarredRepos), getResources().getString(R.string.pageTitleOrganizations),
|
||||
getResources().getString(R.string.pageTitleRepositories), getResources().getString(R.string.pageTitleProfile), getResources().getString(R.string.pageTitleExplore),
|
||||
getResources().getString(R.string.titleDrafts)};
|
||||
String[] appHomeDefaultScreen = getResources().getStringArray(R.array.appDefaultHomeScreen);
|
||||
|
||||
String[] homeDefaultScreenNew = {getResources().getString(R.string.pageTitleMyRepos), getResources().getString(R.string.pageTitleStarredRepos), getResources().getString(R.string.pageTitleOrganizations),
|
||||
getResources().getString(R.string.pageTitleRepositories), getResources().getString(R.string.pageTitleProfile), getResources().getString(R.string.pageTitleExplore),
|
||||
getResources().getString(R.string.titleDrafts), getResources().getString(R.string.pageTitleNotifications)};
|
||||
String[] appHomeDefaultScreenNew = getResources().getStringArray(R.array.appDefaultHomeScreenNew);
|
||||
|
||||
if(new Version(tinyDB.getString("giteaVersion")).higherOrEqual("1.12.3")) {
|
||||
|
||||
homeDefaultScreen_ = homeDefaultScreenNew;
|
||||
appHomeDefaultScreen = appHomeDefaultScreenNew;
|
||||
}
|
||||
|
||||
homeScreenList = new ArrayList<>(Arrays.asList(homeDefaultScreen_));
|
||||
homeScreenList = new ArrayList<>(Arrays.asList(appHomeDefaultScreen));
|
||||
String[] homeScreenArray = new String[homeScreenList.size()];
|
||||
homeScreenList.toArray(homeScreenArray);
|
||||
|
||||
|
@ -113,34 +109,14 @@ public class SettingsGeneralActivity extends BaseActivity {
|
|||
// home screen
|
||||
|
||||
// link handler
|
||||
String[] defaultScreen_ = {getResources().getString(R.string.generalDeepLinkSelectedText), getResources().getString(R.string.navRepos), getResources().getString(R.string.navOrg), getResources().getString(R.string.pageTitleNotifications), getResources().getString(R.string.navExplore)};
|
||||
defaultScreen = new ArrayList<>(Arrays.asList(defaultScreen_));
|
||||
String[] linkHandlerDefaultScreenList = getResources().getStringArray(R.array.linkHandlerDefaultScreen);
|
||||
linkHandlerDefaultScreen = new ArrayList<>(Arrays.asList(linkHandlerDefaultScreenList));
|
||||
|
||||
String[] linksArray = new String[defaultScreen.size()];
|
||||
defaultScreen.toArray(linksArray);
|
||||
String[] linksArray = new String[linkHandlerDefaultScreen.size()];
|
||||
linkHandlerDefaultScreen.toArray(linksArray);
|
||||
|
||||
if(defaultLinkHandlerScreenSelectedChoice == 0) {
|
||||
|
||||
defaultLinkHandlerScreenSelectedChoice = tinyDB.getInt("defaultScreenId");
|
||||
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.generalDeepLinkSelectedText));
|
||||
}
|
||||
|
||||
if(defaultLinkHandlerScreenSelectedChoice == 1) {
|
||||
|
||||
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.navRepos));
|
||||
}
|
||||
else if(defaultLinkHandlerScreenSelectedChoice == 2) {
|
||||
|
||||
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.navOrg));
|
||||
}
|
||||
else if(defaultLinkHandlerScreenSelectedChoice == 3) {
|
||||
|
||||
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.pageTitleNotifications));
|
||||
}
|
||||
else if(defaultLinkHandlerScreenSelectedChoice == 4) {
|
||||
|
||||
viewBinding.generalDeepLinkSelected.setText(getResources().getString(R.string.navExplore));
|
||||
}
|
||||
defaultLinkHandlerScreenSelectedChoice = tinyDB.getInt("defaultScreenId");
|
||||
viewBinding.generalDeepLinkSelected.setText(linksArray[defaultLinkHandlerScreenSelectedChoice]);
|
||||
|
||||
viewBinding.setDefaultLinkHandler.setOnClickListener(setDefaultLinkHandler -> {
|
||||
|
||||
|
|
|
@ -19,4 +19,53 @@
|
|||
<item>tr</item>
|
||||
<item>uk</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="timeFormats">
|
||||
<item>@string/settingsDateTimeHeaderDefault</item>
|
||||
<item>@string/settingsDateTimeNormal</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="fonts">
|
||||
<item>Roboto</item>
|
||||
<item>Manrope</item>
|
||||
<item>Source Code Pro</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="themes">
|
||||
<item>Dark</item>
|
||||
<item>Light</item>
|
||||
<item>Auto (Light/Dark)</item>
|
||||
<item>Retro</item>
|
||||
<item>Auto (Retro/Dark)</item>
|
||||
<item>Pitch Black</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="appDefaultHomeScreen">
|
||||
<item>@string/pageTitleMyRepos</item>
|
||||
<item>@string/pageTitleStarredRepos</item>
|
||||
<item>@string/pageTitleOrganizations</item>
|
||||
<item>@string/pageTitleRepositories</item>
|
||||
<item>@string/pageTitleProfile</item>
|
||||
<item>@string/pageTitleExplore</item>
|
||||
<item>@string/titleDrafts</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="appDefaultHomeScreenNew">
|
||||
<item>@string/pageTitleMyRepos</item>
|
||||
<item>@string/pageTitleStarredRepos</item>
|
||||
<item>@string/pageTitleOrganizations</item>
|
||||
<item>@string/pageTitleRepositories</item>
|
||||
<item>@string/pageTitleProfile</item>
|
||||
<item>@string/pageTitleExplore</item>
|
||||
<item>@string/titleDrafts</item>
|
||||
<item>@string/pageTitleNotifications</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="linkHandlerDefaultScreen">
|
||||
<item>@string/generalDeepLinkSelectedText</item>
|
||||
<item>@string/navRepos</item>
|
||||
<item>@string/navOrg</item>
|
||||
<item>@string/pageTitleNotifications</item>
|
||||
<item>@string/navExplore</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
|
|
@ -233,6 +233,7 @@
|
|||
<string name="settingsLanguageSelectedHeaderDefault">English</string>
|
||||
<string name="settingsAppearanceHeader">Appearance</string>
|
||||
<string name="settingsDateTimeHeaderDefault">Pretty</string>
|
||||
<string name="settingsDateTimeNormal">Normal</string>
|
||||
<string name="settingsLanguageSelectorDialogTitle">Choose Language</string>
|
||||
<string name="settingsTimeSelectorDialogTitle">Choose Time Format</string>
|
||||
<string name="settingsHelpTranslateText">Translate GitNex via Crowdin</string>
|
||||
|
|
Loading…
Reference in New Issue