|
@@ -41,7 +41,6 @@ import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import android.os.Handler;
|
|
import android.text.Html;
|
|
import android.text.Html;
|
|
-import android.text.TextUtils;
|
|
|
|
import android.view.Menu;
|
|
import android.view.Menu;
|
|
import android.view.MenuItem;
|
|
import android.view.MenuItem;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
@@ -412,6 +411,34 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|
|
|
|
|
setDrawerMenuItemChecked(menuItem.getItemId());
|
|
setDrawerMenuItemChecked(menuItem.getItemId());
|
|
|
|
|
|
|
|
+ if (menuItem.getGroupId() == R.id.drawer_menu_accounts) {
|
|
|
|
+ switch (menuItem.getItemId()) {
|
|
|
|
+ case R.id.drawer_menu_account_add:
|
|
|
|
+ boolean isProviderOrOwnInstallationVisible = getResources()
|
|
|
|
+ .getBoolean(R.bool.show_provider_or_own_installation);
|
|
|
|
+
|
|
|
|
+ if (isProviderOrOwnInstallationVisible) {
|
|
|
|
+ Intent firstRunIntent = new Intent(getApplicationContext(), FirstRunActivity.class);
|
|
|
|
+ firstRunIntent.putExtra(FirstRunActivity.EXTRA_ALLOW_CLOSE, true);
|
|
|
|
+ startActivity(firstRunIntent);
|
|
|
|
+ } else {
|
|
|
|
+ createAccount(false);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case R.id.drawer_menu_account_manage:
|
|
|
|
+ Intent manageAccountsIntent = new Intent(getApplicationContext(), ManageAccountsActivity.class);
|
|
|
|
+ startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ accountClicked(menuItem.getItemId());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
switch (menuItem.getItemId()) {
|
|
switch (menuItem.getItemId()) {
|
|
case R.id.nav_all_files:
|
|
case R.id.nav_all_files:
|
|
showFiles(false);
|
|
showFiles(false);
|
|
@@ -469,22 +496,6 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|
menuItem.setChecked(false);
|
|
menuItem.setChecked(false);
|
|
UserInfoActivity.openAccountRemovalConfirmationDialog(getAccount(), getSupportFragmentManager(), true);
|
|
UserInfoActivity.openAccountRemovalConfirmationDialog(getAccount(), getSupportFragmentManager(), true);
|
|
break;
|
|
break;
|
|
- case R.id.drawer_menu_account_add:
|
|
|
|
- boolean isProviderOrOwnInstallationVisible = getResources()
|
|
|
|
- .getBoolean(R.bool.show_provider_or_own_installation);
|
|
|
|
-
|
|
|
|
- if (isProviderOrOwnInstallationVisible) {
|
|
|
|
- Intent firstRunIntent = new Intent(getApplicationContext(), FirstRunActivity.class);
|
|
|
|
- firstRunIntent.putExtra(FirstRunActivity.EXTRA_ALLOW_CLOSE, true);
|
|
|
|
- startActivity(firstRunIntent);
|
|
|
|
- } else {
|
|
|
|
- createAccount(false);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case R.id.drawer_menu_account_manage:
|
|
|
|
- Intent manageAccountsIntent = new Intent(getApplicationContext(), ManageAccountsActivity.class);
|
|
|
|
- startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS);
|
|
|
|
- break;
|
|
|
|
case R.id.nav_recently_added:
|
|
case R.id.nav_recently_added:
|
|
handleSearchEvents(new SearchEvent("%", SearchRemoteOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
handleSearchEvents(new SearchEvent("%", SearchRemoteOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
|
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
|
|
@@ -501,10 +512,6 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|
handleSearchEvents(new SearchEvent("video/%", SearchRemoteOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
handleSearchEvents(new SearchEvent("video/%", SearchRemoteOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
|
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
|
|
break;
|
|
break;
|
|
- case Menu.NONE:
|
|
|
|
- // account clicked
|
|
|
|
- accountClicked(menuItem.getTitle().toString());
|
|
|
|
- break;
|
|
|
|
default:
|
|
default:
|
|
if (menuItem.getItemId() >= MENU_ITEM_EXTERNAL_LINK &&
|
|
if (menuItem.getItemId() >= MENU_ITEM_EXTERNAL_LINK &&
|
|
menuItem.getItemId() <= MENU_ITEM_EXTERNAL_LINK + 100) {
|
|
menuItem.getItemId() <= MENU_ITEM_EXTERNAL_LINK + 100) {
|
|
@@ -542,12 +549,12 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|
* sets the new/current account and restarts. In case the given account equals the actual/current account the
|
|
* sets the new/current account and restarts. In case the given account equals the actual/current account the
|
|
* call will be ignored.
|
|
* call will be ignored.
|
|
*
|
|
*
|
|
- * @param accountName The account name to be set
|
|
|
|
|
|
+ * @param hashCode HashCode of account to be set
|
|
*/
|
|
*/
|
|
- private void accountClicked(String accountName) {
|
|
|
|
|
|
+ private void accountClicked(int hashCode) {
|
|
final Account currentAccount = accountManager.getCurrentAccount();
|
|
final Account currentAccount = accountManager.getCurrentAccount();
|
|
- if (currentAccount != null && !TextUtils.equals(currentAccount.name, accountName)) {
|
|
|
|
- AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), accountName);
|
|
|
|
|
|
+ if (currentAccount != null && currentAccount.hashCode() != hashCode &&
|
|
|
|
+ AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), hashCode)) {
|
|
fetchExternalLinks(true);
|
|
fetchExternalLinks(true);
|
|
restart();
|
|
restart();
|
|
}
|
|
}
|
|
@@ -577,7 +584,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|
* @param view the clicked ImageView
|
|
* @param view the clicked ImageView
|
|
*/
|
|
*/
|
|
public void onAccountDrawerClick(View view) {
|
|
public void onAccountDrawerClick(View view) {
|
|
- accountClicked(view.getContentDescription().toString());
|
|
|
|
|
|
+ accountClicked(Integer.parseInt(view.getContentDescription().toString()));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -703,7 +710,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|
if (!getAccount().name.equals(account.name)) {
|
|
if (!getAccount().name.equals(account.name)) {
|
|
MenuItem accountMenuItem = mNavigationView.getMenu().add(
|
|
MenuItem accountMenuItem = mNavigationView.getMenu().add(
|
|
R.id.drawer_menu_accounts,
|
|
R.id.drawer_menu_accounts,
|
|
- Menu.NONE,
|
|
|
|
|
|
+ account.hashCode(),
|
|
MENU_ORDER_ACCOUNT,
|
|
MENU_ORDER_ACCOUNT,
|
|
DisplayUtils.getAccountNameDisplayText(this, account, account.name, account.name))
|
|
DisplayUtils.getAccountNameDisplayText(this, account, account.name, account.name))
|
|
.setIcon(TextDrawable.createAvatar(account, mMenuAccountAvatarRadiusDimension));
|
|
.setIcon(TextDrawable.createAvatar(account, mMenuAccountAvatarRadiusDimension));
|
|
@@ -713,10 +720,10 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
Log_OC.e(TAG, "Error calculating RGB value for account menu item.", e);
|
|
Log_OC.e(TAG, "Error calculating RGB value for account menu item.", e);
|
|
mNavigationView.getMenu().add(
|
|
mNavigationView.getMenu().add(
|
|
- R.id.drawer_menu_accounts,
|
|
|
|
- Menu.NONE,
|
|
|
|
- MENU_ORDER_ACCOUNT,
|
|
|
|
- DisplayUtils.getAccountNameDisplayText(this, account, account.name, account.name))
|
|
|
|
|
|
+ R.id.drawer_menu_accounts,
|
|
|
|
+ account.hashCode(),
|
|
|
|
+ MENU_ORDER_ACCOUNT,
|
|
|
|
+ DisplayUtils.getAccountNameDisplayText(this, account, account.name, account.name))
|
|
.setIcon(R.drawable.ic_user);
|
|
.setIcon(R.drawable.ic_user);
|
|
}
|
|
}
|
|
}
|
|
}
|