Skip to content

Commit d3c83de

Browse files
committed
Bump target sdk to 33 and add notifications item in Settings
1 parent ab4b829 commit d3c83de

6 files changed

Lines changed: 40 additions & 1 deletion

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ buildscript {
33
// SDK
44
sdkCompileVersion = 33
55
sdkMinVersion = 21
6-
sdkTargetVersion = 31
6+
sdkTargetVersion = 33
77

88
// Android jetpack
99
androidxArchCore = "2.2.0"

owncloudApp/src/main/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
API >= 23; the app needs to handle this
4040
-->
4141
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
42+
<!--
43+
Notifications are off by default since API 33;
44+
See note in https://developer.android.com/develop/ui/views/notifications/notification-permission
45+
-->
46+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
4247
<!--
4348
Next permissions are always approved in installation time,
4449
the apps needs to do nothing special in runtime

owncloudApp/src/main/java/com/owncloud/android/presentation/settings/SettingsFragment.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ import android.content.ClipData
2424
import android.content.ClipboardManager
2525
import android.content.Context
2626
import android.content.Intent
27+
import android.os.Build
2728
import android.os.Bundle
29+
import android.provider.Settings
2830
import androidx.preference.Preference
2931
import androidx.preference.PreferenceFragmentCompat
3032
import androidx.preference.PreferenceScreen
@@ -50,6 +52,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
5052
private var subsectionMore: Preference? = null
5153
private var prefPrivacyPolicy: Preference? = null
5254
private var subsectionWhatsNew: Preference? = null
55+
private var subsectionNotifications: Preference? = null
5356
private var prefAboutApp: Preference? = null
5457

5558
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
@@ -61,6 +64,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
6164
subsectionMore = findPreference(SUBSECTION_MORE)
6265
prefPrivacyPolicy = findPreference(PREFERENCE_PRIVACY_POLICY)
6366
subsectionWhatsNew = findPreference(SUBSECTION_WHATSNEW)
67+
subsectionNotifications = findPreference(SUBSECTION_NOTIFICATIONS)
6468
prefAboutApp = findPreference(PREFERENCE_ABOUT_APP)
6569

6670
subsectionPictureUploads?.isVisible = settingsViewModel.isThereAttachedAccount()
@@ -89,6 +93,18 @@ class SettingsFragment : PreferenceFragmentCompat() {
8993
true
9094
}
9195

96+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
97+
subsectionNotifications?.setOnPreferenceClickListener {
98+
val intent = Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS).apply {
99+
putExtra(Settings.EXTRA_APP_PACKAGE, requireContext().packageName)
100+
}
101+
startActivity(intent)
102+
true
103+
}
104+
} else {
105+
settingsScreen.removePreferenceFromScreen(subsectionNotifications)
106+
}
107+
92108
prefAboutApp?.apply {
93109
summary = String.format(
94110
getString(R.string.prefs_app_version_summary),
@@ -114,6 +130,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
114130
private const val SUBSECTION_PICTURE_UPLOADS = "picture_uploads_subsection"
115131
private const val SUBSECTION_VIDEO_UPLOADS = "video_uploads_subsection"
116132
private const val SUBSECTION_MORE = "more_subsection"
133+
private const val SUBSECTION_NOTIFICATIONS = "notifications_subsection"
117134

118135
// Remove preference with nullability check
119136
fun PreferenceScreen?.removePreferenceFromScreen(preference: Preference?) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:tint="?attr/colorControlNormal"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z" />
10+
</vector>

owncloudApp/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
<string name="prefs_camera_video_upload_on_wifi">Upload videos via wifi only</string>
7474
<string name="prefs_camera_video_upload_on_charging">Upload videos only when charging</string>
7575
<string name="prefs_subsection_advanced">Advanced</string>
76+
<string name="prefs_subsection_notifications">Manage notifications</string>
7677
<string name="prefs_show_hidden_files">Show hidden files</string>
7778
<string name="prefs_log_open_logs_list_view">Log files</string>
7879
<string name="prefs_log_no_logs_list_view">Empty log folder!</string>

owncloudApp/src/main/res/xml/settings.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
app:summary="@string/prefs_subsection_security_summary"
2626
app:title="@string/prefs_subsection_security" />
2727

28+
<Preference
29+
app:allowDividerAbove="true"
30+
app:icon="@drawable/ic_notifications"
31+
app:key="notifications_subsection"
32+
app:title="@string/prefs_subsection_notifications" />
33+
2834
<Preference
2935
app:allowDividerAbove="true"
3036
app:fragment="com.owncloud.android.presentation.settings.logging.SettingsLogsFragment"

0 commit comments

Comments
 (0)