From c75fa05c9bae685b78a993bc89b17e0b90f79632 Mon Sep 17 00:00:00 2001 From: DHD2280 Date: Mon, 22 Apr 2024 22:09:43 +0200 Subject: [PATCH] Added Weather Custom Margins Fixed Fingerprint Icon Scaling --- app/build.gradle.kts | 6 +- .../mods/lockscreen/LockscreenWeather.java | 46 ++++++++++++++-- .../dhd/oxygencustomizer/utils/Constants.java | 9 +++ .../utils/PreferenceHelper.java | 9 +++ .../hooks/systemui/lockscreen/Lockscreen.java | 55 ++++++++++++------- .../systemui/lockscreen/LockscreenClock.java | 29 +++++++++- .../statusbar/BatteryStyleManager.java | 1 - .../xposed/utils/DrawableConverter.java | 11 ---- .../xposed/views/CurrentWeatherView.java | 6 +- app/src/main/res/values/colors.xml | 2 + app/src/main/res/values/strings.xml | 43 +++++++++++---- app/src/main/res/xml/weather_settings.xml | 26 +++++++++ gradle.properties | 1 + 13 files changed, 187 insertions(+), 57 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d8e827456..f1e3fc317 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -17,8 +17,8 @@ android { applicationId = "it.dhd.oxygencustomizer" minSdk = 33 targetSdk = 34 - versionCode = 2 - versionName = "1.0.1" + versionCode = 3 + versionName = "1.0.3" setProperty("archivesBaseName", "Oxygen Customizer v$versionName") testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } @@ -146,6 +146,8 @@ dependencies { implementation("org.greenrobot:eventbus:3.3.1") implementation("com.crossbowffs.remotepreferences:remotepreferences:0.8") + + implementation("com.github.tiagohm.MarkdownView:library:0.19.0") } tasks.register("printVersionName") { diff --git a/app/src/main/java/it/dhd/oxygencustomizer/ui/fragments/mods/lockscreen/LockscreenWeather.java b/app/src/main/java/it/dhd/oxygencustomizer/ui/fragments/mods/lockscreen/LockscreenWeather.java index d90714990..cad009baf 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/ui/fragments/mods/lockscreen/LockscreenWeather.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/ui/fragments/mods/lockscreen/LockscreenWeather.java @@ -22,6 +22,7 @@ import android.content.pm.ResolveInfo; import android.graphics.drawable.Drawable; import android.location.LocationManager; +import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.provider.Settings; @@ -63,7 +64,7 @@ public class LockscreenWeather Preference.OnPreferenceChangeListener { private static final String DEFAULT_WEATHER_ICON_PACKAGE = "it.dhd.oxygencustomizer.google"; - private SharedPreferences mPrefs = PreferenceHelper.instance.mPreferences; + private SharedPreferences mPrefs; private ListPreference mProvider; private SwitchPreferenceCompat mCustomLocation; private ListPreference mUnits; @@ -119,7 +120,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { public void onResume() { super.onResume(); mWeatherClient.addObserver(this); - doLoadPreferences(); + //doLoadPreferences(); // values can be changed from outside if (mTriggerPermissionCheck) { checkLocationPermissions(true); @@ -128,6 +129,15 @@ public void onResume() { queryAndUpdateWeather(); } + private boolean hasPermissions() { + return requireContext().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) + == PackageManager.PERMISSION_GRANTED + && requireContext().checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) + == PackageManager.PERMISSION_GRANTED + && requireContext().checkSelfPermission(Manifest.permission.ACCESS_BACKGROUND_LOCATION) + == PackageManager.PERMISSION_GRANTED; + } + ActivityResultLauncher mCustomLocationLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { if (result.getResultCode() == Activity.RESULT_OK) { @@ -145,11 +155,12 @@ public void onResume() { }); private void checkLocationPermissions(boolean force) { - if (getContext().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) + Log.d("LockscreenWeather", "checking location permissions"); + if (requireContext().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED - || getContext().checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) + || requireContext().checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED || - getContext().checkSelfPermission(Manifest.permission.ACCESS_BACKGROUND_LOCATION) + requireContext().checkSelfPermission(Manifest.permission.ACCESS_BACKGROUND_LOCATION) != PackageManager.PERMISSION_GRANTED) { requestPermissionLauncher.launch(new String[]{ Manifest.permission.ACCESS_FINE_LOCATION, @@ -205,6 +216,20 @@ private void showDialog() { dialog.show(); } + private void showPermissionDialog() { + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext()); + builder.setTitle(R.string.weather_permission_dialog_title); + builder.setMessage(R.string.weather_permission_dialog_message); + builder.setCancelable(false); + builder.setPositiveButton(android.R.string.ok, (dialog, which) -> { + Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + Uri uri = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null); + intent.setData(uri); + startActivity(intent); + }); + builder.show(); + } + private void disableService() { // stop any pending WeatherUpdateService.cancelAllUpdate(getContext()); @@ -222,6 +247,14 @@ public void onPause() { public void doLoadPreferences() { + if (mPrefs == null) { + if (PreferenceHelper.instance != null) { + mPrefs = PreferenceHelper.instance.mPreferences; + } else { + mPrefs = getContext().createDeviceProtectedStorageContext().getSharedPreferences(BuildConfig.APPLICATION_ID + "_preferences", Context.MODE_PRIVATE); + } + } + final PreferenceScreen prefScreen = getPreferenceScreen(); mEnable = findPreference(LOCKSCREEN_WEATHER_SWITCH); if (mEnable != null) { @@ -405,6 +438,9 @@ public boolean onPreferenceChange(@NonNull Preference preference, Object newValu if (preference == mEnable) { Config.setEnabled(getContext(), (Boolean) newValue); if ((Boolean) newValue) { + if (!hasPermissions()) { + showPermissionDialog(); + } enableService(); if (!mCustomLocation.isChecked()) { checkLocationEnabledInitial(); diff --git a/app/src/main/java/it/dhd/oxygencustomizer/utils/Constants.java b/app/src/main/java/it/dhd/oxygencustomizer/utils/Constants.java index f930f9ba5..93b44708e 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/utils/Constants.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/utils/Constants.java @@ -430,6 +430,9 @@ public static class LockscreenWeather { public static final String LOCKSCREEN_WEATHER_WIND = "weather_show_wind"; public static final String LOCKSCREEN_WEATHER_CUSTOM_COLOR_SWITCH = "weather_custom_color_switch"; public static final String LOCKSCREEN_WEATHER_CUSTOM_COLOR = "weather_custom_color"; + public static final String LOCKSCREEN_WEATHER_CUSTOM_MARGINS = "weather_custom_margins"; + public static final String LOCKSCREEN_WEATHER_CUSTOM_MARGIN_LEFT = "weather_margin_left"; + public static final String LOCKSCREEN_WEATHER_CUSTOM_MARGIN_TOP = "weather_margin_top"; public static final String[] LOCKSCREEN_WEATHER_PREFS = { LOCKSCREEN_WEATHER_SWITCH, @@ -449,6 +452,12 @@ public static class LockscreenWeather { LOCKSCREEN_WEATHER_CUSTOM_COLOR }; + public static final String[] LOCKSCREEN_WEATHER_MARGINS = { + LOCKSCREEN_WEATHER_CUSTOM_MARGINS, + LOCKSCREEN_WEATHER_CUSTOM_MARGIN_LEFT, + LOCKSCREEN_WEATHER_CUSTOM_MARGIN_TOP + }; + } public static final class SoundPrefs { diff --git a/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java b/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java index ed65abf88..0cb07ad60 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java @@ -4,6 +4,9 @@ import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_CUSTOM_COLOR; import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_CUSTOM_COLOR_SWITCH; import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_CUSTOM_LOCATION; +import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_CUSTOM_MARGINS; +import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_CUSTOM_MARGIN_LEFT; +import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_CUSTOM_MARGIN_TOP; import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_HUMIDITY; import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_ICON_PACK; import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_IMAGE_SIZE; @@ -364,6 +367,10 @@ public static boolean isVisible(String key) { return instance.mPreferences.getBoolean(LOCKSCREEN_WEATHER_SWITCH, false) && instance.mPreferences.getBoolean(LOCKSCREEN_WEATHER_CUSTOM_COLOR_SWITCH, false); } + case LOCKSCREEN_WEATHER_CUSTOM_MARGIN_TOP, + LOCKSCREEN_WEATHER_CUSTOM_MARGIN_LEFT -> { + return instance.mPreferences.getBoolean(LOCKSCREEN_WEATHER_CUSTOM_MARGINS, false); + } // Volume Panel Customization case "volume_panel_seekbar_link_primary" -> { @@ -545,6 +552,8 @@ public static String getSummary(Context fragmentCompat, @NonNull String key) { // Lockscreen Weather case LOCKSCREEN_WEATHER_IMAGE_SIZE -> instance.mPreferences.getSliderInt(LOCKSCREEN_WEATHER_IMAGE_SIZE, 18) + "dp"; case LOCKSCREEN_WEATHER_TEXT_SIZE -> instance.mPreferences.getSliderInt(LOCKSCREEN_WEATHER_TEXT_SIZE, 16) + "sp"; + case LOCKSCREEN_WEATHER_CUSTOM_MARGIN_TOP -> instance.mPreferences.getSliderInt(LOCKSCREEN_WEATHER_CUSTOM_MARGIN_TOP, 0) + "dp"; + case LOCKSCREEN_WEATHER_CUSTOM_MARGIN_LEFT -> instance.mPreferences.getSliderInt(LOCKSCREEN_WEATHER_CUSTOM_MARGIN_LEFT, 0) + "dp"; // Sound Prefs case "volume_dialog_timeout" -> instance.mPreferences.getSliderInt("volume_dialog_timeout", 3) + " s"; diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/lockscreen/Lockscreen.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/lockscreen/Lockscreen.java index 8cb8e1c78..f96360ae4 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/lockscreen/Lockscreen.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/lockscreen/Lockscreen.java @@ -21,6 +21,7 @@ import android.graphics.ImageDecoder; import android.graphics.drawable.AnimatedImageDrawable; import android.graphics.drawable.Drawable; +import android.os.Build; import android.os.Environment; import androidx.core.content.res.ResourcesCompat; @@ -49,6 +50,7 @@ public class Lockscreen extends XposedMods { private int fingerprintStyle = 0; private Object mFpIcon; private float mFpScale = 1.0f; + private Drawable mFpDrawable = null; public Lockscreen(Context context) { super(context); @@ -62,6 +64,15 @@ public void updatePrefs(String... Key) { customFingerprint = Xprefs.getBoolean(LOCKSCREEN_CUSTOM_FINGERPRINT, false); fingerprintStyle = Integer.parseInt(Xprefs.getString(LOCKSCREEN_FINGERPRINT_STYLE, "0")); mFpScale = Xprefs.getSliderFloat(LOCKSCREEN_FINGERPRINT_SCALING, 1.0f); + + if (Key.length > 0) { + if (Key[0].equals(LOCKSCREEN_FINGERPRINT_STYLE) + || Key[0].equals(LOCKSCREEN_CUSTOM_FINGERPRINT) + || Key[0].equals(LOCKSCREEN_HIDE_FINGERPRINT) + || Key[0].equals(LOCKSCREEN_FINGERPRINT_SCALING)) { + updateDrawable(); + } + } } private boolean isMethodSecure() { @@ -149,38 +160,42 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { private void updateFingerprintIcon(XC_MethodHook.MethodHookParam param, boolean isStartMethod) { if (mFpIcon == null) mFpIcon = getObjectField(param.thisObject, "mFpIcon"); - log(TAG + "updateFingerprintIcon"); - AtomicReference d = new AtomicReference<>(null); + if (BuildConfig.DEBUG) log(TAG + "updateFingerprintIcon"); + + if (mFpDrawable == null) { + setObjectField(param.thisObject, "mFadeInAnimDrawable", null); + setObjectField(param.thisObject, "mFadeOutAnimDrawable", null); + } + setObjectField(param.thisObject, "mImMobileDrawable", mFpDrawable); + if (mFpIcon != null) { + callMethod(mFpIcon, "setImageDrawable", mFpDrawable == null ? null : mFpDrawable); + } + if (hideFingerprint && isStartMethod) { + param.setResult(null); + } + //if (!isStartMethod) callMethod(param.thisObject, "updateFpIconColor"); + } + + private void updateDrawable() { if (customFingerprint) { if (fingerprintStyle != -1) { @SuppressLint("DiscouragedApi") int resId = ResourceManager.modRes.getIdentifier("fingerprint_" + fingerprintStyle,"drawable", BuildConfig.APPLICATION_ID); - d.set(ResourcesCompat.getDrawable(ResourceManager.modRes, + mFpDrawable = (ResourcesCompat.getDrawable(ResourceManager.modRes, resId, mContext.getTheme())); } else { try { ImageDecoder.Source source = ImageDecoder.createSource(new File(Environment.getExternalStorageDirectory() + "/.oxygen_customizer/lockscreen_fp_icon.png")); - d.set(ImageDecoder.decodeDrawable(source)); - if (d.get() instanceof AnimatedImageDrawable) { - ((AnimatedImageDrawable) d.get()).setRepeatCount(AnimatedImageDrawable.REPEAT_INFINITE); - ((AnimatedImageDrawable) d.get()).start(); + mFpDrawable = ImageDecoder.decodeDrawable(source); + if (mFpDrawable instanceof AnimatedImageDrawable) { + ((AnimatedImageDrawable) mFpDrawable).setRepeatCount(AnimatedImageDrawable.REPEAT_INFINITE); + ((AnimatedImageDrawable) mFpDrawable).start(); } } catch (Throwable ignored) {} } + } else { + mFpDrawable = null; } - if (d.get() == null) { - setObjectField(param.thisObject, "mFadeInAnimDrawable", null); - setObjectField(param.thisObject, "mFadeOutAnimDrawable", null); - } - //Drawable scaled = (Drawable) scaleDrawable(mContext, d.get(), mFpScale); - setObjectField(param.thisObject, "mImMobileDrawable", d.get()); - if (mFpIcon != null) { - callMethod(mFpIcon, "setImageDrawable", d.get() == null ? null : d.get()); - } - if (hideFingerprint && isStartMethod) { - param.setResult(null); - } - //if (!isStartMethod) callMethod(param.thisObject, "updateFpIconColor"); } @Override diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/lockscreen/LockscreenClock.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/lockscreen/LockscreenClock.java index ffffa9724..9fbd3e566 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/lockscreen/LockscreenClock.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/lockscreen/LockscreenClock.java @@ -10,8 +10,12 @@ import static it.dhd.oxygencustomizer.utils.Constants.LOCKSCREEN_CLOCK_LAYOUT; import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_CUSTOM_COLOR; import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_CUSTOM_COLOR_SWITCH; +import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_CUSTOM_MARGINS; +import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_CUSTOM_MARGIN_LEFT; +import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_CUSTOM_MARGIN_TOP; import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_HUMIDITY; import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_IMAGE_SIZE; +import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_MARGINS; import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_PREFS; import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_SHOW_CONDITION; import static it.dhd.oxygencustomizer.utils.Constants.LockscreenWeather.LOCKSCREEN_WEATHER_SHOW_LOCATION; @@ -41,6 +45,7 @@ import static it.dhd.oxygencustomizer.xposed.hooks.systemui.OpUtils.getPrimaryColor; import static it.dhd.oxygencustomizer.xposed.utils.ViewHelper.dp2px; import static it.dhd.oxygencustomizer.xposed.utils.ViewHelper.loadLottieAnimationView; +import static it.dhd.oxygencustomizer.xposed.utils.ViewHelper.setMargins; import android.annotation.SuppressLint; import android.app.ActivityManager; @@ -69,6 +74,7 @@ import android.text.SpannableString; import android.text.format.DateFormat; import android.text.style.ForegroundColorSpan; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -135,6 +141,8 @@ public class LockscreenClock extends XposedMods { private boolean weatherCustomColor = false; private int weatherColor = Color.WHITE; private int weatherStartPadding = 0, weatherTextSize = 16, weatherImageSize = 18; + private boolean mCustomMargins = false; + private int mLeftMargin = 0, mTopMargin = 0; private final BroadcastReceiver mBatteryReceiver = new BroadcastReceiver() { @Override @@ -203,6 +211,9 @@ public void updatePrefs(String... Key) { weatherShowWind = Xprefs.getBoolean(LOCKSCREEN_WEATHER_WIND, true); weatherCustomColor = Xprefs.getBoolean(LOCKSCREEN_WEATHER_CUSTOM_COLOR_SWITCH, false); weatherColor = Xprefs.getInt(LOCKSCREEN_WEATHER_CUSTOM_COLOR, Color.WHITE); + mCustomMargins = Xprefs.getBoolean(LOCKSCREEN_WEATHER_CUSTOM_MARGINS, false); + mLeftMargin = Xprefs.getSliderInt(LOCKSCREEN_WEATHER_CUSTOM_MARGIN_LEFT, 0); + mTopMargin = Xprefs.getSliderInt(LOCKSCREEN_WEATHER_CUSTOM_MARGIN_TOP, 0); if (Key.length > 0) { for(String LCPrefs : LOCKSCREEN_CLOCK_PREFS) { @@ -217,6 +228,9 @@ public void updatePrefs(String... Key) { for(String LCWeatherPref : LOCKSCREEN_WEATHER_PREFS) { if (Key[0].equals(LCWeatherPref)) updateWeatherView(); } + for(String LCWeatherMargins : LOCKSCREEN_WEATHER_MARGINS) { + if (Key[0].equals(LCWeatherMargins)) updateMargins(CurrentWeatherView.getInstance()); + } } } @@ -243,7 +257,6 @@ protected void afterHookedMethod(MethodHookParam param) { mClockView = KeyguardStatusView.findViewById(mContext.getResources().getIdentifier("keyguard_clock_container", "id", mContext.getPackageName())); - mMediaHostContainer = (View) getObjectField(param.thisObject, "mMediaHostContainer"); @@ -466,7 +479,7 @@ private void modifyClockView(View clockView) { typeface = Typeface.createFromFile(new File(customFont)); } - ViewHelper.setMargins(clockView, mContext, 0, topMargin, 0, bottomMargin); + setMargins(clockView, mContext, 0, topMargin, 0, bottomMargin); ViewHelper.findViewWithTagAndChangeColor(clockView, "accent1", customColor ? accent1 : systemAccent); ViewHelper.findViewWithTagAndChangeColor(clockView, "accent2", customColor ? accent2 : systemAccent); @@ -668,13 +681,23 @@ private void placeWeatherView() { ((ViewGroup) currentWeatherView.getParent()).removeView(currentWeatherView); } catch (Throwable ignored) { } - currentWeatherView.setPadding(weatherStartPadding, 0, 0, 0); mClockViewContainer.addView(currentWeatherView); refreshWeatherView(currentWeatherView); + updateMargins(currentWeatherView); } catch (Throwable ignored) { } } + private void updateMargins(CurrentWeatherView weatherView) { + if (weatherView == null) return; + if (mCustomMargins) { + weatherView.setPadding(dp2px(mContext, mLeftMargin), dp2px(mContext, mTopMargin), 0, 0); + } else { + weatherView.setPadding(weatherStartPadding, 0, 0, 0); + } + + } + private void refreshWeatherView(CurrentWeatherView currentWeatherView) { if (currentWeatherView == null) return; CurrentWeatherView.updateSizes(weatherTextSize, weatherImageSize); diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/BatteryStyleManager.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/BatteryStyleManager.java index 6851a099a..be90b1e09 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/BatteryStyleManager.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/BatteryStyleManager.java @@ -414,7 +414,6 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { progress.setProgress(0); progress.setVisibility(View.GONE); } else { - batteryPercentOutView.setVisibility(View.VISIBLE); if (customizePercSize) { batteryPercentOutView.setTextSize(TypedValue.COMPLEX_UNIT_SP, mBatteryPercSize); } diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/DrawableConverter.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/DrawableConverter.java index ad86228bf..29d5961e2 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/DrawableConverter.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/DrawableConverter.java @@ -273,25 +273,14 @@ public static int findContrastColor(int color, int other, boolean findFg, double } public static BitmapDrawable scaleDrawable(Context context, Drawable drawable, float scale) { - // Ottieni le dimensioni originali del Drawable int width = drawable.getIntrinsicWidth(); int height = drawable.getIntrinsicHeight(); - - // Calcola le nuove dimensioni scalate int newWidth = (int) (width * scale); int newHeight = (int) (height * scale); - - // Crea una Bitmap vuota con le nuove dimensioni Bitmap scaledBitmap = Bitmap.createBitmap(newWidth, newHeight, Bitmap.Config.ARGB_8888); - - // Crea un Canvas per disegnare la Bitmap scalata Canvas canvas = new Canvas(scaledBitmap); - - // Disegna il Drawable scalato sulla Bitmap drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); - - // Ritorna il Drawable scalato come BitmapDrawable return new BitmapDrawable(context.getResources(), scaledBitmap); } diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/views/CurrentWeatherView.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/views/CurrentWeatherView.java index ddb0634c9..db2ac72fa 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/views/CurrentWeatherView.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/views/CurrentWeatherView.java @@ -263,9 +263,9 @@ private void queryAndUpdateWeather() { mCurrentImage.setImageDrawable(d); mRightText.setText(mWeatherInfo.temp + " " + mWeatherInfo.tempUnits); mLeftText.setText(mWeatherInfo.city); - mLeftText.setVisibility(View.VISIBLE); + mLeftText.setVisibility(mShowWeatherLocation ? View.VISIBLE : View.GONE); mWeatherText.setText(" · " + formattedCondition); - mWeatherText.setVisibility(View.VISIBLE); + mWeatherText.setVisibility(mShowWeatherText ? View.VISIBLE : View.GONE); mHumImage.setImageDrawable(mHumDrawable); mHumText.setText(mWeatherInfo.humidity); @@ -284,7 +284,7 @@ private void queryAndUpdateWeather() { public static void updateWeatherSettings(boolean showLocation, boolean showText, boolean showHumidity, boolean showWind) { - log(TAG + "updateWeatherSettings " + (instance!=null)); + if (BuildConfig.DEBUG) log(TAG + "updateWeatherSettings " + (instance!=null)); instance.mShowWeatherLocation = showLocation; instance.mShowWeatherText = showText; instance.mShowWeatherHumidity = showHumidity; diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 475f6a632..29e1df72f 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -82,4 +82,6 @@ #FFFFFF #000000 + #2F3B49 + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 93fa4dd62..8d3b31e3c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -636,20 +636,8 @@ Hide in Lockscreen Show entry in Settings - - Sensor block per-package - Block access to certain sensors for some apps to save battery - Block sensors for these apps - Add apps for Sensor block - Significant motion, accelerometer, linear acceleration sensors will be blocked for these apps - Delete - Remove selected item? - Choose app - Enable - Hooks - Reboot pending Connected packages Package responsive Package not enabled in LSposed @@ -664,6 +652,31 @@ Launch app Restart app + + In addition to the normal text, dynamic variables are also available, like Date, Data usage and Temperature:\n\n$G\<format\> : Gregorian date, based on format*\n$P<format> : Persian date, based on format*\n$Nrx : Total Downloads in specified period ** ***\n$Ntx: Total Uploads in specified period ** ***\n$Nall : Total Traffic in specified period ** ***\n$Nssid : WiFi SSID name (if applicable)\n\n$T\<format\>[interval] : Temperature; \nformat can be b (for battery), c (for CPU), g (for GPU) and s (for skin) \nLastly, there is OPTIONAL number of update interval in seconds (default: 60 seconds)\n\n*for format documentation, search for "Java Date Format"\n**You can specify the statistics period in PixelXpert/Miscellaneous menu/Network Statistics Settings\n***If you replace $N with $Nc you will get with mobile data statistics (e.g. $Ncrx instead of Nrx) + Updates + Update downloaded + Tap here to install + Failed to download the update + Please try again later + Update channel + Stable + Canary + Package Type + Full + Xposed Only + Installed version: + Latest version: + ROOT ACCESS NOT GRANTED! + Reboot pending + Reboot device now + Checking… + Downloading - Please tap on the notification once completed + Update + Switch branch + Reinstall + Changelog + Advanced Reboot Advanced Reboot Authentication @@ -756,6 +769,12 @@ Theme Select location Search for a location + Custom Margins + Top margin + Center Layout + Left Margin + Enable Location Permissions + Location permissions are required to fetch weather data. Click OK to open Settings. Cloudy diff --git a/app/src/main/res/xml/weather_settings.xml b/app/src/main/res/xml/weather_settings.xml index bd71990f4..028cbc303 100644 --- a/app/src/main/res/xml/weather_settings.xml +++ b/app/src/main/res/xml/weather_settings.xml @@ -159,4 +159,30 @@ android:title="@string/weather_icon_pack_title" android:dependency="lockscreen_weather_enabled" /> + + + + + + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 745a9ed07..4d1feab4a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,6 +15,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # Android operating system, and which are packaged with your app's APK # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true +android.enableJetifier=true # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library