Skip to content

Commit

Permalink
Changed method how version code is being incremented,
Browse files Browse the repository at this point in the history
Removed some dependencies,
Hide amoled option if dark theme is disabled,
Use correct colors in the light theme
  • Loading branch information
MrBoomDeveloper committed Jun 29, 2024
1 parent 8290661 commit 865c940
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 149 deletions.
56 changes: 38 additions & 18 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ plugins {
id "kotlin-android"
}

// Edit this line every release
def releaseVersion = "1.0.5"

// Note: Please, don't edit it if you don't know what it does
def startVersionCode = 2808
def startMillis = 1719658313080

def gitCommitHash = providers.exec {
commandLine("git", "rev-parse", "--short", "HEAD")
}.standardOutput.asText.get().trim()
Expand All @@ -20,19 +23,39 @@ android {
applicationId "com.mrboomdev.awery"
targetSdk 34

/* We want to make sure that all build versions across the planet will be in sync */
var timezone = TimeZone.getTimeZone("UTC")
var calendarCurrent = Calendar.getInstance(timezone)
/* Only one version can be published per second or else horrible things will happen.
* After 70 years we'll be required to make Awery 2 because of an integer limit,
* Date receiver from the test below:
*
* 3865053756028 : 2145398250 - Mon Jun 23 15:02:36 YEKT 2092
* 3865747384956 : 2146091879 - Tue Jul 01 15:43:04 YEKT 2092
* 3866441013884 : 2146785508 - Wed Jul 09 16:23:33 YEKT 2092
* 3867134642812 : 2147479137 - Thu Jul 17 17:04:02 YEKT 2092
* 3867828271740 : -2146794530 - Fri Jul 25 17:44:31 YEKT 2092
* */
versionName "$releaseVersion-$gitCommitHash"
versionCode ((startVersionCode + ((System.currentTimeMillis() - startMillis) / 1000)) as int)

/*long i = System.currentTimeMillis()
var a = new Date(i)
while(true) {
i += (1000 * 60 * 60 * 24 * 356)
a.setTime(i)
/* Just a random date to begin with */
var calendarBegin = Calendar.getInstance(timezone)
calendarBegin.set(2024, 2, 4)
versionCode ((startVersionCode + ((i - startMillis) / 1000)) as int)
/* Only one version can be published per hour or else horrible things will happen */
var newVersionCodeTimeout = 60 * 60 * 1000
System.out.println("$i : $versionCode - ${a}")
versionName "$releaseVersion-$gitCommitHash"
versionCode (((calendarCurrent.timeInMillis - calendarBegin.timeInMillis) / newVersionCodeTimeout) as int)
if(versionCode < 0 || versionCode >= Integer.MAX_VALUE) {
throw new IllegalStateException("We've reached the end. Now Awery 2 must be released!" +
" Input: $versionCode : ${a}")
}
}*/

if(versionCode < 0 || versionCode >= Integer.MAX_VALUE) {
throw new IllegalStateException("We've reached the end. " +
"Now Awery 2 must be released! Input int: $versionCode")
}

javaCompileOptions {
annotationProcessorOptions {
Expand Down Expand Up @@ -167,19 +190,18 @@ dependencies {
annotationProcessor "androidx.room:room-compiler:$room_version"

// UI
implementation "androidx.core:core-splashscreen:1.0.1"
implementation "androidx.recyclerview:recyclerview:1.3.2"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation "com.google.android.material:material:1.12.0"
implementation "nl.joery.animatedbottombar:library:1.1.0"
implementation "com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0"
implementation "com.github.VipulOG:ebook-reader:0.1.6"
implementation "com.github.emilaleborn:PageIndicatorView:905cd4e2ab"
implementation "androidx.paging:paging-runtime-ktx:3.3.0"
implementation "com.github.skydoves:colorpickerview:2.3.0"
implementation "androidx.core:core-splashscreen:1.0.1"
implementation "com.github.skydoves:balloon:1.6.4"
implementation "nl.dionsegijn:konfetti-xml:2.0.4"
implementation "com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0"
implementation "com.rubensousa.dpadrecyclerview:dpadrecyclerview:1.3.0-alpha04"
implementation "nl.dionsegijn:konfetti-xml:2.0.4"
implementation "nl.joery.animatedbottombar:library:1.1.0"

// Markdown
for(String module_name : List.of("core", "editor", "ext-strikethrough", "html", "image", "image-glide", "linkify")) {
Expand Down Expand Up @@ -214,8 +236,6 @@ dependencies {
implementation "com.github.inorichi.injekt:injekt-core:65b0440"
implementation "org.jsoup:jsoup:1.15.4"
implementation "com.github.gpanther:java-nat-sort:natural-comparator-1.1"
implementation "com.github.tachiyomiorg:unifile:17bec43"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialization_verison"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json-okio:$kotlin_serialization_verison"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$kotlin_serialization_verison"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public Boolean getBoolean(String key, Boolean defaultValue) {
return null;
}

checkEditorExistence().putBoolean(key, defaultValue);
setValue(key, defaultValue);
saveSync();
return defaultValue;
}
Expand Down
12 changes: 4 additions & 8 deletions app/src/main/java/com/mrboomdev/awery/ui/ThemeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,7 @@ public static void apply(
return;
}

// In light mode there is no amoled theme so we need to check the current night mode
if(useOLED && (activity.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) {
activity.setTheme(getThemeRes(palette, false));
return;
}

activity.setTheme(getThemeRes(palette, useOLED));
activity.setTheme(getThemeRes(palette, useOLED && isDarkModeEnabled()));
}

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

@SuppressLint("PrivateResource")
public static int getThemeRes(@NonNull AwerySettings.ThemeColorPalette_Values theme, boolean isAmoled) {
// Amoled theme breaks some colors in a light theme.
isAmoled = isAmoled && isDarkModeEnabled();

return switch(theme) {
case RED -> isAmoled ? R.style.Theme_Awery_RedOLED : R.style.Theme_Awery_Red;
case PINK -> isAmoled ? R.style.Theme_Awery_PinkOLED : R.style.Theme_Awery_Pink;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static com.mrboomdev.awery.app.AweryLifecycle.getActivities;
import static com.mrboomdev.awery.data.settings.NicePreferences.getPrefs;
import static com.mrboomdev.awery.data.settings.NicePreferences.getSettingsMap;
import static com.mrboomdev.awery.ui.ThemeManager.isDarkModeEnabled;
import static com.mrboomdev.awery.util.NiceUtils.find;
import static com.mrboomdev.awery.util.NiceUtils.returnWith;
import static com.mrboomdev.awery.util.ui.ViewUtil.dpPx;
Expand Down Expand Up @@ -65,10 +66,15 @@ public static ConcatAdapter create(Context context) {
setBottomPadding(recycler, dpPx(24));
return recycler;
}), new SettingsAdapter(new SettingsItem() {
private final List<SettingsItem> items = List.of(
getSettingsMap().findItem(AwerySettings.USE_DARK_THEME.getKey()),
getSettingsMap().findItem(AwerySettings.USE_AMOLED_THEME.getKey())
);
private final List<SettingsItem> items = new ArrayList<>();

{
items.add(getSettingsMap().findItem(AwerySettings.USE_DARK_THEME.getKey()));

if(AwerySettings.USE_DARK_THEME.getValue()) {
items.add(getSettingsMap().findItem(AwerySettings.USE_AMOLED_THEME.getKey()));
}
}

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

if(AwerySettings.USE_DARK_THEME.getKey().equals(item.getKey())) {
ThemeManager.applyApp(context);
return;
}

for(var activity : getActivities(AppCompatActivity.class)) {
Expand All @@ -99,7 +106,7 @@ public void saveValue(SettingsItem item, Object newValue) {
@Override
public Object restoreValue(SettingsItem item) {
if(AwerySettings.USE_DARK_THEME.getKey().equals(item.getKey())) {
return getPrefs().getBoolean(item.getKey(), ThemeManager.isDarkModeEnabled());
return getPrefs().getBoolean(item.getKey(), isDarkModeEnabled());
}

// NOTE: There are only boolean settings, so we don't expect other setting types.
Expand Down
117 changes: 0 additions & 117 deletions app/src/main/java/eu/kanade/tachiyomi/util/storage/DiskUtil.kt

This file was deleted.

0 comments on commit 865c940

Please sign in to comment.