mirror of
https://github.com/TrianguloY/LightningLauncher.git
synced 2025-01-15 03:40:49 +01:00
sesame integration first draft
This commit is contained in:
parent
87d16ab200
commit
3db14d85d0
7 changed files with 105 additions and 29 deletions
BIN
app/llx/app/libs/sesame-lib-1.2.1.aar
Normal file
BIN
app/llx/app/libs/sesame-lib-1.2.1.aar
Normal file
Binary file not shown.
|
@ -1,7 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="net.pierrox.lightning_launcher_extreme"
|
package="net.pierrox.lightning_launcher_extreme"
|
||||||
android:sharedUserId="net.pierrox.lightning_launcher" >
|
android:sharedUserId="net.pierrox.lightning_launcher">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
|
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
|
||||||
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
|
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
|
||||||
|
@ -28,6 +29,9 @@
|
||||||
<!-- Tasker -->
|
<!-- Tasker -->
|
||||||
<uses-permission android:name="net.dinglisch.android.tasker.PERMISSION_RUN_TASKS"/>
|
<uses-permission android:name="net.dinglisch.android.tasker.PERMISSION_RUN_TASKS"/>
|
||||||
|
|
||||||
|
<!-- Sesame -->
|
||||||
|
<uses-sdk tools:overrideLibrary="ninja.sesame.lib.bridge.v1"/>
|
||||||
|
|
||||||
<permission
|
<permission
|
||||||
android:name="net.pierrox.lightning_launcher.USE_SCRIPT_SERVICE"
|
android:name="net.pierrox.lightning_launcher.USE_SCRIPT_SERVICE"
|
||||||
android:protectionLevel="dangerous"
|
android:protectionLevel="dangerous"
|
||||||
|
|
|
@ -19,6 +19,7 @@ import net.pierrox.lightning_launcher.prefs.LLPreference;
|
||||||
import net.pierrox.lightning_launcher.script.Script;
|
import net.pierrox.lightning_launcher.script.Script;
|
||||||
import net.pierrox.lightning_launcher.util.EmptyService;
|
import net.pierrox.lightning_launcher.util.EmptyService;
|
||||||
import net.pierrox.lightning_launcher.util.MPReceiver;
|
import net.pierrox.lightning_launcher.util.MPReceiver;
|
||||||
|
import ninja.sesame.lib.bridge.v1.SesameFrontend;
|
||||||
|
|
||||||
public abstract class LLAppPhone extends LLApp {
|
public abstract class LLAppPhone extends LLApp {
|
||||||
|
|
||||||
|
@ -45,6 +46,9 @@ public abstract class LLAppPhone extends LLApp {
|
||||||
|
|
||||||
registerReceiver(mMPReceiver, intent_filter);
|
registerReceiver(mMPReceiver, intent_filter);
|
||||||
}
|
}
|
||||||
|
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
SesameFrontend.init(this, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -37,6 +37,7 @@ import android.graphics.RectF;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.graphics.drawable.Icon;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
@ -145,6 +146,8 @@ import net.pierrox.lightning_launcher.views.item.WidgetView;
|
||||||
import net.pierrox.lightning_launcher_extreme.BuildConfig;
|
import net.pierrox.lightning_launcher_extreme.BuildConfig;
|
||||||
import net.pierrox.lightning_launcher_extreme.R;
|
import net.pierrox.lightning_launcher_extreme.R;
|
||||||
|
|
||||||
|
import ninja.sesame.lib.bridge.v1.SesameFrontend;
|
||||||
|
import ninja.sesame.lib.bridge.v1.SesameShortcut;
|
||||||
import org.mozilla.javascript.Function;
|
import org.mozilla.javascript.Function;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -740,6 +743,10 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
|
||||||
@Override
|
@Override
|
||||||
public void startActivity(Intent intent) {
|
public void startActivity(Intent intent) {
|
||||||
mPausedBecauseOfLaunch = true;
|
mPausedBecauseOfLaunch = true;
|
||||||
|
if("ninja.sesame.app.edge".equals(intent.getPackage()) ||
|
||||||
|
(intent.getComponent() != null) && "ninja.sesame.app.edge".equals(intent.getComponent().getPackageName())) {
|
||||||
|
SesameFrontend.addPackageAuth(this, intent);
|
||||||
|
}
|
||||||
super.startActivity(intent);
|
super.startActivity(intent);
|
||||||
applyLaunchAnimation(mLastLaunchAnimation, true);
|
applyLaunchAnimation(mLastLaunchAnimation, true);
|
||||||
}
|
}
|
||||||
|
@ -3768,6 +3775,7 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.N_MR1)
|
@TargetApi(Build.VERSION_CODES.N_MR1)
|
||||||
private void addAppShortcutBubbleItem(Object shortcutObject) {
|
private void addAppShortcutBubbleItem(Object shortcutObject) {
|
||||||
|
if(shortcutObject instanceof ShortcutInfo) {
|
||||||
ShortcutInfo shortcut = (ShortcutInfo) shortcutObject;
|
ShortcutInfo shortcut = (ShortcutInfo) shortcutObject;
|
||||||
final LauncherApps launcherApps = (LauncherApps) getSystemService(LAUNCHER_APPS_SERVICE);
|
final LauncherApps launcherApps = (LauncherApps) getSystemService(LAUNCHER_APPS_SERVICE);
|
||||||
final View view = getLayoutInflater().inflate(R.layout.two_lines_list_item, null);
|
final View view = getLayoutInflater().inflate(R.layout.two_lines_list_item, null);
|
||||||
|
@ -3778,10 +3786,10 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
|
||||||
|
|
||||||
|
|
||||||
CharSequence label = shortcut.getLongLabel();
|
CharSequence label = shortcut.getLongLabel();
|
||||||
if(label == null || label.length() == 0) {
|
if (label == null || label.length() == 0) {
|
||||||
label = shortcut.getShortLabel();
|
label = shortcut.getShortLabel();
|
||||||
}
|
}
|
||||||
((TextView)view.findViewById(android.R.id.text1)).setText(label);
|
((TextView) view.findViewById(android.R.id.text1)).setText(label);
|
||||||
view.findViewById(android.R.id.text2).setVisibility(View.GONE);
|
view.findViewById(android.R.id.text2).setVisibility(View.GONE);
|
||||||
Drawable background = getDrawable(R.drawable.bubble_item_bg);
|
Drawable background = getDrawable(R.drawable.bubble_item_bg);
|
||||||
view.setBackground(background);
|
view.setBackground(background);
|
||||||
|
@ -3826,6 +3834,57 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
|
||||||
view.setOnLongClickListener(mAppShortcutLongClickListener);
|
view.setOnLongClickListener(mAppShortcutLongClickListener);
|
||||||
view.setTag(shortcut);
|
view.setTag(shortcut);
|
||||||
mBubbleContent.addView(view);
|
mBubbleContent.addView(view);
|
||||||
|
} else if(shortcutObject instanceof SesameShortcut) {
|
||||||
|
SesameShortcut shortcut = (SesameShortcut) shortcutObject;
|
||||||
|
final View view = getLayoutInflater().inflate(R.layout.two_lines_list_item, null);
|
||||||
|
final Drawable iconDrawable = Icon.createWithContentUri(shortcut.iconUri).loadDrawable(this);
|
||||||
|
Bitmap icon = Utils.createBitmapFromDrawable(iconDrawable);
|
||||||
|
ImageView iconView = (ImageView) view.findViewById(android.R.id.icon);
|
||||||
|
iconView.setImageBitmap(icon);
|
||||||
|
|
||||||
|
|
||||||
|
CharSequence label = shortcut.plainLabel;
|
||||||
|
((TextView) view.findViewById(android.R.id.text1)).setText(label);
|
||||||
|
view.findViewById(android.R.id.text2).setVisibility(View.GONE);
|
||||||
|
Drawable background = getDrawable(R.drawable.bubble_item_bg);
|
||||||
|
view.setBackground(background);
|
||||||
|
|
||||||
|
if(mAppShortcutClickListener == null) {
|
||||||
|
mAppShortcutClickListener = new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
closeBubble();
|
||||||
|
SesameShortcut shortcutInfo = (SesameShortcut) view.getTag();
|
||||||
|
Rect bounds = new Rect();
|
||||||
|
view.getHitRect(bounds);
|
||||||
|
SesameFrontend.runAction(Dashboard.this, shortcutInfo.actions[0]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mAppShortcutLongClickListener == null) {
|
||||||
|
mAppShortcutLongClickListener = new OnLongClickListener() {
|
||||||
|
@TargetApi(Build.VERSION_CODES.N_MR1)
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View view) {
|
||||||
|
closeBubble();
|
||||||
|
|
||||||
|
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
||||||
|
|
||||||
|
SesameShortcut shortcutInfo = (SesameShortcut) view.getTag();
|
||||||
|
ClipData clipData = ClipData.newPlainText("id", shortcutInfo.id);
|
||||||
|
View shadowView = view.findViewById(android.R.id.icon);
|
||||||
|
view.startDragAndDrop(clipData, new View.DragShadowBuilder(shadowView), shortcutInfo, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
view.setOnClickListener(mAppShortcutClickListener);
|
||||||
|
view.setOnLongClickListener(mAppShortcutLongClickListener);
|
||||||
|
view.setTag(shortcut);
|
||||||
|
mBubbleContent.addView(view);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnClickListener mAppShortcutClickListener;
|
private View.OnClickListener mAppShortcutClickListener;
|
||||||
|
@ -4186,13 +4245,17 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ShortcutInfo> shortcuts = null;
|
List<?> shortcuts = null;
|
||||||
if(activity != null) {
|
if(activity != null) {
|
||||||
|
if(SesameFrontend.isConnected()) {
|
||||||
|
shortcuts = SesameFrontend.getRecentAppShortcuts(activity.getPackageName(), true, 5);
|
||||||
|
} else {
|
||||||
LauncherApps.ShortcutQuery query = new LauncherApps.ShortcutQuery();
|
LauncherApps.ShortcutQuery query = new LauncherApps.ShortcutQuery();
|
||||||
query.setQueryFlags(LauncherApps.ShortcutQuery.FLAG_MATCH_MANIFEST | LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC | LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED);
|
query.setQueryFlags(LauncherApps.ShortcutQuery.FLAG_MATCH_MANIFEST | LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC | LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED);
|
||||||
query.setActivity(activity);
|
query.setActivity(activity);
|
||||||
shortcuts = launcherApps.getShortcuts(query, userHandle);
|
shortcuts = launcherApps.getShortcuts(query, userHandle);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(shortcuts == null || shortcuts.size() == 0) {
|
if(shortcuts == null || shortcuts.size() == 0) {
|
||||||
Toast.makeText(this, R.string.as_no_s, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.as_no_s, Toast.LENGTH_SHORT).show();
|
||||||
|
@ -6495,7 +6558,7 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemLayoutAppShortcutDropped(ItemLayout itemLayout, Object shortcutInfoObject, float x, float y) {
|
public void onItemLayoutAppShortcutDropped(ItemLayout itemLayout, Object shortcutInfoObject, float x, float y) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1 && shortcutInfoObject instanceof ShortcutInfo) {
|
||||||
ShortcutInfo shortcutInfo = (ShortcutInfo) shortcutInfoObject;
|
ShortcutInfo shortcutInfo = (ShortcutInfo) shortcutInfoObject;
|
||||||
CharSequence label = shortcutInfo.getLongLabel();
|
CharSequence label = shortcutInfo.getLongLabel();
|
||||||
if(label == null || label.length() == 0) {
|
if(label == null || label.length() == 0) {
|
||||||
|
@ -6509,6 +6572,11 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
|
||||||
intent.putExtra(Shortcut.INTENT_EXTRA_APP_SHORTCUT_PKG, shortcutInfo.getPackage());
|
intent.putExtra(Shortcut.INTENT_EXTRA_APP_SHORTCUT_PKG, shortcutInfo.getPackage());
|
||||||
intent.putExtra(Shortcut.INTENT_EXTRA_APP_SHORTCUT_DISABLED_MSG, shortcutInfo.getDisabledMessage());
|
intent.putExtra(Shortcut.INTENT_EXTRA_APP_SHORTCUT_DISABLED_MSG, shortcutInfo.getDisabledMessage());
|
||||||
Utils.addShortcut(label.toString(), icon, intent, itemLayout.getPage(), x, y, 1, true);
|
Utils.addShortcut(label.toString(), icon, intent, itemLayout.getPage(), x, y, 1, true);
|
||||||
|
} else if (shortcutInfoObject instanceof SesameShortcut) {
|
||||||
|
SesameShortcut shortcut = (SesameShortcut) shortcutInfoObject;
|
||||||
|
Drawable drawable = Icon.createWithContentUri(shortcut.iconUri).loadDrawable(Dashboard.this);
|
||||||
|
Bitmap icon = Utils.createBitmapFromDrawable(drawable);
|
||||||
|
Utils.addShortcut(shortcut.htmlLabel, icon, shortcut.actions[0].intent, itemLayout.getPage(), x,y, 1, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ buildscript {
|
||||||
google()
|
google()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.3.2'
|
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1040,7 +1040,7 @@ public class ItemLayout extends ViewGroup {
|
||||||
|
|
||||||
case DragEvent.ACTION_DROP:
|
case DragEvent.ACTION_DROP:
|
||||||
mAutoScrolling = false;
|
mAutoScrolling = false;
|
||||||
mScreen.onItemLayoutAppShortcutDropped(this, (ShortcutInfo) event.getLocalState(), event.getX(), event.getY());
|
mScreen.onItemLayoutAppShortcutDropped(this, event.getLocalState(), event.getX(), event.getY());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.onDragEvent(event);
|
return super.onDragEvent(event);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#Tue Dec 12 04:46:31 CET 2017
|
#Sun Jan 05 23:25:48 CET 2020
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
Loading…
Reference in a new issue