Skip to content

Commit 206e822

Browse files
authored
Require minSdkVersion 23 (was 21) to simply code (#105)
Require minSdkVersion 23 (was 21) to simply code
1 parent 616f9e7 commit 206e822

22 files changed

+61
-66
lines changed

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ android {
2727
// API level 21: Jetpack Compose
2828
defaultConfig {
2929
applicationId 'ee.ioc.phon.android.speak'
30-
minSdkVersion 21
30+
minSdkVersion 23
3131
targetSdkVersion 33
32-
versionCode 1817
33-
versionName '1.8.17'
32+
versionCode 1900
33+
versionName '1.9.00'
3434
vectorDrawables.useSupportLibrary = true
3535
// Keep only en and et resources
3636
resConfigs 'en', 'et'

app/src/main/java/ee/ioc/phon/android/speak/AppListCursorAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
*/
4444
public class AppListCursorAdapter extends CursorAdapter {
4545

46-
private String mDefaultServerUrl;
47-
private PackageManager mPm;
46+
private final String mDefaultServerUrl;
47+
private final PackageManager mPm;
4848

4949
public AppListCursorAdapter(Context context, Cursor c, boolean autoRequery) {
5050
super(context, c, autoRequery);

app/src/main/java/ee/ioc/phon/android/speak/Caller.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public Caller(PendingIntent pendingIntent, Bundle bundle) {
7070
if (pendingIntent == null) {
7171
mPrimaryCaller = bundle.getString(RecognizerIntent.EXTRA_CALLING_PACKAGE);
7272
} else {
73-
mPrimaryCaller = pendingIntent.getTargetPackage();
73+
mPrimaryCaller = pendingIntent.getCreatorPackage();
7474
}
7575
mSecondaryCaller = getPackageName(bundle);
7676
}
@@ -120,7 +120,7 @@ public static String getCaller(ComponentName callingActivity, PendingIntent pend
120120
return callingActivity.getPackageName();
121121
}
122122
} else {
123-
return pendingIntent.getTargetPackage();
123+
return pendingIntent.getCreatorPackage();
124124
}
125125
return null;
126126
}

app/src/main/java/ee/ioc/phon/android/speak/QuickSettingsManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public class QuickSettingsManager {
2121
COMBOS_MULTILINGUAL = Collections.unmodifiableSet(set);
2222
}
2323

24-
private SharedPreferences mPrefs;
25-
private Resources mRes;
24+
private final SharedPreferences mPrefs;
25+
private final Resources mRes;
2626

2727
public QuickSettingsManager(SharedPreferences prefs, Resources res) {
2828
mPrefs = prefs;

app/src/main/java/ee/ioc/phon/android/speak/activity/AbstractRecognizerIntentActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public abstract class AbstractRecognizerIntentActivity extends AppCompatActivity
8686

8787
private Iterable<UtteranceRewriter> mRewriters;
8888

89-
private static SparseIntArray mErrorCodesServiceToIntent = IntentUtils.createErrorCodesServiceToIntent();
89+
private static final SparseIntArray mErrorCodesServiceToIntent = IntentUtils.createErrorCodesServiceToIntent();
9090

9191
private List<byte[]> mBufferList = new ArrayList<>();
9292

@@ -580,7 +580,7 @@ private SparseArray<String> createErrorMessages() {
580580
*/
581581
protected void setResultError(int errorCode) {
582582
if (mIsReturnErrors) {
583-
Integer errorCodeIntent = mErrorCodesServiceToIntent.get(errorCode);
583+
int errorCodeIntent = mErrorCodesServiceToIntent.get(errorCode);
584584
setResult(errorCodeIntent);
585585
finish();
586586
}

app/src/main/java/ee/ioc/phon/android/speak/activity/DetailsActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void onCreate(Bundle savedInstanceState) {
5454
Bundle extras = intent.getExtras();
5555

5656
if (extras == null) {
57-
requestWindowFeature(Window.FEATURE_NO_TITLE);
57+
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
5858
mIsFinishAfterPlayAudio = true;
5959
}
6060

@@ -66,7 +66,7 @@ public void onCreate(Bundle savedInstanceState) {
6666
if (extras != null) {
6767
String title = extras.getString(EXTRA_TITLE);
6868
if (title == null) {
69-
requestWindowFeature(Window.FEATURE_NO_TITLE);
69+
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
7070
} else {
7171
setTitle(title);
7272
}

app/src/main/java/ee/ioc/phon/android/speak/activity/RewritesLoaderActivity.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import androidx.appcompat.app.AppCompatActivity;
3232

3333
import java.io.IOException;
34-
import java.io.UnsupportedEncodingException;
34+
import java.nio.charset.StandardCharsets;
3535
import java.util.ArrayList;
3636
import java.util.Collections;
3737
import java.util.List;
@@ -113,11 +113,7 @@ public void onCreate(Bundle savedInstanceState) {
113113
if (uri != null) {
114114
if ("k6".equals(uri.getScheme())) {
115115
byte[] data = Base64.decode(uri.getSchemeSpecificPart().substring(2), Base64.NO_WRAP | Base64.URL_SAFE);
116-
try {
117-
utteranceRewriter = new UtteranceRewriter(new String(data, "UTF-8"));
118-
} catch (UnsupportedEncodingException e) {
119-
// TODO: dont ignore
120-
}
116+
utteranceRewriter = new UtteranceRewriter(new String(data, StandardCharsets.UTF_8));
121117
} else {
122118
utteranceRewriter = loadFromUri(uri);
123119
}

app/src/main/java/ee/ioc/phon/android/speak/activity/ServerListActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class ServerListActivity extends AbstractContentActivity {
3232
Server.Columns.URL
3333
};
3434

35-
private static int[] TO = new int[]{
35+
private static final int[] TO = new int[]{
3636
R.id.itemServerId,
3737
R.id.itemServerUrl
3838
};

app/src/main/java/ee/ioc/phon/android/speak/demo/EncoderListDemo.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import android.widget.ListView
66
import androidx.appcompat.app.AppCompatActivity
77
import ee.ioc.phon.android.speak.R
88
import ee.ioc.phon.android.speechutils.utils.AudioUtils
9-
import java.util.*
109

1110
class EncoderListDemo : AppCompatActivity() {
1211

@@ -17,7 +16,7 @@ class EncoderListDemo : AppCompatActivity() {
1716
val mime = "audio/flac"
1817
info.add(mime + " encoders: " + AudioUtils.getEncoderNamesForType(mime).toString())
1918
info.addAll(AudioUtils.getAvailableEncoders(mime, 16000))
20-
val listView = findViewById(android.R.id.list) as ListView
19+
val listView = findViewById<ListView>(android.R.id.list)
2120
listView.adapter = ArrayAdapter(this, R.layout.list_item_detail, info.toTypedArray())
2221
}
2322
}

app/src/main/java/ee/ioc/phon/android/speak/demo/HandsfreeDemoActivity.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,22 @@ class HandsfreeDemoActivity : AbstractRecognizerDemoActivity() {
8181

8282

8383
private fun updateListView(list: List<String>) {
84-
(findViewById<View>(R.id.list_matches) as ListView).adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, list)
84+
(findViewById<View>(R.id.list_matches) as ListView).adapter =
85+
ArrayAdapter(this, android.R.layout.simple_list_item_1, list)
8586
}
8687

8788
companion object {
8889

8990
// TODO: smaller values (e.g. < 800) cause an error with the local server with a single slot
90-
private val SLEEP_TIME = 10
91-
private val MAX_COUNT = 5
91+
private const val SLEEP_TIME = 10
92+
private const val MAX_COUNT = 5
9293

9394
private fun createRecognizerIntent(): Intent {
9495
val intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
95-
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM)
96+
intent.putExtra(
97+
RecognizerIntent.EXTRA_LANGUAGE_MODEL,
98+
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM
99+
)
96100
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3)
97101
intent.putExtra(Extras.EXTRA_AUTO_START, true)
98102
intent.putExtra(Extras.EXTRA_RETURN_ERRORS, true)

0 commit comments

Comments
 (0)