Add toggle functionality for action bar

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2023-11-08 09:08:31 +01:00
parent 4930d6cb97
commit 7959a1d266
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF
2 changed files with 22 additions and 1 deletions

View file

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

View file

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