update the bright display and strobo icons + misc adjustments
@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
|
||||
import com.squareup.otto.Bus;
|
||||
@ -14,9 +15,11 @@ class MarshmallowCamera {
|
||||
|
||||
private CameraManager manager;
|
||||
private String cameraId;
|
||||
private Context mContext;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
MarshmallowCamera(Context context) {
|
||||
mContext = context;
|
||||
manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
|
||||
try {
|
||||
final String[] list = manager.getCameraIdList();
|
||||
@ -31,7 +34,14 @@ class MarshmallowCamera {
|
||||
manager.setTorchMode(cameraId, enable);
|
||||
} catch (CameraAccessException e) {
|
||||
Log.e(TAG, "toggle marshmallow flashlight " + e.getMessage());
|
||||
bus.post(new Events.CameraUnavailable());
|
||||
|
||||
Runnable mainRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
bus.post(new Events.CameraUnavailable());
|
||||
}
|
||||
};
|
||||
new Handler(mContext.getMainLooper()).post(mainRunnable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class MyCameraImpl {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void stopStroboscope() {
|
||||
public void stopStroboscope() {
|
||||
mShouldStroboscopeStop = true;
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ public class MyCameraImpl {
|
||||
|
||||
if (mCamera != null) {
|
||||
mCamera.setParameters(torchOff);
|
||||
if (!mShouldEnableFlashlight) {
|
||||
if (!mShouldEnableFlashlight || mIsMarshmallow) {
|
||||
mCamera.release();
|
||||
mCamera = null;
|
||||
}
|
||||
|
@ -118,6 +118,7 @@ public class MainActivity extends SimpleActivity {
|
||||
if (isCameraPermissionGranted()) {
|
||||
if (mCameraImpl.toggleStroboscope()) {
|
||||
mStroboscopeBar.setVisibility(mStroboscopeBar.getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE);
|
||||
changeIconColor(mStroboscopeBar.getVisibility() == View.VISIBLE ? R.color.colorPrimary : R.color.translucent_white, mStroboscopeBtn);
|
||||
}
|
||||
} else {
|
||||
final String[] permissions = {Manifest.permission.CAMERA};
|
||||
@ -156,7 +157,10 @@ public class MainActivity extends SimpleActivity {
|
||||
|
||||
mBrightDisplayBtn.setVisibility(mConfig.getBrightDisplay() ? View.VISIBLE : View.GONE);
|
||||
mStroboscopeBtn.setVisibility(mConfig.getStroboscope() ? View.VISIBLE : View.GONE);
|
||||
mStroboscopeBar.setVisibility(View.INVISIBLE);
|
||||
if (!mConfig.getStroboscope()) {
|
||||
mCameraImpl.stopStroboscope();
|
||||
mStroboscopeBar.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -193,6 +197,7 @@ public class MainActivity extends SimpleActivity {
|
||||
}
|
||||
|
||||
public void enableFlashlight() {
|
||||
changeIconColor(R.color.translucent_white, mStroboscopeBtn);
|
||||
changeIconColor(R.color.colorPrimary, mToggleBtn);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/buttons_margin"
|
||||
android:background="@mipmap/bright_display"
|
||||
android:background="@mipmap/stroboscope"
|
||||
android:padding="@dimen/activity_margin"/>
|
||||
|
||||
<SeekBar
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/mipmap-hdpi/stroboscope.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 717 B After Width: | Height: | Size: 983 B |
BIN
app/src/main/res/mipmap-mdpi/stroboscope.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/mipmap-xhdpi/stroboscope.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 2.7 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/stroboscope.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/stroboscope.png
Normal file
After Width: | Height: | Size: 4.6 KiB |