fade out the top right buttons
This commit is contained in:
parent
51bc08732a
commit
0526a2e111
|
@ -60,12 +60,14 @@ public class MainActivity extends SimpleActivity
|
||||||
|
|
||||||
private static final int CAMERA_STORAGE_PERMISSION = 1;
|
private static final int CAMERA_STORAGE_PERMISSION = 1;
|
||||||
private static final int AUDIO_PERMISSION = 2;
|
private static final int AUDIO_PERMISSION = 2;
|
||||||
|
private static final int FADE_DELAY = 5000;
|
||||||
|
|
||||||
private static SensorManager mSensorManager;
|
private static SensorManager mSensorManager;
|
||||||
private static Preview mPreview;
|
private static Preview mPreview;
|
||||||
private static FocusRectView mFocusRectView;
|
private static FocusRectView mFocusRectView;
|
||||||
private static Handler mTimerHandler;
|
private static Handler mTimerHandler;
|
||||||
private static Uri mPreviewUri;
|
private static Uri mPreviewUri;
|
||||||
|
private static Handler mFadeHandler;
|
||||||
|
|
||||||
private static boolean mIsFlashEnabled;
|
private static boolean mIsFlashEnabled;
|
||||||
private static boolean mIsInPhotoMode;
|
private static boolean mIsInPhotoMode;
|
||||||
|
@ -168,7 +170,9 @@ public class MainActivity extends SimpleActivity
|
||||||
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
|
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
|
||||||
mIsInPhotoMode = true;
|
mIsInPhotoMode = true;
|
||||||
mTimerHandler = new Handler();
|
mTimerHandler = new Handler();
|
||||||
|
mFadeHandler = new Handler();
|
||||||
setupPreviewImage(true);
|
setupPreviewImage(true);
|
||||||
|
scheduleFadeOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasCameraAndStoragePermission() {
|
private boolean hasCameraAndStoragePermission() {
|
||||||
|
@ -306,8 +310,12 @@ public class MainActivity extends SimpleActivity
|
||||||
|
|
||||||
@OnClick(R.id.settings)
|
@OnClick(R.id.settings)
|
||||||
public void launchSettings() {
|
public void launchSettings() {
|
||||||
final Intent intent = new Intent(getApplicationContext(), SettingsActivity.class);
|
if (mSettingsBtn.getAlpha() == 1.f) {
|
||||||
startActivity(intent);
|
final Intent intent = new Intent(getApplicationContext(), SettingsActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
} else {
|
||||||
|
fadeInButtons();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.toggle_photo_video)
|
@OnClick(R.id.toggle_photo_video)
|
||||||
|
@ -446,6 +454,32 @@ public class MainActivity extends SimpleActivity
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void scheduleFadeOut() {
|
||||||
|
mFadeHandler.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
fadeOutButtons();
|
||||||
|
}
|
||||||
|
}, FADE_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fadeOutButtons() {
|
||||||
|
fadeAnim(mSettingsBtn, .5f);
|
||||||
|
fadeAnim(mTogglePhotoVideoBtn, .0f);
|
||||||
|
fadeAnim(mLastPhotoVideoPreview, .0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fadeInButtons() {
|
||||||
|
fadeAnim(mSettingsBtn, 1.f);
|
||||||
|
fadeAnim(mTogglePhotoVideoBtn, 1.f);
|
||||||
|
fadeAnim(mLastPhotoVideoPreview, 1.f);
|
||||||
|
scheduleFadeOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fadeAnim(View view, float value) {
|
||||||
|
view.animate().alpha(value).start();
|
||||||
|
}
|
||||||
|
|
||||||
private void hideNavigationBarIcons() {
|
private void hideNavigationBarIcons() {
|
||||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
|
||||||
}
|
}
|
||||||
|
@ -514,6 +548,9 @@ public class MainActivity extends SimpleActivity
|
||||||
if (!hasCameraAndStoragePermission() || mIsAskingPermissions)
|
if (!hasCameraAndStoragePermission() || mIsAskingPermissions)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (mFadeHandler != null)
|
||||||
|
mFadeHandler.removeCallbacksAndMessages(null);
|
||||||
|
|
||||||
hideTimer();
|
hideTimer();
|
||||||
if (mPreview != null) {
|
if (mPreview != null) {
|
||||||
mPreview.releaseCamera();
|
mPreview.releaseCamera();
|
||||||
|
|
Loading…
Reference in New Issue