Skip to content

Commit

Permalink
Merge pull request #11305 from keymanapp/chore/beta-to-master-b17s6-2
Browse files Browse the repository at this point in the history
chore(common): Merge beta to master for Sprint B17S6 (part 2)
  • Loading branch information
darcywong00 authored Apr 26, 2024
2 parents 8a62c30 + 12c79fb commit 71f3287
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 110 deletions.
13 changes: 13 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@
* chore(common): move to 18.0 alpha (#10713)
* chore: move to 18.0 alpha

## 17.0.314 beta 2024-04-25

* fix(android/engine): URIEncode strings passed to Javascript (#11206)
* fix(android/app): Update storage permissions for Android 12.0+ (#11299)
* test(developer): keyboard info compiler messages unit tests 2 (#11253)

## 17.0.313 beta 2024-04-23

* chore(common): Set fetch-latest-cldr.sh executable (#11289)
* chore(common): Fix missing entries in HISTORY.md (#11290)
* fix(developer): report missing help to sentry instead of local xml (#11271)
* fix(developer): "use strict" for downlevel browsers in Server (#11276)

## 17.0.312 beta 2024-04-22

* fix(developer): emit JSON strings as characters, not surrogate pairs (#11243)
Expand Down
4 changes: 4 additions & 0 deletions android/KMAPro/kMAPro/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />

<!-- API 33 and above -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />

<!-- Devices running up to Android 12L
Starting in API level 33, this permission has no effect:
https://developer.android.com/reference/android/Manifest.permission#READ_EXTERNAL_STORAGE -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@ public static boolean isPermissionOK(Activity activity) {
return permissionsOK;
}

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
permissionsOK = Environment.isExternalStorageManager();
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) {
// TODO: Workout scoped storage permission #10659
}
} else {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
// < API 30
permissionsOK = checkPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
// API 30-32
permissionsOK = Environment.isExternalStorageManager() ||
checkPermission(activity, Manifest.permission.READ_EXTERNAL_STORAGE);
} else {
// API 33+
//https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions
// Manifest.permission.READ_MEDIA_AUDIO doesn't seem to be needed
permissionsOK = permissionsOK && checkPermission(activity, Manifest.permission.READ_MEDIA_IMAGES);
permissionsOK = permissionsOK && checkPermission(activity, Manifest.permission.READ_MEDIA_VIDEO);
}

return permissionsOK;
Expand Down
9 changes: 4 additions & 5 deletions android/KMEA/app/src/main/assets/android-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ function setKeymanLanguage(k) {
}

function setSpacebarText(mode) {
keyman.config.spacebarText = mode;
var text = (mode == undefined) || !mode.text ? '' : mode.text;
keyman.config.spacebarText = text;
}

// #6665: we need to know when the user has pressed a hardware key so we don't
Expand Down Expand Up @@ -234,10 +235,8 @@ function setNumericLayer() {
}
}

function updateKMText(text) {
if(text == undefined) {
text = '';
}
function updateKMText(k) {
var text = (k == undefined) || !k.text ? '' : k.text;

console_debug('updateKMText(text=' + text + ') with: \n' + build_context_string(keyman.context));

Expand Down
28 changes: 23 additions & 5 deletions android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Handler;
import android.util.DisplayMetrics;
import android.util.Log;
Expand Down Expand Up @@ -149,13 +150,19 @@ protected void setShouldIgnoreSelectionChange(boolean ignore) {

protected boolean updateText(String text) {
boolean result = false;
JSONObject reg = new JSONObject();
String kmText = "";
if (text != null) {
kmText = text.toString().replace("\\", "\\u005C").replace("'", "\\u0027").replace("\n", "\\n");
// Use JSON to handle passing string to Javascript
try {
reg.put("text", text.toString());
} catch (JSONException e) {
KMLog.LogException(TAG, "", e);
}
}

if (KMManager.isKeyboardLoaded(this.keyboardType) && !shouldIgnoreTextChange) {
this.loadJavascript(KMString.format("updateKMText('%s')", kmText));
this.loadJavascript(KMString.format("updateKMText(%s)", reg.toString()));
result = true;
}

Expand Down Expand Up @@ -229,6 +236,7 @@ public void initKMKeyboard(final Context context) {

getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
getSettings().setSupportZoom(false);
getSettings().setTextZoom(100);

getSettings().setUseWideViewPort(true);
getSettings().setLoadWithOverviewMode(true);
Expand Down Expand Up @@ -350,7 +358,8 @@ public void run() {
allCalls.append(";");
}

loadUrl("javascript:" + allCalls.toString());
// Ensure strings safe for Javascript. TODO: font strings
loadUrl("javascript:" + Uri.encode(allCalls.toString()));

if(javascriptAfterLoad.size() > 0 && keyboardSet) {
callJavascriptAfterLoad();
Expand Down Expand Up @@ -1098,8 +1107,17 @@ public void reloadAfterError() {
}

public void setSpacebarText(KMManager.SpacebarText mode) {
String jsString = KMString.format("setSpacebarText('%s')", mode.toString());
loadJavascript(jsString);
JSONObject reg = new JSONObject();
if (mode != null) {
// Use JSON to handle passing string to Javascript
try {
reg.put("text", mode.toString());
} catch (JSONException e) {
KMLog.LogException(TAG, "", e);
}
}

this.loadJavascript(KMString.format("setSpacebarText(%s)", reg.toString()));
}

/* Implement handleTouchEvent to catch long press gesture without using Android system default time
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
</Info>
<Files>
<File>
<Name>..\..\..\..\..\..\..\web\testing\chirality\chirality.js</Name>
<Name>..\..\..\..\..\..\..\web\src\test\manual\web\chirality\chirality.js</Name>
<Description>File chirality.js</Description>
<CopyLocation>0</CopyLocation>
<FileType>.js</FileType>
</File>
<File>
<Name>..\..\..\..\..\..\..\web\testing\platform\platformtest.js</Name>
<Name>..\..\..\..\..\..\..\web\src\test\manual\web\platform\platformtest.js</Name>
<Description>File platformtest.js</Description>
<CopyLocation>0</CopyLocation>
<FileType>.js</FileType>
Expand Down Expand Up @@ -62,7 +62,7 @@
</Languages>
</Keyboard>
<Keyboard>
<Name>longpress</Name>
<Name>longpress '"\|5% +</Name>
<ID>longpress</ID>
<Version>1.0</Version>
<OSKFont>code2001.ttf</OSKFont>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ KeymanWeb.KR(new Keyboard_longpress());

function Keyboard_longpress() {
this.KI = "Keyboard_longpress";
this.KN = "longpress";
this.KN = "longpress '\"\\|5% +";
this.KV = null;
this.KH = '';
this.KM = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected void onCreate(Bundle savedInstanceState) {
Keyboard longpressKBbInfo = new Keyboard(
"keyboardharness",
"longpress",
"Longpress Keyboard",
"longpress '\"\\|5% +",
"en",
"English",
"1.0",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/help/android_images/keyman-storage-permission-ap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 18 additions & 3 deletions android/help/troubleshooting/grant-storage-permission.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@
title: How To - Granting Storage Permission
---

## Granting storage permission
## Granting Storage Permission
If Keyman for Android is permanently denied storage access, attempts to install custom packages will fail with the
notification "Storage permission request was denied". Perform these steps to grant Keyman for Android access to storage

### Android 11.0 to 12L Devices

Step 1)
Go to Android Settings.

Step 2)
Depending on your device, click "Apps", "Apps & notifications", or "App permissions" and grant Keyman
storage permission. The screenshot below is from Android 9.0 Pie.
permission to access storage / "file and media". The screenshot below is from Android 12.0 S.

![](../android_images/keyman-storage-permission-ap.png)

### Android 13.0+ Devices

Step 1)
Go to Android Settings.

Step 2)
Depending on your device, click "Apps" and grant Keyman permission to the following:
* Photos and videos --> Always allow all

The screenshot below is from Android 14.0.

![](../android_images/keyman-storage-permission-ap.png)
![](../android_images/keyman-storage-permission-34b.png)
Loading

0 comments on commit 71f3287

Please sign in to comment.