diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 526b4c2..91bb3e9 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -10,6 +10,7 @@ diff --git a/API/.gitignore b/API/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/API/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/API/build.gradle b/API/build.gradle new file mode 100644 index 0000000..80bb683 --- /dev/null +++ b/API/build.gradle @@ -0,0 +1,34 @@ +plugins { + id 'com.android.library' + id 'com.github.dcendents.android-maven' +} + +android { + compileSdk 31 + + defaultConfig { + minSdk 16 + targetSdk 31 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + + implementation 'com.google.android.material:material:1.4.0' +} \ No newline at end of file diff --git a/API/consumer-rules.pro b/API/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/API/proguard-rules.pro b/API/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/API/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/API/src/main/AndroidManifest.xml b/API/src/main/AndroidManifest.xml new file mode 100644 index 0000000..2c14974 --- /dev/null +++ b/API/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/API/src/main/java/StatusBarLyric/API/StatusBarLyric.java b/API/src/main/java/StatusBarLyric/API/StatusBarLyric.java new file mode 100644 index 0000000..1ad8cc2 --- /dev/null +++ b/API/src/main/java/StatusBarLyric/API/StatusBarLyric.java @@ -0,0 +1,86 @@ +package StatusBarLyric.API; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; +import android.util.Base64; + +import java.io.ByteArrayOutputStream; + +public class StatusBarLyric { + + String icon; + Context context; + String serviceName; + boolean useSystemMusicActive; + + /** + * InitStatusBarLyric / 初始化状态栏歌词   + *

+ * Call {@link #sendLyric} to send lyrics, Call {@link #stopLyric} to clear (of course, your app will be cleared if killed), Call {@link #hasEnable} to determine whether to activate the Xposed module. + *

+ * 调用{@link #sendLyric}发送歌词, 调用{@link #stopLyric}清除(当然你的应用被杀死也会清除), 调用{@link #hasEnable}判断是否激活模块. + *

+ * + * @param context context + * @param drawable (notification) icon (you can use your music service's notification icon), Null: do not display icon, Drawable, format should be webp. 通知栏图标, null 为不显示图标, (Webp格式, Drawable) + * @param serviceName ServiceName, for example (demo.abc.Service) 服务名称, 例如 (demo.abc.Service) + * @param useSystemMusicActive detect your music service running status via system. 是否使用系统检测音乐是否播放 + */ + public StatusBarLyric(Context context, Drawable drawable, String serviceName, boolean useSystemMusicActive) { + icon = drawableToBase64(drawable); + this.context = context; + this.useSystemMusicActive = useSystemMusicActive; + this.serviceName = serviceName; + } + + /** + * SendLyric / 发送歌词   + *

+ * this function will broadcast a intent containing a single line lyrics, which would be displayed (and remained) on statusbar until you send another intent or you call {@link #stopLyric} manually or your app is killed. + *

+ * 发送单行歌词的广播Intent, 歌词将一直停留在状态栏! 调用{@link #stopLyric}清除(当然你的应用被杀死也会清除) + *

+ * + * @param lyric A single line lyrics 单行歌词 + */ + public void updateLyric(String lyric) { + sendLyric(context, lyric, icon, serviceName, useSystemMusicActive); + } + + /** + * Whether to activate the Xposed module / 是否激活模块   + *

+ * Get whether the Xposed module is activated for this software + *

+ * 获取模块是否对本软件激活 + *

+ */ + public boolean hasEnable() { + return false; + } + + /** + * StopLyric (useSystemMusicActive for 'true' No need to use) / 停止播放 (useSystemMusicActive 为 'true' 无需使用) + */ + public void stopLyric() { + stopLyric(context); + } + + protected String drawableToBase64(Drawable drawable) { + if (drawable == null) { + return ""; + } + Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + bitmap.compress(Bitmap.CompressFormat.PNG,100,baos); + byte[] bytes = baos.toByteArray(); + return Base64.encodeToString(bytes, Base64.DEFAULT); + } + + protected void sendLyric(Context context, String lyric, String icon, String serviceName, boolean useSystemMusicActive) {} + + protected void stopLyric(Context context) {} + +} diff --git a/build.gradle b/build.gradle index 887d7c7..8097d1e 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,8 @@ buildscript { maven { url 'https://www.jitpack.io' } } dependencies { - classpath "com.android.tools.build:gradle:7.0.3" + classpath 'com.android.tools.build:gradle:4.2.2' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d89f751..dc590e8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Dec 02 19:44:51 CST 2021 +#Wed Dec 08 22:11:59 CST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME