upd
This commit is contained in:
parent
9abaeb4776
commit
f0cd85370f
3 changed files with 19 additions and 13 deletions
|
@ -15,6 +15,8 @@ android {
|
|||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
package cc.jerryxiao.easterscrsaver
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.drawable.Drawable
|
||||
|
@ -57,13 +56,13 @@ fun releaseIdentifiedCOLREmoji() {
|
|||
cachedDrawable.clear()
|
||||
}
|
||||
|
||||
fun Array<Bubble>.identifierCOLREmoji(activity: Activity) {
|
||||
fun Array<Bubble>.identifierCOLREmoji(context: Context) {
|
||||
val list = ArrayList<CharSequence>()
|
||||
for (bubble in this) {
|
||||
val drawable = activity.identifierEmojiDrawable(bubble.text, list)
|
||||
val drawable = context.identifierEmojiDrawable(bubble.text, list)
|
||||
if (drawable != null) {
|
||||
bubble.drawable = drawable
|
||||
bubble.text = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,18 +35,15 @@ public class EasterDream extends DreamService {
|
|||
private static String TAG = "easter_daydream";
|
||||
private Drawable wallPaperDrawable = null;
|
||||
private FrameLayout last = null;
|
||||
private boolean enabled = false;
|
||||
public void refresh() {
|
||||
final ImageView mLogo;
|
||||
final BubblesDrawable mBg;
|
||||
final FrameLayout layout = new FrameLayout(this);
|
||||
|
||||
Point size = new Point();
|
||||
getWindowManager().getDefaultDisplay().getRealSize(size);
|
||||
|
||||
final DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||
final float dp = dm.density;
|
||||
//final int minSide = Math.min(dm.widthPixels, dm.heightPixels);
|
||||
final int minSide = Math.min(size.x, size.y);
|
||||
final int minSide = Math.min(dm.widthPixels, dm.heightPixels);
|
||||
final int widgetSize = (int) (minSide * 0.75);
|
||||
|
||||
final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(widgetSize, widgetSize);
|
||||
|
@ -77,7 +74,7 @@ public class EasterDream extends DreamService {
|
|||
else {
|
||||
layout.setAlpha(0f);
|
||||
layout.setVisibility(View.VISIBLE);
|
||||
addContentView(layout, new ViewGroup.LayoutParams(size.x, size.y));
|
||||
addContentView(layout, new ViewGroup.LayoutParams(last.getWidth(), last.getHeight()));
|
||||
int animDuration = getResources().getInteger(android.R.integer.config_longAnimTime);
|
||||
animDuration = Math.max(animDuration, 1500);
|
||||
layout.animate().alpha(1f).setDuration(animDuration).setListener(null);
|
||||
|
@ -96,6 +93,11 @@ public class EasterDream extends DreamService {
|
|||
last = layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
enabled = false;
|
||||
}
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
@ -106,6 +108,8 @@ public class EasterDream extends DreamService {
|
|||
setFullscreen(true);
|
||||
// Set the dream layout
|
||||
|
||||
enabled = true;
|
||||
|
||||
WallpaperManager wallPaperManager = WallpaperManager.getInstance(this);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && wallPaperManager.isWallpaperSupported()) {
|
||||
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
|
@ -229,13 +233,14 @@ class BubblesDrawable extends Drawable {
|
|||
drawn++;
|
||||
}
|
||||
|
||||
timer.schedule(new TimerTask() {
|
||||
if (timer != null) timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
timer.cancel();
|
||||
timer.purge();
|
||||
timer = null;
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
context.refresh();
|
||||
if (context.enabled) try { context.refresh(); } catch (Exception ignored) {}
|
||||
});
|
||||
//randomize();
|
||||
//chooseEmojiSet();
|
||||
|
@ -263,7 +268,7 @@ class BubblesDrawable extends Drawable {
|
|||
}
|
||||
// support code
|
||||
if (!supportCOLR) {
|
||||
COLREmojiCompat.identifierCOLREmoji(mBubbs, null);
|
||||
COLREmojiCompat.identifierCOLREmoji(mBubbs, this.context);
|
||||
}
|
||||
invalidateSelf();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue