Skip to content

Commit 36d31f0

Browse files
committed
Style changes and permission ask rollbacks
* Main app theme now targets material3 * Permission checker/granter rollback for READ permission
1 parent fe2ae1d commit 36d31f0

File tree

10 files changed

+71
-90
lines changed

10 files changed

+71
-90
lines changed

NeoLang/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ dependencies {
3232
}
3333

3434
java {
35-
sourceCompatibility = JavaVersion.VERSION_1_8
36-
targetCompatibility = JavaVersion.VERSION_1_8
35+
sourceCompatibility = JavaVersion.VERSION_17
36+
targetCompatibility = JavaVersion.VERSION_17
3737
}

NeoTermBridge/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ dependencies {
3030
}
3131

3232
java {
33-
sourceCompatibility = JavaVersion.VERSION_1_8
34-
targetCompatibility = JavaVersion.VERSION_1_8
33+
sourceCompatibility = JavaVersion.VERSION_17
34+
targetCompatibility = JavaVersion.VERSION_17
3535
}

Xorg/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ dependencies {
3535
}
3636

3737
java {
38-
sourceCompatibility = JavaVersion.VERSION_1_8
39-
targetCompatibility = JavaVersion.VERSION_1_8
38+
sourceCompatibility = JavaVersion.VERSION_17
39+
targetCompatibility = JavaVersion.VERSION_17
4040
}

chrome-tabs/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ dependencies {
2525
}
2626

2727
java {
28-
sourceCompatibility = JavaVersion.VERSION_1_8
29-
targetCompatibility = JavaVersion.VERSION_1_8
28+
sourceCompatibility = JavaVersion.VERSION_17
29+
targetCompatibility = JavaVersion.VERSION_17
3030
}

nhterm/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ dependencies {
8787
}
8888

8989
java {
90-
sourceCompatibility = JavaVersion.VERSION_1_8
91-
targetCompatibility = JavaVersion.VERSION_1_8
90+
sourceCompatibility = JavaVersion.VERSION_17
91+
targetCompatibility = JavaVersion.VERSION_17
9292
}

nhterm/src/main/AndroidManifest.xml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
android:name=".ui.term.NeoTermActivity"
4949
android:configChanges="orientation|keyboardHidden|screenSize"
5050
android:launchMode="singleTask"
51-
android:theme="@style/AppTheme.NoActionBar.Dark"
51+
android:theme="@style/AppTheme.NoActionBar"
5252
android:windowSoftInputMode="adjustResize|stateHidden"
5353
android:exported="true">
5454
<intent-filter>
@@ -81,7 +81,7 @@
8181
android:name=".ui.term.NeoTermRemoteInterface"
8282
android:configChanges="orientation|keyboardHidden"
8383
android:exported="true"
84-
android:theme="@style/AppTheme.Dark"
84+
android:theme="@style/AppTheme"
8585
android:windowSoftInputMode="adjustResize|stateHidden">
8686
<intent-filter>
8787
<category android:name="android.intent.category.DEFAULT"/>
@@ -143,12 +143,12 @@
143143
android:name=".ui.other.AboutActivity"
144144
android:exported="false"
145145
android:label="@string/about"
146-
android:theme="@style/AppTheme.NoActionBar.Dark"/>
146+
android:theme="@style/AppTheme.NoActionBar"/>
147147
<activity
148148
android:name=".ui.other.CrashActivity"
149149
android:exported="false"
150150
android:label="@string/error"
151-
android:theme="@style/AppTheme.NoActionBar.Dark"/>
151+
android:theme="@style/AppTheme.NoActionBar"/>
152152
<activity
153153
android:name=".ui.other.SetupActivity"
154154
android:configChanges="keyboardHidden|orientation|screenSize"
@@ -158,34 +158,34 @@
158158
android:name=".ui.other.BonusActivity"
159159
android:configChanges="orientation|keyboardHidden"
160160
android:exported="false"
161-
android:theme="@style/AppTheme.NoActionBar.Dark"/>
161+
android:theme="@style/AppTheme.NoActionBar"/>
162162
<activity
163163
android:name=".ui.pm.PackageManagerActivity"
164164
android:exported="false"
165165
android:label="@string/package_settings"
166-
android:theme="@style/AppTheme.NoActionBar.Dark"/>
166+
android:theme="@style/AppTheme.NoActionBar"/>
167167
<activity
168168
android:name=".ui.customize.CustomizeActivity"
169169
android:exported="false"
170170
android:label="@string/customization_settings"
171-
android:theme="@style/AppTheme.NoActionBar.Dark"/>
171+
android:theme="@style/AppTheme.NoActionBar"/>
172172
<activity
173173
android:name=".ui.customize.ColorSchemeActivity"
174174
android:exported="false"
175175
android:label="@string/pref_customization_color_scheme"
176-
android:theme="@style/AppTheme.NoActionBar.Dark"/>
176+
android:theme="@style/AppTheme.NoActionBar"/>
177177
<activity
178178
android:name=".ui.settings.SettingActivity"
179179
android:exported="false"
180-
android:theme="@style/AppTheme.Dark"/>
180+
android:theme="@style/AppTheme"/>
181181
<activity
182182
android:name=".ui.settings.GeneralSettingsActivity"
183183
android:exported="false"
184-
android:theme="@style/AppTheme.Dark"/>
184+
android:theme="@style/AppTheme"/>
185185
<activity
186186
android:name=".ui.settings.UISettingsActivity"
187187
android:exported="false"
188-
android:theme="@style/AppTheme.Dark"/>
188+
android:theme="@style/AppTheme"/>
189189

