Skip to content

Commit 715908d

Browse files
committedJul 21, 2020
Add android.permission.QUERY_ALL_PACKAGES (Android v11)
+ small fixes
1 parent 2897e4c commit 715908d

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed
 

‎app/build.gradle

+7-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ android {
2626
applicationId 'ee.ioc.phon.android.speak'
2727
minSdkVersion 16
2828
targetSdkVersion 30
29-
versionCode 1733
30-
versionName '1.7.33'
29+
versionCode 1734
30+
versionName '1.7.34'
3131
vectorDrawables.useSupportLibrary = true
3232
// Keep only en and et resources
3333
resConfigs "en", "et"
@@ -85,6 +85,7 @@ if (project.hasProperty('storePassword') &&
8585
android.signingConfigs.release.storePassword = storePassword
8686
android.signingConfigs.release.keyPassword = keyPassword
8787
} else {
88+
println "WARNING: The release will not be signed"
8889
android.buildTypes.release.signingConfig = null
8990
}
9091

@@ -97,11 +98,13 @@ task deploy {
9798

9899
def version = android.defaultConfig.versionName
99100

101+
def name = 'K6nele'
102+
100103
def outputs = 'build/outputs/'
101104
def apk1 = outputs + 'apk/release/app-release.apk'
102-
def apk2 = "${deploy_dir}K6nele-${version}.apk"
105+
def apk2 = "${deploy_dir}${name}-${version}.apk"
103106
def mapping1 = outputs + 'mapping/release/mapping.txt'
104-
def mapping2 = "${deploy_dir}K6nele-mapping-${version}.txt"
107+
def mapping2 = "${deploy_dir}${name}-mapping-${version}.txt"
105108

106109
exec {
107110
commandLine 'cp', '--verbose', apk1, apk2

‎app/src/main/AndroidManifest.xml

+3-4
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,13 @@
4242
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
4343

4444
<!-- TODO: try to avoid having to request this permission.
45-
We query packages for 2 reasons:
45+
Android v11. We query packages for 3 reasons:
4646
1) finding speech recognizer providers (this query is declared below in the queries-section)
4747
2) listing apps (with icon and launch intent) that have previously launched Kõnele
48-
It is unclear if the latter use-case can be declared via the queries-section.
48+
3) launching intents (e.g. setting the alarm or opening maps) via rewrites
49+
It is unclear if use-cases 2 and 3 could be instead declared via the queries-section.
4950
-->
50-
<!--
5151
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
52-
-->
5352

5453
<!-- Custom permission required by GetPutPreferenceActivity to be able to read/write the Kõnele settings. -->
5554
<!--

‎app/src/main/java/ee/ioc/phon/android/speak/model/RecService.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.content.ComponentName;
44
import android.content.Context;
55
import android.content.Intent;
6+
import android.content.pm.PackageManager;
67
import android.content.pm.ServiceInfo;
78
import android.graphics.drawable.Drawable;
89
import android.util.Pair;
@@ -22,17 +23,23 @@ public class RecService {
2223
private final ComponentName mComponentName;
2324

2425
public RecService(Context context, String id) {
26+
String mDesc1 = "";
2527
// Can return <null, "">
2628
Pair<ComponentName, String> pair = RecognitionServiceManager.unflattenFromString(id);
2729
mComponentName = pair.first;
30+
2831
mLabel = RecognitionServiceManager.getServiceLabel(context, mComponentName);
2932
ServiceInfo si = RecognitionServiceManager.getServiceInfo(context, mComponentName);
3033
int resId = si.descriptionRes;
31-
if (resId == 0) {
32-
mDesc = "";
33-
} else {
34-
mDesc = context.getString(si.descriptionRes);
34+
if (resId != 0) {
35+
try {
36+
PackageManager manager = context.getPackageManager();
37+
mDesc1 = manager.getResourcesForApplication(mComponentName.getPackageName()).getString(resId);
38+
} catch (PackageManager.NameNotFoundException e) {
39+
// Should not happen
40+
}
3541
}
42+
mDesc = mDesc1;
3643
try {
3744
mSettingsActivity = RecognitionServiceManager.getSettingsActivity(context, si);
3845
Log.i(mSettingsActivity);

‎app/src/main/java/ee/ioc/phon/android/speak/utils/Utils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static String idToValue(Context context, Uri contentUri, String columnId,
101101
* is Theme.Translucent.NoTitleBar then the dialog is unstyled (maybe an Android bug?)
102102
*/
103103
public static AlertDialog getLaunchIntentDialog(final AppCompatActivity activity, String msg, final Intent intent) {
104-
return new AlertDialog.Builder(activity, android.R.style.Theme_DeviceDefault_Dialog)
104+
return new AlertDialog.Builder(activity, R.style.Theme_K6nele_Dialog)
105105
.setPositiveButton(activity.getString(R.string.buttonGoToSettings), (dialog, id) -> {
106106
activity.startActivity(intent);
107107
activity.finish();
@@ -127,7 +127,7 @@ public static AlertDialog getYesNoDialog(Context context, String confirmationMes
127127
}
128128

129129
public static AlertDialog getYesNoDialog(Context context, String confirmationMessage, final Executable ex1, final Executable ex2) {
130-
AlertDialog.Builder builder = new AlertDialog.Builder(context, android.R.style.Theme_DeviceDefault_Dialog);
130+
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.Theme_K6nele_Dialog);
131131
builder
132132
.setMessage(confirmationMessage)
133133
.setCancelable(false)

‎build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:4.0.0'
8+
classpath 'com.android.tools.build:gradle:4.0.1'
99
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1010
}
1111
}

0 commit comments

Comments
 (0)
Failed to load comments.