Skip to content

Commit a484ddf

Browse files
Settings for Tablets andAndroid 13 improved
Signed-off-by: Manfred Mueller <mail@manfred-mueller.org>
1 parent 1c01fa2 commit a484ddf

File tree

15 files changed

+167
-70
lines changed

15 files changed

+167
-70
lines changed

.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ android {
7474

7575
dependencies {
7676
implementation fileTree(dir: "libs", include: ["*.jar"])
77-
implementation 'androidx.appcompat:appcompat:1.7.0'
77+
def appcompat_version = "1.6.1"
78+
implementation("androidx.appcompat:appcompat:$appcompat_version")
79+
implementation("androidx.appcompat:appcompat-resources:$appcompat_version")
7880
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
7981
implementation 'androidx.gridlayout:gridlayout:1.0.0'
8082
implementation 'androidx.cardview:cardview:1.0.0'
@@ -84,4 +86,4 @@ dependencies {
8486
implementation 'androidx.browser:browser:1.8.0'
8587
implementation 'androidx.multidex:multidex:2.0.1'
8688
implementation project(':appupdate')
87-
}
89+
}

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
1313
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
1414
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
15+
<uses-permission android:name="android.permission.STATUS_BAR" />
1516
<queries>
1617
<intent>
1718
<action android:name="android.media.action.IMAGE_CAPTURE" />
@@ -109,6 +110,10 @@
109110
android:name=".SupportActivity"
110111
android:windowSoftInputMode="stateHidden"
111112
android:configChanges="orientation|fontScale|density|screenSize|keyboardHidden|uiMode" />
113+
<activity
114+
android:name=".StatusBarActivity"
115+
android:windowSoftInputMode="stateHidden"
116+
android:configChanges="orientation|fontScale|density|screenSize|keyboardHidden|uiMode" />
112117
<service
113118
android:name=".ShutdownService"
114119
android:enabled="true"

app/src/main/java/com/nass/ek/w3kiosk/ChecksAndConfigs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static boolean isScanner() {
7474
}
7575

7676
public static boolean isTablet() {
77-
return android.os.Build.MODEL.toUpperCase().startsWith("RK");
77+
return android.os.Build.MODEL.toUpperCase().startsWith("RK") || android.os.Build.MODEL.toUpperCase().startsWith("PRIME");
7878
}
7979

8080
public static boolean isTv() {

app/src/main/java/com/nass/ek/w3kiosk/MainActivity.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ public void onReceive(Context context, Intent intent) {
147147
@Override
148148
protected void onCreate(Bundle savedInstanceState) {
149149
super.onCreate(savedInstanceState);
150+
enableImmersiveMode();
150151
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
151152
checkmobileMode = sharedPreferences.getBoolean("mobileMode", false);
152153
checkAutoLogin = sharedPreferences.getBoolean("autoLogin", false);
@@ -238,20 +239,6 @@ public void onFinish() {
238239
}
239240
}
240241

241-
final int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
242-
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
243-
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
244-
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
245-
| View.SYSTEM_UI_FLAG_FULLSCREEN
246-
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
247-
getWindow().getDecorView().setSystemUiVisibility(flags);
248-
final View decorView = getWindow().getDecorView();
249-
decorView.setOnSystemUiVisibilityChangeListener(visibility -> {
250-
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
251-
decorView.setSystemUiVisibility(flags);
252-
}
253-
});
254-
255242
setupSettings();
256243

257244
if (ChecksAndConfigs.isScanner()) {
@@ -567,6 +554,7 @@ public void onWindowFocusChanged(boolean hasFocus) {
567554
@Override
568555
protected void onResume() {
569556
super.onResume();
557+
enableImmersiveMode();
570558
IntentFilter filter = new IntentFilter();
571559
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
572560
registerReceiver(connectionReceiver, filter);
@@ -864,4 +852,19 @@ public static String getLocalIpAddress(Context context) {
864852
}
865853
return null; // Return null if no IP address was found
866854
}
855+
private void enableImmersiveMode() {
856+
final int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
857+
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
858+
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
859+
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
860+
| View.SYSTEM_UI_FLAG_FULLSCREEN
861+
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
862+
getWindow().getDecorView().setSystemUiVisibility(flags);
863+
final View decorView = getWindow().getDecorView();
864+
decorView.setOnSystemUiVisibilityChangeListener(visibility -> {
865+
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
866+
decorView.setSystemUiVisibility(flags);
867+
}
868+
});
869+
}
867870
}

app/src/main/java/com/nass/ek/w3kiosk/SettingsActivity.java

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -320,19 +320,22 @@ public boolean onDoubleTap(MotionEvent e) {
320320
}
321321

322322
c = findViewById(R.id.writeStorage);
323-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
324-
if (Environment.isExternalStorageManager()) {
325-
c.setChecked(true);
326-
c.setEnabled(false);
323+
if (ChecksAndConfigs.isTablet()) {
324+
c.setVisibility(View.GONE);
325+
} else {
326+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
327+
if (Environment.isExternalStorageManager()) {
328+
c.setChecked(true);
329+
c.setEnabled(false);
330+
} else {
331+
c.setChecked(false);
332+
c.setEnabled(true);
333+
}
327334
} else {
328-
c.setChecked(false);
329-
c.setEnabled(true);
335+
c.setChecked(context.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
336+
c.setEnabled(context.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED);
330337
}
331-
} else {
332-
c.setChecked(context.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
333-
c.setEnabled(context.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED);
334338
}
335-
336339
String configFileContent = readConfigFileContents();
337340

338341
if (configFileContent.isEmpty()) {
@@ -341,7 +344,7 @@ public boolean onDoubleTap(MotionEvent e) {
341344
}
342345

343346
c = findViewById(R.id.camAccess);
344-
if (ChecksAndConfigs.isTv()) {
347+
if (ChecksAndConfigs.isTv() || ChecksAndConfigs.isTablet()) {
345348
c.setVisibility(View.GONE);
346349
} else {
347350
c.setChecked(context.checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED);
@@ -357,8 +360,12 @@ public boolean onDoubleTap(MotionEvent e) {
357360
}
358361

359362
c = findViewById(R.id.powerMenu);
360-
c.setChecked(isAccessibilitySettingsOn());
361-
c.setEnabled(!isAccessibilitySettingsOn());
363+
if (ChecksAndConfigs.isTablet()) {
364+
c.setVisibility(View.GONE);
365+
} else {
366+
c.setChecked(isAccessibilitySettingsOn());
367+
c.setEnabled(!isAccessibilitySettingsOn());
368+
}
362369

363370
c = findViewById(R.id.writeSystem);
364371
if (ChecksAndConfigs.isTv()) {
@@ -603,9 +610,13 @@ protected void onResume() {
603610
int zoomValue = sharedPreferences.getInt("zoomFactor",5);
604611
zoomDropdown.setSelection(zoomValue);
605612

606-
c = findViewById(R.id.writeStorage);
607-
c.setChecked(context.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
608-
c.setEnabled(context.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED);
613+
c = findViewById(R.id.writeStorage);
614+
if (!ChecksAndConfigs.isTablet()) {
615+
c.setVisibility(View.GONE);
616+
} else {
617+
c.setChecked(context.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
618+
c.setEnabled(context.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED);
619+
}
609620

610621
c = findViewById(R.id.camAccess);
611622
if (ChecksAndConfigs.isTv()) {
@@ -624,8 +635,12 @@ protected void onResume() {
624635
}
625636

626637
c = findViewById(R.id.powerMenu);
627-
c.setChecked(isAccessibilitySettingsOn());
628-
c.setEnabled(!isAccessibilitySettingsOn());
638+
if (!ChecksAndConfigs.isTablet()) {
639+
c.setVisibility(View.GONE);
640+
} else {
641+
c.setChecked(isAccessibilitySettingsOn());
642+
c.setEnabled(!isAccessibilitySettingsOn());
643+
}
629644

630645
c = findViewById(R.id.writeSystem);
631646
if (ChecksAndConfigs.isTv()) {
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.nass.ek.w3kiosk;
2+
3+
import android.app.Activity;
4+
import android.content.Context;
5+
import android.graphics.PixelFormat;
6+
import android.util.Log;
7+
import android.view.Gravity;
8+
import android.view.MotionEvent;
9+
import android.view.ViewGroup;
10+
import android.view.WindowManager;
11+
12+
import androidx.appcompat.app.AppCompatActivity;
13+
14+
public class StatusBarActivity extends AppCompatActivity {
15+
public static void preventStatusBarExpansion(Context context) {
16+
WindowManager manager = ((WindowManager) context.getApplicationContext()
17+
.getSystemService(Context.WINDOW_SERVICE));
18+
19+
Activity activity = (Activity)context;
20+
WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
21+
localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
22+
localLayoutParams.gravity = Gravity.TOP;
23+
localLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
24+
25+
// this is to enable the notification to recieve touch events
26+
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
27+
28+
// Draws over status bar
29+
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
30+
31+
localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
32+
int resId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
33+
int result = 0;
34+
if (resId > 0) {
35+
result = activity.getResources().getDimensionPixelSize(resId);
36+
}
37+
38+
localLayoutParams.height = result;
39+
40+
localLayoutParams.format = PixelFormat.TRANSPARENT;
41+
42+
customViewGroup view = new customViewGroup(context);
43+
44+
manager.addView(view, localLayoutParams);
45+
}
46+
47+
public static class customViewGroup extends ViewGroup {
48+
49+
public customViewGroup(Context context) {
50+
super(context);
51+
}
52+
53+
@Override
54+
protected void onLayout(boolean changed, int l, int t, int r, int b) {
55+
}
56+
57+
@Override
58+
public boolean onInterceptTouchEvent(MotionEvent ev) {
59+
Log.v("customViewGroup", "**********Intercepted");
60+
return true;
61+
}
62+
}
63+
}

app/src/main/res/layout/activity_settings.xml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@
493493
android:layout_width="match_parent"
494494
android:layout_height="match_parent"
495495
android:orientation="vertical"
496-
android:visibility="gone">
496+
android:visibility="visible">
497497

498498
<LinearLayout
499499
android:layout_width="match_parent"
@@ -540,13 +540,12 @@
540540
android:layout_weight="1">
541541

542542
<CheckBox
543-
android:id="@+id/writeStorage"
543+
android:id="@+id/overlayPerm"
544544
android:layout_width="wrap_content"
545545
android:layout_height="wrap_content"
546-
android:layout_alignParentStart="true"
547546
android:clickable="false"
548-
android:onClick="checkStoragePermission"
549-
android:text="@string/storage_permission" />
547+
android:onClick="checkOverlayPermission"
548+
android:text="@string/overlay_permission" />
550549
</RelativeLayout>
551550

552551
<RelativeLayout
@@ -555,12 +554,13 @@
555554
android:layout_weight="1">
556555

557556
<CheckBox
558-
android:id="@+id/overlayPerm"
557+
android:id="@+id/writeStorage"
559558
android:layout_width="wrap_content"
560559
android:layout_height="wrap_content"
560+
android:layout_alignParentStart="true"
561561
android:clickable="false"
562-
android:onClick="checkOverlayPermission"
563-
android:text="@string/overlay_permission" />
562+
android:onClick="checkStoragePermission"
563+
android:text="@string/storage_permission" />
564564
</RelativeLayout>
565565
</LinearLayout>
566566

@@ -576,13 +576,12 @@
576576
android:layout_weight="1">
577577

578578
<CheckBox
579-
android:id="@+id/camAccess"
579+
android:id="@+id/writeSystem"
580580
android:layout_width="wrap_content"
581581
android:layout_height="wrap_content"
582-
android:layout_alignParentStart="true"
583582
android:clickable="false"
584-
android:onClick="checkCameraPermission"
585-
android:text="@string/camera_access" />
583+
android:onClick="checkWritePermission"
584+
android:text="@string/write_system_settings" />
586585
</RelativeLayout>
587586

588587
<RelativeLayout
@@ -591,12 +590,13 @@
591590
android:layout_weight="1">
592591

593592
<CheckBox
594-
android:id="@+id/writeSystem"
593+
android:id="@+id/camAccess"
595594
android:layout_width="wrap_content"
596595
android:layout_height="wrap_content"
596+
android:layout_alignParentStart="true"
597597
android:clickable="false"
598-
android:onClick="checkWritePermission"
599-
android:text="@string/write_system_settings" />
598+
android:onClick="checkCameraPermission"
599+
android:text="@string/camera_access" />
600600
</RelativeLayout>
601601
</LinearLayout>
602602

@@ -612,13 +612,12 @@
612612
android:layout_weight="1">
613613

614614
<CheckBox
615-
android:id="@+id/powerMenu"
615+
android:id="@+id/installApps"
616616
android:layout_width="wrap_content"
617617
android:layout_height="wrap_content"
618-
android:layout_alignParentStart="true"
619618
android:clickable="false"
620-
android:onClick="checkAccessibilityPermission"
621-
android:text="@string/powermenu" />
619+
android:onClick="checkInstallPermission"
620+
android:text="@string/apps_permission" />
622621
</RelativeLayout>
623622

624623
<RelativeLayout
@@ -627,12 +626,13 @@
627626
android:layout_weight="1">
628627

629628
<CheckBox
630-
android:id="@+id/installApps"
629+
android:id="@+id/powerMenu"
631630
android:layout_width="wrap_content"
632631
android:layout_height="wrap_content"
632+
android:layout_alignParentStart="true"
633633
android:clickable="false"
634-
android:onClick="checkInstallPermission"
635-
android:text="@string/apps_permission" />
634+
android:onClick="checkAccessibilityPermission"
635+
android:text="@string/powermenu" />
636636
</RelativeLayout>
637637
</LinearLayout>
638638

0 commit comments

Comments
 (0)