android-shortcut-gradle-plugin


Source link: https://github.com/Zellius/android-shortcut-gradle-plugin

android-shortcut-gradle-plugin

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.1'
  
}
 
}
  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.

Resources

A Reactive library for WiFi scanning on Android.

An Android Library based on ZXing Library with support for Portrait Orientation and some cool stuffs.

An enhanced EditText with easy ability to get valid email from user. An error message will appear for invalid emails.

InstagRealm is a sample Android application, which shows you how to integrate some of the most popular Android libraries together.

Android Photo Editing & Sharing App.

Versatile map area / geofence utility for google maps v2 for android. Create geofence areas in your map by initializing MarkerBuilderManager.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes