-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
152 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="StatusBarLyric.API"> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 / 初始化状态栏歌词 | ||
* <p> | ||
* 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. | ||
* </p><p> | ||
* 调用{@link #sendLyric}发送歌词, 调用{@link #stopLyric}清除(当然你的应用被杀死也会清除), 调用{@link #hasEnable}判断是否激活模块. | ||
* </p> | ||
* | ||
* @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 / 发送歌词 | ||
* <p> | ||
* 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. | ||
* </p><p> | ||
* 发送单行歌词的广播Intent, 歌词将一直停留在状态栏! 调用{@link #stopLyric}清除(当然你的应用被杀死也会清除) | ||
* </p> | ||
* | ||
* @param lyric A single line lyrics 单行歌词 | ||
*/ | ||
public void updateLyric(String lyric) { | ||
sendLyric(context, lyric, icon, serviceName, useSystemMusicActive); | ||
} | ||
|
||
/** | ||
* Whether to activate the Xposed module / 是否激活模块 | ||
* <p> | ||
* Get whether the Xposed module is activated for this software | ||
* </p><p> | ||
* 获取模块是否对本软件激活 | ||
* </p> | ||
*/ | ||
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) {} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |