Explorar el Código

use server slogan if present when browsing root folder

tobiasKaminsky hace 8 años
padre
commit
fdfc4951e8

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

@@ -1911,6 +1911,7 @@ public class FileDataStorageManager {
         cv.put(ProviderTableMeta.CAPABILITIES_SERVER_NAME, capability.getServerName());
         cv.put(ProviderTableMeta.CAPABILITIES_SERVER_COLOR, capability.getServerColor());
         cv.put(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_URL, capability.getServerBackground());
+        cv.put(ProviderTableMeta.CAPABILITIES_SERVER_SLOGAN, capability.getServerSlogan());
 
         if (capabilityExists(mAccount.name)) {
             if (getContentResolver() != null) {
@@ -2054,6 +2055,7 @@ public class FileDataStorageManager {
             capability.setServerColor(c.getString(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SERVER_COLOR)));
             capability.setServerBackground(c.getString(c.getColumnIndex(
                     ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_URL)));
+            capability.setServerSlogan(c.getString(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SERVER_SLOGAN)));
         }
         return capability;
     }

+ 1 - 0
src/main/java/com/owncloud/android/db/ProviderMeta.java

@@ -150,6 +150,7 @@ public class ProviderMeta {
         public static final String CAPABILITIES_SERVER_NAME = "server_name";
         public static final String CAPABILITIES_SERVER_COLOR = "server_color";
         public static final String CAPABILITIES_SERVER_BACKGROUND_URL = "background_url";
+        public static final String CAPABILITIES_SERVER_SLOGAN = "server_slogan";
 
         public static final String CAPABILITIES_DEFAULT_SORT_ORDER = CAPABILITIES_ACCOUNT_NAME
                 + " collate nocase asc";

+ 4 - 1
src/main/java/com/owncloud/android/providers/FileContentProvider.java

@@ -1012,7 +1012,7 @@ public class FileContentProvider extends ContentProvider {
             }
 
             if (oldVersion < 22 && newVersion >= 22) {
-                Log_OC.i(SQL, "Adding arbitrary data table");
+                Log_OC.i(SQL, "Entering in the #22 Adding user theming to capabilities table");
                 db.beginTransaction();
                 try {
                     db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
@@ -1021,6 +1021,8 @@ public class FileContentProvider extends ContentProvider {
                             ADD_COLUMN + ProviderTableMeta.CAPABILITIES_SERVER_COLOR + " TEXT ");
                     db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
                             ADD_COLUMN + ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_URL + " TEXT ");
+                    db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
+                            ADD_COLUMN + ProviderTableMeta.CAPABILITIES_SERVER_SLOGAN + " TEXT ");
                     upgraded = true;
                     db.setTransactionSuccessful();
                 } finally {
@@ -1114,6 +1116,7 @@ public class FileContentProvider extends ContentProvider {
                 + ProviderTableMeta.CAPABILITIES_EXTERNAL_LINKS + INTEGER  // boolean
                 + ProviderTableMeta.CAPABILITIES_SERVER_NAME + TEXT
                 + ProviderTableMeta.CAPABILITIES_SERVER_COLOR + TEXT
+                + ProviderTableMeta.CAPABILITIES_SERVER_SLOGAN + TEXT
                 + ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_URL + " TEXT );");
     }
 

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

@@ -33,6 +33,7 @@ import android.widget.ProgressBar;
 import com.owncloud.android.R;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.utils.DisplayUtils;
 
 /**
  * Base class providing toolbar registration functionality, see {@link #setupToolbar()}.
@@ -64,7 +65,7 @@ public abstract class ToolbarActivity extends BaseActivity {
      * Updates title bar and home buttons (state and icon).
      */
     protected void updateActionBarTitleAndHomeButton(OCFile chosenFile) {
-        String title = getString(R.string.default_display_name_for_root_folder);    // default
+        String title = DisplayUtils.getDefaultDisplayNameForRootFolder();    // default
         boolean inRoot;
 
         // choose the appropriate title

+ 23 - 7
src/main/java/com/owncloud/android/utils/DisplayUtils.java

@@ -692,20 +692,26 @@ public class DisplayUtils {
         return text.toString();
     }
 
-    public static Drawable tintDrawable(@DrawableRes int id, @ColorRes int color) {
-        int colorToUse = MainApp.getAppContext().getResources().getColor(color);
-
+    private static OCCapability getCapability() {
         Account account = AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext());
 
         if (account != null) {
             Context context = MainApp.getAppContext();
 
             FileDataStorageManager storageManager = new FileDataStorageManager(account, context.getContentResolver());
-            OCCapability capability = storageManager.getCapability(account.name);
+            return storageManager.getCapability(account.name);
+        } else {
+            return new OCCapability();
+        }
+    }
 
-            if (!capability.getServerColor().isEmpty()) {
-                colorToUse = Color.parseColor(capability.getServerColor());
-            }
+    public static Drawable tintDrawable(@DrawableRes int id, @ColorRes int color) {
+        int colorToUse = MainApp.getAppContext().getResources().getColor(color);
+
+        OCCapability capability = getCapability();
+
+        if (!capability.getServerColor().isEmpty()) {
+            colorToUse = Color.parseColor(capability.getServerColor());
         }
 
         Drawable drawable = ResourcesCompat.getDrawable(MainApp.getAppContext().getResources(), id, null);
@@ -714,4 +720,14 @@ public class DisplayUtils {
         return drawable;
     }
 
+    public static String getDefaultDisplayNameForRootFolder() {
+        OCCapability capability = getCapability();
+
+        if (capability.getServerSlogan().isEmpty()) {
+            return MainApp.getAppContext().getResources().getString(R.string.default_display_name_for_root_folder);
+        } else {
+            return capability.getServerSlogan();
+        }
+    }
+
 }