Skip to content

Commit 865c940

Browse files
Changed method how version code is being incremented,
Removed some dependencies, Hide amoled option if dark theme is disabled, Use correct colors in the light theme
1 parent 8290661 commit 865c940

File tree

5 files changed

+55
-149
lines changed

5 files changed

+55
-149
lines changed

app/build.gradle

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ plugins {
55
id "kotlin-android"
66
}
77

8-
// Edit this line every release
98
def releaseVersion = "1.0.5"
109

10+
// Note: Please, don't edit it if you don't know what it does
11+
def startVersionCode = 2808
12+
def startMillis = 1719658313080
13+
1114
def gitCommitHash = providers.exec {
1215
commandLine("git", "rev-parse", "--short", "HEAD")
1316
}.standardOutput.asText.get().trim()
@@ -20,19 +23,39 @@ android {
2023
applicationId "com.mrboomdev.awery"
2124
targetSdk 34
2225

23-
/* We want to make sure that all build versions across the planet will be in sync */
24-
var timezone = TimeZone.getTimeZone("UTC")
25-
var calendarCurrent = Calendar.getInstance(timezone)
26+
/* Only one version can be published per second or else horrible things will happen.
27+
* After 70 years we'll be required to make Awery 2 because of an integer limit,
28+
* Date receiver from the test below:
29+
*
30+
* 3865053756028 : 2145398250 - Mon Jun 23 15:02:36 YEKT 2092
31+
* 3865747384956 : 2146091879 - Tue Jul 01 15:43:04 YEKT 2092
32+
* 3866441013884 : 2146785508 - Wed Jul 09 16:23:33 YEKT 2092
33+
* 3867134642812 : 2147479137 - Thu Jul 17 17:04:02 YEKT 2092
34+
* 3867828271740 : -2146794530 - Fri Jul 25 17:44:31 YEKT 2092
35+
* */
36+
versionName "$releaseVersion-$gitCommitHash"
37+
versionCode ((startVersionCode + ((System.currentTimeMillis() - startMillis) / 1000)) as int)
38+
39+
/*long i = System.currentTimeMillis()
40+
var a = new Date(i)
41+
while(true) {
42+
i += (1000 * 60 * 60 * 24 * 356)
43+
a.setTime(i)
2644
27-
/* Just a random date to begin with */
28-
var calendarBegin = Calendar.getInstance(timezone)
29-
calendarBegin.set(2024, 2, 4)
45+
versionCode ((startVersionCode + ((i - startMillis) / 1000)) as int)
3046
31-
/* Only one version can be published per hour or else horrible things will happen */
32-
var newVersionCodeTimeout = 60 * 60 * 1000
47+
System.out.println("$i : $versionCode - ${a}")
3348
34-
versionName "$releaseVersion-$gitCommitHash"
35-
versionCode (((calendarCurrent.timeInMillis - calendarBegin.timeInMillis) / newVersionCodeTimeout) as int)
49+
if(versionCode < 0 || versionCode >= Integer.MAX_VALUE) {
50+
throw new IllegalStateException("We've reached the end. Now Awery 2 must be released!" +
51+
" Input: $versionCode : ${a}")
52+
}
53+
}*/
54+
55+
if(versionCode < 0 || versionCode >= Integer.MAX_VALUE) {
56+
throw new IllegalStateException("We've reached the end. " +
57+
"Now Awery 2 must be released! Input int: $versionCode")
58+
}
3659