190190
<service
191191
android:name=".services.NeoTermService"

nhterm/src/main/java/com/offsec/nhterm/App.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class App : Application() {
3535
}
3636

3737
fun errorDialog(context: Context, message: String, dismissCallback: (() -> Unit)?) {
38-
MaterialAlertDialogBuilder(context, R.style.DialogStyleCompat)
38+
MaterialAlertDialogBuilder(context, R.style.DialogStyle)
3939
.setTitle(R.string.error)
4040
.setMessage(message)
4141
.setNegativeButton(android.R.string.no, null)

nhterm/src/main/java/com/offsec/nhterm/ui/term/NeoTermActivity.kt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,18 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
6464
override fun onCreate(savedInstanceState: Bundle?) {
6565
super.onCreate(savedInstanceState)
6666

67+
val SDCARD_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1
68+
6769
NeoPermission.initAppPermission(this, NeoPermission.REQUEST_APP_PERMISSION)
6870

71+
if (ContextCompat.checkSelfPermission(
72+
this,
73+
Manifest.permission.READ_EXTERNAL_STORAGE,
74+
) != PackageManager.PERMISSION_GRANTED
75+
) {
76+
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), SDCARD_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE)
77+
}
78+
6979
val fullscreen = NeoPreference.isFullScreenEnabled()
7080
if (fullscreen) {
7181
window.setFlags(
@@ -74,19 +84,6 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
7484
)
7585
}
7686

77-
val SDCARD_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1
78-
if (ContextCompat.checkSelfPermission(
79-
this,
80-
Manifest.permission.MANAGE_EXTERNAL_STORAGE,
81-
) != PackageManager.PERMISSION_GRANTED
82-
) {
83-
ActivityCompat.requestPermissions(
84-
this,
85-
arrayOf(Manifest.permission.MANAGE_EXTERNAL_STORAGE),
86-
SDCARD_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE,
87-
)
88-
}
89-
9087
setContentView(R.layout.ui_main)
9188

9289
toolbar = findViewById(R.id.terminal_toolbar)

nhterm/src/main/java/com/offsec/nhterm/utils/NeoPermission.kt

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,45 +19,35 @@ object NeoPermission {
1919
const val REQUEST_APP_PERMISSION = 10086
2020

2121
fun initAppPermission(context: AppCompatActivity, requestCode: Int) {
22-
if (ContextCompat.checkSelfPermission(
23-
context,
24-
Manifest.permission.READ_EXTERNAL_STORAGE
25-
)
26-
!= PackageManager.PERMISSION_GRANTED
27-
) {
28-
29-
if (ActivityCompat.shouldShowRequestPermissionRationale(
22+
if (ContextCompat.checkSelfPermission(
3023
context,
3124
Manifest.permission.READ_EXTERNAL_STORAGE
3225
)
33-
) {
34-
MaterialAlertDialogBuilder(context, R.style.DialogStyleCompat).setMessage("Please enable Storage permission")
35-
.setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int ->
36-
doRequestPermission(context, requestCode)
37-
}
38-
.show()
26+
!= PackageManager.PERMISSION_GRANTED) {
27+
28+
if (ActivityCompat.shouldShowRequestPermissionRationale(
29+
context,
30+
Manifest.permission.READ_EXTERNAL_STORAGE
31+
)) {
32+
MaterialAlertDialogBuilder(context, R.style.DialogStyle).setMessage("Please enable Storage permission")
33+
.setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int ->
34+
doRequestPermission(context, requestCode)
35+
}.show()
3936

40-
} else {
41-
doRequestPermission(context, requestCode)
37+
} else {
38+
doRequestPermission(context, requestCode)
39+
}
4240
}
4341
}
4442
}
4543

4644
private fun doRequestPermission(context: AppCompatActivity, requestCode: Int) {
4745
try {
48-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
4946
ActivityCompat.requestPermissions(
5047
context,
51-
arrayOf(Manifest.permission.MANAGE_EXTERNAL_STORAGE),
48+
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE),
5249
requestCode)
53-
} else {
54-
ActivityCompat.requestPermissions(
55-
context,
56-
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE),
57-
requestCode)
58-
}
59-
} catch (ignore: ActivityNotFoundException) {
60-
// for MIUI, we ignore it.
61-
}
50+
} catch (ignore: ActivityNotFoundException) {
51+
// for MIUI, we ignore it.
6252
}
6353
}

