-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
68 changed files
with
1,028 additions
and
255 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
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
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
64 changes: 64 additions & 0 deletions
64
android/app/src/main/java/deckers/thibault/aves/channel/calls/AppShortcutHandler.java
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,64 @@ | ||
package deckers.thibault.aves.channel.calls; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.text.TextUtils; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.core.content.pm.ShortcutInfoCompat; | ||
import androidx.core.content.pm.ShortcutManagerCompat; | ||
import androidx.core.graphics.drawable.IconCompat; | ||
|
||
import java.util.List; | ||
|
||
import deckers.thibault.aves.MainActivity; | ||
import deckers.thibault.aves.R; | ||
import io.flutter.plugin.common.MethodCall; | ||
import io.flutter.plugin.common.MethodChannel; | ||
|
||
public class AppShortcutHandler implements MethodChannel.MethodCallHandler { | ||
public static final String CHANNEL = "deckers.thibault/aves/shortcut"; | ||
|
||
private Context context; | ||
|
||
public AppShortcutHandler(Context context) { | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) { | ||
switch (call.method) { | ||
case "canPin": { | ||
result.success(ShortcutManagerCompat.isRequestPinShortcutSupported(context)); | ||
break; | ||
} | ||
case "pin": { | ||
String label = call.argument("label"); | ||
List<String> filters = call.argument("filters"); | ||
pin(label, filters); | ||
result.success(null); | ||
break; | ||
} | ||
default: | ||
result.notImplemented(); | ||
break; | ||
} | ||
} | ||
|
||
private void pin(String label, @Nullable List<String> filters) { | ||
if (!ShortcutManagerCompat.isRequestPinShortcutSupported(context) || filters == null) { | ||
return; | ||
} | ||
|
||
ShortcutInfoCompat shortcut = new ShortcutInfoCompat.Builder(context, "collection-" + TextUtils.join("-", filters)) | ||
.setShortLabel(label) | ||
.setIcon(IconCompat.createWithResource(context, R.mipmap.ic_shortcut_collection)) | ||
.setIntent(new Intent(Intent.ACTION_MAIN, null, context, MainActivity.class) | ||
.putExtra("page", "/collection") | ||
.putExtra("filters", filters.toArray(new String[0]))) | ||
.build(); | ||
|
||
ShortcutManagerCompat.requestPinShortcut(context, shortcut, null); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
android/app/src/main/res/drawable/ic_shortcut_collection_foreground.xml
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,15 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="108dp" | ||
android:height="108dp" | ||
android:viewportWidth="108" | ||
android:viewportHeight="108" | ||
android:tint="#455A64"> | ||
<group android:scaleX="1.7226" | ||
android:scaleY="1.7226" | ||
android:translateX="33.3288" | ||
android:translateY="33.3288"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M20,4v12L8,16L8,4h12m0,-2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM11.5,11.67l1.69,2.26 2.48,-3.1L19,15L9,15zM2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6L2,6z"/> | ||
</group> | ||
</vector> |
15 changes: 15 additions & 0 deletions
15
android/app/src/main/res/drawable/ic_shortcut_movie_foreground.xml
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,15 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="108dp" | ||
android:height="108dp" | ||
android:viewportWidth="108" | ||
android:viewportHeight="108" | ||
android:tint="#455A64"> | ||
<group android:scaleX="1.7226" | ||
android:scaleY="1.7226" | ||
android:translateX="33.3288" | ||
android:translateY="33.3288"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M4,6.47L5.76,10H20v8H4V6.47M22,4h-4l2,4h-3l-2,-4h-2l2,4h-3l-2,-4H8l2,4H7L5,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V4z"/> | ||
</group> | ||
</vector> |
15 changes: 15 additions & 0 deletions
15
android/app/src/main/res/drawable/ic_shortcut_search_foreground.xml
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,15 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="108dp" | ||
android:height="108dp" | ||
android:viewportWidth="108" | ||
android:viewportHeight="108" | ||
android:tint="#455A64"> | ||
<group android:scaleX="1.7226" | ||
android:scaleY="1.7226" | ||
android:translateX="33.3288" | ||
android:translateY="33.3288"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/> | ||
</group> | ||
</vector> |
5 changes: 5 additions & 0 deletions
5
android/app/src/main/res/mipmap-anydpi-v26/ic_shortcut_collection.xml
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<background android:drawable="@color/ic_shortcut_background"/> | ||
<foreground android:drawable="@drawable/ic_shortcut_collection_foreground"/> | ||
</adaptive-icon> |
5 changes: 5 additions & 0 deletions
5
android/app/src/main/res/mipmap-anydpi-v26/ic_shortcut_movie.xml
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<background android:drawable="@color/ic_shortcut_background"/> | ||
<foreground android:drawable="@drawable/ic_shortcut_movie_foreground"/> | ||
</adaptive-icon> |
5 changes: 5 additions & 0 deletions
5
android/app/src/main/res/mipmap-anydpi-v26/ic_shortcut_search.xml
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<background android:drawable="@color/ic_shortcut_background"/> | ||
<foreground android:drawable="@drawable/ic_shortcut_search_foreground"/> | ||
</adaptive-icon> |
1 change: 1 addition & 0 deletions
1
...ain/res/values/ic_launcher_background.xml → android/app/src/main/res/values/colors.xml
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,4 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="ic_launcher_background">#FFFFFF</color> | ||
<color name="ic_shortcut_background">#FFFFFF</color> | ||
</resources> |
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,4 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">Aves</string> | ||
<string name="search_shortcut_short_label">Search</string> | ||
<string name="videos_shortcut_short_label">Videos</string> | ||
</resources> |
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
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
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
Oops, something went wrong.