WhatsNew - 自动展示更新日志的提示库

WhatsNew
项目地址: https://github.com/TonnyL/Wha...

图片描述

当用户更新 App 后, WhatsNew 会自动展示一条简短的更新日志. 灵感来自 WhatsNew.

下载

Gradle

  • 将 JitPack 仓库添加到你的根 build.gradle 文件中:
repositories {
    maven { url "https://jitpack.io" }
}
  • 将下面的代码添加至 module 中的 build.gradle 文件中:
dependencies {
    implementation 'io.github.tonnyl:whatsnew:x.y.z'
}

Maven

<dependency>
  <groupId>io.github.tonnyl</groupId>
  <artifactId>whatsnew</artifactId>
  <version>x.y.z</version>
  <type>pom</type>
</dependency>

用法

基础

Kotlin:

WhatsNew.newInstance(
    WhatsNewItem("Nice Icons", "Completely customize colors, texts and icons.", R.drawable.ic_heart),
    WhatsNewItem("Such Easy", "Setting this up only takes 2 lines of code, impressive you say?", R.drawable.ic_thumb_up),
    WhatsNewItem("Very Sleep", "It helps you get more sleep by writing less code.", R.drawable.ic_satisfied_face),
    WhatsNewItem("Text Only", "No icons? Just go with plain text.")
).presentAutomatically(this@MainActivity)

或者是 DSL 风格的代码:

val whatsnew = whatsNew {
    item {
        title = "Nice Icons"
        content = "Completely customize colors, texts and icons."
        imageRes = R.drawable.ic_heart
    }
    item {
        title = "Such Easy"
        content = "Setting this up only takes 2 lines of code, impressive you say?"
        imageRes = R.drawable.ic_thumb_up
    }
}
whatsnew.presentAutomatically(this)

Java:

WhatsNew.newInstance(
    new WhatsNewItem("Nice Icons", "Completely customize colors, texts and icons.", R.drawable.ic_heart),
    new WhatsNewItem("Such Easy", "Setting this up only takes 2 lines of code, impressive you say?", R.drawable.ic_thumb_up),
    new WhatsNewItem("Very Sleep", "It helps you get more sleep by writing less code.", R.drawable.ic_satisfied_face),
    new WhatsNewItem("Text Only", "No icons? Just go with plain text.")
).presentAutomatically(AnotherActivity.this);

定制

Kotlin:

val whatsnew = WhatsNew.newInstance(
      WhatsNewItem("Nice Icons", "Completely customize colors, texts and icons.", R.drawable.ic_heart),
      WhatsNewItem("Such Easy", "Setting this up only takes 2 lines of code, impressive you say?", R.drawable.ic_thumb_up),
      WhatsNewItem("Very Sleep", "It helps you get more sleep by writing less code.", R.drawable.ic_satisfied_face),
      WhatsNewItem("Text Only", "No icons? Just go with plain text."))
      with(whatsnew) {
        presentationOption = PresentationOption.DEBUG
        titleColor = ContextCompat.getColor(this@MainActivity, R.color.colorAccent)
        titleText = "What's Up"
        buttonText = "Got it!"
        buttonBackground = ContextCompat.getColor(this@MainActivity, R.color.colorPrimaryDark)
        buttonTextColor = ContextCompat.getColor(this@MainActivity, R.color.colorAccent)
        itemContentColor = Color.parseColor("#808080")
        itemTitleColor = ContextCompat.getColor(this@MainActivity, R.color.colorAccent)
      }
whatsnew.presentAutomatically(this@MainActivity)

Java:

WhatsNew whatsNew = WhatsNew.newInstance(
    new WhatsNewItem("Nice Icons", "Completely customize colors, texts and icons.", R.drawable.ic_heart),
    new WhatsNewItem("Such Easy", "Setting this up only takes 2 lines of code, impressive you say?", R.drawable.ic_thumb_up),
    new WhatsNewItem("Very Sleep", "It helps you get more sleep by writing less code.", R.drawable.ic_satisfied_face),
    new WhatsNewItem("Text Only", "No icons? Just go with plain text."));
    whatsNew.setPresentationOption(PresentationOption.DEBUG);
    whatsNew.setTitleColor(ContextCompat.getColor(this, R.color.colorAccent));
    whatsNew.setTitleText("What's Up");
    whatsNew.setButtonText("Got it!");
    whatsNew.setButtonBackground(ContextCompat.getColor(this, R.color.colorPrimaryDark));
    whatsNew.setButtonTextColor(ContextCompat.getColor(this, R.color.colorAccent));
    whatsNew.setItemTitleColor(ContextCompat.getColor(this, R.color.colorAccent));
    whatsNew.setItemContentColor(Color.parseColor("#808080"));
    whatsNew.presentAutomatically(AnotherActivity.this);

致谢

Patrick Balestra

许可

WhatsNew 采用 MIT 许可证.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值