2020-04-26 15:36:33 +02:00
|
|
|
package org.mian.gitnex.activities;
|
|
|
|
|
2021-08-02 18:59:30 +02:00
|
|
|
import android.app.Dialog;
|
|
|
|
import android.app.TimePickerDialog;
|
2020-04-26 15:36:33 +02:00
|
|
|
import android.os.Bundle;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.LinearLayout;
|
2021-08-02 18:59:30 +02:00
|
|
|
import android.widget.TimePicker;
|
2022-02-09 21:06:13 +01:00
|
|
|
import androidx.annotation.NonNull;
|
2020-04-26 15:36:33 +02:00
|
|
|
import androidx.appcompat.app.AlertDialog;
|
2021-08-02 18:59:30 +02:00
|
|
|
import androidx.fragment.app.DialogFragment;
|
2020-10-29 14:13:19 +01:00
|
|
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
2020-04-26 15:36:33 +02:00
|
|
|
import org.mian.gitnex.R;
|
2021-01-26 16:10:31 +01:00
|
|
|
import org.mian.gitnex.databinding.ActivitySettingsAppearanceBinding;
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
import org.mian.gitnex.fragments.SettingsFragment;
|
2021-08-02 18:59:30 +02:00
|
|
|
import org.mian.gitnex.helpers.TinyDB;
|
2020-04-26 15:36:33 +02:00
|
|
|
import org.mian.gitnex.helpers.Toasty;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Author M M Arif
|
|
|
|
*/
|
|
|
|
|
|
|
|
public class SettingsAppearanceActivity extends BaseActivity {
|
|
|
|
|
|
|
|
private View.OnClickListener onClickListener;
|
|
|
|
|
2021-06-05 16:07:05 +02:00
|
|
|
private static String[] timeList;
|
2020-04-26 15:36:33 +02:00
|
|
|
private static int timeSelectedChoice = 0;
|
|
|
|
|
2021-06-05 16:07:05 +02:00
|
|
|
private static String[] customFontList;
|
2020-04-26 15:36:33 +02:00
|
|
|
private static int customFontSelectedChoice = 0;
|
|
|
|
|
2021-06-05 16:07:05 +02:00
|
|
|
private static String[] themeList;
|
2020-04-26 15:36:33 +02:00
|
|
|
private static int themeSelectedChoice = 0;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
2021-01-26 16:10:31 +01:00
|
|
|
ActivitySettingsAppearanceBinding activitySettingsAppearanceBinding = ActivitySettingsAppearanceBinding.inflate(getLayoutInflater());
|
2021-01-26 18:43:25 +01:00
|
|
|
setContentView(activitySettingsAppearanceBinding.getRoot());
|
2020-04-26 15:36:33 +02:00
|
|
|
|
2021-01-26 16:10:31 +01:00
|
|
|
ImageView closeActivity = activitySettingsAppearanceBinding.close;
|
2020-04-26 15:36:33 +02:00
|
|
|
|
2021-01-26 16:10:31 +01:00
|
|
|
LinearLayout timeFrame = activitySettingsAppearanceBinding.timeFrame;
|
|
|
|
LinearLayout customFontFrame = activitySettingsAppearanceBinding.customFontFrame;
|
|
|
|
LinearLayout themeFrame = activitySettingsAppearanceBinding.themeSelectionFrame;
|
2021-08-02 18:59:30 +02:00
|
|
|
LinearLayout lightTimeFrame = activitySettingsAppearanceBinding.lightThemeTimeSelectionFrame;
|
|
|
|
LinearLayout darkTimeFrame = activitySettingsAppearanceBinding.darkThemeTimeSelectionFrame;
|
2021-01-26 16:10:31 +01:00
|
|
|
|
|
|
|
SwitchMaterial counterBadgesSwitch = activitySettingsAppearanceBinding.switchCounterBadge;
|
2020-04-26 15:36:33 +02:00
|
|
|
|
2021-06-05 16:07:05 +02:00
|
|
|
timeList = getResources().getStringArray(R.array.timeFormats);
|
|
|
|
customFontList = getResources().getStringArray(R.array.fonts);
|
|
|
|
themeList = getResources().getStringArray(R.array.themes);
|
|
|
|
|
2020-04-26 15:36:33 +02:00
|
|
|
initCloseListener();
|
|
|
|
closeActivity.setOnClickListener(onClickListener);
|
|
|
|
|
2021-08-02 18:59:30 +02:00
|
|
|
String lightMinute = String.valueOf(tinyDB.getInt("lightThemeTimeMinute"));
|
|
|
|
String lightHour = String.valueOf(tinyDB.getInt("lightThemeTimeHour"));
|
|
|
|
if(lightMinute.length() == 1) lightMinute = "0" + lightMinute;
|
|
|
|
if(lightHour.length() == 1) lightHour = "0" + lightHour;
|
|
|
|
|
|
|
|
String darkMinute = String.valueOf(tinyDB.getInt("darkThemeTimeMinute"));
|
|
|
|
String darkHour = String.valueOf(tinyDB.getInt("darkThemeTimeHour"));
|
|
|
|
if(darkMinute.length() == 1) darkMinute = "0" + darkMinute;
|
|
|
|
if(darkHour.length() == 1) darkHour = "0" + darkHour;
|
|
|
|
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
timeSelectedChoice = tinyDB.getInt("timeId");
|
|
|
|
customFontSelectedChoice = tinyDB.getInt("customFontId", 1);
|
2022-03-27 20:47:08 +02:00
|
|
|
themeSelectedChoice = tinyDB.getInt("themeId", 6); // use system theme as default
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
|
2021-08-02 18:59:30 +02:00
|
|
|
activitySettingsAppearanceBinding.lightThemeSelectedTime.setText(ctx.getResources().getString(R.string.settingsThemeTimeSelectedHint, lightHour,
|
|
|
|
lightMinute));
|
|
|
|
activitySettingsAppearanceBinding.darkThemeSelectedTime.setText(ctx.getResources().getString(R.string.settingsThemeTimeSelectedHint, darkHour,
|
|
|
|
darkMinute));
|
2022-03-27 20:47:08 +02:00
|
|
|
activitySettingsAppearanceBinding.tvDateTimeSelected.setText(timeList[timeSelectedChoice]);
|
2021-08-02 18:59:30 +02:00
|
|
|
activitySettingsAppearanceBinding.customFontSelected.setText(tinyDB.getString("customFontStr", "Manrope"));
|
2022-03-27 20:47:08 +02:00
|
|
|
activitySettingsAppearanceBinding.themeSelected.setText(themeList[themeSelectedChoice]);
|
2021-08-02 18:59:30 +02:00
|
|
|
|
2022-03-27 20:47:08 +02:00
|
|
|
if(themeList[themeSelectedChoice].startsWith("Auto")) {
|
2021-08-02 18:59:30 +02:00
|
|
|
darkTimeFrame.setVisibility(View.VISIBLE);
|
|
|
|
lightTimeFrame.setVisibility(View.VISIBLE);
|
2020-04-26 15:36:33 +02:00
|
|
|
}
|
2021-08-02 18:59:30 +02:00
|
|
|
else {
|
|
|
|
darkTimeFrame.setVisibility(View.GONE);
|
|
|
|
lightTimeFrame.setVisibility(View.GONE);
|
2020-04-26 15:36:33 +02:00
|
|
|
}
|
|
|
|
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
counterBadgesSwitch.setChecked(tinyDB.getBoolean("enableCounterBadges", true));
|
2020-04-26 15:36:33 +02:00
|
|
|
|
|
|
|
// counter badge switcher
|
|
|
|
counterBadgesSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
|
|
|
|
2020-11-02 16:17:00 +01:00
|
|
|
tinyDB.putBoolean("enableCounterBadges", isChecked);
|
2020-10-29 14:13:19 +01:00
|
|
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
2020-04-26 15:36:33 +02:00
|
|
|
});
|
2021-12-17 20:56:12 +01:00
|
|
|
activitySettingsAppearanceBinding.counterBadgeFrame.setOnClickListener(v -> counterBadgesSwitch.setChecked(!counterBadgesSwitch.isChecked()));
|
2020-04-26 15:36:33 +02:00
|
|
|
|
2022-03-28 19:57:47 +02:00
|
|
|
// show labels in lists(issues, pr) - default is color dots
|
|
|
|
activitySettingsAppearanceBinding.switchLabelsInListBadge.setChecked(tinyDB.getBoolean("showLabelsInList", false));
|
|
|
|
|
|
|
|
activitySettingsAppearanceBinding.switchLabelsInListBadge.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
|
|
|
|
|
|
|
tinyDB.putBoolean("showLabelsInList", isChecked);
|
|
|
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
|
|
|
});
|
|
|
|
activitySettingsAppearanceBinding.labelsInListFrame.setOnClickListener(v -> activitySettingsAppearanceBinding.switchLabelsInListBadge.setChecked(!activitySettingsAppearanceBinding.switchLabelsInListBadge.isChecked()));
|
|
|
|
|
2020-04-26 15:36:33 +02:00
|
|
|
// theme selection dialog
|
|
|
|
themeFrame.setOnClickListener(view -> {
|
|
|
|
|
|
|
|
AlertDialog.Builder tsBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
|
|
|
|
|
|
|
|
tsBuilder.setTitle(getResources().getString(R.string.themeSelectorDialogTitle));
|
2020-10-29 14:13:19 +01:00
|
|
|
tsBuilder.setCancelable(themeSelectedChoice != -1);
|
2020-04-26 15:36:33 +02:00
|
|
|
|
|
|
|
tsBuilder.setSingleChoiceItems(themeList, themeSelectedChoice, (dialogInterfaceTheme, i) -> {
|
|
|
|
|
|
|
|
themeSelectedChoice = i;
|
2021-08-02 18:59:30 +02:00
|
|
|
activitySettingsAppearanceBinding.themeSelected.setText(themeList[i]);
|
2020-11-02 16:17:00 +01:00
|
|
|
tinyDB.putInt("themeId", i);
|
2020-04-26 15:36:33 +02:00
|
|
|
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
SettingsFragment.refreshParent = true;
|
2020-04-26 15:36:33 +02:00
|
|
|
this.recreate();
|
|
|
|
this.overridePendingTransition(0, 0);
|
|
|
|
dialogInterfaceTheme.dismiss();
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
2020-04-26 15:36:33 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
AlertDialog cfDialog = tsBuilder.create();
|
|
|
|
cfDialog.show();
|
|
|
|
});
|
|
|
|
|
2021-08-02 18:59:30 +02:00
|
|
|
lightTimeFrame.setOnClickListener(view -> {
|
|
|
|
LightTimePicker timePicker = new LightTimePicker();
|
|
|
|
timePicker.show(getSupportFragmentManager(), "timePicker");
|
|
|
|
});
|
|
|
|
|
|
|
|
darkTimeFrame.setOnClickListener(view -> {
|
|
|
|
DarkTimePicker timePicker = new DarkTimePicker();
|
|
|
|
timePicker.show(getSupportFragmentManager(), "timePicker");
|
|
|
|
});
|
|
|
|
|
2020-04-26 15:36:33 +02:00
|
|
|
// custom font dialog
|
|
|
|
customFontFrame.setOnClickListener(view -> {
|
|
|
|
|
|
|
|
AlertDialog.Builder cfBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
|
|
|
|
|
|
|
|
cfBuilder.setTitle(R.string.settingsCustomFontSelectorDialogTitle);
|
2020-10-29 14:13:19 +01:00
|
|
|
cfBuilder.setCancelable(customFontSelectedChoice != -1);
|
2020-04-26 15:36:33 +02:00
|
|
|
|
|
|
|
cfBuilder.setSingleChoiceItems(customFontList, customFontSelectedChoice, (dialogInterfaceCustomFont, i) -> {
|
|
|
|
|
|
|
|
customFontSelectedChoice = i;
|
2021-08-02 18:59:30 +02:00
|
|
|
activitySettingsAppearanceBinding.customFontSelected.setText(customFontList[i]);
|
2020-11-02 16:17:00 +01:00
|
|
|
tinyDB.putString("customFontStr", customFontList[i]);
|
|
|
|
tinyDB.putInt("customFontId", i);
|
2020-04-26 15:36:33 +02:00
|
|
|
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
SettingsFragment.refreshParent = true;
|
2020-04-26 15:36:33 +02:00
|
|
|
this.recreate();
|
|
|
|
this.overridePendingTransition(0, 0);
|
|
|
|
dialogInterfaceCustomFont.dismiss();
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.success(appCtx, appCtx.getResources().getString(R.string.settingsSave));
|
2020-04-26 15:36:33 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
AlertDialog cfDialog = cfBuilder.create();
|
|
|
|
cfDialog.show();
|
|
|
|
});
|
|
|
|
|
|
|
|
// time and date dialog
|
|
|
|
timeFrame.setOnClickListener(view -> {
|
|
|
|
|
|
|
|
AlertDialog.Builder tBuilder = new AlertDialog.Builder(SettingsAppearanceActivity.this);
|
|
|
|
|
|
|
|
tBuilder.setTitle(R.string.settingsTimeSelectorDialogTitle);
|
2020-10-29 14:13:19 +01:00
|
|
|
tBuilder.setCancelable(timeSelectedChoice != -1);
|
2020-04-26 15:36:33 +02:00
|
|
|
|
|
|
|
tBuilder.setSingleChoiceItems(timeList, timeSelectedChoice, (dialogInterfaceTime, i) -> {
|
|
|
|
|
|
|
|
timeSelectedChoice = i;
|
2021-08-02 18:59:30 +02:00
|
|
|
activitySettingsAppearanceBinding.tvDateTimeSelected.setText(timeList[i]);
|
2020-11-02 16:17:00 +01:00
|
|
|
tinyDB.putString("timeStr", timeList[i]);
|
|
|
|
tinyDB.putInt("timeId", i);
|
2020-04-26 15:36:33 +02:00
|
|
|
|
2021-06-05 16:07:05 +02:00
|
|
|
switch(i) {
|
|
|
|
case 0:
|
|
|
|
tinyDB.putString("dateFormat", "pretty");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
tinyDB.putString("dateFormat", "normal");
|
|
|
|
break;
|
2020-04-26 15:36:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dialogInterfaceTime.dismiss();
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
2020-04-26 15:36:33 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
AlertDialog tDialog = tBuilder.create();
|
|
|
|
tDialog.show();
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void initCloseListener() {
|
2020-08-06 17:16:51 +02:00
|
|
|
onClickListener = view -> finish();
|
2020-04-26 15:36:33 +02:00
|
|
|
}
|
|
|
|
|
2021-08-02 18:59:30 +02:00
|
|
|
public static class LightTimePicker extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
|
|
|
|
|
|
|
|
TinyDB db = TinyDB.getInstance(getContext());
|
|
|
|
|
2022-02-09 21:06:13 +01:00
|
|
|
@NonNull
|
2021-08-02 18:59:30 +02:00
|
|
|
@Override
|
|
|
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
|
|
int hour = db.getInt("lightThemeTimeHour");
|
|
|
|
int minute = db.getInt("lightThemeTimeMinute");
|
|
|
|
|
|
|
|
return new TimePickerDialog(getActivity(), this, hour, minute, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
|
|
|
db.putInt("lightThemeTimeHour", hourOfDay);
|
|
|
|
db.putInt("lightThemeTimeMinute", minute);
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
SettingsFragment.refreshParent = true;
|
2021-08-02 18:59:30 +02:00
|
|
|
requireActivity().overridePendingTransition(0, 0);
|
|
|
|
this.dismiss();
|
|
|
|
Toasty.success(requireActivity().getApplicationContext(), requireContext().getResources().getString(R.string.settingsSave));
|
|
|
|
requireActivity().recreate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class DarkTimePicker extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
|
|
|
|
|
|
|
|
TinyDB db = TinyDB.getInstance(getContext());
|
|
|
|
|
2022-02-09 21:06:13 +01:00
|
|
|
@NonNull
|
2021-08-02 18:59:30 +02:00
|
|
|
@Override
|
|
|
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
|
|
int hour = db.getInt("darkThemeTimeHour");
|
|
|
|
int minute = db.getInt("darkThemeTimeMinute");
|
|
|
|
|
|
|
|
return new TimePickerDialog(getActivity(), this, hour, minute, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
|
|
|
db.putInt("darkThemeTimeHour", hourOfDay);
|
|
|
|
db.putInt("darkThemeTimeMinute", minute);
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
SettingsFragment.refreshParent = true;
|
2021-08-02 18:59:30 +02:00
|
|
|
requireActivity().overridePendingTransition(0, 0);
|
|
|
|
this.dismiss();
|
|
|
|
Toasty.success(requireActivity().getApplicationContext(), requireContext().getResources().getString(R.string.settingsSave));
|
|
|
|
requireActivity().recreate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-26 15:36:33 +02:00
|
|
|
}
|