Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account switching in navigation drawer #1537

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 5 additions & 28 deletions res/layout/drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,10 @@
android:background="@color/background_color"
>

<!--TODO re-enable when "Accounts" is available in Navigation Drawer-->
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_margin="5dp">-->

<!--<ImageView-->
<!--android:id="@+id/drawer_userIcon"-->
<!--android:layout_width="40dp"-->
<!--android:layout_height="40dp"-->
<!--android:src="@drawable/abc_ab_bottom_solid_dark_holo" />-->

<!--<TextView-->
<!--android:id="@+id/drawer_username"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="center_vertical"-->
<!--android:layout_marginLeft="5dp"-->
<!--android:layout_marginStart="5dp"-->
<!--android:textAppearance="?android:attr/textAppearanceLarge" />-->

<!--</LinearLayout>-->

<!--<TextView-->
<!--android:layout_width="fill_parent"-->
<!--android:layout_height="2dip"-->
<!--android:background="@color/list_item_lastmod_and_filesize_text" />-->
<TextView
android:layout_width="fill_parent"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, as a general rule, use "match_parent"; "fill_parent" is obsolete.

android:layout_height="2dip"
android:background="@color/list_item_lastmod_and_filesize_text" />

<ListView
android:id="@+id/drawer_list"
Expand All @@ -74,7 +51,7 @@
android:background="@color/drawer_header_color">

<ImageView
android:id="@+id/itemIcon"
android:id="@+id/drawer_userIcon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginLeft="@dimen/standard_padding"
Expand Down
3 changes: 1 addition & 2 deletions res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
</string-array>
<!--TODO re-enable when server-side folder size calculation is available
<item>Biggest - Smallest</item>-->
<!--TODO re-enable when "Accounts" is available in Navigation Drawer-->
<!--<string name="drawer_item_accounts">Accounts</string>-->
<string name="drawer_item_accounts">Accounts</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't include changes in translated languages through git, or will break daily merge of translations. Please, undo this change, let the equivalent in res/values/strings.xml.

<string name="drawer_item_all_files">Alle Dateien</string>
<!--TODO re-enable when "On Device" is available
<string name="drawer_item_on_device">On device</string>-->
Expand Down
6 changes: 2 additions & 4 deletions res/values/drawer_resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@
<resources>
<!-- Nav Drawer Menu Items -->
<string-array name="drawer_items">
<!--TODO re-enable when "Accounts" is available in Navigation Drawer-->
<!--<item>@string/prefs_accounts</item>-->
<item>@string/drawer_item_all_files</item>
<!--<item>@string/drawer_item_on_device</item>-->
<item>@string/prefs_accounts</item>
<item>@string/actionbar_settings</item>
<item>@string/actionbar_logger</item>
</string-array>

<!-- Nav Drawer Content Descriptions -->
<string-array name="drawer_content_descriptions">
<!-- TODO re-enable when "Accounts" is available in Navigation Drawer-->
<!--<item>@string/drawer_item_accounts</item>-->
<item>@string/drawer_item_all_files</item>
<!--<item>@string/drawer_item_on_device</item>-->
<item>@string/drawer_item_accounts</item>
<item>@string/drawer_item_settings</item>
<item>@string/drawer_item_logs</item>
</string-array>
Expand Down
3 changes: 1 addition & 2 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
<!-- TODO re-enable when server-side folder size calculation is available
<item>Biggest - Smallest</item> -->
</string-array>
<!-- TODO re-enable when "Accounts" is available in Navigation Drawer -->
<!--<string name="drawer_item_accounts">Accounts</string>-->
<string name="drawer_item_accounts">Accounts</string>
<string name="drawer_item_all_files">All files</string>
<!-- TODO re-enable when "On Device" is available
<string name="drawer_item_on_device">On device</string>-->
Expand Down
97 changes: 46 additions & 51 deletions src/com/owncloud/android/ui/activity/FileActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
Expand Down Expand Up @@ -86,6 +87,7 @@
import com.owncloud.android.ui.adapter.NavigationDrawerListAdapter;
import com.owncloud.android.ui.dialog.LoadingDialog;
import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.ErrorMessageAdapter;

import java.util.ArrayList;
Expand Down Expand Up @@ -168,10 +170,7 @@ public class FileActivity extends AppCompatActivity

protected NavigationDrawerListAdapter mNavigationDrawerAdapter = null;



// TODO re-enable when "Accounts" is available in Navigation Drawer
// protected boolean mShowAccounts = false;
protected boolean mShowAccounts = false;

/**
* Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of
Expand Down Expand Up @@ -359,20 +358,19 @@ protected void initDrawer(){
RelativeLayout navigationDrawerLayout = (RelativeLayout) findViewById(R.id.left_drawer);
mDrawerList = (ListView) navigationDrawerLayout.findViewById(R.id.drawer_list);

// TODO re-enable when "Accounts" is available in Navigation Drawer
// // load Account in the Drawer Title
// // User-Icon
// ImageView userIcon = (ImageView) navigationDrawerLayout.findViewById(R.id.drawer_userIcon);
// userIcon.setImageResource(DisplayUtils.getSeasonalIconId());
//
// // Username
// TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
// Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
//
// if (account != null) {
// int lastAtPos = account.name.lastIndexOf("@");
// username.setText(account.name.substring(0, lastAtPos));
// }
// load Account in the Drawer Title
// User-Icon
ImageView userIcon = (ImageView) navigationDrawerLayout.findViewById(R.id.drawer_userIcon);
userIcon.setImageResource(DisplayUtils.getSeasonalIconId());

// Username
TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());

if (account != null) {
int lastAtPos = account.name.lastIndexOf("@");
username.setText(account.name.substring(0, lastAtPos));
}

// Display username in drawer
setUsernameInDrawer(navigationDrawerLayout, AccountUtils.getCurrentOwnCloudAccount(getApplicationContext()));
Expand All @@ -387,26 +385,26 @@ protected void initDrawer(){
// nav drawer items
mDrawerItems = new ArrayList<NavigationDrawerItem>();
// adding nav drawer items to array
// TODO re-enable when "Accounts" is available in Navigation Drawer
// Accounts
// mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[0],
// mDrawerContentDescriptions[0]));
// All Files
mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[0], mDrawerContentDescriptions[0],
R.drawable.ic_folder_open));

// Accounts
mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[1], mDrawerContentDescriptions[1],
R.drawable.ic_account_circle));

// TODO Enable when "On Device" is recovered
// On Device
//mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2],
// mDrawerContentDescriptions[2]));

// Settings
mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[1], mDrawerContentDescriptions[1],
mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2], mDrawerContentDescriptions[2],
R.drawable.ic_settings));
// Logs
if (BuildConfig.DEBUG) {
mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2],
mDrawerContentDescriptions[2],R.drawable.ic_log));
mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[3],
mDrawerContentDescriptions[3],R.drawable.ic_log));
}

// setting the nav drawer list adapter
Expand Down Expand Up @@ -997,10 +995,9 @@ public void restart(){
startActivity(i);
}

// TODO re-enable when "Accounts" is available in Navigation Drawer
// public void closeDrawer() {
// mDrawerLayout.closeDrawers();
// }
public void closeDrawer() {
mDrawerLayout.closeDrawers();
}

public void allFilesOption(){
restart();
Expand All @@ -1009,18 +1006,10 @@ public void allFilesOption(){
private class DrawerItemClickListener implements ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// TODO re-enable when "Accounts" is available in Navigation Drawer
// if (mShowAccounts && position > 0){
// position = position - 1;
// }
switch (position){
// TODO re-enable when "Accounts" is available in Navigation Drawer
// case 0: // Accounts
// mShowAccounts = !mShowAccounts;
// mNavigationDrawerAdapter.setShowAccounts(mShowAccounts);
// mNavigationDrawerAdapter.notifyDataSetChanged();
// break;

if (mShowAccounts && position > 0){
position = position - 1;
}
switch (position) {
case 0: // All Files
allFilesOption();
mDrawerLayout.closeDrawers();
Expand All @@ -1032,19 +1021,25 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
// mDrawerLayout.closeDrawers();
// break;

case 1: // Settings
Intent settingsIntent = new Intent(getApplicationContext(),
Preferences.class);
startActivity(settingsIntent);
mDrawerLayout.closeDrawers();
case 1: // Accounts
mShowAccounts = !mShowAccounts;
mNavigationDrawerAdapter.setShowAccounts(mShowAccounts);
mNavigationDrawerAdapter.notifyDataSetChanged();
break;

case 2: // Logs
Intent loggerIntent = new Intent(getApplicationContext(),
case 2: // Settings
Intent settingsIntent = new Intent(getApplicationContext(),
Preferences.class);
startActivity(settingsIntent);
mDrawerLayout.closeDrawers();
break;

case 3: // Logs
Intent loggerIntent = new Intent(getApplicationContext(),
LogHistoryActivity.class);
startActivity(loggerIntent);
mDrawerLayout.closeDrawers();
break;
startActivity(loggerIntent);
mDrawerLayout.closeDrawers();
break;
}
}
}
Expand Down
Loading