Browse Source

Refactor and fix bug

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

+ 1 - 1
src/main/java/com/nextcloud/client/errorhandling/ShowErrorActivity.kt

@@ -44,7 +44,7 @@ class ShowErrorActivity : AppCompatActivity() {
 
         text_view_error.text = intent.getStringExtra(EXTRA_ERROR_TEXT)
 
-        setSupportActionBar(default_toolbar)
+        setSupportActionBar(toolbar)
         supportActionBar!!.title = createErrorTitle()
 
         val snackbar = DisplayUtils.createSnackbar(

+ 4 - 8
src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java

@@ -30,7 +30,6 @@ import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.Configuration;
-import android.graphics.PorterDuff;
 import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.LayerDrawable;
@@ -292,6 +291,8 @@ public abstract class DrawerActivity extends ToolbarActivity
         mDrawerLayout.addDrawerListener(mDrawerToggle);
         mDrawerToggle.setDrawerIndicatorEnabled(true);
         mDrawerToggle.setDrawerSlideAnimationEnabled(true);
+        Drawable backArrow = getResources().getDrawable(R.drawable.ic_arrow_back);
+        mDrawerToggle.setHomeAsUpIndicator(ThemeUtils.tintDrawable(backArrow, ThemeUtils.fontAppbarColor(this)));
     }
 
     /**
@@ -773,17 +774,12 @@ public abstract class DrawerActivity extends ToolbarActivity
         super.updateActionBarTitleAndHomeButton(chosenFile);
 
         // set home button properties
-        if (mDrawerToggle != null && chosenFile != null) {
-            if (isRoot(chosenFile)) {
+        if (mDrawerToggle != null) {
+            if (chosenFile != null && isRoot(chosenFile)) {
                 mDrawerToggle.setDrawerIndicatorEnabled(true);
             } else {
                 mDrawerToggle.setDrawerIndicatorEnabled(false);
-                Drawable backArrow = getResources().getDrawable(R.drawable.ic_arrow_back);
-                mDrawerToggle.setHomeAsUpIndicator(ThemeUtils.tintDrawable(backArrow,
-                                                                              ThemeUtils.fontAppbarColor(this)));
             }
-        } else if (mDrawerToggle != null) {
-            mDrawerToggle.setDrawerIndicatorEnabled(false);
         }
     }
 

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

@@ -65,7 +65,7 @@ public abstract class ToolbarActivity extends BaseActivity {
         int primaryColor = ThemeUtils.primaryAppbarColor(this);
         int fontColor = ThemeUtils.fontAppbarColor(this);
 
-        Toolbar toolbar = findViewById(R.id.default_toolbar);
+        Toolbar toolbar = findViewById(R.id.toolbar);
         setSupportActionBar(toolbar);
 
         mProgressBar = findViewById(R.id.toolbar_progressBar);

+ 0 - 6
src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.java

@@ -223,12 +223,6 @@ public class TrashbinActivity extends FileActivity implements
             trashbinPresenter.enterFolder(file.getRemotePath());
 
             mDrawerToggle.setDrawerIndicatorEnabled(false);
-
-            // TODO remove?
-            Toolbar toolbar = findViewById(R.id.default_toolbar);
-            if (toolbar != null && toolbar.getNavigationIcon() != null) {
-                ThemeUtils.tintDrawable(toolbar.getNavigationIcon(), ThemeUtils.fontColor(this));
-            }
         }
     }
 

+ 2 - 2
src/main/res/layout/toolbar_standard.xml

@@ -51,7 +51,7 @@
         </FrameLayout>
 
         <androidx.appcompat.widget.Toolbar
-            android:id="@+id/default_toolbar"
+            android:id="@+id/toolbar"
             android:layout_width="match_parent"
             android:layout_height="?attr/actionBarSize"
             app:popupTheme="@style/Theme.AppCompat.DayNight.NoActionBar" />
@@ -61,7 +61,7 @@
             style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_below="@id/default_toolbar"
+            android:layout_below="@id/toolbar"
             android:layout_marginTop="-7dp"
             android:layout_marginBottom="-7dp"
             android:indeterminate="true"