mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Some java modernization, cleanup
This commit is contained in:
1 parent
97ef1f8599
commit
853810b59f
11 files changed
+56
-107
No files matched your search
@@ -111,10 +111,6 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<meta-data
|
||||
android:name="xperiaplayoptimized_content"
|
||||
android:resource="@mipmap/ic_launcher" />
|
||||
|
||||
<profileable android:shell="true" android:enabled="true" />
|
||||
</application>
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.ppsspp.ppsspp;
|
||||
import android.media.AudioManager;
|
||||
import android.media.AudioManager.OnAudioFocusChangeListener;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
public class AudioFocusChangeListener implements OnAudioFocusChangeListener {
|
||||
// not used right now, but we may need to use it sometime. So just store it
|
||||
// for now.
|
||||
@@ -21,6 +23,7 @@ public class AudioFocusChangeListener implements OnAudioFocusChangeListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
public boolean hasAudioFocus() {
|
||||
return hasAudioFocus;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.ppsspp.ppsspp;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.ImageFormat;
|
||||
import android.graphics.Rect;
|
||||
@@ -13,6 +12,8 @@ import android.view.Display;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -124,31 +125,28 @@ class CameraHelper {
|
||||
return output;
|
||||
}
|
||||
|
||||
private final Camera.PreviewCallback mPreviewCallback = new Camera.PreviewCallback() {
|
||||
@Override
|
||||
public void onPreviewFrame(byte[] previewData, Camera camera) {
|
||||
// throttle at 16 ms
|
||||
long currentTime = SystemClock.elapsedRealtime();
|
||||
if (currentTime - mLastFrameTime < 16) {
|
||||
return;
|
||||
}
|
||||
mLastFrameTime = currentTime;
|
||||
private final Camera.PreviewCallback mPreviewCallback = (previewData, camera) -> {
|
||||
// throttle at 16 ms
|
||||
long currentTime = SystemClock.elapsedRealtime();
|
||||
if (currentTime - mLastFrameTime < 16) {
|
||||
return;
|
||||
}
|
||||
mLastFrameTime = currentTime;
|
||||
|
||||
int cameraRotation = getCameraRotation();
|
||||
byte[] newPreviewData = rotateNV21(previewData, mPreviewSize.width, mPreviewSize.height,
|
||||
mTargetWidth, mTargetHeight, cameraRotation);
|
||||
YuvImage yuvImage = new YuvImage(newPreviewData, ImageFormat.NV21, mTargetWidth, mTargetHeight, null);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int cameraRotation = getCameraRotation();
|
||||
byte[] newPreviewData = rotateNV21(previewData, mPreviewSize.width, mPreviewSize.height,
|
||||
mTargetWidth, mTargetHeight, cameraRotation);
|
||||
YuvImage yuvImage = new YuvImage(newPreviewData, ImageFormat.NV21, mTargetWidth, mTargetHeight, null);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
// convert to Jpeg
|
||||
Rect crop = new Rect(0, 0, mTargetWidth, mTargetHeight);
|
||||
yuvImage.compressToJpeg(crop, 80, baos);
|
||||
NativeApp.pushCameraImageAndroid(baos.toByteArray());
|
||||
try {
|
||||
baos.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG,"Camera I/O exception: " + e);
|
||||
}
|
||||
// convert to Jpeg
|
||||
Rect crop = new Rect(0, 0, mTargetWidth, mTargetHeight);
|
||||
yuvImage.compressToJpeg(crop, 80, baos);
|
||||
NativeApp.pushCameraImageAndroid(baos.toByteArray());
|
||||
try {
|
||||
baos.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG,"Camera I/O exception: " + e);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -158,6 +156,7 @@ class CameraHelper {
|
||||
mSurfaceTexture = new SurfaceTexture(10);
|
||||
}
|
||||
|
||||
@Keep
|
||||
static ArrayList<String> getDeviceList() {
|
||||
ArrayList<String> deviceList = new ArrayList<>();
|
||||
if (PpssppActivity.isVRDevice()) {
|
||||
|
||||
@@ -58,14 +58,6 @@ public class ContentUri {
|
||||
}
|
||||
}
|
||||
|
||||
private static final String[] columns = new String[] {
|
||||
DocumentsContract.Document.COLUMN_DISPLAY_NAME,
|
||||
DocumentsContract.Document.COLUMN_SIZE,
|
||||
DocumentsContract.Document.COLUMN_FLAGS,
|
||||
DocumentsContract.Document.COLUMN_MIME_TYPE, // check for MIME_TYPE_DIR
|
||||
DocumentsContract.Document.COLUMN_LAST_MODIFIED
|
||||
};
|
||||
|
||||
private static String cursorToString(Cursor c, String prefixLowercase) {
|
||||
final int flags = c.getInt(2);
|
||||
// Filter out any virtual or partial nonsense.
|
||||
|
||||
@@ -3,11 +3,8 @@ package org.ppsspp.ppsspp;
|
||||
import android.content.Context;
|
||||
import android.hardware.ConsumerIrManager;
|
||||
import android.hardware.ConsumerIrManager.CarrierFrequencyRange;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.ppsspp.ppsspp;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.location.GnssStatus;
|
||||
import android.location.GpsSatellite;
|
||||
@@ -16,8 +15,6 @@ import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
class LocationHelper implements LocationListener {
|
||||
private static final String TAG = LocationHelper.class.getSimpleName();
|
||||
private static final int GPGGA_ID_INDEX = 0;
|
||||
@@ -37,7 +34,6 @@ class LocationHelper implements LocationListener {
|
||||
mLocationEnable = false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
void startLocationUpdates() {
|
||||
Log.d(TAG, "startLocationUpdates");
|
||||
if (!mLocationEnable) {
|
||||
@@ -56,22 +52,12 @@ class LocationHelper implements LocationListener {
|
||||
}
|
||||
};
|
||||
mLocationManager.registerGnssStatusCallback(mGnssStatusCallback);
|
||||
mNmeaMessageListener = new OnNmeaMessageListener() {
|
||||
@Override
|
||||
public void onNmeaMessage(String message, long timestamp) {
|
||||
onNmea(message);
|
||||
}
|
||||
};
|
||||
mNmeaMessageListener = (message, timestamp) -> onNmea(message);
|
||||
mLocationManager.addNmeaListener(mNmeaMessageListener);
|
||||
} else {
|
||||
mGpsStatusListener = this::onGpsStatus;
|
||||
mLocationManager.addGpsStatusListener(mGpsStatusListener);
|
||||
mNmeaListener = new GpsStatus.NmeaListener() {
|
||||
@Override
|
||||
public void onNmeaReceived(long timestamp, String nmea) {
|
||||
onNmea(nmea);
|
||||
}
|
||||
};
|
||||
mNmeaListener = (timestamp, nmea) -> onNmea(nmea);
|
||||
mLocationManager.addNmeaListener(mNmeaListener);
|
||||
}
|
||||
mLocationEnable = true;
|
||||
@@ -85,7 +71,6 @@ class LocationHelper implements LocationListener {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
void stopLocationUpdates() {
|
||||
Log.d(TAG, "stopLocationUpdates");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.ppsspp.ppsspp;
|
||||
|
||||
// Note that the display* methods are in NativeRenderer.java
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.InputDevice;
|
||||
|
||||
@@ -1240,7 +1240,7 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList
|
||||
char c = (char) unicode;
|
||||
Log.i(TAG, "Key char event " + unicode);
|
||||
// Handle alphanumeric character
|
||||
NativeApp.keyChar(NativeApp.DEVICE_ID_KEYBOARD, (int)c);
|
||||
NativeApp.keyChar(NativeApp.DEVICE_ID_KEYBOARD, c);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1507,7 +1507,7 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
private AlertDialog.Builder createDialogBuilderNew() {
|
||||
return new AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Dialog_Alert);
|
||||
return new AlertDialog.Builder(this, android.R.style.Theme_Material_Dialog_Alert);
|
||||
}
|
||||
|
||||
private AlertDialog.Builder createDialogBuilder() {
|
||||
@@ -1533,7 +1533,6 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList
|
||||
input.setText(defaultText);
|
||||
input.setFocusableInTouchMode(true);
|
||||
input.requestFocus();
|
||||
|
||||
input.selectAll();
|
||||
//input.setSelection(input.getText().length());
|
||||
|
||||
@@ -1545,9 +1544,7 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList
|
||||
NativeApp.sendRequestResult(requestId, true, input.getText().toString(), 0);
|
||||
// Dismiss happens automatically.
|
||||
})
|
||||
.setNegativeButton("Cancel", (d, which) -> {
|
||||
d.cancel();
|
||||
});
|
||||
.setNegativeButton("Cancel", (d, which) -> d.cancel());
|
||||
builder.setOnDismissListener( d -> {
|
||||
Log.i(TAG, "input box dismissed");
|
||||
// This will be ignored if we already sent a success.
|
||||
@@ -1951,12 +1948,9 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList
|
||||
public void postCommand(String command, String parameter) {
|
||||
final String cmd = command;
|
||||
final String param = parameter;
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!processCommand(cmd, param)) {
|
||||
Log.e(TAG, "processCommand failed: cmd: '" + cmd + "' param: '" + param + "'");
|
||||
}
|
||||
runOnUiThread(() -> {
|
||||
if (!processCommand(cmd, param)) {
|
||||
Log.e(TAG, "processCommand failed: cmd: '" + cmd + "' param: '" + param + "'");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -74,19 +74,17 @@ public class SimpleFileChooser {
|
||||
|
||||
// Comparator for Arrays.sort(). Separate folders from files, order
|
||||
// alphabetically, ignore case.
|
||||
private final Comparator<File> fileArrayComparator = new Comparator<>() {
|
||||
public int compare(File file1, File file2) {
|
||||
if (file1 == null || file2 == null) // if either null, assume equal
|
||||
return 0;
|
||||
// put folder first before file
|
||||
else if (file1.isDirectory() && (!file2.isDirectory()))
|
||||
return -1;
|
||||
else if (file2.isDirectory() && (!file1.isDirectory()))
|
||||
return 1;
|
||||
else
|
||||
// when both are folders or both are files, sort by name
|
||||
return file1.getName().toUpperCase(Locale.ROOT).compareTo(file2.getName().toUpperCase(Locale.ROOT));
|
||||
}
|
||||
private final Comparator<File> fileArrayComparator = (file1, file2) -> {
|
||||
if (file1 == null || file2 == null) // if either null, assume equal
|
||||
return 0;
|
||||
// put folder first before file
|
||||
else if (file1.isDirectory() && (!file2.isDirectory()))
|
||||
return -1;
|
||||
else if (file2.isDirectory() && (!file1.isDirectory()))
|
||||
return 1;
|
||||
else
|
||||
// when both are folders or both are files, sort by name
|
||||
return file1.getName().toUpperCase(Locale.ROOT).compareTo(file2.getName().toUpperCase(Locale.ROOT));
|
||||
};
|
||||
|
||||
// Event when user click item on dialog
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package org.ppsspp.ppsspp;
|
||||
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Point;
|
||||
import android.os.Build;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
@@ -11,10 +9,6 @@ import android.view.Surface;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
public class SizeManager implements SurfaceHolder.Callback {
|
||||
private static final String TAG = "PPSSPPSizeManager";
|
||||
@@ -106,7 +100,7 @@ public class SizeManager implements SurfaceHolder.Callback {
|
||||
Log.v(TAG, "surfaceChanged: isCreating:" + holder.isCreating() + " holder: " + holder);
|
||||
if (holder.isCreating() && desiredSize.x > 0 && desiredSize.y > 0) {
|
||||
// We have called setFixedSize which will trigger another surfaceChanged after the initial
|
||||
// one. This one is the original one and we don't care about it.
|
||||
// one. This one is the original one, and we don't care about it.
|
||||
Log.w(TAG, "holder.isCreating = true, ignoring. width=" + width + " height=" + height + " desWidth=" + desiredSize.x + " desHeight=" + desiredSize.y);
|
||||
|
||||
// TODO: Should we still set earlySurface here, to be sure?
|
||||
@@ -171,18 +165,15 @@ public class SizeManager implements SurfaceHolder.Callback {
|
||||
}
|
||||
|
||||
public void setupSystemUiCallback(final View view) {
|
||||
view.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
|
||||
@Override
|
||||
public void onSystemUiVisibilityChange(int visibility) {
|
||||
// Called when the system UI's visibility changes, regardless of
|
||||
// whether it's because of our or system actions.
|
||||
// We will try to force it to follow our preference but will not stupidly
|
||||
// act as if it's visible if it's not.
|
||||
navigationHidden = ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0);
|
||||
// TODO: Check here if it's the state we want.
|
||||
Log.i(TAG, "SystemUiVisibilityChange! visibility=" + visibility + " navigationHidden: " + navigationHidden + " decorView: " + view.getWidth() + "x" + view.getHeight());
|
||||
checkDisplayMeasurements();
|
||||
}
|
||||
view.setOnSystemUiVisibilityChangeListener(visibility -> {
|
||||
// Called when the system UI's visibility changes, regardless of
|
||||
// whether it's because of our or system actions.
|
||||
// We will try to force it to follow our preference but will not stupidly
|
||||
// act as if it's visible if it's not.
|
||||
navigationHidden = ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0);
|
||||
// TODO: Check here if it's the state we want.
|
||||
Log.i(TAG, "SystemUiVisibilityChange! visibility=" + visibility + " navigationHidden: " + navigationHidden + " decorView: " + view.getWidth() + "x" + view.getHeight());
|
||||
checkDisplayMeasurements();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,6 @@ import androidx.annotation.Keep;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class TextRenderer {
|
||||
private static class Font {
|
||||
public Paint paint;
|
||||
public Typeface typeFace;
|
||||
}
|
||||
|
||||
private static Paint textPaint = null;
|
||||
|
||||
private static final Paint bg;
|
||||
@@ -22,7 +17,7 @@ public class TextRenderer {
|
||||
|
||||
private static int idGen = 1;
|
||||
|
||||
private static HashMap<java.lang.Integer, Typeface> fontMap = new HashMap<>();
|
||||
private static final HashMap<java.lang.Integer, Typeface> fontMap = new HashMap<>();
|
||||
|
||||
private static boolean highContrastFontsEnabled = false;
|
||||
|
||||
|
||||
Reference in new issue
Block a user