1
0
Fork 0
mirror of https://github.com/TrianguloY/LightningLauncher.git synced 2025-01-13 20:01:34 +01:00

sesame integration first draft

This commit is contained in:
f43nd1r 2020-01-17 18:50:57 +01:00
parent 87d16ab200
commit 3db14d85d0
7 changed files with 105 additions and 29 deletions
app/llx
app
libs
src/main
AndroidManifest.xml
java/net/pierrox/lightning_launcher
build.gradle
core/src/main/java/net/pierrox/lightning_launcher/views
gradle/wrapper

Binary file not shown.

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.pierrox.lightning_launcher_extreme"
android:sharedUserId="net.pierrox.lightning_launcher" >
xmlns:tools="http://schemas.android.com/tools"
package="net.pierrox.lightning_launcher_extreme"
android:sharedUserId="net.pierrox.lightning_launcher">
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
@ -28,6 +29,9 @@
<!-- Tasker -->
<uses-permission android:name="net.dinglisch.android.tasker.PERMISSION_RUN_TASKS"/>
<!-- Sesame -->
<uses-sdk tools:overrideLibrary="ninja.sesame.lib.bridge.v1"/>
<permission
android:name="net.pierrox.lightning_launcher.USE_SCRIPT_SERVICE"
android:protectionLevel="dangerous"

View file

@ -19,6 +19,7 @@ import net.pierrox.lightning_launcher.prefs.LLPreference;
import net.pierrox.lightning_launcher.script.Script;
import net.pierrox.lightning_launcher.util.EmptyService;
import net.pierrox.lightning_launcher.util.MPReceiver;
import ninja.sesame.lib.bridge.v1.SesameFrontend;
public abstract class LLAppPhone extends LLApp {
@ -45,6 +46,9 @@ public abstract class LLAppPhone extends LLApp {
registerReceiver(mMPReceiver, intent_filter);
}
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
SesameFrontend.init(this, null);
}
}
@Override

View file

@ -37,6 +37,7 @@ import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.AsyncTask;
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.R;
import ninja.sesame.lib.bridge.v1.SesameFrontend;
import ninja.sesame.lib.bridge.v1.SesameShortcut;
import org.mozilla.javascript.Function;
import java.io.File;
@ -740,6 +743,10 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
@Override
public void startActivity(Intent intent) {
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);
applyLaunchAnimation(mLastLaunchAnimation, true);
}
@ -3768,23 +3775,24 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
@TargetApi(Build.VERSION_CODES.N_MR1)
private void addAppShortcutBubbleItem(Object shortcutObject) {
ShortcutInfo shortcut = (ShortcutInfo) shortcutObject;
final LauncherApps launcherApps = (LauncherApps) getSystemService(LAUNCHER_APPS_SERVICE);
final View view = getLayoutInflater().inflate(R.layout.two_lines_list_item, null);
final Drawable iconDrawable = launcherApps.getShortcutIconDrawable(shortcut, Utils.getLauncherIconDensity());
Bitmap icon = Utils.createBitmapFromDrawable(iconDrawable);
ImageView iconView = (ImageView) view.findViewById(android.R.id.icon);
iconView.setImageBitmap(icon);
if(shortcutObject instanceof ShortcutInfo) {
ShortcutInfo shortcut = (ShortcutInfo) shortcutObject;
final LauncherApps launcherApps = (LauncherApps) getSystemService(LAUNCHER_APPS_SERVICE);
final View view = getLayoutInflater().inflate(R.layout.two_lines_list_item, null);
final Drawable iconDrawable = launcherApps.getShortcutIconDrawable(shortcut, Utils.getLauncherIconDensity());
Bitmap icon = Utils.createBitmapFromDrawable(iconDrawable);
ImageView iconView = (ImageView) view.findViewById(android.R.id.icon);
iconView.setImageBitmap(icon);
CharSequence label = shortcut.getLongLabel();
if(label == null || label.length() == 0) {
label = shortcut.getShortLabel();
}
((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);
CharSequence label = shortcut.getLongLabel();
if (label == null || label.length() == 0) {
label = shortcut.getShortLabel();
}
((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() {
@ -3826,6 +3834,57 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
view.setOnLongClickListener(mAppShortcutLongClickListener);
view.setTag(shortcut);
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;
@ -4186,12 +4245,16 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
}
}
List<ShortcutInfo> shortcuts = null;
List<?> shortcuts = null;
if(activity != null) {
LauncherApps.ShortcutQuery query = new LauncherApps.ShortcutQuery();
query.setQueryFlags(LauncherApps.ShortcutQuery.FLAG_MATCH_MANIFEST | LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC | LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED);
query.setActivity(activity);
shortcuts = launcherApps.getShortcuts(query, userHandle);
if(SesameFrontend.isConnected()) {
shortcuts = SesameFrontend.getRecentAppShortcuts(activity.getPackageName(), true, 5);
} else {
LauncherApps.ShortcutQuery query = new LauncherApps.ShortcutQuery();
query.setQueryFlags(LauncherApps.ShortcutQuery.FLAG_MATCH_MANIFEST | LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC | LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED);
query.setActivity(activity);
shortcuts = launcherApps.getShortcuts(query, userHandle);
}
}
if(shortcuts == null || shortcuts.size() == 0) {
@ -6495,7 +6558,7 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
@Override
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;
CharSequence label = shortcutInfo.getLongLabel();
if(label == null || label.length() == 0) {
@ -6509,7 +6572,12 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
intent.putExtra(Shortcut.INTENT_EXTRA_APP_SHORTCUT_PKG, shortcutInfo.getPackage());
intent.putExtra(Shortcut.INTENT_EXTRA_APP_SHORTCUT_DISABLED_MSG, shortcutInfo.getDisabledMessage());
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);
}
}
@Override

View file

@ -10,7 +10,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.5.0'
}
}

View file

@ -1040,7 +1040,7 @@ public class ItemLayout extends ViewGroup {
case DragEvent.ACTION_DROP:
mAutoScrolling = false;
mScreen.onItemLayoutAppShortcutDropped(this, (ShortcutInfo) event.getLocalState(), event.getX(), event.getY());
mScreen.onItemLayoutAppShortcutDropped(this, event.getLocalState(), event.getX(), event.getY());
return true;
}
return super.onDragEvent(event);

View file

@ -1,6 +1,6 @@
#Tue Dec 12 04:46:31 CET 2017
#Sun Jan 05 23:25:48 CET 2020
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
zipStoreBase=GRADLE_USER_HOME