-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(web): Merge branch 'fix/web/infinite-model-replacement-loop' in…
…to fix/web/proper-gesture-match-sequencing
- Loading branch information
Showing
423 changed files
with
14,454 additions
and
2,874 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
17.0.271 | ||
17.0.285 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
android/KMAPro/kMAPro/src/main/java/com/tavultesoft/kmapro/CheckPermissions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/** | ||
* Copyright 2024 SIL International | ||
*/ | ||
package com.tavultesoft.kmapro; | ||
|
||
import static com.tavultesoft.kmapro.MainActivity.PERMISSION_REQUEST_STORAGE; | ||
|
||
import android.Manifest; | ||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.content.pm.PackageManager; | ||
import android.os.Build; | ||
import android.os.Environment; | ||
import android.widget.Toast; | ||
|
||
import androidx.appcompat.app.AlertDialog; | ||
import androidx.core.app.ActivityCompat; | ||
import androidx.core.content.ContextCompat; | ||
|
||
public class CheckPermissions { | ||
|
||
public static boolean isPermissionOK(Activity activity) { | ||
boolean permissionsOK = true; | ||
|
||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { | ||
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 { | ||
permissionsOK = checkPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE); | ||
} | ||
|
||
return permissionsOK; | ||
} | ||
|
||
public static boolean checkPermission(Activity activity, String permission) { | ||
return ContextCompat.checkSelfPermission(activity.getApplicationContext(), permission) == PackageManager.PERMISSION_GRANTED; | ||
} | ||
|
||
public static void requestPermission (Activity activity, Context context) { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { | ||
// Need to request multiple permissions at once | ||
// TODO: request multiple permissions at once #10659 | ||
showPermissionDenied(context); | ||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { | ||
// TODO: find alternative to below. #10659 | ||
// It works, but would need Play Store approval | ||
// For now, show permission denied | ||
showPermissionDenied(context); | ||
/* | ||
try { | ||
Intent intent = new Intent(); | ||
intent.setAction(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION); | ||
Uri uri = Uri.fromParts("package", activity.getPackageName(), null); | ||
intent.setData(uri); | ||
activity.startActivity(intent); | ||
} catch (Exception e) { | ||
Intent intent = new Intent(); | ||
intent.setAction(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION); | ||
activity.startActivity(intent); | ||
} | ||
*/ | ||
} else if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.READ_EXTERNAL_STORAGE)) { | ||
// Provide additional rationale to the user if the permission was not granted | ||
String message = activity.getApplicationContext().getString(R.string.request_storage_permission); | ||
Toast.makeText(activity.getApplicationContext(), message , | ||
Toast.LENGTH_LONG).show(); | ||
ActivityCompat.requestPermissions(activity, | ||
new String[]{ Manifest.permission.READ_EXTERNAL_STORAGE }, | ||
PERMISSION_REQUEST_STORAGE); | ||
} else { | ||
// Request the permission. The result will be received in onRequestPermissionsResult(). | ||
ActivityCompat.requestPermissions(activity, | ||
new String[]{ Manifest.permission.READ_EXTERNAL_STORAGE }, | ||
PERMISSION_REQUEST_STORAGE); | ||
} | ||
} | ||
|
||
public static void showPermissionDenied(Context context) { | ||
// Permission request denied | ||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context); | ||
dialogBuilder.setTitle(String.format(context.getString(R.string.title_add_keyboard))); | ||
dialogBuilder.setMessage(String.format(context.getString(R.string.storage_permission_denied2))); | ||
dialogBuilder.setPositiveButton(context.getString(R.string.label_ok), null); | ||
AlertDialog dialog = dialogBuilder.create(); | ||
dialog.show(); | ||
|
||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
android/KMAPro/kMAPro/src/main/java/com/tavultesoft/kmapro/DefaultLanguageResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (C) 2024 SIL International. All rights reserved. | ||
*/ | ||
|
||
package com.tavultesoft.kmapro; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
|
||
import com.keyman.engine.KMManager; | ||
import com.keyman.engine.data.LexicalModel; | ||
|
||
import java.util.HashMap; | ||
|
||
public class DefaultLanguageResource { | ||
private static final String defaultKeyboardInstalled = "DefaultKeyboardInstalled"; | ||
private static final String defaultDictionaryInstalled = "DefaultDictionaryInstalled"; | ||
|
||
/** | ||
* Check if app has installed default keyboard and dictionary. If not, install them | ||
* @param context | ||
*/ | ||
public static void install(Context context) { | ||
SharedPreferences prefs = context.getSharedPreferences(context.getString(R.string.kma_prefs_name), Context.MODE_PRIVATE); | ||
|
||
// Add default keyboard | ||
boolean installDefaultKeyboard = prefs.getBoolean(defaultKeyboardInstalled, false); | ||
if (!installDefaultKeyboard) { | ||
if (!KMManager.keyboardExists(context, KMManager.KMDefault_PackageID, KMManager.KMDefault_KeyboardID, | ||
KMManager.KMDefault_LanguageID)) { | ||
KMManager.addKeyboard(context, KMManager.getDefaultKeyboard(context.getApplicationContext())); | ||
} | ||
SharedPreferences.Editor editor = prefs.edit(); | ||
editor.putBoolean(defaultKeyboardInstalled, true); | ||
editor.commit(); | ||
} | ||
|
||
// Add default dictionary | ||
boolean installDefaultDictionary = prefs.getBoolean(defaultDictionaryInstalled, false); | ||
if (!installDefaultDictionary) { | ||
LexicalModel defaultLexicalModel = LexicalModel.getDefaultLexicalModel(context); | ||
HashMap<String, String> lexicalModelInfo = new HashMap<String, String>(); | ||
lexicalModelInfo.put(KMManager.KMKey_PackageID, defaultLexicalModel.getPackageID()); | ||
lexicalModelInfo.put(KMManager.KMKey_LanguageID, defaultLexicalModel.getLanguageID()); | ||
lexicalModelInfo.put(KMManager.KMKey_LanguageName, defaultLexicalModel.getLanguageName()); | ||
lexicalModelInfo.put(KMManager.KMKey_LexicalModelID, defaultLexicalModel.getLexicalModelID()); | ||
lexicalModelInfo.put(KMManager.KMKey_LexicalModelName, defaultLexicalModel.getLexicalModelName()); | ||
lexicalModelInfo.put(KMManager.KMKey_LexicalModelVersion, defaultLexicalModel.getVersion()); | ||
/* | ||
// If welcome.htm exists, add custom help link | ||
welcomeFile = new File(KMManager.getLexicalModelsDir(), KMManager.KMDefault_DictionaryPackageID + File.separator + FileUtils.WELCOME_HTM); | ||
lexicalModelInfo.put(KMManager.KMKey_CustomHelpLink, welcomeFile.getPath()); | ||
*/ | ||
KMManager.addLexicalModel(context, lexicalModelInfo); | ||
KMManager.registerAssociatedLexicalModel(KMManager.KMDefault_LanguageID); | ||
|
||
SharedPreferences.Editor editor = prefs.edit(); | ||
editor.putBoolean(defaultDictionaryInstalled, true); | ||
editor.commit(); | ||
} | ||
} | ||
} |
Oops, something went wrong.