Files
Camera/app/src/main/java/com/simplemobiletools/camera/Utils.java
2016-04-28 00:10:04 +02:00

40 lines
1.2 KiB
Java

package com.simplemobiletools.camera;
import android.content.Context;
import android.hardware.Camera;
import android.widget.Toast;
import java.util.List;
public class Utils {
public static Camera.CameraInfo getCameraInfo(int cameraId) {
final Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
Camera.getCameraInfo(cameraId, info);
return info;
}
public static void showToast(Context context, int resId) {
Toast.makeText(context, context.getResources().getString(resId), Toast.LENGTH_SHORT).show();
}
public static boolean hasFlash(Camera camera) {
if (camera == null) {
return false;
}
final Camera.Parameters parameters = camera.getParameters();
if (parameters.getFlashMode() == null) {
return false;
}
final List<String> supportedFlashModes = parameters.getSupportedFlashModes();
if (supportedFlashModes == null || supportedFlashModes.isEmpty() ||
supportedFlashModes.size() == 1 && supportedFlashModes.get(0).equals(Camera.Parameters.FLASH_MODE_OFF)) {
return false;
}
return true;
}
}