|
@@ -28,6 +28,7 @@ import android.accounts.AccountManagerFuture;
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
import android.content.SharedPreferences;
|
|
import android.content.SharedPreferences;
|
|
import android.content.res.Configuration;
|
|
import android.content.res.Configuration;
|
|
|
|
+import android.graphics.Color;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.os.Build;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
@@ -37,14 +38,17 @@ import android.support.design.widget.NavigationView;
|
|
import android.support.v4.view.GravityCompat;
|
|
import android.support.v4.view.GravityCompat;
|
|
import android.support.v4.widget.DrawerLayout;
|
|
import android.support.v4.widget.DrawerLayout;
|
|
import android.support.v7.app.ActionBarDrawerToggle;
|
|
import android.support.v7.app.ActionBarDrawerToggle;
|
|
|
|
+import android.text.Html;
|
|
import android.view.Menu;
|
|
import android.view.Menu;
|
|
import android.view.MenuItem;
|
|
import android.view.MenuItem;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
|
+import android.webkit.URLUtil;
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.ProgressBar;
|
|
import android.widget.ProgressBar;
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
+import com.bumptech.glide.Glide;
|
|
import com.bumptech.glide.request.animation.GlideAnimation;
|
|
import com.bumptech.glide.request.animation.GlideAnimation;
|
|
import com.bumptech.glide.request.target.SimpleTarget;
|
|
import com.bumptech.glide.request.target.SimpleTarget;
|
|
import com.owncloud.android.MainApp;
|
|
import com.owncloud.android.MainApp;
|
|
@@ -71,6 +75,7 @@ import com.owncloud.android.ui.events.MenuItemClickEvent;
|
|
import com.owncloud.android.ui.events.SearchEvent;
|
|
import com.owncloud.android.ui.events.SearchEvent;
|
|
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
|
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
|
import com.owncloud.android.utils.DisplayUtils;
|
|
import com.owncloud.android.utils.DisplayUtils;
|
|
|
|
+import com.owncloud.android.utils.ThemeUtils;
|
|
import com.owncloud.android.utils.svg.MenuSimpleTarget;
|
|
import com.owncloud.android.utils.svg.MenuSimpleTarget;
|
|
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
import org.greenrobot.eventbus.EventBus;
|
|
@@ -249,6 +254,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
// Set the drawer toggle as the DrawerListener
|
|
// Set the drawer toggle as the DrawerListener
|
|
mDrawerLayout.addDrawerListener(mDrawerToggle);
|
|
mDrawerLayout.addDrawerListener(mDrawerToggle);
|
|
mDrawerToggle.setDrawerIndicatorEnabled(true);
|
|
mDrawerToggle.setDrawerIndicatorEnabled(true);
|
|
|
|
+ mDrawerToggle.getDrawerArrowDrawable().setColor(ThemeUtils.fontColor());
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -260,6 +266,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
mAccountEndAccountAvatar = (ImageView) findNavigationViewChildById(R.id.drawer_account_end);
|
|
mAccountEndAccountAvatar = (ImageView) findNavigationViewChildById(R.id.drawer_account_end);
|
|
|
|
|
|
mAccountChooserToggle = (ImageView) findNavigationViewChildById(R.id.drawer_account_chooser_toogle);
|
|
mAccountChooserToggle = (ImageView) findNavigationViewChildById(R.id.drawer_account_chooser_toogle);
|
|
|
|
+ mAccountChooserToggle.setColorFilter(ThemeUtils.fontColor());
|
|
|
|
|
|
if (getResources().getBoolean(R.bool.allow_profile_click)) {
|
|
if (getResources().getBoolean(R.bool.allow_profile_click)) {
|
|
mAccountChooserToggle.setImageResource(R.drawable.ic_down);
|
|
mAccountChooserToggle.setImageResource(R.drawable.ic_down);
|
|
@@ -284,7 +291,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
mQuotaProgressBar = (ProgressBar) findQuotaViewById(R.id.drawer_quota_ProgressBar);
|
|
mQuotaProgressBar = (ProgressBar) findQuotaViewById(R.id.drawer_quota_ProgressBar);
|
|
mQuotaTextPercentage = (TextView) findQuotaViewById(R.id.drawer_quota_percentage);
|
|
mQuotaTextPercentage = (TextView) findQuotaViewById(R.id.drawer_quota_percentage);
|
|
mQuotaTextLink = (TextView) findQuotaViewById(R.id.drawer_quota_link);
|
|
mQuotaTextLink = (TextView) findQuotaViewById(R.id.drawer_quota_link);
|
|
- DisplayUtils.colorPreLollipopHorizontalProgressBar(mQuotaProgressBar);
|
|
|
|
|
|
+ ThemeUtils.colorPreLollipopHorizontalProgressBar(mQuotaProgressBar);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -293,11 +300,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
* @param navigationView the drawers navigation view
|
|
* @param navigationView the drawers navigation view
|
|
*/
|
|
*/
|
|
protected void setupDrawerMenu(NavigationView navigationView) {
|
|
protected void setupDrawerMenu(NavigationView navigationView) {
|
|
- // on pre lollipop the light theme adds a black tint to icons with white coloring
|
|
|
|
- // ruining the generic avatars, so tinting for icons is deactivated pre lollipop
|
|
|
|
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
|
|
|
- navigationView.setItemIconTintList(null);
|
|
|
|
- }
|
|
|
|
|
|
+ navigationView.setItemIconTintList(null);
|
|
|
|
|
|
// setup actions for drawer menu items
|
|
// setup actions for drawer menu items
|
|
navigationView.setNavigationItemSelectedListener(
|
|
navigationView.setNavigationItemSelectedListener(
|
|
@@ -410,36 +413,27 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
|
|
|
|
private void selectNavigationItem(final MenuItem menuItem) {
|
|
private void selectNavigationItem(final MenuItem menuItem) {
|
|
|
|
|
|
|
|
+ setDrawerMenuItemChecked(menuItem.getItemId());
|
|
|
|
+
|
|
switch (menuItem.getItemId()) {
|
|
switch (menuItem.getItemId()) {
|
|
case R.id.nav_all_files:
|
|
case R.id.nav_all_files:
|
|
- menuItem.setChecked(true);
|
|
|
|
- mCheckedMenuItem = menuItem.getItemId();
|
|
|
|
showFiles(false);
|
|
showFiles(false);
|
|
EventBus.getDefault().post(new ChangeMenuEvent());
|
|
EventBus.getDefault().post(new ChangeMenuEvent());
|
|
break;
|
|
break;
|
|
case R.id.nav_favorites:
|
|
case R.id.nav_favorites:
|
|
- menuItem.setChecked(true);
|
|
|
|
- mCheckedMenuItem = menuItem.getItemId();
|
|
|
|
-
|
|
|
|
switchToSearchFragment(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH,
|
|
switchToSearchFragment(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH,
|
|
SearchEvent.UnsetType.NO_UNSET), menuItem);
|
|
SearchEvent.UnsetType.NO_UNSET), menuItem);
|
|
break;
|
|
break;
|
|
case R.id.nav_photos:
|
|
case R.id.nav_photos:
|
|
- menuItem.setChecked(true);
|
|
|
|
- mCheckedMenuItem = menuItem.getItemId();
|
|
|
|
-
|
|
|
|
switchToSearchFragment(new SearchEvent("image/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
switchToSearchFragment(new SearchEvent("image/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
SearchEvent.UnsetType.NO_UNSET), menuItem);
|
|
SearchEvent.UnsetType.NO_UNSET), menuItem);
|
|
break;
|
|
break;
|
|
case R.id.nav_on_device:
|
|
case R.id.nav_on_device:
|
|
- menuItem.setChecked(true);
|
|
|
|
- mCheckedMenuItem = menuItem.getItemId();
|
|
|
|
EventBus.getDefault().post(new ChangeMenuEvent());
|
|
EventBus.getDefault().post(new ChangeMenuEvent());
|
|
showFiles(true);
|
|
showFiles(true);
|
|
break;
|
|
break;
|
|
case R.id.nav_uploads:
|
|
case R.id.nav_uploads:
|
|
- Intent uploadListIntent = new Intent(getApplicationContext(),
|
|
|
|
- UploadListActivity.class);
|
|
|
|
|
|
+ Intent uploadListIntent = new Intent(getApplicationContext(), UploadListActivity.class);
|
|
uploadListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
uploadListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
startActivity(uploadListIntent);
|
|
startActivity(uploadListIntent);
|
|
break;
|
|
break;
|
|
@@ -465,8 +459,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
startActivity(settingsIntent);
|
|
startActivity(settingsIntent);
|
|
break;
|
|
break;
|
|
case R.id.nav_participate:
|
|
case R.id.nav_participate:
|
|
- Intent participateIntent = new Intent(getApplicationContext(),
|
|
|
|
- ParticipateActivity.class);
|
|
|
|
|
|
+ Intent participateIntent = new Intent(getApplicationContext(), ParticipateActivity.class);
|
|
startActivity(participateIntent);
|
|
startActivity(participateIntent);
|
|
break;
|
|
break;
|
|
case R.id.nav_logout:
|
|
case R.id.nav_logout:
|
|
@@ -478,35 +471,22 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
createAccount(false);
|
|
createAccount(false);
|
|
break;
|
|
break;
|
|
case R.id.drawer_menu_account_manage:
|
|
case R.id.drawer_menu_account_manage:
|
|
- Intent manageAccountsIntent = new Intent(getApplicationContext(),
|
|
|
|
- ManageAccountsActivity.class);
|
|
|
|
|
|
+ Intent manageAccountsIntent = new Intent(getApplicationContext(), ManageAccountsActivity.class);
|
|
startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS);
|
|
startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS);
|
|
break;
|
|
break;
|
|
case R.id.nav_recently_added:
|
|
case R.id.nav_recently_added:
|
|
- menuItem.setChecked(true);
|
|
|
|
- mCheckedMenuItem = menuItem.getItemId();
|
|
|
|
-
|
|
|
|
switchToSearchFragment(new SearchEvent("%",SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
switchToSearchFragment(new SearchEvent("%",SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
|
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
|
|
break;
|
|
break;
|
|
case R.id.nav_recently_modified:
|
|
case R.id.nav_recently_modified:
|
|
- menuItem.setChecked(true);
|
|
|
|
- mCheckedMenuItem = menuItem.getItemId();
|
|
|
|
-
|
|
|
|
switchToSearchFragment(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH,
|
|
switchToSearchFragment(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH,
|
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
|
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
|
|
break;
|
|
break;
|
|
case R.id.nav_shared:
|
|
case R.id.nav_shared:
|
|
- menuItem.setChecked(true);
|
|
|
|
- mCheckedMenuItem = menuItem.getItemId();
|
|
|
|
-
|
|
|
|
switchToSearchFragment(new SearchEvent("", SearchOperation.SearchType.SHARED_SEARCH,
|
|
switchToSearchFragment(new SearchEvent("", SearchOperation.SearchType.SHARED_SEARCH,
|
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
|
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
|
|
break;
|
|
break;
|
|
case R.id.nav_videos:
|
|
case R.id.nav_videos:
|
|
- menuItem.setChecked(true);
|
|
|
|
- mCheckedMenuItem = menuItem.getItemId();
|
|
|
|
-
|
|
|
|
switchToSearchFragment(new SearchEvent("video/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
switchToSearchFragment(new SearchEvent("video/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
|
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
|
|
break;
|
|
break;
|
|
@@ -743,9 +723,11 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
TextView username = (TextView) findNavigationViewChildById(R.id.drawer_username);
|
|
TextView username = (TextView) findNavigationViewChildById(R.id.drawer_username);
|
|
TextView usernameFull = (TextView) findNavigationViewChildById(R.id.drawer_username_full);
|
|
TextView usernameFull = (TextView) findNavigationViewChildById(R.id.drawer_username_full);
|
|
usernameFull.setText(account.name);
|
|
usernameFull.setText(account.name);
|
|
|
|
+ usernameFull.setTextColor(ThemeUtils.fontColor());
|
|
try {
|
|
try {
|
|
OwnCloudAccount oca = new OwnCloudAccount(account, this);
|
|
OwnCloudAccount oca = new OwnCloudAccount(account, this);
|
|
username.setText(oca.getDisplayName());
|
|
username.setText(oca.getDisplayName());
|
|
|
|
+ username.setTextColor(ThemeUtils.fontColor());
|
|
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
|
|
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
|
|
Log_OC.w(TAG, "Couldn't read display name of account fallback to account name");
|
|
Log_OC.w(TAG, "Couldn't read display name of account fallback to account name");
|
|
username.setText(AccountUtils.getAccountUsername(account.name));
|
|
username.setText(AccountUtils.getAccountUsername(account.name));
|
|
@@ -821,7 +803,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
*/
|
|
*/
|
|
private void setQuotaInformation(long usedSpace, long totalSpace, int relative) {
|
|
private void setQuotaInformation(long usedSpace, long totalSpace, int relative) {
|
|
mQuotaProgressBar.setProgress(relative);
|
|
mQuotaProgressBar.setProgress(relative);
|
|
- DisplayUtils.colorHorizontalProgressBar(mQuotaProgressBar, DisplayUtils.getRelativeInfoColor(this, relative));
|
|
|
|
|
|
+ ThemeUtils.colorHorizontalProgressBar(mQuotaProgressBar, DisplayUtils.getRelativeInfoColor(this, relative));
|
|
|
|
|
|
updateQuotaLink();
|
|
updateQuotaLink();
|
|
|
|
|
|
@@ -906,9 +888,26 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
* @param menuItemId the menu item to be highlighted
|
|
* @param menuItemId the menu item to be highlighted
|
|
*/
|
|
*/
|
|
protected void setDrawerMenuItemChecked(int menuItemId) {
|
|
protected void setDrawerMenuItemChecked(int menuItemId) {
|
|
- if (mNavigationView != null && mNavigationView.getMenu() != null && mNavigationView.getMenu().findItem
|
|
|
|
- (menuItemId) != null) {
|
|
|
|
- mNavigationView.getMenu().findItem(menuItemId).setChecked(true);
|
|
|
|
|
|
+ if (mNavigationView != null && mNavigationView.getMenu() != null &&
|
|
|
|
+ mNavigationView.getMenu().findItem(menuItemId) != null) {
|
|
|
|
+
|
|
|
|
+ MenuItem item = mNavigationView.getMenu().findItem(menuItemId);
|
|
|
|
+ item.setChecked(true);
|
|
|
|
+
|
|
|
|
+ // reset all tinted icons
|
|
|
|
+ for (int i = 0; i < mNavigationView.getMenu().size(); i++) {
|
|
|
|
+ MenuItem menuItem = mNavigationView.getMenu().getItem(i);
|
|
|
|
+ if (menuItem.getIcon() != null) {
|
|
|
|
+ menuItem.getIcon().clearColorFilter();
|
|
|
|
+ menuItem.setTitle(Html.fromHtml("<font color='#000000'>" + menuItem.getTitle() + "</font>"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ThemeUtils.tintDrawable(item.getIcon(), ThemeUtils.primaryColor());
|
|
|
|
+
|
|
|
|
+ String colorHex = ThemeUtils.colorToHexString(ThemeUtils.primaryColor());
|
|
|
|
+ item.setTitle(Html.fromHtml("<font color='" + colorHex + "'>" + item.getTitle() + "</font>"));
|
|
|
|
+
|
|
mCheckedMenuItem = menuItemId;
|
|
mCheckedMenuItem = menuItemId;
|
|
} else {
|
|
} else {
|
|
Log_OC.w(TAG, "setDrawerMenuItemChecked has been called with invalid menu-item-ID");
|
|
Log_OC.w(TAG, "setDrawerMenuItemChecked has been called with invalid menu-item-ID");
|
|
@@ -1000,6 +999,43 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void updateHeaderBackground() {
|
|
|
|
+ if (getAccount() != null &&
|
|
|
|
+ getStorageManager().getCapability(getAccount().name).getServerBackground() != null) {
|
|
|
|
+ final LinearLayout navigationHeader = (LinearLayout) findNavigationViewChildById(R.id.drawer_header_view);
|
|
|
|
+
|
|
|
|
+ if (navigationHeader != null) {
|
|
|
|
+ String background = getStorageManager().getCapability(getAccount().name).getServerBackground();
|
|
|
|
+
|
|
|
|
+ if (URLUtil.isValidUrl(background) || background.isEmpty()) {
|
|
|
|
+ // background image
|
|
|
|
+ SimpleTarget target = new SimpleTarget<Drawable>() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onResourceReady(Drawable resource, GlideAnimation glideAnimation) {
|
|
|
|
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
|
|
|
+ navigationHeader.setBackgroundDrawable(resource);
|
|
|
|
+ } else {
|
|
|
|
+ navigationHeader.setBackground(resource);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ Glide.with(this)
|
|
|
|
+ .load(background)
|
|
|
|
+ .centerCrop()
|
|
|
|
+ .placeholder(R.drawable.background)
|
|
|
|
+ .error(R.drawable.background)
|
|
|
|
+ .crossFade()
|
|
|
|
+ .into(target);
|
|
|
|
+ } else {
|
|
|
|
+ // plain color
|
|
|
|
+ int color = Color.parseColor(background);
|
|
|
|
+ navigationHeader.setBackgroundColor(color);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
@@ -1058,6 +1094,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
updateAccountList();
|
|
updateAccountList();
|
|
updateExternalLinksInDrawer();
|
|
updateExternalLinksInDrawer();
|
|
updateQuotaLink();
|
|
updateQuotaLink();
|
|
|
|
+ updateHeaderBackground();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1111,7 +1148,13 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
* @return The view if found or <code>null</code> otherwise.
|
|
* @return The view if found or <code>null</code> otherwise.
|
|
*/
|
|
*/
|
|
private View findNavigationViewChildById(int id) {
|
|
private View findNavigationViewChildById(int id) {
|
|
- return ((NavigationView) findViewById(R.id.nav_view)).getHeaderView(0).findViewById(id);
|
|
|
|
|
|
+ NavigationView view = ((NavigationView) findViewById(R.id.nav_view));
|
|
|
|
+
|
|
|
|
+ if (view != null) {
|
|
|
|
+ return view.getHeaderView(0).findViewById(id);
|
|
|
|
+ } else {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|