Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
Add Q support
Browse files Browse the repository at this point in the history
  • Loading branch information
runo280 committed Jan 13, 2020
1 parent 13dc4df commit cd5cae4
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 60 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
13 changes: 7 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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'
}
3 changes: 2 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-keep public class io.github.runo280.shamsidate.LockScreen
-keep public class io.github.runo280.shamsidate.LockScreen
-keep public class io.github.runo280.shamsidate.NotificationDrawer
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<meta-data
android:name="xposedmodule"
android:value="true" />
<meta-data
android:name="xposeddescription"
android:value="ShamsiDate for Lockscreen and NotificationDrawer on LOS 16.0" />
android:value="ShamsiDate for Lockscreen and NotificationDrawer on LOS 16.0 &amp; 17.0" />
<meta-data
android:name="xposedminversion"
android:value="89" />
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/assets/xposed_init
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
io.github.runo280.shamsidate.LockScreen
io.github.runo280.shamsidate.LockScreen
io.github.runo280.shamsidate.NotificationDrawer
52 changes: 18 additions & 34 deletions app/src/main/java/io/github/runo280/shamsidate/LockScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,41 @@

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;

/**
* 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());
}
});
}
}
Original file line number Diff line number Diff line change
@@ -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()));
}
});
}
}
1 change: 0 additions & 1 deletion app/src/main/java/io/github/runo280/shamsidate/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
/**
* Created by runo280
*/

class Utils {

private static String getFormat(Calendar calendar) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<resources>
<string name="app_name">ShamsiDate for LOS16.0</string>
<string name="app_name">ShamsiDate</string>
</resources>
7 changes: 0 additions & 7 deletions app/src/main/res/values/styles.xml

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
# org.gradle.parallel=true
android.useAndroidX=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cd5cae4

Please sign in to comment.