mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
[android] address review comments for image fullscreen swiping
This commit is contained in:
@@ -134,7 +134,7 @@ public class ImageActivity extends BriarActivity
|
||||
viewPager.setCurrentItem(position);
|
||||
|
||||
if (SDK_INT >= 16) {
|
||||
viewModel.getOnImageClicked().observe(this, this::onPhotoClicked);
|
||||
viewModel.getOnImageClicked().observe(this, this::onImageClicked);
|
||||
window.getDecorView().setSystemUiVisibility(
|
||||
SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
@@ -168,6 +168,8 @@ public class ImageActivity extends BriarActivity
|
||||
);
|
||||
if (SDK_INT >= 16) {
|
||||
layout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
} else {
|
||||
layout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,8 +205,9 @@ public class ImageActivity extends BriarActivity
|
||||
supportFinishAfterTransition();
|
||||
}
|
||||
|
||||
private void onPhotoClicked(@Nullable Boolean clicked) {
|
||||
if (clicked != null&& clicked && SDK_INT >= 16) {
|
||||
@RequiresApi(api = 16)
|
||||
private void onImageClicked(@Nullable Boolean clicked) {
|
||||
if (clicked != null && clicked) {
|
||||
toggleSystemUi();
|
||||
viewModel.onOnImageClickSeen();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ImageFragment extends Fragment {
|
||||
viewModelFactory).get(ImageViewModel.class);
|
||||
|
||||
photoView = v.findViewById(R.id.photoView);
|
||||
photoView.setOnClickListener(view -> viewModel.clickPhoto());
|
||||
photoView.setOnClickListener(view -> viewModel.clickImage());
|
||||
|
||||
// Request Listener
|
||||
RequestListener<Drawable> listener = new RequestListener<Drawable>() {
|
||||
|
||||
@@ -50,7 +50,8 @@ public class ImageViewModel extends AndroidViewModel {
|
||||
@IoExecutor
|
||||
private final Executor ioExecutor;
|
||||
|
||||
private final MutableLiveData<Boolean> imageClicked = new MutableLiveData<>();
|
||||
private final MutableLiveData<Boolean> imageClicked =
|
||||
new MutableLiveData<>();
|
||||
private final MutableLiveData<Boolean> saveState = new MutableLiveData<>();
|
||||
private int toolbarTop, toolbarBottom;
|
||||
|
||||
@@ -65,7 +66,7 @@ public class ImageViewModel extends AndroidViewModel {
|
||||
this.ioExecutor = ioExecutor;
|
||||
}
|
||||
|
||||
void clickPhoto() {
|
||||
void clickImage() {
|
||||
imageClicked.setValue(true);
|
||||
}
|
||||
|
||||
@@ -97,7 +98,7 @@ public class ImageViewModel extends AndroidViewModel {
|
||||
float scaleFactor = Math.min(widthPercentage, heightPercentage);
|
||||
int realWidth = (int) (width * scaleFactor);
|
||||
int realHeight = (int) (height * scaleFactor);
|
||||
// return if photo doesn't use the full width,
|
||||
// return if image doesn't use the full width,
|
||||
// because it will be moved to the right otherwise
|
||||
if (realWidth < screenView.getWidth()) return false;
|
||||
int drawableTop = (screenView.getHeight() - realHeight) / 2;
|
||||
|
||||
Reference in New Issue
Block a user