From cd5cae4ed67cfe939e2174d1c288db6f30c5958a Mon Sep 17 00:00:00 2001 From: runo280 Date: Mon, 13 Jan 2020 10:36:44 +0330 Subject: [PATCH] Add Q support --- README.md | 8 +-- app/build.gradle | 13 ++--- app/proguard-rules.pro | 3 +- app/src/main/AndroidManifest.xml | 4 +- app/src/main/assets/xposed_init | 3 +- .../github/runo280/shamsidate/LockScreen.java | 52 +++++++------------ .../shamsidate/NotificationDrawer.java | 30 +++++++++++ .../io/github/runo280/shamsidate/Utils.java | 1 - app/src/main/res/values/strings.xml | 2 +- app/src/main/res/values/styles.xml | 7 --- build.gradle | 2 +- gradle.properties | 3 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 13 files changed, 70 insertions(+), 60 deletions(-) create mode 100644 app/src/main/java/io/github/runo280/shamsidate/NotificationDrawer.java delete mode 100644 app/src/main/res/values/styles.xml diff --git a/README.md b/README.md index ba9e284..82316e5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# ShamsiDate for LineageOS 16.0 -Display Shamsi date on LockScreen & NotificationDrawer via Xposed framework +# ShamsiDate for LineageOS 16.0 & 17.0 +Display Shamsi date on LockScreen & NotificationDrawer via Xposed framework -* This project created for personal use, so LineageOS 16.0 support only +* This project created for personal use, so LineageOS 16.0 & 17.0 support only * It might works on Stock,Vanilla & Pure Android versions ## Screenshots @@ -25,7 +25,7 @@ Downlaod `apk` form [release page](https://github.com/runo280/ShamsiDate/release ## License MIT License - Copyright (c) 2018 Ruhollah Nosrati + Copyright (c) 2019 runo280 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/app/build.gradle b/app/build.gradle index 1084648..a0d2428 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,13 +1,14 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 28 + compileSdkVersion 29 + buildToolsVersion "29.0.2" defaultConfig { applicationId "io.github.runo280.shamsidate" - minSdkVersion 28 - targetSdkVersion 28 - versionCode 7 - versionName "2.0_LOS16" + minSdkVersion 26 + targetSdkVersion 29 + versionCode 8 + versionName "3.0 for Pie & Q" } Properties keystoreProperties = new Properties() @@ -52,5 +53,5 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation project(':PersianDT') compileOnly 'de.robv.android.xposed:api:82' - implementation 'androidx.legacy:legacy-support-v4:1.0.0' +// implementation 'androidx.legacy:legacy-support-v4:1.0.0' } \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index e84516e..4f83739 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -20,4 +20,5 @@ # hide the original source file name. #-renamesourcefileattribute SourceFile --keep public class io.github.runo280.shamsidate.LockScreen \ No newline at end of file +-keep public class io.github.runo280.shamsidate.LockScreen +-keep public class io.github.runo280.shamsidate.NotificationDrawer \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bf23078..88d5ab5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,14 +9,14 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher" android:supportsRtl="true" - android:theme="@style/AppTheme" + android:theme="@android:style/Theme.Light" tools:ignore="AllowBackup,GoogleAppIndexingWarning"> + android:value="ShamsiDate for Lockscreen and NotificationDrawer on LOS 16.0 & 17.0" /> diff --git a/app/src/main/assets/xposed_init b/app/src/main/assets/xposed_init index 4c264f9..7994334 100755 --- a/app/src/main/assets/xposed_init +++ b/app/src/main/assets/xposed_init @@ -1 +1,2 @@ -io.github.runo280.shamsidate.LockScreen \ No newline at end of file +io.github.runo280.shamsidate.LockScreen +io.github.runo280.shamsidate.NotificationDrawer \ No newline at end of file diff --git a/app/src/main/java/io/github/runo280/shamsidate/LockScreen.java b/app/src/main/java/io/github/runo280/shamsidate/LockScreen.java index c326089..c23fe85 100755 --- a/app/src/main/java/io/github/runo280/shamsidate/LockScreen.java +++ b/app/src/main/java/io/github/runo280/shamsidate/LockScreen.java @@ -2,13 +2,12 @@ import android.icu.text.DateFormat; import android.icu.text.DisplayContext; -import android.widget.TextView; +import android.os.Build; import java.util.Date; import java.util.Locale; import de.robv.android.xposed.IXposedHookLoadPackage; -import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XC_MethodReplacement; import de.robv.android.xposed.XposedHelpers; import de.robv.android.xposed.callbacks.XC_LoadPackage; @@ -16,43 +15,28 @@ /** * Created by runo280 */ - public class LockScreen implements IXposedHookLoadPackage { - @Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { if (!lpparam.packageName.equals("com.android.systemui")) return; - - // LockScreen - XposedHelpers.findAndHookMethod("com.android.systemui.keyguard.KeyguardSliceProvider", lpparam.classLoader, "getFormattedDate", new XC_MethodReplacement() { - @Override - protected Object replaceHookedMethod(MethodHookParam param) throws Throwable { - DateFormat dateFormat = (DateFormat) XposedHelpers.getObjectField(param.thisObject, "mDateFormat"); - String str = (String) XposedHelpers.getObjectField(param.thisObject, "mDatePattern"); - Date date = (Date) XposedHelpers.getObjectField(param.thisObject, "mCurrentTime"); - if (dateFormat == null) { - dateFormat = DateFormat.getInstanceForSkeleton(str, Locale.getDefault()); - dateFormat.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE); - } - date.setTime(System.currentTimeMillis()); - return String.format("%s %s %s", dateFormat.format(date), "◼", Utils.getPersianDateShort()); - - } - }); - - // NotificationDrawer - XposedHelpers.findAndHookMethod("com.android.systemui.statusbar.policy.DateView", lpparam.classLoader, "updateClock", new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - TextView textView = (TextView) param.thisObject; - String date = (String) XposedHelpers.getObjectField(param.thisObject, "mLastText"); - textView.setText(String.format("%s | %s", date, Utils.getPersianDateShort())); - - } - }); - - + String methodName = Build.VERSION.SDK_INT == Build.VERSION_CODES.Q ? "getFormattedDateLocked" : "getFormattedDate"; + XposedHelpers.findAndHookMethod("com.android.systemui.keyguard.KeyguardSliceProvider", + lpparam.classLoader, methodName, + new XC_MethodReplacement() { + @Override + protected Object replaceHookedMethod(MethodHookParam param) throws Throwable { + DateFormat dateFormat = (DateFormat) XposedHelpers.getObjectField(param.thisObject, "mDateFormat"); + String str = (String) XposedHelpers.getObjectField(param.thisObject, "mDatePattern"); + Date date = (Date) XposedHelpers.getObjectField(param.thisObject, "mCurrentTime"); + if (dateFormat == null) { + dateFormat = DateFormat.getInstanceForSkeleton(str, Locale.getDefault()); + dateFormat.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE); + } + date.setTime(System.currentTimeMillis()); + return String.format("%s %s %s", dateFormat.format(date), "◼", Utils.getPersianDateShort()); + } + }); } } \ No newline at end of file diff --git a/app/src/main/java/io/github/runo280/shamsidate/NotificationDrawer.java b/app/src/main/java/io/github/runo280/shamsidate/NotificationDrawer.java new file mode 100644 index 0000000..a76ea55 --- /dev/null +++ b/app/src/main/java/io/github/runo280/shamsidate/NotificationDrawer.java @@ -0,0 +1,30 @@ +package io.github.runo280.shamsidate; + +import android.widget.TextView; + +import de.robv.android.xposed.IXposedHookLoadPackage; +import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.XposedHelpers; +import de.robv.android.xposed.callbacks.XC_LoadPackage; + +/** + * Created by runo280 + */ +public class NotificationDrawer implements IXposedHookLoadPackage { + + @Override + public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { + if (!lpparam.packageName.equals("com.android.systemui")) + return; + XposedHelpers.findAndHookMethod("com.android.systemui.statusbar.policy.DateView", + lpparam.classLoader, + "updateClock", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + TextView textView = (TextView) param.thisObject; + String date = (String) XposedHelpers.getObjectField(param.thisObject, "mLastText"); + textView.setText(String.format("%s ◼ %s", date, Utils.getPersianDateShort())); + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/java/io/github/runo280/shamsidate/Utils.java b/app/src/main/java/io/github/runo280/shamsidate/Utils.java index 5617e84..0979a98 100755 --- a/app/src/main/java/io/github/runo280/shamsidate/Utils.java +++ b/app/src/main/java/io/github/runo280/shamsidate/Utils.java @@ -10,7 +10,6 @@ /** * Created by runo280 */ - class Utils { private static String getFormat(Calendar calendar) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e947b1f..6238bbc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,3 @@ - ShamsiDate for LOS16.0 + ShamsiDate diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml deleted file mode 100644 index 14fabe2..0000000 --- a/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - diff --git a/build.gradle b/build.gradle index b9634a1..fc5c8ce 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.1' + classpath 'com.android.tools.build:gradle:3.6.0-rc01' // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle.properties b/gradle.properties index 76b34c8..02c8c97 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,4 +10,5 @@ org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true \ No newline at end of file +# org.gradle.parallel=true +android.useAndroidX=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5376422..b9d2049 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip