All Projects → Zellius → android-shortcut-gradle-plugin

Zellius / android-shortcut-gradle-plugin

Licence: MIT license
Android Gradle plugin generates App Shortcuts shortcuts.xml for different flavors with different applicationId.

Programming Languages

groovy
2714 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to android-shortcut-gradle-plugin

allure-gradle
Allure Gradle Plugin
Stars: ✭ 62 (+210%)
Mutual labels:  gradle-plugin
gradle-versioneye-plugin
Plugin for Gradle to update your project's dependencies status on www.versioneye.com
Stars: ✭ 31 (+55%)
Mutual labels:  gradle-plugin
androidNativeBundle
a gradle plugin that support publish c/c++ headers to 'aar' and depend those 'aar'
Stars: ✭ 60 (+200%)
Mutual labels:  gradle-plugin
android-gradle-plugins
Gradle Plugins for Android builds
Stars: ✭ 12 (-40%)
Mutual labels:  gradle-plugin
metalava-gradle
A Gradle plugin for Metalava, AOSP's tool for API metadata extraction and compatibility tracking.
Stars: ✭ 29 (+45%)
Mutual labels:  gradle-plugin
secrets-gradle-plugin
A Gradle plugin for providing your secrets to your Android project.
Stars: ✭ 475 (+2275%)
Mutual labels:  gradle-plugin
corda-gradle-plugins
Gradle plugins used by Corda and Cordapps
Stars: ✭ 21 (+5%)
Mutual labels:  gradle-plugin
native-build-tools
Native-image plugins for various build tools
Stars: ✭ 168 (+740%)
Mutual labels:  gradle-plugin
Robfuscate
Obfuscate the int index of R.id/R.string/R.layout… in the classes.dex of Android project
Stars: ✭ 56 (+180%)
Mutual labels:  gradle-plugin
laboratory
Feature flags for multi-module Kotlin Android projects
Stars: ✭ 71 (+255%)
Mutual labels:  gradle-plugin
gradle-android-emulator
Gradle plugin for starting the Android Emulator when running instrumentation tests
Stars: ✭ 30 (+50%)
Mutual labels:  gradle-plugin
xjc-generation-gradle-plugin
A Gradle Plugin for generating JAXB Java sources using the XJC compiler
Stars: ✭ 20 (+0%)
Mutual labels:  gradle-plugin
gradle-git-versioning-plugin
This extension will set project version, based on current Git branch or tag.
Stars: ✭ 44 (+120%)
Mutual labels:  gradle-plugin
micSwitch
macOS menu bar application for the mic mute/unmute with single click or shortcut with walkie-talkie style support
Stars: ✭ 37 (+85%)
Mutual labels:  shortcut
sentry-android-gradle-plugin
Gradle plugin for Sentry Android. Upload proguard, debug files, and more.
Stars: ✭ 67 (+235%)
Mutual labels:  gradle-plugin
StringFuck
Yet Another String Obfuscator for Android
Stars: ✭ 50 (+150%)
Mutual labels:  gradle-plugin
android-buddy
Transform Android project classes with Byte Buddy at compile time
Stars: ✭ 42 (+110%)
Mutual labels:  gradle-plugin
parcl
Gradle plugin for bundling your Java application for distribution on Windows, Mac and Linux
Stars: ✭ 52 (+160%)
Mutual labels:  gradle-plugin
extra-java-module-info
A Gradle 6.4+ plugin to use legacy Java libraries as Java Modules in a modular Java project
Stars: ✭ 39 (+95%)
Mutual labels:  gradle-plugin
kfc-plugins
Kotlin/JS Fast Configuration
Stars: ✭ 37 (+85%)
Mutual labels:  gradle-plugin

android-shortcut-gradle-plugin

Android Arsenal

Android 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

  1. Create shortcuts.xml (or name it how you want) and put it in your project. Do not set any android:targetPackage.
<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>
  1. Apply android-shortcut-gradle-plugin.
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'
  1. Set path to your shortcuts.xml.
shortcutHelper.filePath = '../shortcuts.xml'
  1. Set shortcuts.xml in your manifest.
<meta-data android:name="android.app.shortcuts"
           android:resource="@xml/shortcuts" />

Android Studio can mark @xml/shortcuts as "cannot resolve"...but it is ok :)

  1. PROFIT!!!!

You can try an example from the repository.

License

The MIT License (MIT)

Copyright (c) 2017 Sergey Solodovnikov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].