Address review
This commit is contained in:
parent
1a659ae4b6
commit
5cfc37470e
@ -6,17 +6,12 @@ package org.citra.citra_emu.camera;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import org.citra.citra_emu.NativeLibrary;
|
||||
import org.citra.citra_emu.R;
|
||||
import org.citra.citra_emu.activities.EmulationActivity;
|
||||
import org.citra.citra_emu.utils.FileBrowserHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.citra.citra_emu.utils.PicassoUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@ -53,11 +48,7 @@ public final class StillImageCameraHelper {
|
||||
|
||||
// Called from EmulationActivity.
|
||||
public static void OnFilePickerResult(Intent result) {
|
||||
if (result == null) {
|
||||
filePickerPath = null;
|
||||
} else {
|
||||
filePickerPath = result.getDataString();
|
||||
}
|
||||
filePickerPath = result == null ? null : result.getDataString();
|
||||
|
||||
synchronized (filePickerLock) {
|
||||
filePickerLock.notifyAll();
|
||||
@ -67,15 +58,6 @@ public final class StillImageCameraHelper {
|
||||
// Blocking call. Load image from file and crop/resize it to fit in width x height.
|
||||
@Nullable
|
||||
public static Bitmap LoadImageFromFile(String uri, int width, int height) {
|
||||
try {
|
||||
return Picasso.get()
|
||||
.load(Uri.parse(uri))
|
||||
.config(Bitmap.Config.ARGB_8888)
|
||||
.centerCrop()
|
||||
.resize(width, height)
|
||||
.get();
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
return PicassoUtils.LoadBitmapFromFile(uri, width, height);
|
||||
}
|
||||
}
|
||||
|
@ -192,17 +192,19 @@ public final class SettingsFragmentPresenter {
|
||||
supportedCameraIdList.add(id);
|
||||
|
||||
final int facing = Objects.requireNonNull(characteristics.get(CameraCharacteristics.LENS_FACING));
|
||||
int stringId = R.string.camera_facing_external;
|
||||
switch (facing) {
|
||||
case CameraCharacteristics.LENS_FACING_FRONT:
|
||||
supportedCameraNameList.add(String.format("%1$s (%2$s)", id, activity.getString(R.string.camera_facing_front)));
|
||||
stringId = R.string.camera_facing_front;
|
||||
break;
|
||||
case CameraCharacteristics.LENS_FACING_BACK:
|
||||
supportedCameraNameList.add(String.format("%1$s (%2$s)", id, activity.getString(R.string.camera_facing_back)));
|
||||
stringId = R.string.camera_facing_back;
|
||||
break;
|
||||
case CameraCharacteristics.LENS_FACING_EXTERNAL:
|
||||
supportedCameraNameList.add(String.format("%1$s (%2$s)", id, activity.getString(R.string.camera_facing_external)));
|
||||
stringId = R.string.camera_facing_external;
|
||||
break;
|
||||
}
|
||||
supportedCameraNameList.add(String.format("%1$s (%2$s)", id, stringId));
|
||||
}
|
||||
} catch (CameraAccessException e) {
|
||||
Log.error("Couldn't retrieve camera list");
|
||||
|
@ -8,12 +8,10 @@ import android.os.Build;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import static android.Manifest.permission.CAMERA;
|
||||
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
|
||||
|
||||
public class PermissionsHandler {
|
||||
public static final int REQUEST_CODE_WRITE_PERMISSION = 500;
|
||||
public static final int REQUEST_CODE_CAMERA = 700;
|
||||
|
||||
// We use permissions acceptance as an indicator if this is a first boot for the user.
|
||||
public static boolean isFirstBoot(final FragmentActivity activity) {
|
||||
|
@ -8,6 +8,10 @@ import com.squareup.picasso.Picasso;
|
||||
|
||||
import org.citra.citra_emu.R;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class PicassoUtils {
|
||||
public static void loadGameIcon(ImageView imageView, String gamePath) {
|
||||
Picasso picassoInstance = new Picasso.Builder(imageView.getContext())
|
||||
@ -25,4 +29,19 @@ public class PicassoUtils {
|
||||
.transform(new PicassoRoundedCornersTransformation())
|
||||
.into(imageView);
|
||||
}
|
||||
|
||||
// Blocking call. Load image from file and crop/resize it to fit in width x height.
|
||||
@Nullable
|
||||
public static Bitmap LoadBitmapFromFile(String uri, int width, int height) {
|
||||
try {
|
||||
return Picasso.get()
|
||||
.load(Uri.parse(uri))
|
||||
.config(Bitmap.Config.ARGB_8888)
|
||||
.centerCrop()
|
||||
.resize(width, height)
|
||||
.get();
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <camera/NdkCameraManager.h>
|
||||
#include "common/common_types.h"
|
||||
@ -47,8 +48,8 @@ private:
|
||||
};
|
||||
|
||||
// Placeholders to mean 'use any front/back camera'
|
||||
constexpr char FrontCameraPlaceholder[] = "_front";
|
||||
constexpr char BackCameraPlaceholder[] = "_back";
|
||||
constexpr std::string_view FrontCameraPlaceholder = "_front";
|
||||
constexpr std::string_view BackCameraPlaceholder = "_back";
|
||||
|
||||
class Factory final : public CameraFactory {
|
||||
public:
|
||||
|
@ -208,19 +208,19 @@ void Config::ReadValues() {
|
||||
Settings::values.camera_name[OuterRightCamera] =
|
||||
sdl2_config->GetString("Camera", "camera_outer_right_name", "ndk");
|
||||
Settings::values.camera_config[OuterRightCamera] = sdl2_config->GetString(
|
||||
"Camera", "camera_outer_right_config", Camera::NDK::BackCameraPlaceholder);
|
||||
"Camera", "camera_outer_right_config", std::string{Camera::NDK::BackCameraPlaceholder});
|
||||
Settings::values.camera_flip[OuterRightCamera] =
|
||||
sdl2_config->GetInteger("Camera", "camera_outer_right_flip", 0);
|
||||
Settings::values.camera_name[InnerCamera] =
|
||||
sdl2_config->GetString("Camera", "camera_inner_name", "ndk");
|
||||
Settings::values.camera_config[InnerCamera] = sdl2_config->GetString(
|
||||
"Camera", "camera_inner_config", Camera::NDK::FrontCameraPlaceholder);
|
||||
"Camera", "camera_inner_config", std::string{Camera::NDK::FrontCameraPlaceholder});
|
||||
Settings::values.camera_flip[InnerCamera] =
|
||||
sdl2_config->GetInteger("Camera", "camera_inner_flip", 0);
|
||||
Settings::values.camera_name[OuterLeftCamera] =
|
||||
sdl2_config->GetString("Camera", "camera_outer_left_name", "ndk");
|
||||
Settings::values.camera_config[OuterLeftCamera] = sdl2_config->GetString(
|
||||
"Camera", "camera_outer_left_config", Camera::NDK::BackCameraPlaceholder);
|
||||
"Camera", "camera_outer_left_config", std::string{Camera::NDK::BackCameraPlaceholder});
|
||||
Settings::values.camera_flip[OuterLeftCamera] =
|
||||
sdl2_config->GetInteger("Camera", "camera_outer_left_flip", 0);
|
||||
|
||||
|
@ -173,8 +173,8 @@ void Java_org_citra_citra_1emu_NativeLibrary_SurfaceChanged(JNIEnv* env,
|
||||
LOG_INFO(Frontend, "Surface changed");
|
||||
}
|
||||
|
||||
void Java_org_citra_citra_1emu_NativeLibrary_SurfaceDestroyed(
|
||||
JNIEnv* env, [[maybe_unused]][[maybe_unused]] jclass clazz) {
|
||||
void Java_org_citra_citra_1emu_NativeLibrary_SurfaceDestroyed(JNIEnv* env,
|
||||
[[maybe_unused]] jclass clazz) {
|
||||
ANativeWindow_release(s_surf);
|
||||
s_surf = nullptr;
|
||||
if (window) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user