Merge pull request #1708 from apicellaj/action_bar

Prevent action bar title from being overwritten
This commit is contained in:
Tobias Kaminsky 2018-10-25 10:02:38 +02:00 committed by GitHub
commit b48fbb2e06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 3 deletions

View file

@ -2501,9 +2501,23 @@ public class FileDisplayActivity extends HookActivity
browseToRoot();
}
public void setActionBarTitle(@StringRes final int title) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (getSupportActionBar() != null) {
ThemeUtils.setColoredTitle(getSupportActionBar(), title, getBaseContext());
}
}
});
}
@Override
public void showFiles(boolean onDeviceOnly) {
super.showFiles(onDeviceOnly);
if (onDeviceOnly) {
setActionBarTitle(R.string.drawer_item_on_device);
}
getListOfFilesFragment().refreshDirectory();
}

View file

@ -1435,6 +1435,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
remoteOperationAsyncTask = new AsyncTask() {
@Override
protected Object doInBackground(Object[] params) {
setTitle();
if (getContext() != null && !isCancelled()) {
RemoteOperationResult remoteOperationResult = remoteOperation.execute(currentAccount, getContext());

View file

@ -224,6 +224,9 @@ public final class ThemeUtils {
public static String getDefaultDisplayNameForRootFolder(Context context) {
OCCapability capability = getCapability(context);
if (MainApp.isOnlyOnDevice()) {
return MainApp.getAppContext().getString(R.string.drawer_item_on_device);
} else {
if (capability.getServerName() == null || capability.getServerName().isEmpty()) {
return MainApp.getAppContext().getResources().getString(R.string.default_display_name_for_root_folder);
} else {
@ -231,6 +234,8 @@ public final class ThemeUtils {
}
}
}
public static void setStatusBarColor(Activity activity, @ColorInt int color) {
if (activity != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().setStatusBarColor(color);