nhterm/src/main/res/values/styles.xml

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
<resources>
22

33
<!-- Base application theme. -->
4-
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
4+
<style name="AppTheme" parent="Theme.Material3.Dark">
55
<item name="colorAccent">@color/colorAccent</item>
66
<item name="colorPrimary">@color/colorPrimary</item>
77
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
88
<item name="windowActionModeOverlay">true</item>
9-
</style>
109

11-
<style name="AppTheme.Dark" parent="Theme.AppCompat">
12-
<item name="colorAccent">@color/colorAccent</item>
13-
<item name="windowActionModeOverlay">true</item>
14-
<item name="colorPrimary">@color/colorPrimary</item>
15-
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
10+
<item name="android:actionBarStyle">@style/AppTheme.ActionBar</item>
11+
<item name="actionBarStyle">@style/AppTheme.ActionBar</item>
1612
</style>
1713

1814
<style name="AppTheme.NoActionBar" parent="@style/AppTheme">
1915
<item name="windowActionBar">false</item>
2016
<item name="windowNoTitle">true</item>
2117
</style>
2218

23-
<style name="AppTheme.NoActionBar.Dark" parent="@style/AppTheme.Dark">
24-
<item name="windowActionBar">false</item>
25-
<item name="windowNoTitle">true</item>
19+
<style name="AppTheme.ActionBar" parent="@style/AppTheme">
20+
<item name="windowNoTitle">false</item>
21+
<item name="android:height">55dp</item>
22+
<item name="height">55dp</item>
23+
<item name="titleTextStyle">@style/AppTheme.ActionBar.TitleText</item>
24+
<item name="android:titleTextStyle">@style/AppTheme.ActionBar.TitleText</item>
2625
</style>
2726

28-
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
27+
<style name="AppTheme.ActionBar.TitleText" parent="@style/AppTheme">
28+
<item name="android:textSize">12sp</item>
29+
</style>
2930

30-
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
31+
<style name="AppTheme.PopupOverlay" parent="@style/Theme.Material3.Dark"/>
3132

3233
<style name="rtl_RecyclerTabLayout">
3334
<item name="rtl_tabMinWidth">72dp</item>
@@ -52,31 +53,24 @@
5253
</style>
5354

5455
<style name="DialogStyle" parent="@style/MaterialAlertDialog.Material3">
55-
<item name="android:windowEnterAnimation">@android:anim/fade_in</item>
56-
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
57-
58-
<item name="colorPrimary">#547383</item>
56+
<item name="colorPrimary">#61A3D7</item>
57+
<item name="colorPrimaryDark">#8DB2D3</item>
58+
<item name="colorAccent">#61A3D7</item>
5959
<item name="android:textColor">@color/textColor</item>
6060
<item name="android:textColorSecondary">@color/textColor</item>
61-
<item name="android:textColorLink">#2D55A3</item>
62-
63-
<item name="buttonBarPositiveButtonStyle">@style/Alert.Button.Positive</item>
64-
<item name="buttonBarNegativeButtonStyle">@style/Alert.Button.Neutral</item>
65-
<item name="buttonBarNeutralButtonStyle">@style/Alert.Button.Neutral</item>
66-
</style>
61+
<item name="android:textColorLink">#2255D3</item>
62+
<item name="background">@color/colorPrimary</item>
6763

68-
<style name="DialogStyleCompat" parent="@style/ThemeOverlay.Material3.MaterialAlertDialog">
6964
<item name="android:windowEnterAnimation">@android:anim/fade_in</item>
7065
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
7166

72-
<item name="colorPrimary">#547383</item>
73-
<item name="android:textColor">@color/textColor</item>
74-
<item name="android:textColorSecondary">@color/textColor</item>
75-
<item name="android:textColorLink">#2D55A3</item>
76-
7767
<item name="buttonBarPositiveButtonStyle">@style/Alert.Button.Positive</item>
68+
<item name="android:buttonBarPositiveButtonStyle">@style/Alert.Button.Positive</item>
7869
<item name="buttonBarNegativeButtonStyle">@style/Alert.Button.Neutral</item>
70+
<item name="android:buttonBarNegativeButtonStyle">@style/Alert.Button.Neutral</item>
7971
<item name="buttonBarNeutralButtonStyle">@style/Alert.Button.Neutral</item>
72+
<item name="android:buttonBarNeutralButtonStyle">@style/Alert.Button.Neutral</item>
73+
8074
</style>
8175

8276
<style name="Alert.Button.Positive" parent="@style/Widget.Material3.Button.TextButton">

0 commit comments

Comments
 (0)