mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Add missing permission alert for Bangle.js app loader
This commit is contained in:
committed by
Arjan Schrijver
parent
1c777550b9
commit
0dd6c9a8d2
+19
-3
@@ -26,12 +26,14 @@ import android.content.IntentFilter;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
|
import android.view.View;
|
||||||
import android.webkit.DownloadListener;
|
import android.webkit.DownloadListener;
|
||||||
import android.webkit.JavascriptInterface;
|
import android.webkit.JavascriptInterface;
|
||||||
import android.webkit.PermissionRequest;
|
import android.webkit.PermissionRequest;
|
||||||
import android.webkit.ValueCallback;
|
import android.webkit.ValueCallback;
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
@@ -106,8 +108,10 @@ public class AppsManagementActivity extends AbstractGBActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
webView.destroy();
|
if (webView != null) {
|
||||||
webView = null;
|
webView.destroy();
|
||||||
|
webView = null;
|
||||||
|
}
|
||||||
LocalBroadcastManager.getInstance(this).unregisterReceiver(deviceUpdateReceiver);
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(deviceUpdateReceiver);
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
finish();
|
finish();
|
||||||
@@ -189,8 +193,20 @@ public class AppsManagementActivity extends AbstractGBActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initViews() {
|
private void initViews() {
|
||||||
//https://stackoverflow.com/questions/4325639/android-calling-javascript-functions-in-webview
|
|
||||||
webView = findViewById(R.id.webview);
|
webView = findViewById(R.id.webview);
|
||||||
|
LinearLayout permissionMissingAlert = findViewById(R.id.permission_missing_alert);
|
||||||
|
if (GBApplication.hasInternetAccess() && !GBApplication.hasDirectInternetAccess()) {
|
||||||
|
// Using the internethelper add-on app, check whether the Bangle.js app loader is allowed in settings
|
||||||
|
boolean appLoaderAllowed = GBApplication.getPrefs().getBoolean("pref_key_internethelper_allow_bangle_app_loader", false);
|
||||||
|
if (!appLoaderAllowed) {
|
||||||
|
webView.setVisibility(View.GONE);
|
||||||
|
permissionMissingAlert.setVisibility(View.VISIBLE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
webView.setVisibility(View.VISIBLE);
|
||||||
|
permissionMissingAlert.setVisibility(View.GONE);
|
||||||
|
//https://stackoverflow.com/questions/4325639/android-calling-javascript-functions-in-webview
|
||||||
WebSettings settings = webView.getSettings();
|
WebSettings settings = webView.getSettings();
|
||||||
settings.setJavaScriptEnabled(true);
|
settings.setJavaScriptEnabled(true);
|
||||||
settings.setDatabaseEnabled(true);
|
settings.setDatabaseEnabled(true);
|
||||||
|
|||||||
@@ -5,7 +5,38 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/permission_missing_alert"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone">
|
||||||
|
<ImageView
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_warning">
|
||||||
|
</ImageView>
|
||||||
|
<TextView
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:text="@string/internet_helper_banglejs_permission_missing_title">
|
||||||
|
</TextView>
|
||||||
|
<TextView
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:text="@string/internet_helper_banglejs_permission_missing_text">
|
||||||
|
</TextView>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<WebView
|
<WebView
|
||||||
android:id="@+id/webview"
|
android:id="@+id/webview"
|
||||||
|
|||||||
@@ -4474,4 +4474,6 @@
|
|||||||
<string name="notification_channel_pebble_js_runner">Pebble JS runner</string>
|
<string name="notification_channel_pebble_js_runner">Pebble JS runner</string>
|
||||||
<string name="notification_pebble_js_service_title">Pebble JavaScript service</string>
|
<string name="notification_pebble_js_service_title">Pebble JavaScript service</string>
|
||||||
<string name="notification_pebble_js_service_text">Running Pebble app/watchface JavaScript</string>
|
<string name="notification_pebble_js_service_text">Running Pebble app/watchface JavaScript</string>
|
||||||
|
<string name="internet_helper_banglejs_permission_missing_title">Permission missing</string>
|
||||||
|
<string name="internet_helper_banglejs_permission_missing_text">Access to the Bangle.js app loader is currently not allowed by your settings. Please go to the internet helper settings in the external integrations settings to enable it.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user