Skip to content

Commit

Permalink
Added immersive mode support for devices running Android KitKat
Browse files Browse the repository at this point in the history
(API 19) and newer.
  • Loading branch information
iiordanov committed Aug 12, 2016
1 parent f4ed5c1 commit ff1a70f
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 7 deletions.
4 changes: 2 additions & 2 deletions eclipse_projects/Opaque/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.undatech.opaque"
android:versionCode="1338"
android:versionName="1.3.8" >
android:versionCode="1339"
android:versionName="1.3.9" >

<uses-sdk
android:minSdkVersion="9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import com.undatech.opaque.input.InputHandlerDirectSwipePan;

public class Constants {

public static final int SDK_INT = android.os.Build.VERSION.SDK_INT;

public static final int DIALOG_DISPLAY_VMS = 0;
public static final int DIALOG_X509_CERT = 1;
public static final int LAUNCH_VNC_VIEWER = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,30 @@ public class RemoteCanvasActivity extends FragmentActivity implements OnKeyListe
boolean hardKeyboardExtended;
boolean extraKeysHidden = false;
int prevBottomOffset = 0;


/**
* Enables sticky immersive mode if supported.
*/
private void enableImmersive() {
if (Constants.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
canvas.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}

@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
enableImmersive();
}
}

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Expand Down Expand Up @@ -254,6 +277,7 @@ public void onGlobalLayout() {
}
setKeyStowDrawableAndVisibility();
prevBottomOffset = offset;
enableImmersive();
}
});

Expand Down Expand Up @@ -1096,5 +1120,4 @@ public void onTextObtained(String obtainedString) {
canvas.spicecomm.notify();
}
}

}
2 changes: 1 addition & 1 deletion eclipse_projects/bVNC/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.iiordanov.bVNC" android:installLocation="auto"
android:versionCode="3820" android:versionName="v3.8.2">
android:versionCode="3830" android:versionName="v3.8.3">

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="10"></uses-sdk>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
Expand Down
2 changes: 2 additions & 0 deletions eclipse_projects/bVNC/src/com/iiordanov/bVNC/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
*/
public class Constants {
public static final String CONNECTION = "com.iiordanov.bVNC.CONNECTION";

public static final int SDK_INT = android.os.Build.VERSION.SDK_INT;

public static final int CONN_TYPE_PLAIN = 0;
public static final int CONN_TYPE_SSH = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,29 @@ public class RemoteCanvasActivity extends FragmentActivity implements OnKeyListe
boolean extraKeysHidden = false;
int prevBottomOffset = 0;

/**
* Enables sticky immersive mode if supported.
*/
private void enableImmersive() {
if (Constants.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
canvas.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}

@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
enableImmersive();
}
}

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Expand Down Expand Up @@ -305,6 +328,7 @@ public void onGlobalLayout() {
}
setKeyStowDrawableAndVisibility();
prevBottomOffset = offset;
enableImmersive();
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
Expand Down Expand Up @@ -164,8 +165,17 @@ private void setCommandIndexAndCommand (int itemIndex) {
*/
private void setRemoteWidthAndHeight () {

nativeWidth = Math.max(mainConfigDialog.getWidth(), mainConfigDialog.getHeight());
nativeHeight = Math.min(mainConfigDialog.getWidth(), mainConfigDialog.getHeight());
// Android devices with SDK newer than KITKAT use immersive mode and therefore
// we get the resolution of the whole display.
if (Constants.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
nativeWidth = Math.max(mainConfigDialog.getWidth(), mainConfigDialog.getHeight());
nativeHeight = Math.min(mainConfigDialog.getWidth(), mainConfigDialog.getHeight());
} else {
Point dS = new Point();
mainConfigDialog.getWindowManager().getDefaultDisplay().getRealSize(dS);
nativeWidth = Math.max(dS.x, dS.y);
nativeHeight = Math.min(dS.x, dS.y);
}

spinnerAutoXGeometry.setSelection(selected.getAutoXResType());
if (selected.getAutoXResType() == Constants.AUTOX_GEOM_SELECT_NATIVE) {
Expand Down

0 comments on commit ff1a70f

Please sign in to comment.