mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-03 11:15:20 +02:00
Merge pull request #20789 from hrydgard/more-modernization
Android: Fix some lint warnings
This commit is contained in:
@@ -51,6 +51,10 @@ android {
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
lint {
|
||||
baseline = file("lint-baseline.xml")
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId 'org.ppsspp.ppsspp'
|
||||
if (androidGitVersion.name() != "unknown") {
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<issues format="6" by="lint 8.12.2" type="baseline" client="gradle" dependencies="false" name="AGP (8.12.2)" variant="all" version="8.12.2">
|
||||
|
||||
<issue
|
||||
id="ScopedStorage"
|
||||
message="WRITE_EXTERNAL_STORAGE is deprecated (and is not granted) when targeting Android 13+. If you need to write to shared storage, use the `MediaStore.createWriteRequest` intent."
|
||||
errorLine1=" <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="AndroidManifest.xml"
|
||||
line="24"
|
||||
column="36"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="ScopedStorage"
|
||||
message="READ_EXTERNAL_STORAGE is deprecated (and is not granted) when targeting Android 13+. If you need to query or interact with MediaStore or media files on the shared storage, you should instead use one or more new storage permissions: `READ_MEDIA_IMAGES`, `READ_MEDIA_VIDEO` or `READ_MEDIA_AUDIO`."
|
||||
errorLine1=" <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="AndroidManifest.xml"
|
||||
line="25"
|
||||
column="36"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="GestureBackNavigation"
|
||||
message="If intercepting back events, this should be handled through the registration of callbacks; see https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture"
|
||||
errorLine1=" case KeyEvent.KEYCODE_BACK:"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="src/org/ppsspp/ppsspp/NativeActivity.java"
|
||||
line="1021"
|
||||
column="8"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="GestureBackNavigation"
|
||||
message="If intercepting back events, this should be handled through the registration of callbacks; see https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture"
|
||||
errorLine1=" case KeyEvent.KEYCODE_BACK:"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="src/org/ppsspp/ppsspp/NativeActivity.java"
|
||||
line="1135"
|
||||
column="8"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="GestureBackNavigation"
|
||||
message="If intercepting back events, this should be handled through the registration of callbacks; see https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture"
|
||||
errorLine1=" case KeyEvent.KEYCODE_BACK:"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="src/org/ppsspp/ppsspp/NativeActivity.java"
|
||||
line="1169"
|
||||
column="8"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="UnusedAttribute"
|
||||
message="Attribute `appCategory` is only used in API level 26 and higher (current min is 21)"
|
||||
errorLine1=" android:appCategory="game""
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="AndroidManifest.xml"
|
||||
line="47"
|
||||
column="9"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="UnusedAttribute"
|
||||
message="Attribute `preserveLegacyExternalStorage` is only used in API level 30 and higher (current min is 21)"
|
||||
errorLine1=" android:preserveLegacyExternalStorage="true">"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="AndroidManifest.xml"
|
||||
line="51"
|
||||
column="9"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="UnusedAttribute"
|
||||
message="Attribute `shell` is only used in API level 29 and higher (current min is 21)"
|
||||
errorLine1=" <profileable android:shell="true" android:enabled="true" />"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="AndroidManifest.xml"
|
||||
line="118"
|
||||
column="22"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="QueryPermissionsNeeded"
|
||||
message="Consider adding a `<queries>` declaration to your manifest when calling this method; see https://g.co/dev/packagevisibility for details"
|
||||
errorLine1=" if (intent.resolveActivityInfo(getPackageManager(), 0) != null) {"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="src/org/ppsspp/ppsspp/NativeActivity.java"
|
||||
line="1669"
|
||||
column="16"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="SourceLockedOrientationActivity"
|
||||
message="You should not lock orientation of your activities, so that you can support a good user experience for any device or orientation"
|
||||
errorLine1=" setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="src/org/ppsspp/ppsspp/NativeActivity.java"
|
||||
line="538"
|
||||
column="4"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="SourceLockedOrientationActivity"
|
||||
message="You should not lock orientation of your activities, so that you can support a good user experience for any device or orientation"
|
||||
errorLine1=" setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="src/org/ppsspp/ppsspp/NativeActivity.java"
|
||||
line="544"
|
||||
column="4"/>
|
||||
</issue>
|
||||
|
||||
</issues>
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<style name="ppsspp_style" parent="android:Theme.DeviceDefault">
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:navigationBarColor">@color/black</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<style name="ppsspp_style" parent="android:Theme.DeviceDefault">
|
||||
<style name="ppsspp_style" parent="Theme.AppCompat.NoActionBar">
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:navigationBarColor">@color/black</item>
|
||||
|
||||
@@ -4,7 +4,4 @@
|
||||
<string name="app_name">PPSSPP</string>
|
||||
<string name="shortcut_name">PPSSPP game</string>
|
||||
|
||||
<string name="bad_disc_title">Unsupported disc</string>
|
||||
<string name="bad_disc_message">The file you selected wasn\'t recognized as a game.</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<style name="ppsspp_style">
|
||||
<style name="ppsspp_style" parent="Theme.AppCompat.NoActionBar">
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:navigationBarColor">@color/black</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@@ -143,7 +144,7 @@ class LocationHelper implements LocationListener {
|
||||
public void onProviderDisabled(@NonNull String provider) {
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.N)
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
private void onSatelliteStatus(GnssStatus status) {
|
||||
short index = 0;
|
||||
for (short i = 0; i < status.getSatelliteCount(); i++) {
|
||||
|
||||
@@ -32,7 +32,10 @@ import android.os.PowerManager;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.documentfile.provider.DocumentFile;
|
||||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
@@ -59,7 +62,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public abstract class NativeActivity extends Activity implements SensorEventListener {
|
||||
public abstract class NativeActivity extends AppCompatActivity implements SensorEventListener {
|
||||
// Remember to loadLibrary your JNI .so in a static {} block
|
||||
|
||||
// Adjust these as necessary
|
||||
@@ -184,7 +187,6 @@ public abstract class NativeActivity extends Activity implements SensorEventList
|
||||
return libdir;
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
boolean askForPermissions(String[] permissions, int requestCode) {
|
||||
boolean shouldAsk = false;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@@ -200,7 +202,6 @@ public abstract class NativeActivity extends Activity implements SensorEventList
|
||||
return shouldAsk;
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
public void sendInitialGrants() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// Let's start out granted if it was granted already.
|
||||
@@ -222,6 +223,7 @@ public abstract class NativeActivity extends Activity implements SensorEventList
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String [] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
switch (requestCode) {
|
||||
case REQUEST_CODE_STORAGE_PERMISSION:
|
||||
if (permissionsGranted(permissions, grantResults)) {
|
||||
@@ -649,7 +651,7 @@ public abstract class NativeActivity extends Activity implements SensorEventList
|
||||
} else {
|
||||
updateSystemUiVisibility();
|
||||
|
||||
mSurfaceView = new NativeSurfaceView(NativeActivity.this);
|
||||
mSurfaceView = new NativeSurfaceView(this);
|
||||
sizeManager.setSurfaceView(mSurfaceView);
|
||||
setContentView(mSurfaceView);
|
||||
startRenderLoopThread();
|
||||
@@ -662,6 +664,29 @@ public abstract class NativeActivity extends Activity implements SensorEventList
|
||||
shortcutParam = null;
|
||||
}
|
||||
|
||||
// Set up the back key handling to be future-compatible
|
||||
OnBackPressedCallback callback = new OnBackPressedCallback(true) {
|
||||
// Note: For "pretty" back handling internally, we could handle things like handleOnBackProgressed etc
|
||||
// if we want to implement our own back previews.
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (NativeApp.isAtTopLevel()) {
|
||||
// Pass through to normal logic, allowing backing out of the main screen.
|
||||
// The setEnabled dance seems to be the normal way of handling this, to avoid recursive loops.
|
||||
setEnabled(false);
|
||||
NativeActivity.this.getOnBackPressedDispatcher().onBackPressed();
|
||||
setEnabled(true);
|
||||
} else {
|
||||
// Pass straight into the native code.
|
||||
NativeApp.keyDown(NativeApp.DEVICE_ID_DEFAULT, KeyEvent.KEYCODE_BACK, false);
|
||||
NativeApp.keyUp(NativeApp.DEVICE_ID_DEFAULT, KeyEvent.KEYCODE_BACK);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Add the callback to the dispatcher
|
||||
getOnBackPressedDispatcher().addCallback(this, callback);
|
||||
|
||||
Log.i(TAG, "onCreate end");
|
||||
}
|
||||
|
||||
@@ -1030,7 +1055,7 @@ public abstract class NativeActivity extends Activity implements SensorEventList
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.N)
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
void sendMouseDelta(float dx, float dy) {
|
||||
// Ignore zero deltas.
|
||||
if (Math.abs(dx) > 0.001 || Math.abs(dx) > 0.001) {
|
||||
@@ -1110,12 +1135,8 @@ public abstract class NativeActivity extends Activity implements SensorEventList
|
||||
case KeyEvent.KEYCODE_BACK:
|
||||
if (event.isAltPressed()) {
|
||||
NativeApp.keyDown(NativeApp.DEVICE_ID_PAD_0, 1004, repeat); // special custom keycode for the O button on Xperia Play
|
||||
} else if (NativeApp.isAtTopLevel()) {
|
||||
Log.i(TAG, "IsAtTopLevel returned true.");
|
||||
// Pass through the back event.
|
||||
return super.onKeyDown(keyCode, event);
|
||||
} else {
|
||||
NativeApp.keyDown(NativeApp.DEVICE_ID_DEFAULT, keyCode, repeat);
|
||||
super.onKeyDown(keyCode, event);
|
||||
}
|
||||
return true;
|
||||
case KeyEvent.KEYCODE_MENU:
|
||||
@@ -1148,11 +1169,8 @@ public abstract class NativeActivity extends Activity implements SensorEventList
|
||||
case KeyEvent.KEYCODE_BACK:
|
||||
if (event.isAltPressed()) {
|
||||
NativeApp.keyUp(NativeApp.DEVICE_ID_PAD_0, 1004); // special custom keycode
|
||||
} else if (NativeApp.isAtTopLevel()) {
|
||||
Log.i(TAG, "IsAtTopLevel returned true.");
|
||||
return super.onKeyUp(keyCode, event);
|
||||
} else {
|
||||
NativeApp.keyUp(NativeApp.DEVICE_ID_DEFAULT, keyCode);
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
return true;
|
||||
case KeyEvent.KEYCODE_MENU:
|
||||
@@ -1281,7 +1299,7 @@ public abstract class NativeActivity extends Activity implements SensorEventList
|
||||
return bld;
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
private AlertDialog.Builder createDialogBuilderNew() {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Dialog_Alert);
|
||||
bld.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@@ -1313,12 +1331,12 @@ public abstract class NativeActivity extends Activity implements SensorEventList
|
||||
input.setText(defaultText);
|
||||
input.selectAll();
|
||||
|
||||
// Lovely!
|
||||
AlertDialog.Builder bld;
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
bld = createDialogBuilderWithDeviceThemeAndUiVisibility();
|
||||
else
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
bld = createDialogBuilderNew();
|
||||
} else {
|
||||
bld = createDialogBuilderWithDeviceThemeAndUiVisibility();
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = bld
|
||||
.setView(fl)
|
||||
|
||||
@@ -118,6 +118,7 @@ public class PpssppActivity extends NativeActivity {
|
||||
|
||||
@Override
|
||||
public void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
String value = parseIntent(intent);
|
||||
if (value != null) {
|
||||
// TODO: Actually send a command to the native code to launch the new game.
|
||||
|
||||
Reference in New Issue
Block a user