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