Skip to content

ghhccghk/HyperFocusApi

Repository files navigation

GitHub License

注:澎湃 OS 对于焦点通知有白名单应用限制,使用前请先安装无视白名单的 XP 模块。

小米官方开发指南

使用方法

1. 项目 Gradle 添加 JitPack 依赖

allprojects {
    repositories {
        // ...
        maven { url 'https://jitpack.io' }
    }
}

or

allprojects {
    repositories {
        // ...
        maven("https://jitpack.io")
    }
}

2. 要使用的模块下添加 HyperFocusApi 依赖

dependencies {
    // ...
    implementation 'com.github.ghhccghk:HyperFocusApi:<VERSION>'
}

or

dependencies {
    // ...
    implementation("com.github.ghhccghk:HyperFocusApi:<VERSION>")
}

3.如何在代码下使用

//代码还需要补充
import com.hyperfocus.api.FocusApi

val sendNotification = NotificationHelper.sendNotification("你好", "世界")
val intent = Intent()
intent.action = "android.settings.APPLICATION_DETAILS_SETTINGS"  // 设置 Action,跳转到应用详情页
intent.data = Uri.fromParts("package", this.packageName, null)  // 指定要打开的应用包名
val actions = FocusApi.ActionInfo(actionsIntent = intent, actionsTitle = "test")
val baseInfo = FocusApi.baseinfo(title = "title", colorTitle = "#FFFFFF",
    basetype = 1, content = "content", colorContent = "#FFFFFF", subContent = "subContent",
    colorSubContent = "#FFFFFF", extraTitle = "extraTitle", colorExtraTitle = "#FFFFFF",
    subTitle = "subTitle", colorsubTitle = "#FFFFFF",
    specialTitle = "special", colorSpecialTitle = "#FFFFFF",)
val hintInfo = FocusApi.HintInfo(type = 1 ,titleLineCount = 6,title = "这是Hint里的title", colortitle = "#FFFFFF" , content = "content",  colorContent = "#FFFFFF", actionInfo = actions)
val api = FocusApi.sendFocus(
    title = "测试",
    baseInfo = baseInfo,
    hintInfo = hintInfo,
    picbg = Icon.createWithResource(this,R.drawable.lycaon_bg_2),
    picmarkv2 = Icon.createWithResource(this,R.drawable.wdlyjz),
    picbgtype = 2,
    picmarkv2type = 2,
    builder = sendNotification,
    ticker = "ticker测试",
    picticker = Icon.createWithResource(this,R.drawable.ic_launcher_foreground)
)
sendNotification.addExtras(api)
NotificationManagerCompat.from(this).notify(1, sendNotification.build())

看完不会写可以看看这个! demo

Star History

Star History Chart

Thanks

About

小米HyperFocus API库

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •