Forráskód Böngészése

Merge pull request #9195 from nextcloud/whats-new-sdk-30

Add What's New view to warn users of changes in storage after sdk 30
Álvaro Brey 3 éve
szülő
commit
518343c4e4

+ 7 - 16
src/main/java/com/nextcloud/client/appinfo/AppInfo.java → src/main/java/com/nextcloud/client/appinfo/AppInfo.kt

@@ -17,9 +17,9 @@
  * You should have received a copy of the GNU Affero General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-package com.nextcloud.client.appinfo;
+package com.nextcloud.client.appinfo
 
-import android.content.Context;
+import android.content.Context
 
 /**
  * This class provides general, static information about application
@@ -27,18 +27,9 @@ import android.content.Context;
  *
  * All methods should be thread-safe.
  */
-public interface AppInfo {
-
-    /**
-     * Get application version code as formatted string.
-     *
-     * @return Formatted version code as defined in AndroidManifest.xml
-     */
-    String getFormattedVersionCode();
-
-    int getVersionCode();
-
-    boolean isDebugBuild();
-
-    String getAppVersion(Context context);
+interface AppInfo {
+    val versionName: String
+    val versionCode: Int
+    val isDebugBuild: Boolean
+    fun getAppVersion(context: Context): String
 }

+ 0 - 61
src/main/java/com/nextcloud/client/appinfo/AppInfoImpl.java

@@ -1,61 +0,0 @@
-/*
- * Nextcloud Android client application
- *
- * @author Chris Narkiewicz
- * Copyright (C) 2019 Chris Narkiewicz <hello@ezaquarii.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.nextcloud.client.appinfo;
-
-import android.content.Context;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-
-import com.owncloud.android.BuildConfig;
-import com.owncloud.android.lib.common.utils.Log_OC;
-
-class AppInfoImpl implements AppInfo {
-
-    @Override
-    public String getFormattedVersionCode() {
-        return Integer.toString(BuildConfig.VERSION_CODE);
-    }
-
-    @Override
-    public int getVersionCode() {
-        return BuildConfig.VERSION_CODE;
-    }
-
-    @Override
-    public boolean isDebugBuild() {
-        return BuildConfig.DEBUG;
-    }
-
-    @Override
-    public String getAppVersion(Context context) {
-        try {
-            PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
-            if (pInfo != null) {
-                return pInfo.versionName;
-            } else {
-                return "n/a";
-            }
-        } catch (PackageManager.NameNotFoundException e) {
-            Log_OC.e(this, "Trying to get packageName", e.getCause());
-
-            return "n/a";
-        }
-    }
-}

+ 45 - 0
src/main/java/com/nextcloud/client/appinfo/AppInfoImpl.kt

@@ -0,0 +1,45 @@
+/*
+ * Nextcloud Android client application
+ *
+ * @author Chris Narkiewicz
+ * Copyright (C) 2019 Chris Narkiewicz <hello@ezaquarii.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.client.appinfo
+
+import android.content.Context
+import android.content.pm.PackageManager
+import com.owncloud.android.BuildConfig
+import com.owncloud.android.lib.common.utils.Log_OC
+
+class AppInfoImpl : AppInfo {
+    override val versionName: String = BuildConfig.VERSION_NAME
+    override val versionCode: Int = BuildConfig.VERSION_CODE
+    override val isDebugBuild: Boolean = BuildConfig.DEBUG
+
+    override fun getAppVersion(context: Context): String {
+        return try {
+            val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
+            if (pInfo != null) {
+                pInfo.versionName
+            } else {
+                "n/a"
+            }
+        } catch (e: PackageManager.NameNotFoundException) {
+            Log_OC.e(this, "Trying to get packageName", e.cause)
+            "n/a"
+        }
+    }
+}

+ 6 - 6
src/main/java/com/nextcloud/client/appinfo/AppInfoModule.java → src/main/java/com/nextcloud/client/appinfo/AppInfoModule.kt

@@ -17,15 +17,15 @@
  * You should have received a copy of the GNU Affero General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-package com.nextcloud.client.appinfo;
+package com.nextcloud.client.appinfo
 
-import dagger.Module;
-import dagger.Provides;
+import dagger.Module
+import dagger.Provides
 
 @Module
-public class AppInfoModule {
+class AppInfoModule {
     @Provides
-    AppInfo appInfo() {
-        return new AppInfoImpl();
+    fun appInfo(): AppInfo {
+        return AppInfoImpl()
     }
 }

+ 18 - 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.Intent
 import android.content.res.Resources
+import android.os.Build
 import com.nextcloud.client.account.CurrentAccountProvider
 import com.nextcloud.client.preferences.AppPreferences
 import com.owncloud.android.BuildConfig
@@ -37,7 +38,7 @@ internal class OnboardingServiceImpl constructor(
 ) : OnboardingService {
 
     private companion object {
-        const val ITEM_VERSION_CODE = 99999999
+        const val ITEM_VERSION_CODE = 30185300
     }
 
     private val notSeenYet: Boolean
@@ -46,8 +47,21 @@ internal class OnboardingServiceImpl constructor(
         }
 
     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
+                ),
+                FeatureItem(
+                    R.drawable.folder_alert_outline, R.string.whats_new_storage_sdk30_title,
+                    R.string
+                        .whats_new_storage_sdk30_content_page2,
+                    true, false
+                )
+            )
         } else {
             emptyArray()
         }
@@ -58,7 +72,7 @@ internal class OnboardingServiceImpl constructor(
         }
 
     override fun shouldShowWhatsNew(callingContext: Context): Boolean {
-        return callingContext !is PassCodeActivity && whatsNew.size > 0
+        return callingContext !is PassCodeActivity && whatsNew.isNotEmpty()
     }
 
     override fun launchActivityIfNeeded(activity: Activity) {

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

@@ -38,7 +38,6 @@ import com.owncloud.android.ui.adapter.FeaturesViewAdapter;
 import com.owncloud.android.ui.adapter.FeaturesWebViewAdapter;
 import com.owncloud.android.ui.whatsnew.ProgressIndicator;
 import com.owncloud.android.utils.theme.ThemeButtonUtils;
-import com.owncloud.android.utils.theme.ThemeUtils;
 
 import javax.inject.Inject;
 
@@ -113,7 +112,7 @@ public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPa
         if (showWebView) {
             tv.setText(R.string.app_name);
         } else {
-            tv.setText(String.format(getString(R.string.whats_new_title), appInfo.getFormattedVersionCode()));
+            tv.setText(String.format(getString(R.string.whats_new_title), appInfo.getVersionName()));
         }
 
         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>

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

@@ -1002,4 +1002,11 @@
     <string name="no_actions">No actions for this user</string>
     <string name="search_error">Error getting search 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>
+    <string name="whats_new_storage_sdk30_content_page2">Please check your auto upload items and verify
+    that Nextcloud still has read access to the local folder.\n\nAdditionally, other applications will not be able to
+    read Nextcloud\'s downloaded files directly from the external storage.</string>
 </resources>