|
@@ -26,14 +26,14 @@ import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.content.IntentFilter;
|
|
|
import android.content.ServiceConnection;
|
|
|
+import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.IBinder;
|
|
|
import android.support.v4.view.ViewPager;
|
|
|
import android.support.v4.widget.DrawerLayout;
|
|
|
-import android.support.v7.app.ActionBar;
|
|
|
import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
|
-import android.view.Window;
|
|
|
+import android.view.WindowManager;
|
|
|
|
|
|
import com.ortiz.touch.ExtendedViewPager;
|
|
|
import com.owncloud.android.MainApp;
|
|
@@ -66,8 +66,6 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
|
public class PreviewImageActivity extends FileActivity implements
|
|
|
FileFragment.ContainerActivity,
|
|
|
ViewPager.OnPageChangeListener, OnRemoteOperationListener {
|
|
|
-
|
|
|
- public static final int DIALOG_SHORT_WAIT = 0;
|
|
|
|
|
|
public static final String TAG = PreviewImageActivity.class.getSimpleName();
|
|
|
|
|
@@ -75,8 +73,6 @@ public class PreviewImageActivity extends FileActivity implements
|
|
|
private static final String KEY_WAITING_FOR_BINDER = "WAITING_FOR_BINDER";
|
|
|
private static final String KEY_SYSTEM_VISIBLE = "TRUE";
|
|
|
|
|
|
- private static final int INITIAL_HIDE_DELAY = 0; // immediate hide
|
|
|
-
|
|
|
private ExtendedViewPager mViewPager;
|
|
|
private PreviewImagePagerAdapter mPreviewImagePagerAdapter;
|
|
|
private int mSavedPosition = 0;
|
|
@@ -85,54 +81,38 @@ public class PreviewImageActivity extends FileActivity implements
|
|
|
private boolean mRequestWaitingForBinder;
|
|
|
|
|
|
private DownloadFinishReceiver mDownloadFinishReceiver;
|
|
|
-
|
|
|
- private View mFullScreenAnchorView;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
- requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
|
|
|
-
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
+ if (Build.VERSION.SDK_INT < 16) {
|
|
|
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
|
+ } else {
|
|
|
+ View decorView = getWindow().getDecorView();
|
|
|
+ // Hide the status bar.
|
|
|
+ int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
|
|
|
+
|
|
|
+ decorView.setSystemUiVisibility(uiOptions);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (savedInstanceState != null && !savedInstanceState.getBoolean(KEY_SYSTEM_VISIBLE, true)) {
|
|
|
+ toggleFullScreen();
|
|
|
+ }
|
|
|
+
|
|
|
setContentView(R.layout.preview_image_activity);
|
|
|
|
|
|
// Navigation Drawer
|
|
|
setupDrawer();
|
|
|
|
|
|
- // ActionBar
|
|
|
- ActionBar actionBar = getSupportActionBar();
|
|
|
- updateActionBarTitleAndHomeButton(null);
|
|
|
-
|
|
|
- mFullScreenAnchorView = getWindow().getDecorView();
|
|
|
- // to keep our UI controls visibility in line with system bars visibility
|
|
|
- mFullScreenAnchorView.setOnSystemUiVisibilityChangeListener
|
|
|
- (new View.OnSystemUiVisibilityChangeListener() {
|
|
|
- @SuppressLint("InlinedApi")
|
|
|
- @Override
|
|
|
- public void onSystemUiVisibilityChange(int flags) {
|
|
|
- boolean visible = (flags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
|
|
|
- ActionBar actionBar = getSupportActionBar();
|
|
|
- if (visible) {
|
|
|
- actionBar.show();
|
|
|
- setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
|
|
|
- } else {
|
|
|
- actionBar.hide();
|
|
|
- setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
if (savedInstanceState != null) {
|
|
|
mRequestWaitingForBinder = savedInstanceState.getBoolean(KEY_WAITING_FOR_BINDER);
|
|
|
- if (!savedInstanceState.getBoolean(KEY_SYSTEM_VISIBLE, true)) {
|
|
|
- hideSystemUI(mFullScreenAnchorView);
|
|
|
- }
|
|
|
} else {
|
|
|
mRequestWaitingForBinder = false;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void initViewPager() {
|
|
|
// get parent from path
|
|
|
String parentPath = getFile().getRemotePath().substring(0,
|
|
@@ -424,23 +404,22 @@ public class PreviewImageActivity extends FileActivity implements
|
|
|
}
|
|
|
|
|
|
public boolean getSystemUIVisible() {
|
|
|
- return (mFullScreenAnchorView.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
|
|
|
+ if (getSupportActionBar() != null && getSupportActionBar().isShowing()) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@SuppressLint("InlinedApi")
|
|
|
public void toggleFullScreen() {
|
|
|
|
|
|
- boolean visible = (mFullScreenAnchorView.getSystemUiVisibility()
|
|
|
- & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
|
|
|
-
|
|
|
- if (visible) {
|
|
|
- hideSystemUI(mFullScreenAnchorView);
|
|
|
- // actionBar.hide(); // propagated through
|
|
|
- // OnSystemUiVisibilityChangeListener()
|
|
|
+ if (getSupportActionBar() != null && getSupportActionBar().isShowing()) {
|
|
|
+ getSupportActionBar().hide();
|
|
|
+ setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
|
|
} else {
|
|
|
- showSystemUI(mFullScreenAnchorView);
|
|
|
- // actionBar.show(); // propagated through
|
|
|
- // OnSystemUiVisibilityChangeListener()
|
|
|
+ getSupportActionBar().show();
|
|
|
+ setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -489,25 +468,4 @@ public class PreviewImageActivity extends FileActivity implements
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @SuppressLint("InlinedApi")
|
|
|
- private void hideSystemUI(View anchorView) {
|
|
|
- anchorView.setSystemUiVisibility(
|
|
|
- View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hides NAVIGATION BAR; Android >= 4.0
|
|
|
- | View.SYSTEM_UI_FLAG_FULLSCREEN // hides STATUS BAR; Android >= 4.1
|
|
|
- | View.SYSTEM_UI_FLAG_IMMERSIVE // stays interactive; Android >= 4.4
|
|
|
- | View.SYSTEM_UI_FLAG_LAYOUT_STABLE // draw full window; Android >= 4.1
|
|
|
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // draw full window; Android >= 4.1
|
|
|
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // draw full window; Android >= 4.1
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- @SuppressLint("InlinedApi")
|
|
|
- private void showSystemUI(View anchorView) {
|
|
|
- anchorView.setSystemUiVisibility(
|
|
|
- View.SYSTEM_UI_FLAG_LAYOUT_STABLE // draw full window; Android >= 4.1
|
|
|
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // draw full window; Android >= 4.1
|
|
|
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // draw full window; Android >= 4.1
|
|
|
- );
|
|
|
- }
|
|
|
}
|