3760
javaCompileOptions {
3861
annotationProcessorOptions {
@@ -167,19 +190,18 @@ dependencies {
167190
annotationProcessor "androidx.room:room-compiler:$room_version"
168191

169192
// UI
193+
implementation "androidx.core:core-splashscreen:1.0.1"
170194
implementation "androidx.recyclerview:recyclerview:1.3.2"
171195
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
172196
implementation "com.google.android.material:material:1.12.0"
173-
implementation "nl.joery.animatedbottombar:library:1.1.0"
174-
implementation "com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0"
175197
implementation "com.github.VipulOG:ebook-reader:0.1.6"
176198
implementation "com.github.emilaleborn:PageIndicatorView:905cd4e2ab"
177-
implementation "androidx.paging:paging-runtime-ktx:3.3.0"
178199
implementation "com.github.skydoves:colorpickerview:2.3.0"
179-
implementation "androidx.core:core-splashscreen:1.0.1"
180200
implementation "com.github.skydoves:balloon:1.6.4"
181-
implementation "nl.dionsegijn:konfetti-xml:2.0.4"
201+
implementation "com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0"
182202
implementation "com.rubensousa.dpadrecyclerview:dpadrecyclerview:1.3.0-alpha04"
203+
implementation "nl.dionsegijn:konfetti-xml:2.0.4"
204+
implementation "nl.joery.animatedbottombar:library:1.1.0"
183205

184206
// Markdown
185207
for(String module_name : List.of("core", "editor", "ext-strikethrough", "html", "image", "image-glide", "linkify")) {
@@ -214,8 +236,6 @@ dependencies {
214236
implementation "com.github.inorichi.injekt:injekt-core:65b0440"
215237
implementation "org.jsoup:jsoup:1.15.4"
216238
implementation "com.github.gpanther:java-nat-sort:natural-comparator-1.1"
217-
implementation "com.github.tachiyomiorg:unifile:17bec43"
218-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
219239
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialization_verison"
220240
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json-okio:$kotlin_serialization_verison"
221241
implementation "org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$kotlin_serialization_verison"

app/src/main/java/com/mrboomdev/awery/data/settings/NicePreferences.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public Boolean getBoolean(String key, Boolean defaultValue) {
9494
return null;
9595
}
9696

97-
checkEditorExistence().putBoolean(key, defaultValue);
97+
setValue(key, defaultValue);
9898
saveSync();
9999
return defaultValue;
100100
}

app/src/main/java/com/mrboomdev/awery/ui/ThemeManager.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,7 @@ public static void apply(
7777
return;
7878
}
7979

80-
// In light mode there is no amoled theme so we need to check the current night mode
81-
if(useOLED && (activity.getResources().getConfiguration().uiMode
82-
& Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) {
83-
activity.setTheme(getThemeRes(palette, false));
84-
return;
85-
}
86-
87-
activity.setTheme(getThemeRes(palette, useOLED));
80+
activity.setTheme(getThemeRes(palette, useOLED && isDarkModeEnabled()));
8881
}
8982

9083
public static void apply(Activity activity) {
@@ -107,6 +100,9 @@ private static void applyMaterialYou(Activity activity, Bitmap bitmap, boolean u
107100

108101
@SuppressLint("PrivateResource")
109102
public static int getThemeRes(@NonNull AwerySettings.ThemeColorPalette_Values theme, boolean isAmoled) {
103+
// Amoled theme breaks some colors in a light theme.
104+
isAmoled = isAmoled && isDarkModeEnabled();
105+
110106
return switch(theme) {
111107
case RED -> isAmoled ? R.style.Theme_Awery_RedOLED : R.style.Theme_Awery_Red;
112108
case PINK -> isAmoled ? R.style.Theme_Awery_PinkOLED : R.style.Theme_Awery_Pink;

app/src/main/java/com/mrboomdev/awery/ui/activity/setup/SetupThemeAdapter.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static com.mrboomdev.awery.app.AweryLifecycle.getActivities;
66
import static com.mrboomdev.awery.data.settings.NicePreferences.getPrefs;
77
import static com.mrboomdev.awery.data.settings.NicePreferences.getSettingsMap;
8+
import static com.mrboomdev.awery.ui.ThemeManager.isDarkModeEnabled;
89
import static com.mrboomdev.awery.util.NiceUtils.find;
910
import static com.mrboomdev.awery.util.NiceUtils.returnWith;
1011
import static com.mrboomdev.awery.util.ui.ViewUtil.dpPx;
@@ -65,10 +66,15 @@ public static ConcatAdapter create(Context context) {
6566
setBottomPadding(recycler, dpPx(24));
6667
return recycler;
6768
}), new SettingsAdapter(new SettingsItem() {
68-
private final List<SettingsItem> items = List.of(
69-
getSettingsMap().findItem(AwerySettings.USE_DARK_THEME.getKey()),
70-
getSettingsMap().findItem(AwerySettings.USE_AMOLED_THEME.getKey())
71-
);
69+
private final List<SettingsItem> items = new ArrayList<>();
70+
71+
{
72+
items.add(getSettingsMap().findItem(AwerySettings.USE_DARK_THEME.getKey()));
73+
74+
if(AwerySettings.USE_DARK_THEME.getValue()) {
75+
items.add(getSettingsMap().findItem(AwerySettings.USE_AMOLED_THEME.getKey()));
76+
}
77+
}
7278

7379
@Override
7480
public List<? extends SettingsItem> getItems() {
@@ -89,6 +95,7 @@ public void saveValue(SettingsItem item, Object newValue) {
8995

9096
if(AwerySettings.USE_DARK_THEME.getKey().equals(item.getKey())) {
9197
ThemeManager.applyApp(context);
98+
return;
9299
}
93100

94101
for(var activity : getActivities(AppCompatActivity.class)) {
@@ -99,7 +106,7 @@ public void saveValue(SettingsItem item, Object newValue) {
99106
@Override
100107
public Object restoreValue(SettingsItem item) {
101108
if(AwerySettings.USE_DARK_THEME.getKey().equals(item.getKey())) {
102-
return getPrefs().getBoolean(item.getKey(), ThemeManager.isDarkModeEnabled());
109+
return getPrefs().getBoolean(item.getKey(), isDarkModeEnabled());
103110
}
104111

105112
// NOTE: There are only boolean settings, so we don't expect other setting types.

app/src/main/java/eu/kanade/tachiyomi/util/storage/DiskUtil.kt

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)