-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/michelelacorte/AndroidSho…
- Loading branch information
Showing
3 changed files
with
177 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
# AndroidShortcuts | ||
<h2 align="center">Shortcuts for Android on Pre Nougat 7.1!</h1> | ||
<h1 align="center">AndroidShortcuts</h1> | ||
<h2 align="center">Shortcuts for Android on Pre Nougat 7.1!</h2> | ||
|
||
<span class="badge-paypal"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LY7EX8WMWPWV6" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span> | ||
|
||
[![Twitter](https://img.shields.io/badge/[email protected]?style=flat)](https://twitter.com/LacorteMichele) | ||
|
||
[![API](https://img.shields.io/badge/API-14%2B-yellow.svg?style=flat)](https://android-arsenal.com/api?level=14) | ||
|
||
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) | ||
|
||
#BIG UPDATE, AIDL COMMUNICATION IS HERE, SOON ALL DEVELOPERS WILL ONLY IMPLEMENT SHORTCUTS LAYOUT, THEN IT'S UP TO DEVELOPER TO IMPLEMENT THEIR OWN SHORTCUTS, LIKE GOOGLE!!! | ||
|
||
|
||
##WHAT IS ANDROID SHORTCUTS? | ||
|
||
The shorctus have a features of Android 7.1 Nougat, and available only for the launcher that implement, in this library, you can implement in your launcher shorctus starting from API 14! | ||
Whit new communication all developers will only implement shortcuts layout (this library), then it's up to developer to implement their own shortcuts, like Google!!! | ||
I have also implemented [Force Touch](https://github.com/michelelacorte/ForceTouch) and YOU CAN USE ON CUSTOM LAUNCHER WITH SHORTCUTS!! | ||
|
||
##DONATIONS | ||
|
@@ -31,33 +39,24 @@ This project needs you! If you would like to support this project's further deve | |
|
||
Of course, you can also choose what you want to donate, all donations are awesome!! | ||
|
||
<img align="left" src="https://s15.postimg.org/km4eygofv/ic_launcher.png"> | ||
#v0.2.0 | ||
|
||
###Here we are! | ||
###The touch force is ready and is going to get on the custom launcher !! | ||
<img align="left" src="https://s23.postimg.org/m2d28wraj/ic_launcher.png"> | ||
#v1.1.0 Preview | ||
|
||
###As promised I've implemented Force Touch in my custom launcher ... and you see the picture | ||
<h1 align="center"><img src="http://i.giphy.com/26gYBk8pQxudwwWQw.gif"/></h1> | ||
|
||
<h1 align="center"><img src="https://s17.postimg.org/vimarchhb/Force_Touch_Launcher_framed.png"/></h1> | ||
##v1.0.0 Preview | ||
|
||
###Yes, I'm working with shortcuts Android 7.1 Nougat! and will soon be available for custom launcher from API 14 !! | ||
###See an example here (beta) | ||
|
||
<h1 align="center"><img src="http://i.giphy.com/3oz8xM1ZWIeAjdXTHy.gif"/></h1> | ||
<h1 align="center"><img src="http://i.giphy.com/l3vR814bxMIwQveiA.gif"/></h1> | ||
|
||
###Stay Tuned! | ||
###For other detail to use force touch follow [Force Touch](https://github.com/michelelacorte/ForceTouch) | ||
##v0.2.0 Preview [Click Here](http://i.giphy.com/3o7TKTplU3uZMUkK4M.gif) | ||
|
||
##APP EXAMPLE | ||
|
||
v1.0.0 Preview | ||
|
||
<h1 align="center"><img src="http://i.giphy.com/l3vR814bxMIwQveiA.gif"/></h1> | ||
####Android Shortcuts is on Google Play!!! | ||
|
||
v0.2.0 Preview | ||
|
||
<h1 align="center"><img src="http://i.giphy.com/3o7TKTplU3uZMUkK4M.gif"/></h1> | ||
<a href="https://play.google.com/store/apps/details?id=it.michelelacorte.exampleandroidshortcuts"> | ||
<img alt="Get it on Google Play" src="https://s32.postimg.org/50h5qj4lx/google_play_badge.png" /> | ||
</a> | ||
|
||
##USAGE | ||
|
||
|
@@ -78,82 +77,12 @@ Than add this dependencies | |
```groovy | ||
compile 'com.github.michelelacorte:AndroidShortcuts:1.0.0' | ||
``` | ||
##DOCUMENTATION | ||
|
||
Now let's start to create Shortcuts! | ||
|
||
```groovy | ||
//Layout for shortcuts | ||
private AdapterView gridView; | ||
private RelativeLayout activityParent; | ||
``` | ||
- [App Shortcuts Locale](https://github.com/michelelacorte/AndroidShortcuts/blob/master/SHORTCUTSLOCALE.md) | ||
|
||
Than in MainActivity | ||
- [App Shortcuts Remote (Coming Soon with v1.1.0)](https://github.com/michelelacorte/AndroidShortcuts/blob/master/SHORTCUTSREMOTE.md) | ||
|
||
``` | ||
activityParent = (RelativeLayout) findViewById(R.id.activity_main); | ||
gridView=(GridView) findViewById(R.id.gridView); | ||
gridView.setAdapter(new MyArrayAdapter(this, R.layout.app_grid_item)); | ||
//Create Shortcuts | ||
final ShortcutsCreation shortcutsCreation = new ShortcutsCreation(MainActivity.this, activityParent, gridView); | ||
//Create gesture detector for onLongPress | ||
final GestureDetector gestureDetector = new GestureDetector(getApplicationContext(), new GestureDetector.OnGestureListener() { | ||
@Override | ||
public boolean onDown(MotionEvent motionEvent) { | ||
shortcutsCreation.clearAllLayout(); | ||
return false; | ||
} | ||
@Override | ||
public void onShowPress(MotionEvent motionEvent) { | ||
shortcutsCreation.clearAllLayout(); | ||
} | ||
@Override | ||
public boolean onSingleTapUp(MotionEvent motionEvent) { | ||
shortcutsCreation.clearAllLayout(); | ||
return false; | ||
} | ||
@Override | ||
public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) { | ||
shortcutsCreation.clearAllLayout(); | ||
return false; | ||
} | ||
@Override | ||
public void onLongPress(MotionEvent motionEvent) { | ||
//Make sure to clear layout before create new | ||
shortcutsCreation.clearAllLayout(); | ||
//Now create shortcuts!! | ||
shortcutsCreation.createShortcuts((int)motionEvent.getX(), (int)motionEvent.getY(), 96, | ||
new Shortcuts(R.mipmap.ic_launcher, "Shortcuts", new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Toast.makeText(getApplicationContext(), "Hello Shortcuts!!", Toast.LENGTH_LONG).show(); | ||
} | ||
}), | ||
new Shortcuts(R.mipmap.ic_launcher, "Hello!")); | ||
} | ||
@Override | ||
public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) { | ||
shortcutsCreation.clearAllLayout(); | ||
return false; | ||
} | ||
}); | ||
// Set custom touch listener | ||
gridView.setOnTouchListener(new View.OnTouchListener() { | ||
@Override | ||
public boolean onTouch(View view, MotionEvent motionEvent) { | ||
return gestureDetector.onTouchEvent(motionEvent); | ||
} | ||
}); | ||
``` | ||
|
||
Coming soon with [Force Touch](https://github.com/michelelacorte/ForceTouch) implementation | ||
|
||
|
@@ -167,34 +96,55 @@ Android API 14+ | |
|
||
##CHANGELOG | ||
|
||
**v1.1.0 (Coming Soon!)** | ||
* Deprecate AIDL communication, not suited to the needs, replaced with simple file data. | ||
* Improved Example App, new version 1.1. | ||
* Improved Shortcuts view, fixed bug. | ||
* Added class `RemoteShortcuts` | ||
* Method `static void saveRemoteShortcuts(Activity activity, String packageName, ArrayList<Shortcuts> listOfShortcuts)` for save shortcuts and make accessible on library. | ||
* Method `static ArrayList<Shortcuts> getRemoteShortcuts(Activity activity, String packageName)` to get shortcuts from library. | ||
* Method `static void checkPermission(Activity activity)` for check WRITE_EXTERNAL_STORAGE permission on Android M and above. | ||
* Method `static void requestPermission(Activity activity)` for request permission to user. | ||
* Update class `Shortcuts` | ||
* Added constructor `Shortcuts(Bitmap shortcutsImage, String shortcutsText)` | ||
* Added constructor `Shortcuts(int shortcutsImage, String shortcutsText, String targetClass, String targetPackage)` only for remote use. | ||
* Added constructor `Shortcuts(Bitmap shortcutsImage, String shortcutsText, String targetClass, String targetPackage)` only for remote use. | ||
* Added constructor `Shortcuts(int shortcutsImage, String shortcutsText, View.OnClickListener onShortcutsClickListener, View.OnClickListener onShortcutsOptionClickListener)` | ||
* Added getter `View.OnClickListener getOnShortcutsOptionClickListener()` | ||
* Added getter `Bitmap getShortcutsImageBitmap()` | ||
* Added getter `String getTargetPackage()` | ||
* Added getter `String getTargetClass()` | ||
* Update class `Utils` | ||
* Added method `static void createShortcutsOnLauncher(Activity activity, Bitmap shortcutsImage, String shortcutsText, String className, String packageName)` for create shortcuts when user click on right menù (option menù) | ||
|
||
**v1.0.0** | ||
* Improved Example App, soon relased on Google Play | ||
* Added class `ShortcutsService` that create remote connection and use AIDL to communicate with launcher, soon all developers will only implement shortcuts layout, then it's up to developer to implement their own shortcuts, like google!!! | ||
* ~~Added class `ShortcutsService` that create remote connection and use AIDL to communicate with launcher, soon all developers will only implement shortcuts layout, then it's up to developer to implement their own shortcuts, like google!!!~~ | ||
* Improved animation, almost equal to the Pixels Launcher. | ||
* Added 2 style right menù of shortcuts (see int optionLayoutStyle) | ||
* Added click shadow on shortcuts. | ||
* Added AIDL interface `IRemoteShortcutClickListener` | ||
* Method `void onShortcutsClickListener()` when user click on shortcuts | ||
* Method `void onShortcutsOptionClickListener()` when user click on right menù | ||
* Added AIDL interface `IRemoteShortcutService` | ||
* Method `void addShortcutsWithRemoteClickListener(int shortcutsImage, String shortcutsText, IRemoteShortcutClickListener onShortcutsClickListener)` | ||
* Method `void addShortcuts(int shortcutsImage, String shortcutsText)` | ||
* Method `List<Shortcuts> getShortcuts()` | ||
* Added AIDL interface `Shortcuts` provide parcelable Shortcuts | ||
* Added class `RemoteServiceConnection` | ||
* Public constructor `RemoteServiceConnection(Activity activity, List<Shortcuts> shortcuts)` | ||
* Public constructor `RemoteServiceConnection(Activity activity, Shortcuts... shortcuts)` | ||
* Public method `boolean connectServiceAndVerifyConnection(RemoteServiceConnection serviceConnection)` to bind service and return boolean to check if is connected. | ||
* Public method `void connectService(RemoteServiceConnection serviceConnection)` to bind service. | ||
* Public method `IRemoteShortcutService getService()` to retreive service. | ||
* Added class `ShortcutsService` to create service | ||
* ~~Added AIDL interface `IRemoteShortcutClickListener`~~ | ||
* ~~Method `void onShortcutsClickListener()` when user click on shortcuts~~ | ||
* ~~Method `void onShortcutsOptionClickListener()` when user click on right menù~~ | ||
* ~~Added AIDL interface `IRemoteShortcutService`~~ | ||
* ~~Method `void addShortcutsWithRemoteClickListener(int shortcutsImage, String shortcutsText, IRemoteShortcutClickListener onShortcutsClickListener)`~~ | ||
* ~~Method `void addShortcuts(int shortcutsImage, String shortcutsText)`~~ | ||
* ~~Method `List<Shortcuts> getShortcuts()`~~ | ||
* ~~Added AIDL interface `Shortcuts` provide parcelable Shortcuts~~ | ||
* ~~Added class `RemoteServiceConnection`~~ | ||
* ~~Public constructor `RemoteServiceConnection(Activity activity, List<Shortcuts> shortcuts)`~~ | ||
* ~~Public constructor `RemoteServiceConnection(Activity activity, Shortcuts... shortcuts)`~~ | ||
* ~~Public method `boolean connectServiceAndVerifyConnection(RemoteServiceConnection serviceConnection)` to bind service and return boolean to check if is connected.~~ | ||
* ~~Public method `void connectService(RemoteServiceConnection serviceConnection)` to bind service.~~ | ||
* ~~Public method `IRemoteShortcutService getService()` to retreive service.~~ | ||
* ~~Added class `ShortcutsService` to create service~~ | ||
* Update class `Shortcuts` | ||
* Added constructor `Shortcuts(int shortcutsImage, String shortcutsText, final IRemoteShortcutClickListener onIRemoteShortcutsClickListener)` | ||
* ~~Added constructor `Shortcuts(int shortcutsImage, String shortcutsText, final IRemoteShortcutClickListener onIRemoteShortcutsClickListener)`~~ | ||
* Added method `int getShortcutsImage()` | ||
* Added method `String getShortcutsText()` | ||
* Added method `IRemoteShortcutClickListener getOnIRemoteShortcutsClickListener()` | ||
* ~~Added method `IRemoteShortcutClickListener getOnIRemoteShortcutsClickListener()`~~ | ||
* Added method `View.OnClickListener getOnShortcutsClickListener()` | ||
* Update class to `Parcelable` for AIDL communication. | ||
* ~~Update class to `Parcelable` for AIDL communication.~~ | ||
* Update class `ShortcutsCreation` | ||
* Added private method `void createShortcutsBasedOnGridSize(int currentXPosition, int currentYPosition, int rowHeight, GridSize gridSize, List<Shortcuts> shortcuts)` | ||
* Update method `void createShortcutsBasedOnGridSize(int currentXPosition, int currentYPosition, int rowHeight, GridSize gridSize, int optionLayoutStyle, List<Shortcuts> shortcuts)` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
Now let's start to create Shortcuts! | ||
|
||
```groovy | ||
//Layout for shortcuts | ||
private AdapterView gridView; | ||
private RelativeLayout activityParent; | ||
``` | ||
|
||
Than in MainActivity | ||
|
||
``` | ||
activityParent = (RelativeLayout) findViewById(R.id.activity_main); | ||
gridView=(GridView) findViewById(R.id.gridView); | ||
gridView.setAdapter(new MyArrayAdapter(this, R.layout.app_grid_item)); | ||
//Create Shortcuts | ||
final ShortcutsCreation shortcutsCreation = new ShortcutsCreation(MainActivity.this, activityParent, gridView); | ||
//Create gesture detector for onLongPress | ||
final GestureDetector gestureDetector = new GestureDetector(getApplicationContext(), new GestureDetector.OnGestureListener() { | ||
@Override | ||
public boolean onDown(MotionEvent motionEvent) { | ||
shortcutsCreation.clearAllLayout(); | ||
return false; | ||
} | ||
@Override | ||
public void onShowPress(MotionEvent motionEvent) { | ||
shortcutsCreation.clearAllLayout(); | ||
} | ||
@Override | ||
public boolean onSingleTapUp(MotionEvent motionEvent) { | ||
shortcutsCreation.clearAllLayout(); | ||
return false; | ||
} | ||
@Override | ||
public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) { | ||
shortcutsCreation.clearAllLayout(); | ||
return false; | ||
} | ||
@Override | ||
public void onLongPress(MotionEvent motionEvent) { | ||
//Make sure to clear layout before create new | ||
shortcutsCreation.clearAllLayout(); | ||
//Now create shortcuts!! | ||
shortcutsCreation.createShortcuts((int)motionEvent.getX(), (int)motionEvent.getY(), 96, 0 | ||
new Shortcuts(R.mipmap.ic_launcher, "Shortcuts", new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Toast.makeText(getApplicationContext(), "Hello Shortcuts!!", Toast.LENGTH_LONG).show(); | ||
} | ||
}), | ||
new Shortcuts(R.mipmap.ic_launcher, "Hello!")); | ||
} | ||
@Override | ||
public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) { | ||
shortcutsCreation.clearAllLayout(); | ||
return false; | ||
} | ||
}); | ||
// Set custom touch listener | ||
gridView.setOnTouchListener(new View.OnTouchListener() { | ||
@Override | ||
public boolean onTouch(View view, MotionEvent motionEvent) { | ||
return gestureDetector.onTouchEvent(motionEvent); | ||
} | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#Here we are! | ||
|
||
##Android Shortcuts Library is now complete for support with other app, now all developers can register own shortcuts and make accessible for the launcher that implement library! | ||
|
||
##No more talk, and let's see how you implement! | ||
|
||
###In App "client" we only do this: | ||
|
||
``` | ||
ArrayList<Shortcuts> listOfShortcuts = new ArrayList<>(); | ||
listOfShortcuts.add(new Shortcuts(R.mipmap.ic_launcher, "Test File AA")); | ||
listOfShortcuts.add(new Shortcuts(R.mipmap.ic_launcher, "Test Service AA", "it.michelelacorte.aa.MainActivity", "it.michelelacorte.aa")); | ||
// Only 1 line!!! | ||
RemoteShortcuts.saveRemoteShortcuts(this, this.getPackageName(), listOfShortcuts); | ||
``` | ||
|
||
###Than in "server" app, launcher for example, we do: | ||
|
||
``` | ||
ArrayList<Shortcuts> listOfShortcuts = new ArrayList<>(); | ||
int positionPointed = ((GridView) gridView).pointToPosition((int) motionEvent.getX(), (int) motionEvent.getY()); | ||
//Get clicked package name | ||
String packageName = ExampleArrayAdapter.pkgAppsList.get(positionPointed).activityInfo.packageName; | ||
//Get shortcuts for this package, again, 1 line! | ||
listOfShortcuts = RemoteShortcuts.getRemoteShortcuts(MainActivity.this, packageName); | ||
//If shortcuts are defined, show it! | ||
if(listOfShortcuts != null && listOfShortcuts.size() > 0) { | ||
shortcutsCreation.createShortcuts((int) motionEvent.getX(), (int) motionEvent.getY(), 96, 0, listOfShortcuts); | ||
}else{ | ||
Toast.makeText(MainActivity.this, "App Shortcuts not found for this package!", Toast.LENGTH_SHORT) | ||
.show(); | ||
} | ||
``` | ||
|