diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 4c6c3ce6..bc4e4fff 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -177,8 +177,6 @@ dependencies {
implementation("com.caverock:androidsvg-aar:1.4")
implementation("com.github.bumptech.glide:glide:$glideVersion")
implementation("com.github.bumptech.glide:okhttp3-integration:$glideVersion")
- implementation("com.github.jinatonic.confetti:confetti:1.1.2")
- implementation("com.github.MatteoBattilana:WeatherView:2.0.3")
implementation("com.google.android.material:material:1.3.0")
implementation("com.google.code.gson:gson:2.8.6")
implementation("com.takisoft.preferencex:preferencex:1.1.0")
diff --git a/app/src/main/java/name/mikanoshi/customiuizer/holidays/FlowerGenerator.java b/app/src/main/java/name/mikanoshi/customiuizer/holidays/FlowerGenerator.java
deleted file mode 100644
index b48c595b..00000000
--- a/app/src/main/java/name/mikanoshi/customiuizer/holidays/FlowerGenerator.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package name.mikanoshi.customiuizer.holidays;
-
-import android.content.Context;
-
-import com.github.jinatonic.confetti.ConfettoGenerator;
-import com.github.jinatonic.confetti.confetto.Confetto;
-import com.github.matteobattilana.weather.PrecipType;
-import com.github.matteobattilana.weather.confetti.ConfettoInfo;
-
-import java.util.Random;
-
-public class FlowerGenerator implements ConfettoGenerator {
- private final ConfettoInfo confettoInfo;
- private final Context context;
-
- public FlowerGenerator(Context ctx) {
- super();
- this.context = ctx;
- this.confettoInfo = new ConfettoInfo(PrecipType.SNOW);
- }
-
- public Confetto generateConfetto(Random random) {
- return new FlowerParticle(this.context, this.confettoInfo);
- }
-
- public final ConfettoInfo getConfettoInfo() {
- return this.confettoInfo;
- }
-}
diff --git a/app/src/main/java/name/mikanoshi/customiuizer/holidays/FlowerParticle.java b/app/src/main/java/name/mikanoshi/customiuizer/holidays/FlowerParticle.java
deleted file mode 100644
index 6e220d8a..00000000
--- a/app/src/main/java/name/mikanoshi/customiuizer/holidays/FlowerParticle.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package name.mikanoshi.customiuizer.holidays;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Matrix;
-import android.graphics.Paint;
-import android.view.Surface;
-import android.view.WindowManager;
-
-import com.github.jinatonic.confetti.confetto.Confetto;
-import com.github.matteobattilana.weather.confetti.ConfettoInfo;
-
-import java.util.Random;
-
-import org.lsposed.manager.R;
-
-@SuppressWarnings("FieldCanBeLocal")
-public class FlowerParticle extends Confetto {
- private final ConfettoInfo confettoInfo;
- private final Bitmap petal;
- private float petalScale;
- private final int[] petals = new int[]{R.drawable.confetti1, R.drawable.confetti1, R.drawable.confetti2, R.drawable.confetti2, R.drawable.confetti3, R.drawable.confetti3, R.drawable.petal};
-
- FlowerParticle(Context context, ConfettoInfo confettoInfo) {
- super();
- this.confettoInfo = confettoInfo;
- petalScale = 0.6f - (float) Math.random() * 0.15f;
- petal = BitmapFactory.decodeResource(context.getResources(), petals[new Random().nextInt(petals.length)]);
-
- int rotation = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
- if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) petalScale *= 1.5;
- }
-
- public int getHeight() {
- return 0;
- }
-
- public int getWidth() {
- return 0;
- }
-
- public void reset() {
- super.reset();
- }
-
- protected void configurePaint(Paint paint) {
- super.configurePaint(paint);
- paint.setColor(-1);
- paint.setAntiAlias(true);
- }
-
- protected void drawInternal(Canvas canvas, Matrix matrix, Paint paint, float x, float y, float rotation, float percentageAnimated) {
- switch (confettoInfo.getPrecipType()) {
- case CLEAR:
- break;
- case SNOW:
- matrix.postScale(petalScale, petalScale);
- matrix.postRotate(rotation, petal.getWidth() / 2f, petal.getHeight() / 2f);
- matrix.postTranslate(x, y);
- canvas.drawBitmap(petal, matrix, paint);
- break;
- }
- }
-
- public final ConfettoInfo getConfettoInfo() {
- return this.confettoInfo;
- }
-}
diff --git a/app/src/main/java/name/mikanoshi/customiuizer/holidays/HolidayHelper.java b/app/src/main/java/name/mikanoshi/customiuizer/holidays/HolidayHelper.java
index 40f5d3f4..c1a308aa 100644
--- a/app/src/main/java/name/mikanoshi/customiuizer/holidays/HolidayHelper.java
+++ b/app/src/main/java/name/mikanoshi/customiuizer/holidays/HolidayHelper.java
@@ -1,118 +1,48 @@
+/*
+ * This file is part of LSPosed.
+ *
+ * LSPosed is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * LSPosed is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with LSPosed. If not, see .
+ *
+ * Copyright (C) 2021 LSPosed Contributors
+ */
+
package name.mikanoshi.customiuizer.holidays;
import android.app.Activity;
-import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
-import androidx.coordinatorlayout.widget.CoordinatorLayout;
-
-import com.github.jinatonic.confetti.ConfettiManager;
-import com.github.jinatonic.confetti.ConfettoGenerator;
-import com.github.matteobattilana.weather.PrecipType;
-import com.github.matteobattilana.weather.WeatherView;
-
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Field;
-
import org.lsposed.manager.R;
-import name.mikanoshi.customiuizer.utils.GravitySensor;
+
import name.mikanoshi.customiuizer.utils.Helpers;
public class HolidayHelper {
- private static WeakReference weatherView;
- private static WeakReference angleListener;
-
- public static void setWeatherGenerator(ConfettoGenerator generator) {
- try {
- ConfettiManager manager = weatherView.get().getConfettiManager();
- Field confettoGenerator = ConfettiManager.class.getDeclaredField("confettoGenerator");
- confettoGenerator.setAccessible(true);
- confettoGenerator.set(manager, generator);
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
public static void setup(Activity activity) {
Helpers.detectHoliday();
- WeatherView view = activity.findViewById(R.id.weather_view);
ImageView header = activity.findViewById(R.id.holiday_header);
- view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
- weatherView = new WeakReference<>(view);
- GravitySensor listener = null;
if (Helpers.currentHoliday == Helpers.Holidays.NEWYEAR) {
- int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
- view.setPrecipType(PrecipType.SNOW);
- view.setSpeed(50);
- view.setEmissionRate(rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270 ? 8 : 4);
- view.setFadeOutPercent(0.75f);
- view.setAngle(0);
- CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
- lp.height = activity.getResources().getDisplayMetrics().heightPixels / (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270 ? 2 : 3);
- view.setLayoutParams(lp);
- setWeatherGenerator(new SnowGenerator(activity));
- view.resetWeather();
- view.setVisibility(View.VISIBLE);
- view.getConfettiManager().setRotationalVelocity(0, 45);
-
- listener = new GravitySensor(activity, view);
- listener.setOrientation(rotation);
- listener.setSpeed(50);
- listener.start();
-
header.setImageResource(R.drawable.newyear_header);
header.setVisibility(View.VISIBLE);
} else if (Helpers.currentHoliday == Helpers.Holidays.LUNARNEWYEAR) {
- int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
- view.setPrecipType(PrecipType.SNOW);
- view.setSpeed(35);
- view.setEmissionRate(rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270 ? 4 : 2);
- view.setFadeOutPercent(0.75f);
- view.setAngle(0);
- CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
- lp.height = activity.getResources().getDisplayMetrics().heightPixels / (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270 ? 3 : 4);
- view.setLayoutParams(lp);
- setWeatherGenerator(new FlowerGenerator(activity));
- view.resetWeather();
- view.setVisibility(View.VISIBLE);
- view.getConfettiManager().setRotationalVelocity(0, 45);
-
- listener = new GravitySensor(activity, view);
- listener.setOrientation(rotation);
- listener.setSpeed(35);
- listener.start();
-
header.setImageResource(R.drawable.lunar_newyear_header);
header.setVisibility(View.VISIBLE);
} else {
- ((ViewGroup) view.getParent()).removeView(view);
((ViewGroup) header.getParent()).removeView(header);
}
- angleListener = new WeakReference<>(listener);
}
-
- public static void onPause() {
- GravitySensor listener = angleListener.get();
- if (listener != null) listener.onPause();
- WeatherView view = weatherView.get();
- if (view != null) view.getConfettiManager().terminate();
- }
-
- public static void onResume() {
- GravitySensor listener = angleListener.get();
- if (listener != null) listener.onResume();
- WeatherView view = weatherView.get();
- if (view != null) view.getConfettiManager().animate();
- }
-
- public static void onDestroy() {
- GravitySensor listener = angleListener.get();
- if (listener != null) listener.stop();
- }
-
}
diff --git a/app/src/main/java/name/mikanoshi/customiuizer/holidays/SnowGenerator.java b/app/src/main/java/name/mikanoshi/customiuizer/holidays/SnowGenerator.java
deleted file mode 100644
index 4721d4ac..00000000
--- a/app/src/main/java/name/mikanoshi/customiuizer/holidays/SnowGenerator.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package name.mikanoshi.customiuizer.holidays;
-
-import android.content.Context;
-
-import com.github.jinatonic.confetti.ConfettoGenerator;
-import com.github.jinatonic.confetti.confetto.Confetto;
-import com.github.matteobattilana.weather.PrecipType;
-import com.github.matteobattilana.weather.confetti.ConfettoInfo;
-
-import java.util.Random;
-
-public class SnowGenerator implements ConfettoGenerator {
- private final ConfettoInfo confettoInfo;
- private final Context context;
-
- public SnowGenerator(Context ctx) {
- super();
- this.context = ctx;
- this.confettoInfo = new ConfettoInfo(PrecipType.SNOW);
- }
-
- public Confetto generateConfetto(Random random) {
- return new SnowParticle(this.context, this.confettoInfo);
- }
-
- public final ConfettoInfo getConfettoInfo() {
- return this.confettoInfo;
- }
-}
diff --git a/app/src/main/java/name/mikanoshi/customiuizer/holidays/SnowParticle.java b/app/src/main/java/name/mikanoshi/customiuizer/holidays/SnowParticle.java
deleted file mode 100644
index 626fc9c2..00000000
--- a/app/src/main/java/name/mikanoshi/customiuizer/holidays/SnowParticle.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package name.mikanoshi.customiuizer.holidays;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Matrix;
-import android.graphics.Paint;
-
-import com.github.jinatonic.confetti.confetto.Confetto;
-import com.github.matteobattilana.weather.confetti.ConfettoInfo;
-
-import org.lsposed.manager.R;
-
-public class SnowParticle extends Confetto {
- private Float prevX;
- private Float prevY;
- private final ConfettoInfo confettoInfo;
- private final Bitmap snowflake;
- private final float snowScale;
- //private float rainStretch;
-
- SnowParticle(Context context, ConfettoInfo confettoInfo) {
- super();
- this.confettoInfo = confettoInfo;
- snowScale = 0.6f - (float) Math.random() * 0.3f;
- //rainStretch = 1.5f + (float)Math.random() - 0.5f;
- snowflake = BitmapFactory.decodeResource(context.getResources(), R.drawable.snowflake);
- }
-
- public int getHeight() {
- return 0;
- }
-
- public int getWidth() {
- return 0;
- }
-
- public void reset() {
- super.reset();
- this.prevX = null;
- this.prevY = null;
- }
-
- protected void configurePaint(Paint paint) {
- super.configurePaint(paint);
- paint.setColor(-1);
- paint.setAntiAlias(true);
- }
-
- protected void drawInternal(Canvas canvas, Matrix matrix, Paint paint, float x, float y, float rotation, float percentageAnimated) {
- if (prevX == null || prevY == null) {
- prevX = x;
- prevY = y;
- }
-
- switch (confettoInfo.getPrecipType()) {
- case CLEAR:
- break;
-// case RAIN:
-// float dX = x - prevX;
-// float dY = y - prevY;
-// float x1 = prevX - dX * rainStretch;
-// float y1 = prevY - dY * rainStretch;
-// float x2 = x + dX * rainStretch;
-// float y2 = y + dY * rainStretch;
-// paint.setShader(new LinearGradient(x1, y1, x2, y2, new int[] { Color.TRANSPARENT, 0xb29aa3ad, 0xb29aa3ad, Color.TRANSPARENT }, new float[] { 0f, 0.45f, 0.55f, 1f }, Shader.TileMode.CLAMP));
-// canvas.drawLine(x1, y1, x2, y2, paint);
-// break;
- case SNOW:
- matrix.postScale(snowScale, snowScale);
- matrix.postRotate(rotation, snowflake.getWidth() / 2f, snowflake.getHeight() / 2f);
- matrix.postTranslate(x, y);
- canvas.drawBitmap(snowflake, matrix, paint);
- break;
- }
- prevX = x;
- prevY = y;
- }
-
- public final ConfettoInfo getConfettoInfo() {
- return this.confettoInfo;
- }
-}
diff --git a/app/src/main/java/name/mikanoshi/customiuizer/utils/GravitySensor.java b/app/src/main/java/name/mikanoshi/customiuizer/utils/GravitySensor.java
deleted file mode 100644
index d0f6c6e4..00000000
--- a/app/src/main/java/name/mikanoshi/customiuizer/utils/GravitySensor.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package name.mikanoshi.customiuizer.utils;
-
-import android.content.Context;
-import android.hardware.Sensor;
-import android.hardware.SensorEvent;
-import android.hardware.SensorEventListener;
-import android.hardware.SensorManager;
-import android.view.Surface;
-
-import com.github.matteobattilana.weather.WeatherView;
-
-public final class GravitySensor implements SensorEventListener {
- private final SensorManager sensorManager;
- private float[] magneticValues;
- private float[] accelerometerValues;
- private int orientation;
- private int speed;
- private boolean started;
- private final Context context;
- private final WeatherView weatherView;
-
- public GravitySensor(Context context, WeatherView weatherView) {
- super();
- this.context = context;
- this.weatherView = weatherView;
- this.sensorManager = (SensorManager) this.context.getSystemService(Context.SENSOR_SERVICE);
- }
-
- public void setOrientation(int orient) {
- this.orientation = orient;
- }
-
- public void setSpeed(int spd) {
- this.speed = spd;
- }
-
- public void onAccuracyChanged(Sensor sensor, int accuracy) {
- }
-
- public void onSensorChanged(SensorEvent event) {
- if (event == null || event.sensor == null) return;
- switch (event.sensor.getType()) {
- case 1:
- this.accelerometerValues = event.values;
- break;
- case 2:
- this.magneticValues = event.values;
- break;
- }
- if (this.magneticValues == null || this.accelerometerValues == null) return;
-
- float[] rotationMatrix = new float[9];
- SensorManager.getRotationMatrix(rotationMatrix, null, this.accelerometerValues, this.magneticValues);
- float[] remappedRotationMatrix = new float[9];
- SensorManager.remapCoordinateSystem(rotationMatrix, SensorManager.AXIS_X, SensorManager.AXIS_Z, remappedRotationMatrix);
- float[] orientationAngles = new float[3];
- SensorManager.getOrientation(remappedRotationMatrix, orientationAngles);
- //double pitch = Math.toDegrees((double)orientationAngles[1]);
- double roll = Math.toDegrees(orientationAngles[2]) + Math.random() * 20 - 10;
- if (this.orientation == Surface.ROTATION_90) roll += 90;
- else if (this.orientation == Surface.ROTATION_270) roll -= 90;
- else if (this.orientation == Surface.ROTATION_180) roll += roll > 0 ? 180 : -180;
- if (roll > 90) roll -= 180;
- else if (roll < -90) roll += 180;
- this.weatherView.setAngle((int) roll);
- this.weatherView.setSpeed(this.speed + (int) Math.round(Math.random() * 20 - 10));
- }
-
- private void registerListener() {
- this.sensorManager.registerListener(this, this.sensorManager.getDefaultSensor(1), 2);
- this.sensorManager.registerListener(this, this.sensorManager.getDefaultSensor(2), 2);
- }
-
- private void unregisterListener() {
- this.sensorManager.unregisterListener(this);
- }
-
- public final void start() {
- this.started = true;
- this.registerListener();
- }
-
- public final void stop() {
- this.started = false;
- this.unregisterListener();
- }
-
- public final void onResume() {
- if (this.started) {
- this.registerListener();
- }
- }
-
- public final void onPause() {
- this.unregisterListener();
- }
-
- public final Context getContext() {
- return this.context;
- }
-
-}
diff --git a/app/src/main/java/org/lsposed/manager/ui/activity/MainActivity.java b/app/src/main/java/org/lsposed/manager/ui/activity/MainActivity.java
index c7dc5ba0..4a4110c9 100644
--- a/app/src/main/java/org/lsposed/manager/ui/activity/MainActivity.java
+++ b/app/src/main/java/org/lsposed/manager/ui/activity/MainActivity.java
@@ -158,18 +158,5 @@ public class MainActivity extends BaseActivity {
super.onResume();
int moduleCount = ModuleUtil.getInstance().getEnabledModules().size();
binding.modulesSummary.setText(getResources().getQuantityString(R.plurals.modules_enabled_count, moduleCount, moduleCount));
- HolidayHelper.onResume();
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- HolidayHelper.onDestroy();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- HolidayHelper.onPause();
}
}
diff --git a/app/src/main/res/drawable-nodpi/confetti1.webp b/app/src/main/res/drawable-nodpi/confetti1.webp
deleted file mode 100644
index b7cc2602..00000000
Binary files a/app/src/main/res/drawable-nodpi/confetti1.webp and /dev/null differ
diff --git a/app/src/main/res/drawable-nodpi/confetti2.webp b/app/src/main/res/drawable-nodpi/confetti2.webp
deleted file mode 100644
index 38c65b36..00000000
Binary files a/app/src/main/res/drawable-nodpi/confetti2.webp and /dev/null differ
diff --git a/app/src/main/res/drawable-nodpi/confetti3.webp b/app/src/main/res/drawable-nodpi/confetti3.webp
deleted file mode 100644
index 92d91473..00000000
Binary files a/app/src/main/res/drawable-nodpi/confetti3.webp and /dev/null differ
diff --git a/app/src/main/res/drawable-nodpi/petal.webp b/app/src/main/res/drawable-nodpi/petal.webp
deleted file mode 100644
index b8221bba..00000000
Binary files a/app/src/main/res/drawable-nodpi/petal.webp and /dev/null differ
diff --git a/app/src/main/res/drawable-nodpi/snowflake.webp b/app/src/main/res/drawable-nodpi/snowflake.webp
deleted file mode 100644
index ca4ed94a..00000000
Binary files a/app/src/main/res/drawable-nodpi/snowflake.webp and /dev/null differ
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index a2559b7d..045b4204 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -28,15 +28,6 @@
app:edgeToEdge="true"
app:fitSystemWindowsInsets="start|end">
-
-