Skip to content

Commit

Permalink
Upgrade to SplashScreen. Update dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarsamurmu committed Jan 20, 2024
1 parent 155ddea commit 9e4de21
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 12 deletions.
9 changes: 5 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
android:networkSecurityConfig="@xml/network_config"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/CandyBar.Theme.App.DayNight"
android:theme="@style/Theme.App.Starting"
tools:targetApi="n">

<activity
<!--<activity
android:name=".activities.SplashActivity"
android:launchMode="singleTop"
android:noHistory="true"
Expand All @@ -40,17 +40,18 @@
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
</activity>-->

<activity
android:name=".activities.MainActivity"
android:launchMode="singleTop"
android:exported="true"
android:theme="@style/CandyBar.Theme.App.DayNight"
android:theme="@style/Theme.App.Starting"
android:configChanges="uiMode|orientation|keyboardHidden|screenSize">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file removed app/src/main/res/drawable/ic_splash_screen.png
Binary file not shown.
4 changes: 4 additions & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="splashColor">#222222</color>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Splash Screen -->
<color name="splashColor">#FFF</color>
<!-- Shortcut Icons -->
<color name="shortcutIconBackground">#26C484</color>
<color name="shortcutIconForeground">#FFF</color>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.1.1'
classpath 'com.android.tools.build:gradle:8.2.1'
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
13 changes: 7 additions & 6 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,22 @@ android {
dependencies {
implementation project(':extLibs:PreLollipopTransitions')

api 'androidx.annotation:annotation:1.5.0'
api 'androidx.appcompat:appcompat:1.5.1'
api 'androidx.annotation:annotation:1.7.1'
api 'androidx.appcompat:appcompat:1.6.1'
api 'com.google.android.apps.muzei:muzei-api:3.4.0'
api 'com.android.billingclient:billing:6.0.1'
api 'com.android.billingclient:billing:6.1.0'
api 'dev.jahir.KustomAPI:api:6369c37'
api 'dev.jahir.KustomAPI:preset:6369c37'

implementation 'androidx.work:work-runtime:2.8.1'
implementation 'androidx.recyclerview:recyclerview:1.3.0'
implementation 'androidx.work:work-runtime:2.9.0'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.palette:palette:1.0.0'
// implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.android.material:material:1.11.0-alpha03'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.viewpager2:viewpager2:1.0.0'
implementation 'com.google.android.play:review:2.0.1'
implementation 'androidx.core:core-splashscreen:1.0.1'

implementation 'com.bluelinelabs:logansquare:1.3.7'
annotationProcessor 'com.bluelinelabs:logansquare-compiler:1.3.7'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
import candybar.lib.services.CandyBarService;
import candybar.lib.tasks.IconRequestTask;
import candybar.lib.tasks.IconsLoaderTask;
import candybar.lib.tasks.WallpaperThumbPreloaderTask;
import candybar.lib.utils.CandyBarGlideModule;
import candybar.lib.utils.Extras;
import candybar.lib.utils.InAppBillingClient;
Expand Down Expand Up @@ -259,6 +260,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
}

checkWallpapers();
new WallpaperThumbPreloaderTask(this).execute();
new IconRequestTask(this).executeOnThreadPool();
new IconsLoaderTask(this).execute();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package candybar.lib.tasks;

import android.content.Context;
import android.util.Log;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.danimahardhika.android.helpers.core.utils.LogUtil;

import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Map;

import candybar.lib.applications.CandyBarApplication;
import candybar.lib.helpers.JsonHelper;
import candybar.lib.helpers.WallpaperHelper;
import candybar.lib.utils.AsyncTaskBase;
import candybar.lib.utils.ImageConfig;

public class WallpaperThumbPreloaderTask extends AsyncTaskBase {

private final WeakReference<Context> context;

public WallpaperThumbPreloaderTask(@NonNull Context context) {
this.context = new WeakReference<>(context);
}

@Override
protected boolean run() {
if (!isCancelled()) {
try {
Thread.sleep(1);

if (WallpaperHelper.getWallpaperType(context.get()) != WallpaperHelper.CLOUD_WALLPAPERS)
return true;

InputStream stream = WallpaperHelper.getJSONStream(context.get());

if (stream != null) {
List<?> list = JsonHelper.parseList(stream);
if (list == null) {
LogUtil.e("Json error, no array with name: "
+ CandyBarApplication.getConfiguration().getWallpaperJsonStructure().getArrayName());
return false;
}

if (list.size() > 0 && list.get(0) instanceof Map) {
Map<?, ?> map = (Map<?, ?>) list.get(0);
String thumbUrl = JsonHelper.getThumbUrl(map);

// Preload the first wallpaper's thumbnail
// It should show up immediately without any delay on first run
// so that the intro popup works correctly
if (context.get() != null) {
Glide.with(context.get())
.load(thumbUrl)
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.override(ImageConfig.getThumbnailSize())
.preload();
}
}
}
return true;
} catch (Exception e) {
LogUtil.e(Log.getStackTraceString(e));
return false;
}
}
return false;
}
}
1 change: 1 addition & 0 deletions library/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
android:background="?cb_mainBackground"
tools:openDrawer="start">

<include
Expand Down
2 changes: 2 additions & 0 deletions library/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Splash Screen -->
<color name="splashColor">#FFF</color>
<!-- Shortcut Icons -->
<color name="shortcutIconBackground">#26C484</color>
<color name="shortcutIconForeground">#FFF</color>
Expand Down
16 changes: 16 additions & 0 deletions library/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,22 @@
<item name="android:windowBackground">@drawable/splash_screen</item>
</style>

<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<!-- Set the splash screen background, animated icon, and animation
duration. -->
<item name="windowSplashScreenBackground">@color/splashColor</item>

<!-- Use windowSplashScreenAnimatedIcon to add a drawable or an animated
drawable. One of these is required. -->
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_splash_screen</item>
<!-- Required for animated icons. -->
<item name="windowSplashScreenAnimationDuration">200</item>

<!-- Set the theme of the Activity that directly follows your splash
screen. This is required. -->
<item name="postSplashScreenTheme">@style/CandyBar.Theme.App.DayNight</item>
</style>

<style name="CandyBar.Theme.Wallpaper" parent="CandyBar.Theme.App.DayNight">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
Expand Down

0 comments on commit 9e4de21

Please sign in to comment.