designing dashboard drawer

This commit is contained in:
Mariotaku Lee 2015-05-28 12:17:49 +08:00
parent 2b37851a2f
commit 9987dd1c23
3 changed files with 69 additions and 16 deletions

View File

@ -123,6 +123,7 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
private AccountSelectorAdapter mAccountsAdapter; private AccountSelectorAdapter mAccountsAdapter;
private AccountOptionsAdapter mAccountOptionsAdapter; private AccountOptionsAdapter mAccountOptionsAdapter;
private AppMenuAdapter mAppMenuAdapter;
private ListView mListView; private ListView mListView;
private View mAccountSelectorView; private View mAccountSelectorView;
@ -312,6 +313,30 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
break; break;
} }
} }
} else if (adapter instanceof AppMenuAdapter) {
if (!(item instanceof OptionItem)) return;
final OptionItem option = (OptionItem) item;
switch (option.id) {
case MENU_ACCOUNTS: {
Utils.openAccountsManager(getActivity());
break;
}
case MENU_DRAFTS: {
Utils.openDrafts(getActivity());
break;
}
case MENU_FILTERS: {
Utils.openFilters(getActivity());
break;
}
case MENU_SETTINGS: {
final Intent intent = new Intent(getActivity(), SettingsActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivityForResult(intent, REQUEST_SETTINGS);
break;
}
}
closeAccountsDrawer();
} }
} }
@ -366,6 +391,7 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
final LayoutInflater inflater = getLayoutInflater(savedInstanceState); final LayoutInflater inflater = getLayoutInflater(savedInstanceState);
mAccountsAdapter = new AccountSelectorAdapter(context, inflater, this); mAccountsAdapter = new AccountSelectorAdapter(context, inflater, this);
mAccountOptionsAdapter = new AccountOptionsAdapter(context); mAccountOptionsAdapter = new AccountOptionsAdapter(context);
mAppMenuAdapter = new AppMenuAdapter(context);
mAccountSelectorView = inflater.inflate(R.layout.header_drawer_account_selector, mListView, false); mAccountSelectorView = inflater.inflate(R.layout.header_drawer_account_selector, mListView, false);
mAccountsSelector = (RecyclerView) mAccountSelectorView.findViewById(R.id.other_accounts_list); mAccountsSelector = (RecyclerView) mAccountSelectorView.findViewById(R.id.other_accounts_list);
final LinearLayoutManager layoutManager = new FixedLinearLayoutManager(context); final LinearLayoutManager layoutManager = new FixedLinearLayoutManager(context);
@ -404,8 +430,8 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
mAdapter.addView(mAccountSelectorView, true); mAdapter.addView(mAccountSelectorView, true);
mAdapter.addAdapter(mAccountOptionsAdapter); mAdapter.addAdapter(mAccountOptionsAdapter);
// mAdapter.addView(mAppMenuSectionView, false); mAdapter.addView(inflater.inflate(R.layout.layout_divider_drawer, mListView, false), false);
// mAdapter.addAdapter(mAppMenuAdapter); mAdapter.addAdapter(mAppMenuAdapter);
mListView.setAdapter(mAdapter); mListView.setAdapter(mAdapter);
mListView.setOnItemClickListener(this); mListView.setOnItemClickListener(this);
mPreferences.registerOnSharedPreferenceChangeListener(this); mPreferences.registerOnSharedPreferenceChangeListener(this);
@ -801,10 +827,10 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
public AppMenuAdapter(final Context context) { public AppMenuAdapter(final Context context) {
super(context); super(context);
add(new OptionItem(R.string.accounts, R.drawable.ic_action_accounts, MENU_ACCOUNTS)); // add(new OptionItem(R.string.accounts, R.drawable.ic_action_accounts, MENU_ACCOUNTS));
add(new OptionItem(R.string.drafts, R.drawable.ic_action_draft, MENU_DRAFTS)); add(new OptionItem(R.string.drafts, R.drawable.ic_action_draft, MENU_DRAFTS));
add(new OptionItem(R.string.filters, R.drawable.ic_action_speaker_muted, MENU_FILTERS)); add(new OptionItem(R.string.filters, R.drawable.ic_action_speaker_muted, MENU_FILTERS));
add(new OptionItem(R.string.settings, R.drawable.ic_action_settings, MENU_SETTINGS)); // add(new OptionItem(R.string.settings, R.drawable.ic_action_settings, MENU_SETTINGS));
} }
} }

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/element_spacing_normal"
android:paddingTop="@dimen/element_spacing_normal">
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?dividerVertical"/>
</FrameLayout>

View File

@ -22,24 +22,18 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
tools:ignore="AlwaysShowAction"> tools:ignore="AlwaysShowAction">
<item
android:id="@id/accounts"
android:layout_weight="0"
android:icon="@drawable/ic_action_accounts"
android:title="@string/accounts"
app:showAsAction="always"/>
<item
android:id="@id/filters"
android:layout_weight="0"
android:icon="@drawable/ic_action_speaker_muted"
android:title="@string/filters"
app:showAsAction="always"/>
<item <item
android:id="@id/settings" android:id="@id/settings"
android:layout_weight="0" android:layout_weight="0"
android:icon="@drawable/ic_action_settings" android:icon="@drawable/ic_action_settings"
android:title="@string/settings" android:title="@string/settings"
app:showAsAction="always"/> app:showAsAction="always"/>
<item
android:id="@id/accounts"
android:layout_weight="0"
android:icon="@drawable/ic_action_accounts"
android:title="@string/accounts"
app:showAsAction="always"/>
<item <item
android:layout_weight="1" android:layout_weight="1"
android:enabled="false" android:enabled="false"