mirror of
https://git.undefined-dev.fr/Blendman974/faceclaw.git
synced 2026-11-19 21:03:09 +00:00
Onboarding "Disconnect Other Apps" page handles case where Even app isn't installed
This commit is contained in:
1 parent
5b8f503ce3
commit
6d85c0ac3e
4 files changed
+38
-15
No files matched your search
@@ -3,6 +3,7 @@ package com.faceclaw.app;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
@@ -47,19 +48,26 @@ public final class FaceclawEvenAppDetector {
|
||||
return hasNotfication;
|
||||
}
|
||||
|
||||
public static void openEvenAppSettings(Context context) {
|
||||
/** Returns "opened", "not-installed", or "failed" for the phone UI. */
|
||||
public static String openEvenAppSettings(Context context) {
|
||||
if (context == null) {
|
||||
return;
|
||||
return "failed";
|
||||
}
|
||||
Context appContext = context.getApplicationContext();
|
||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
intent.setData(Uri.parse("package:" + EVEN_PACKAGE_NAME));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
try {
|
||||
// Settings may launch successfully and then immediately close for a
|
||||
// missing package, so check before starting the activity.
|
||||
appContext.getPackageManager().getApplicationInfo(EVEN_PACKAGE_NAME, 0);
|
||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
intent.setData(Uri.parse("package:" + EVEN_PACKAGE_NAME));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
appContext.startActivity(intent);
|
||||
} catch (Throwable t) {
|
||||
return "opened";
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return "not-installed";
|
||||
} catch (Exception t) {
|
||||
Log.w(TAG, "failed to open Even app settings", t);
|
||||
openNotificationAccessSettings(appContext);
|
||||
return "failed";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Utils } from "@nativescript/core";
|
||||
import { Dialogs, Utils } from "@nativescript/core";
|
||||
|
||||
declare const com: any;
|
||||
|
||||
@@ -23,11 +23,19 @@ export function readEvenAppNotificationState(): EvenAppNotificationState {
|
||||
}
|
||||
|
||||
export function openEvenAppSettings(): void {
|
||||
if (!global.isAndroid) return;
|
||||
const context = Utils.android.getApplicationContext();
|
||||
if (context) {
|
||||
com.faceclaw.app.FaceclawEvenAppDetector.openEvenAppSettings(context);
|
||||
}
|
||||
const context = global.isAndroid ? Utils.android.getApplicationContext() : null;
|
||||
const result = context
|
||||
? com.faceclaw.app.FaceclawEvenAppDetector.openEvenAppSettings(context)
|
||||
: "failed";
|
||||
if (result === "opened") return;
|
||||
const notInstalled = result === "not-installed";
|
||||
void Dialogs.alert({
|
||||
title: notInstalled ? "Even app not installed" : "Unable to open Even app settings",
|
||||
message: notInstalled
|
||||
? "The official Even Realities app isn't installed on this phone. If your glasses are connected to another app or phone, disconnect them there. Otherwise, you can continue."
|
||||
: "Open your phone's settings manually to manage the Even app, or disconnect your glasses from within the app that's connected to them.",
|
||||
okButtonText: "OK",
|
||||
});
|
||||
}
|
||||
|
||||
export function openNotificationAccessSettings(): void {
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
<StackLayout>
|
||||
<Label text="Disconnect Other Apps" class="h1 text-center m-t-24" textWrap="true" />
|
||||
<Label
|
||||
text="Faceclaw and the official Even Realities app can't both be connected to the glasses at once. Before continuing, open the Even app, go to Home, select your glasses, open the Connection submenu, and press Disconnect (or turn off the Even app's Bluetooth). If any other glasses app is installed (such as Mentra), disconnect it too."
|
||||
text="Your glasses can only be connected to one app or phone at a time. If they're connected to another app (such as Even Realities or MentraOS) or another phone, disconnect them there before continuing. If nothing else is connected, you can continue."
|
||||
class="body-text m-t-24" textWrap="true" />
|
||||
<Button text="Open Even App Settings" tap="{{ onOpenEvenAppSettingsTap }}" width="{{ settingsButtonWidth }}" horizontalAlignment="center" class="-primary m-t-24" />
|
||||
<Label
|
||||
text="If you use the Even Realities app, go to Home, select your glasses, open the Connection submenu, and press Disconnect (or turn off the Even app's Bluetooth)."
|
||||
class="body-text m-t-16" textWrap="true" />
|
||||
<Button text="Open Even App Settings" tap="{{ onOpenEvenAppSettingsTap }}" visibility="{{ settingsButtonVisibility }}" width="{{ settingsButtonWidth }}" horizontalAlignment="center" class="-primary m-t-24" />
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
||||
@@ -3,6 +3,10 @@ import { Frame, Observable, Screen } from "@nativescript/core";
|
||||
import { openEvenAppSettings } from "../native/even-app-conflict";
|
||||
|
||||
export class OnboardingUnpairViewModel extends Observable {
|
||||
get settingsButtonVisibility(): "visible" | "collapsed" {
|
||||
return global.isAndroid ? "visible" : "collapsed";
|
||||
}
|
||||
|
||||
onOpenEvenAppSettingsTap(): void {
|
||||
openEvenAppSettings();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user