mirror of
https://github.com/nextcloud/android.git
synced 2024-12-18 06:51:55 +03:00
use server slogan if present when browsing root folder
This commit is contained in:
parent
8c2c900f24
commit
3950da52c1
5 changed files with 32 additions and 9 deletions
|
@ -1869,6 +1869,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) {
|
||||
|
@ -2011,6 +2012,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;
|
||||
}
|
||||
|
|
|
@ -148,6 +148,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";
|
||||
|
|
|
@ -969,7 +969,7 @@ public class FileContentProvider extends ContentProvider {
|
|||
}
|
||||
|
||||
if (oldVersion < 21 && newVersion >= 21) {
|
||||
Log_OC.i(SQL, "Adding arbitrary data table");
|
||||
Log_OC.i(SQL, "Adding user theming to capabilities table");
|
||||
db.beginTransaction();
|
||||
try {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
|
||||
|
@ -978,6 +978,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 {
|
||||
|
@ -1071,6 +1073,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 );");
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -684,20 +684,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);
|
||||
|
@ -706,4 +712,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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue