update the bright display and strobo icons + misc adjustments

This commit is contained in:
tibbi 2016-09-25 22:05:37 +02:00
parent 167c26dff4
commit ec5d7cf0ad
14 changed files with 20 additions and 5 deletions

View File

@ -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);
}
}
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 717 B

After

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB