Browse Source

Add What's New view to warn users of changes in storage after sdk 30

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
Álvaro Brey Vilas 3 years ago
parent
commit
be43a629fd

+ 12 - 4
src/main/java/com/nextcloud/client/onboarding/OnboardingServiceImpl.kt

@@ -22,6 +22,7 @@ import android.app.Activity
 import android.content.Context
 import android.content.Context
 import android.content.Intent
 import android.content.Intent
 import android.content.res.Resources
 import android.content.res.Resources
+import android.os.Build
 import com.nextcloud.client.account.CurrentAccountProvider
 import com.nextcloud.client.account.CurrentAccountProvider
 import com.nextcloud.client.preferences.AppPreferences
 import com.nextcloud.client.preferences.AppPreferences
 import com.owncloud.android.BuildConfig
 import com.owncloud.android.BuildConfig
@@ -37,7 +38,7 @@ internal class OnboardingServiceImpl constructor(
 ) : OnboardingService {
 ) : OnboardingService {
 
 
     private companion object {
     private companion object {
-        const val ITEM_VERSION_CODE = 99999999
+        const val ITEM_VERSION_CODE = 30185300
     }
     }
 
 
     private val notSeenYet: Boolean
     private val notSeenYet: Boolean
@@ -46,8 +47,15 @@ internal class OnboardingServiceImpl constructor(
         }
         }
 
 
     override val whatsNew: Array<FeatureItem>
     override val whatsNew: Array<FeatureItem>
-        get() = if (!isFirstRun && notSeenYet) {
-            emptyArray()
+        get() = if (!isFirstRun && notSeenYet && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+            arrayOf(
+                FeatureItem(
+                    R.drawable.folder_alert_outline, R.string.whats_new_storage_sdk30_title,
+                    R.string
+                        .whats_new_storage_sdk30_content,
+                    true, false
+                )
+            )
         } else {
         } else {
             emptyArray()
             emptyArray()
         }
         }
@@ -58,7 +66,7 @@ internal class OnboardingServiceImpl constructor(
         }
         }
 
 
     override fun shouldShowWhatsNew(callingContext: Context): Boolean {
     override fun shouldShowWhatsNew(callingContext: Context): Boolean {
-        return callingContext !is PassCodeActivity && whatsNew.size > 0
+        return callingContext !is PassCodeActivity && whatsNew.isNotEmpty()
     }
     }
 
 
     override fun launchActivityIfNeeded(activity: Activity) {
     override fun launchActivityIfNeeded(activity: Activity) {

+ 1 - 1
src/main/java/com/nextcloud/client/onboarding/WhatsNewActivity.java

@@ -113,7 +113,7 @@ public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPa
         if (showWebView) {
         if (showWebView) {
             tv.setText(R.string.app_name);
             tv.setText(R.string.app_name);
         } else {
         } else {
-            tv.setText(String.format(getString(R.string.whats_new_title), appInfo.getFormattedVersionCode()));
+            tv.setText(String.format(getString(R.string.whats_new_title), BuildConfig.VERSION_NAME));
         }
         }
 
 
         updateNextButtonIfNeeded();
         updateNextButtonIfNeeded();

+ 8 - 0
src/main/res/drawable/folder_alert_outline.xml

@@ -0,0 +1,8 @@
+<!-- drawable/folder_alert_outline.xml -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:height="24dp"
+    android:width="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+    <path android:fillColor="#000" android:pathData="M15,12H17V17H15V12M15,18H17V20H15V18M16,9C17.07,9 18.09,9.24 19,9.67V8H3V18H9.29C9.1,17.36 9,16.69 9,16A7,7 0 0,1 16,9M23,16A7,7 0 0,1 16,23C13.62,23 11.5,21.81 10.25,20H3C1.89,20 1,19.1 1,18V6C1,4.89 1.89,4 3,4H9L11,6H19A2,2 0 0,1 21,8V11.1C22.24,12.36 23,14.09 23,16M16,11A5,5 0 0,0 11,16A5,5 0 0,0 16,21A5,5 0 0,0 21,16A5,5 0 0,0 16,11Z" />
+</vector>

+ 4 - 0
src/main/res/values/strings.xml

@@ -1002,4 +1002,8 @@
     <string name="no_actions">No actions for this user</string>
     <string name="no_actions">No actions for this user</string>
     <string name="search_error">Error getting search results</string>
     <string name="search_error">Error getting search results</string>
     <string name="load_more_results">Load more results</string>
     <string name="load_more_results">Load more results</string>
+    <string name="whats_new_storage_sdk30_title">Changes in storage access from Android 11</string>
+    <string name="whats_new_storage_sdk30_content">From Android 11 onwards, strict storage access
+        control is enforced.\n\nAs a consequence, Nextcloud will no longer be able to delete or write files on
+        external storage, or read files in private folders owned by other apps.</string>
 </resources>
 </resources>