From 7959a1d266156ef7d5ee18c284fc211542e8fa19 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Wed, 8 Nov 2023 09:08:31 +0100 Subject: [PATCH] Add toggle functionality for action bar Signed-off-by: alperozturk --- .../android/ui/preview/PreviewImageActivity.java | 16 +++++++++++++++- .../android/ui/preview/PreviewImageFragment.java | 7 +++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java index 304b82035d..4d26f9f8e8 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java @@ -100,6 +100,8 @@ public class PreviewImageActivity extends FileActivity implements @Inject AppPreferences preferences; @Inject LocalBroadcastManager localBroadcastManager; + private ActionBar actionBar; + public static Intent previewFileIntent(Context context, User user, OCFile file) { final Intent intent = new Intent(context, PreviewImageActivity.class); intent.putExtra(FileActivity.EXTRA_FILE, file); @@ -111,7 +113,7 @@ public class PreviewImageActivity extends FileActivity implements protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - final ActionBar actionBar = getSupportActionBar(); + actionBar = getSupportActionBar(); if (savedInstanceState != null && !savedInstanceState.getBoolean(KEY_SYSTEM_VISIBLE, true) && actionBar != null) { @@ -144,6 +146,18 @@ public class PreviewImageActivity extends FileActivity implements } } + public void toggleActionBarVisibility(boolean hide) { + if (actionBar == null) { + return; + } + + if (hide) { + actionBar.hide(); + } else { + actionBar.show(); + } + } + private void initViewPager(User user) { // virtual folder final Serializable virtualFolderType = getIntent().getSerializableExtra(EXTRA_VIRTUAL_TYPE); diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java index 852e37a05e..0bc5df813e 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -222,11 +222,18 @@ public class PreviewImageFragment extends FileFragment implements Injectable { } } + private void toggleActionBarVisibility(boolean hide) { + PreviewImageActivity activity = (PreviewImageActivity) requireActivity(); + activity.toggleActionBarVisibility(hide); + } + private void playLivePhoto(OCFile file) { if (file == null) { return; } + toggleActionBarVisibility(true); + Fragment mediaFragment = PreviewMediaFragment.newInstance(file, accountManager.getUser(), 0, true); FragmentManager fragmentManager = requireActivity().getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();