Shortcut
A simple library to add dynamic and pinned shortcuts
Integrating the shortcut sdk into your android app
build.gradle
Add jitpack maven repo to app module's allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add dependency
gradle
dependencies {
implementation 'com.github.MehdiKh93:Shortcut:1.0.2'
}
maven
<dependency>
<groupId>com.github.MehdiKh93</groupId>
<artifactId>Shortcut</artifactId>
<version>1.0.2</version>
</dependency>
Usage
ShortcutUtils
class
init ShortcutUtils shortcutUtils = new ShortcutUtils(context);
DynamicShortcut
adding a Shortcut dynamicShortcut = new Shortcut.ShortcutBuilder()
.setShortcutIcon(R.drawable.icon)
.setShortcutId("dynamicShortcutId")
.setShortcutLongLabel("dynamicShortcutLongLable")
.setShortcutShortLabel("dynamicShortcutShortLabel")
.setIntentAction("dynamicShortcutIntentAction")
.setIntentStringExtraKey("dynamicShortcutKey")
.setIntentStringExtraValue("dynamicShortcutValue")
.build();
shortcutUtils.addDynamicShortCut(dynamicHomeShortcut, new IReceiveStringExtra() {
@Override
public void onReceiveStringExtra(String stringExtraKey, String stringExtraValue) {
String intent = getIntent().getStringExtra(stringExtraKey);
if (intent != null) {
if (intent.equals("dynamicShortcutValue")) {
//write any code here
}
}
}
});
}
DynamicShortcut
temporary
disabling a shortcutUtils.disableDynamicShortCut(dynamicShortcut);
DynamicShortcut
temporary
removing a shortcutUtils.removeDynamicShortCut(dynamicShortcut);
DynamicShortcut
temporary
enabling a shortcutUtils.enableDynamicShortCut(dynamicShortcut);
PinnedShortcut
initing a Shortcut pinnedShortcut = new Shortcut.ShortcutBuilder()
.setShortcutIcon(R.drawable.icon)
.setShortcutId("pinnedShortcutId")
.setShortcutLongLabel("pinnedShortcutLongLabel")
.setShortcutShortLabel("pinnedShortcutShortLabel")
.setIntentAction("pinnedShortcutIntentAction")
.setIntentStringExtraKey("pinnedShortcutKey")
.setIntentStringExtraValue("pinnedShortcutValue")
.build();
shortcutUtils.initPinnedShortCut(pinnedShortcut, new IReceiveStringExtra() {
@Override
public void onReceiveStringExtra(String stringExtraKey, String stringExtraValue) {
String intent = getIntent().getStringExtra(stringExtraKey);
if (intent != null) {
if (intent.equals("pinnedShortcutValue")) {
//write any code here
}
}
}
});
}
PinnedShortcut
requesting a shortcutUtils.requestPinnedShortcut(pinnedShortcut);
PinnedShortcut
disabling a shortcutUtils.disablePinnedShortCut(pinnedShortcut);
PinnedShortcut
enabling a shortcutUtils.enablePinnedShortCut(pinnedShortcut);
Issues
Please send all issues and feedback to [email protected] or Telegram ID: https://t.me/mehdikhalifeh
License
Copyright 2019 Mehdi Khalifeh
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.