Browse Source

Fix userinfo and previewimage toolbar

Signed-off-by: Joris Bodin <joris.bodin@infomaniak.com>
Joris Bodin 5 years ago
parent
commit
5a8cec6372

+ 3 - 9
src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java

@@ -67,7 +67,6 @@ public abstract class ToolbarActivity extends BaseActivity {
     private TextView mInfoBoxMessage;
 
     private boolean isHomeSearchToolbarShow = false;
-    private boolean isUserInfo = false;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -78,7 +77,7 @@ public abstract class ToolbarActivity extends BaseActivity {
      * Toolbar setup that must be called in implementer's {@link #onCreate} after {@link #setContentView} if they want
      * to use the toolbar.
      */
-    protected void setupToolbar(boolean isUserInfo, boolean isHomeSearchToolbarShow) {
+    protected void setupToolbar(boolean isHomeSearchToolbarShow) {
         int fontColor = ThemeUtils.appBarPrimaryFontColor(this);
 
         Toolbar toolbar = findViewById(R.id.toolbar);
@@ -92,7 +91,6 @@ public abstract class ToolbarActivity extends BaseActivity {
         mSwitchAccountButton = findViewById(R.id.switch_account_button);
 
         this.isHomeSearchToolbarShow = isHomeSearchToolbarShow;
-        this.isUserInfo = isUserInfo;
         updateActionBarTitleAndHomeButton(null);
 
         mInfoBox = findViewById(R.id.info_box);
@@ -113,11 +111,7 @@ public abstract class ToolbarActivity extends BaseActivity {
     }
 
     public void setupToolbar() {
-        setupToolbar(false, false);
-    }
-
-    public void setupToolbar(boolean homeSearchToolbarShow) {
-        setupToolbar(false, homeSearchToolbarShow);
+        setupToolbar(false);
     }
 
     /**
@@ -130,7 +124,7 @@ public abstract class ToolbarActivity extends BaseActivity {
         title = isRoot ? ThemeUtils.getDefaultDisplayNameForRootFolder(this) : chosenFile.getFileName();
         updateActionBarTitleAndHomeButtonByString(title);
 
-        if (!isUserInfo) {
+        if (mAppBar != null) {
             showHomeSearchToolbar(title, isRoot);
         }
     }

+ 4 - 12
src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java

@@ -142,12 +142,7 @@ public class UserInfoActivity extends FileActivity implements Injectable {
         setContentView(R.layout.user_info_layout);
         unbinder = ButterKnife.bind(this);
 
-
-        boolean useBackgroundImage = URLUtil.isValidUrl(
-                getStorageManager().getCapability(user.getAccountName()).getServerBackground());
-
-        setupToolbar(useBackgroundImage, false);
-
+        setupToolbar(false);
 
         // set the back button from action bar
         ActionBar actionBar = getSupportActionBar();
@@ -156,11 +151,9 @@ public class UserInfoActivity extends FileActivity implements Injectable {
         if (actionBar != null) {
             actionBar.setDisplayHomeAsUpEnabled(true);
             actionBar.setDisplayShowHomeEnabled(true);
+            actionBar.setTitle("");
         }
 
-        // set title Action bar
-        updateActionBarTitleAndHomeButtonByString("");
-
         mUserInfoList.setAdapter(new UserInfoAdapter(null, ThemeUtils.primaryColor(getAccount(), true, this)));
 
         if (userInfo != null) {
@@ -230,10 +223,9 @@ public class UserInfoActivity extends FileActivity implements Injectable {
 
     private void setHeaderImage() {
         if (getStorageManager().getCapability(user.getAccountName()).getServerBackground() != null) {
-            ViewGroup appBar = findViewById(R.id.appbar);
+            ImageView backgroundImageView = findViewById(R.id.drawer_header_background);
 
-            if (appBar != null) {
-                ImageView backgroundImageView = appBar.findViewById(R.id.drawer_header_background);
+            if (backgroundImageView != null) {
 
                 String background = getStorageManager().getCapability(user.getAccountName()).getServerBackground();
                 int primaryColor = ThemeUtils.primaryColor(getAccount(), false, this);

+ 3 - 0
src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java

@@ -29,6 +29,7 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.ServiceConnection;
+import android.graphics.Color;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.text.TextUtils;
@@ -117,6 +118,8 @@ public class PreviewImageActivity extends FileActivity implements
         // ActionBar
         updateActionBarTitleAndHomeButton(null);
 
+        ThemeUtils.tintBackButton(actionBar, this, Color.WHITE);
+
         mFullScreenAnchorView = getWindow().getDecorView();
         // to keep our UI controls visibility in line with system bars visibility
         setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

+ 7 - 3
src/main/java/com/owncloud/android/utils/ThemeUtils.java

@@ -309,12 +309,16 @@ public final class ThemeUtils {
      * @param supportActionBar
      */
     public static void tintBackButton(@Nullable ActionBar supportActionBar, Context context) {
+        tintBackButton(supportActionBar, context, ThemeUtils.appBarPrimaryFontColor(context));
+    }
+
+    public static void tintBackButton(@Nullable ActionBar supportActionBar, Context context, @ColorInt int color) {
         if (supportActionBar == null) {
             return;
         }
 
         Drawable backArrow = context.getResources().getDrawable(R.drawable.ic_arrow_back);
-        supportActionBar.setHomeAsUpIndicator(ThemeUtils.tintDrawable(backArrow, ThemeUtils.appBarPrimaryFontColor(context)));
+        supportActionBar.setHomeAsUpIndicator(ThemeUtils.tintDrawable(backArrow, color));
     }
 
     public static Spanned getColoredTitle(String title, int color) {
@@ -550,8 +554,8 @@ public final class ThemeUtils {
     /**
      * Theme search view
      *
-     * @param searchView       searchView to be changed
-     * @param context          the app's context
+     * @param searchView searchView to be changed
+     * @param context    the app's context
      */
     public static void themeSearchView(SearchView searchView, Context context) {
         // hacky as no default way is provided

+ 0 - 1
src/main/res/layout/toolbar_user_information.xml

@@ -20,7 +20,6 @@
 <com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
-    android:id="@+id/appbar"
     android:layout_width="match_parent"
     android:layout_height="@dimen/nav_drawer_header_height"
     android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar">