在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):Zellius/android-shortcut-gradle-plugin开源软件地址(OpenSource Url):https://github.com/Zellius/android-shortcut-gradle-plugin开源编程语言(OpenSource Language):Groovy 90.8%开源软件介绍(OpenSource Introduction):android-shortcut-gradle-pluginAndroid Gradle plugin generates App Shortcuts shortcuts.xml for build flavors with different applicationId. When it useful?If you look at the official documentation of static App Shortcuts, you'll see that for each intent you need to set the android:targetPackage. But, what if you have different applicationId in different flavors? android {
defaultConfig {
applicationId "ru.solodovnikov.shortcutgradlehelper"
}
productFlavors {
dev {
applicationIdSuffix "dev"
}
prod {
applicationId "ru.solodovnikov.shortcut"
}
}
} In this example, you'll need copy your shortcuts.xml in two folder dev and prod with single difference. And if you create a new flavor with different applicationId you need to copy it again. Since at this moment we do not have any built-in merge tools applicationId from build.gradle to the shortcuts.xml this gradle plugin will be useful. Example
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut android:shortcutId="test1" android:enabled="true" android:icon="@mipmap/ic_launcher"
android:shortcutShortLabel="@string/app_name" android:shortcutLongLabel="@string/app_name"
android:shortcutDisabledMessage="@string/app_name">
<intent android:action="android.intent.action.VIEW"
android:targetClass="ru.solodovnikov.shortcuthelper.MainActivity" />
<intent android:action="android.intent.action.VIEW"
android:targetClass="ru.solodovnikov.shortcuthelper.SecondActivity" />
<categories android:name="android.shortcut.conversation" />
</shortcut>
</shortcuts>
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.zellius:android-shortcut-gradle-plugin:0.1.2'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.github.zellius.shortcut-helper'
shortcutHelper.filePath = '../shortcuts.xml'
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" /> Android Studio can mark @xml/shortcuts as "cannot resolve"...but it is ok :)
You can try an example from the repository. License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论