Skip to content

Commit

Permalink
初始化Maven
Browse files Browse the repository at this point in the history
  • Loading branch information
577fkj committed Dec 8, 2021
1 parent 07ae84a commit 15edbb5
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 3 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions API/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
34 changes: 34 additions & 0 deletions API/build.gradle
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 added API/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions API/proguard-rules.pro
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
5 changes: 5 additions & 0 deletions API/src/main/AndroidManifest.xml
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>
86 changes: 86 additions & 0 deletions API/src/main/java/StatusBarLyric/API/StatusBarLyric.java
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 / 初始化状态栏歌词 &nbsp;
* <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 / 发送歌词 &nbsp;
* <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 / 是否激活模块 &nbsp;
* <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) {}

}
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
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

0 comments on commit 15edbb5

Please sign in to comment.