Эх сурвалжийг харах

use capability to check if activity app is enabled

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 6 жил өмнө
parent
commit
97f050b799

+ 4 - 4
build.gradle

@@ -61,7 +61,7 @@ def versionMinor = 3
 def versionPatch = 0
 def versionBuild = 0 // 0-49=Alpha / 50-98=RC / 99=stable
 
-def taskRequest = getGradle().getStartParameter().getTaskRequests().toString();
+def taskRequest = getGradle().getStartParameter().getTaskRequests().toString()
 if (taskRequest.contains("Gplay") || taskRequest.contains("findbugs") || taskRequest.contains("lint")) {
     apply from: 'gplay.gradle'
 }
@@ -211,9 +211,9 @@ dependencies {
     // dependencies for app building
     implementation 'com.android.support:multidex:1.0.3'
 //    implementation project('nextcloud-android-library')
-    genericImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
-    gplayImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
-    versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' // use always latest master
+    genericImplementation "com.github.nextcloud:android-library:activityCapability-SNAPSHOT"
+    gplayImplementation "com.github.nextcloud:android-library:activityCapability-SNAPSHOT"
+    versionDevImplementation 'com.github.nextcloud:android-library:activityCapability-SNAPSHOT' // use always latest master
     implementation "com.android.support:support-v4:${supportLibraryVersion}"
     implementation "com.android.support:design:${supportLibraryVersion}"
     implementation 'com.jakewharton:disklrucache:2.0.2'

+ 3 - 0
src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java

@@ -1949,6 +1949,7 @@ public class FileDataStorageManager {
                 .getValue());
         cv.put(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_PLAIN, capability.getServerBackgroundPlain()
                 .getValue());
+        cv.put(ProviderTableMeta.CAPABILITIES_ACTIVITY, capability.isActivityEnabled().getValue());
 
         if (capabilityExists(mAccount.name)) {
             if (getContentResolver() != null) {
@@ -2102,6 +2103,8 @@ public class FileDataStorageManager {
                     c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_DEFAULT))));
             capability.setServerBackgroundPlain(CapabilityBooleanType.fromValue(
                     c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_PLAIN))));
+            capability.setActivity(CapabilityBooleanType.fromValue(
+                    c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_ACTIVITY))));
         }
         return capability;
     }

+ 3 - 2
src/main/java/com/owncloud/android/db/ProviderMeta.java

@@ -32,7 +32,7 @@ import com.owncloud.android.MainApp;
 public class ProviderMeta {
 
     public static final String DB_NAME = "filelist";
-    public static final int DB_VERSION = 32;
+    public static final int DB_VERSION = 33;
 
     private ProviderMeta() {
     }
@@ -171,6 +171,7 @@ public class ProviderMeta {
         public static final String CAPABILITIES_SERVER_BACKGROUND_PLAIN = "background_plain";
         
         public static final String CAPABILITIES_END_TO_END_ENCRYPTION = "end_to_end_encryption";
+        public static final String CAPABILITIES_ACTIVITY = "activity";
 
         public static final String CAPABILITIES_DEFAULT_SORT_ORDER = CAPABILITIES_ACCOUNT_NAME
                 + " collate nocase asc";
@@ -230,4 +231,4 @@ public class ProviderMeta {
         public static final String FILESYSTEM_SYNCED_FOLDER_ID = "syncedfolder_id";
         public static final String FILESYSTEM_CRC32 = "crc32";
     }
-}
+}

+ 18 - 0
src/main/java/com/owncloud/android/providers/FileContentProvider.java

@@ -804,6 +804,7 @@ public class FileContentProvider extends ContentProvider {
                 + ProviderTableMeta.CAPABILITIES_SERVER_SLOGAN + TEXT
                 + ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_URL + TEXT
                 + ProviderTableMeta.CAPABILITIES_END_TO_END_ENCRYPTION + INTEGER
+                + ProviderTableMeta.CAPABILITIES_ACTIVITY + INTEGER
                 + ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_DEFAULT + INTEGER
                 + ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_PLAIN + " INTEGER );");
     }
@@ -1704,6 +1705,23 @@ public class FileContentProvider extends ContentProvider {
             if (!upgraded) {
                 Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
             }
+
+            if (oldVersion < 33 && newVersion >= 33) {
+                Log_OC.i(SQL, "Entering in the #3 Adding activity to capability");
+                db.beginTransaction();
+                try {
+                    db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
+                            ADD_COLUMN + ProviderTableMeta.CAPABILITIES_ACTIVITY + " INTEGER ");
+                    upgraded = true;
+                    db.setTransactionSuccessful();
+                } finally {
+                    db.endTransaction();
+                }
+            }
+
+            if (!upgraded) {
+                Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
+            }
         }
 
         @Override

+ 2 - 1
src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java

@@ -346,7 +346,8 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
     private void filterDrawerMenu(Menu menu, Account account) {
         DrawerMenuUtil.filterForBottomToolbarMenuItems(menu, getResources());
         DrawerMenuUtil.filterSearchMenuItems(menu, account, getResources());
-        DrawerMenuUtil.filterTrashbinMenuItems(menu, account, getContentResolver());
+        DrawerMenuUtil.filterTrashbinMenuItem(menu, account, getContentResolver());
+        DrawerMenuUtil.filterActivityMenuItem(menu, account, getContentResolver());
 
         DrawerMenuUtil.setupHomeMenuItem(menu, getResources());
 

+ 12 - 1
src/main/java/com/owncloud/android/utils/DrawerMenuUtil.java

@@ -67,7 +67,7 @@ public class DrawerMenuUtil {
         }
     }
 
-    public static void filterTrashbinMenuItems(Menu menu, Account account, ContentResolver contentResolver) {
+    public static void filterTrashbinMenuItem(Menu menu, Account account, ContentResolver contentResolver) {
         if (account != null) {
             FileDataStorageManager storageManager = new FileDataStorageManager(account, contentResolver);
             OCCapability capability = storageManager.getCapability(account.name);
@@ -79,6 +79,17 @@ public class DrawerMenuUtil {
         }
     }
 
+    public static void filterActivityMenuItem(Menu menu, Account account, ContentResolver contentResolver) {
+        if (account != null) {
+            FileDataStorageManager storageManager = new FileDataStorageManager(account, contentResolver);
+            OCCapability capability = storageManager.getCapability(account.name);
+
+            if (capability.isActivityEnabled().isFalse() || capability.isActivityEnabled().isUnknown()) {
+                filterMenuItems(menu, R.id.nav_activity);
+            }
+        }
+    }
+
     public static void removeMenuItem(Menu menu, int id, boolean remove) {
         if (remove) {
             menu.removeItem(id);