Fix wallpaper transparency, Recents setup guide, and drawer animation
This commit is contained in:
1 parent
2fa7bd745b
commit
216c80252d
14 files changed
+474
-86
No files matched your search
@@ -36,6 +36,7 @@ import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.Window;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.RenderProcessGoneDetail;
|
||||
@@ -77,9 +78,10 @@ import java.util.concurrent.Executors;
|
||||
*
|
||||
* and exposes window.Android (launch, appInfo, uninstall, addWidget, removeWidget,
|
||||
* placeWidgets, coverWidgets, widgetLimits, excludeGestures, loadIcons, haptic, keyboard,
|
||||
* openSettings, pickWallpaper, openRecents, httpGet, installApk, installedVersion,
|
||||
* declinedVersion) for the page's host effects. No decisions are made here: the page
|
||||
* (core/ and app/ in MoonBit) decides, this class carries them out.
|
||||
* openSettings, pickWallpaper, openRecents, recentsEnabled, openAccessibilitySettings,
|
||||
* openSelfAppInfo, httpGet, installApk, installedVersion, declinedVersion) for the page's
|
||||
* host effects. No decisions are made here: the page (core/ and app/ in MoonBit) decides,
|
||||
* this class carries them out.
|
||||
*
|
||||
* Widgets are real AppWidgetHostViews in a layer above the WebView. The page reports where
|
||||
* its live widget slots are (placeWidgets), and this class moves the views there. Package
|
||||
@@ -110,6 +112,12 @@ public class HomeActivity extends Activity {
|
||||
private final Map<String, byte[]> icons = new ConcurrentHashMap<>();
|
||||
private final Map<String, LauncherActivityInfo> activities = new ConcurrentHashMap<>();
|
||||
private final Handler main = new Handler(Looper.getMainLooper());
|
||||
private final Runnable showIme = () -> {
|
||||
if (!ready || web == null) return;
|
||||
web.requestFocus();
|
||||
InputMethodManager imm = getSystemService(InputMethodManager.class);
|
||||
if (imm != null) imm.showSoftInput(web, InputMethodManager.SHOW_IMPLICIT);
|
||||
};
|
||||
private final ExecutorService iconThread = Executors.newSingleThreadExecutor();
|
||||
|
||||
private final LauncherApps.Callback packages = new LauncherApps.Callback() {
|
||||
@@ -129,6 +137,11 @@ public class HomeActivity extends Activity {
|
||||
widgetHost = new Host(this);
|
||||
|
||||
Window w = getWindow();
|
||||
w.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
|
||||
if (Build.VERSION.SDK_INT >= 29) {
|
||||
w.setNavigationBarContrastEnforced(false);
|
||||
w.setStatusBarContrastEnforced(false);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
w.setDecorFitsSystemWindows(false);
|
||||
} else {
|
||||
@@ -139,6 +152,7 @@ public class HomeActivity extends Activity {
|
||||
}
|
||||
|
||||
private void createWebView() {
|
||||
main.removeCallbacks(showIme);
|
||||
ready = false;
|
||||
web = new WebView(this);
|
||||
web.setBackgroundColor(Color.TRANSPARENT);
|
||||
@@ -174,7 +188,9 @@ public class HomeActivity extends Activity {
|
||||
widgetViews.clear();
|
||||
widgetSizes.clear();
|
||||
widgetLayer = new CoverLayer(this);
|
||||
widgetLayer.setBackgroundColor(Color.TRANSPARENT);
|
||||
FrameLayout root = new FrameLayout(this);
|
||||
root.setBackgroundColor(Color.TRANSPARENT);
|
||||
root.addView(web);
|
||||
root.addView(widgetLayer);
|
||||
setContentView(root);
|
||||
@@ -196,6 +212,7 @@ public class HomeActivity extends Activity {
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
launcher.unregisterCallback(packages);
|
||||
main.removeCallbacks(showIme);
|
||||
iconThread.shutdownNow();
|
||||
web.destroy();
|
||||
super.onDestroy();
|
||||
@@ -752,13 +769,16 @@ public class HomeActivity extends Activity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Recents through RecentsService. Until the user has turned the service on, take
|
||||
* them to Accessibility settings, with our service highlighted where Settings supports it.
|
||||
* Show Recents through RecentsService, falling back to Accessibility settings if
|
||||
* invoked directly while the service isn't running.
|
||||
*/
|
||||
private void openRecents() {
|
||||
if (RecentsService.showRecents()) return;
|
||||
Toast.makeText(this, "Turn on \"" + getString(R.string.recents_service_label)
|
||||
+ "\" to show open windows", Toast.LENGTH_LONG).show();
|
||||
openAccessibilitySettings();
|
||||
}
|
||||
|
||||
/** Open Accessibility settings with RecentsService highlighted where Settings supports it. */
|
||||
private void openAccessibilitySettings() {
|
||||
String me = new ComponentName(this, RecentsService.class).flattenToString();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(":settings:fragment_args_key", me);
|
||||
@@ -767,6 +787,12 @@ public class HomeActivity extends Activity {
|
||||
.putExtra(":settings:show_fragment_args", args));
|
||||
}
|
||||
|
||||
/** Open ultra Home's own App info page (for "Allow restricted settings" on Android 13+). */
|
||||
private void openSelfAppInfo() {
|
||||
startIntent(new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||
Uri.fromParts("package", getPackageName(), null)));
|
||||
}
|
||||
|
||||
/** window.Android: called from the page's @jscall imports on a binder thread. */
|
||||
final class Bridge {
|
||||
@JavascriptInterface public void launch(String component) {
|
||||
@@ -833,16 +859,14 @@ public class HomeActivity extends Activity {
|
||||
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING));
|
||||
}
|
||||
|
||||
/** The page focused the drawer's search box; show the keyboard for it. */
|
||||
/** The page focused the drawer's search box; show the keyboard once the entrance finishes. */
|
||||
@JavascriptInterface public void showKeyboard() {
|
||||
main.postDelayed(() -> {
|
||||
web.requestFocus();
|
||||
InputMethodManager imm = getSystemService(InputMethodManager.class);
|
||||
if (imm != null) imm.showSoftInput(web, InputMethodManager.SHOW_IMPLICIT);
|
||||
}, 50);
|
||||
main.removeCallbacks(showIme);
|
||||
main.postDelayed(showIme, 190);
|
||||
}
|
||||
|
||||
@JavascriptInterface public void hideKeyboard() {
|
||||
main.removeCallbacks(showIme);
|
||||
main.post(() -> {
|
||||
InputMethodManager imm = getSystemService(InputMethodManager.class);
|
||||
if (imm != null) imm.hideSoftInputFromWindow(web.getWindowToken(), 0);
|
||||
@@ -857,8 +881,22 @@ public class HomeActivity extends Activity {
|
||||
main.post(() -> startIntent(Intent.createChooser(new Intent(Intent.ACTION_SET_WALLPAPER), "Wallpaper")));
|
||||
}
|
||||
|
||||
@JavascriptInterface public void openRecents() {
|
||||
@JavascriptInterface public boolean openRecents() {
|
||||
if (!RecentsService.isRunning()) return false;
|
||||
main.post(HomeActivity.this::openRecents);
|
||||
return true;
|
||||
}
|
||||
|
||||
@JavascriptInterface public boolean recentsEnabled() {
|
||||
return RecentsService.isRunning();
|
||||
}
|
||||
|
||||
@JavascriptInterface public void openAccessibilitySettings() {
|
||||
main.post(HomeActivity.this::openAccessibilitySettings);
|
||||
}
|
||||
|
||||
@JavascriptInterface public void openSelfAppInfo() {
|
||||
main.post(HomeActivity.this::openSelfAppInfo);
|
||||
}
|
||||
|
||||
/** GET a URL on a background thread; the page hears back through launcher.httpResult(tag, ok, text). */
|
||||
|
||||
@@ -13,6 +13,11 @@ import android.view.accessibility.AccessibilityEvent;
|
||||
public class RecentsService extends AccessibilityService {
|
||||
private static volatile RecentsService running;
|
||||
|
||||
/** Whether the accessibility service is currently connected. */
|
||||
static boolean isRunning() {
|
||||
return running != null;
|
||||
}
|
||||
|
||||
/** Open Recents; false when the service isn't turned on. */
|
||||
static boolean showRecents() {
|
||||
RecentsService s = running;
|
||||
|
||||
Reference in new issue
Block a user