(menu) change menu array to list

laster we will put some logic for show or not the savedToot part
main
torrentcome 8 years ago
parent 6447f407c7
commit 7184878b63
  1. 43
      app/src/main/java/com/keylesspalace/tusky/MainActivity.java

@ -65,7 +65,6 @@ import retrofit2.Response;
public class MainActivity extends BaseActivity { public class MainActivity extends BaseActivity {
private static final String TAG = "MainActivity"; // logging tag private static final String TAG = "MainActivity"; // logging tag
protected static int COMPOSE_RESULT = 1;
private static final long DRAWER_ITEM_EDIT_PROFILE = 0; private static final long DRAWER_ITEM_EDIT_PROFILE = 0;
private static final long DRAWER_ITEM_FAVOURITES = 1; private static final long DRAWER_ITEM_FAVOURITES = 1;
private static final long DRAWER_ITEM_MUTED_USERS = 2; private static final long DRAWER_ITEM_MUTED_USERS = 2;
@ -75,7 +74,10 @@ public class MainActivity extends BaseActivity {
private static final long DRAWER_ITEM_ABOUT = 6; private static final long DRAWER_ITEM_ABOUT = 6;
private static final long DRAWER_ITEM_LOG_OUT = 7; private static final long DRAWER_ITEM_LOG_OUT = 7;
private static final long DRAWER_ITEM_FOLLOW_REQUESTS = 8; private static final long DRAWER_ITEM_FOLLOW_REQUESTS = 8;
private static final long DRAWER_ITEM_SAVED_TOOT = 9;
protected static int COMPOSE_RESULT = 1;
public FloatingActionButton composeButton;
private String loggedInAccountId; private String loggedInAccountId;
private String loggedInAccountUsername; private String loggedInAccountUsername;
private Stack<Integer> pageHistory; private Stack<Integer> pageHistory;
@ -83,8 +85,6 @@ public class MainActivity extends BaseActivity {
private Drawer drawer; private Drawer drawer;
private ViewPager viewPager; private ViewPager viewPager;
public FloatingActionButton composeButton;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -179,7 +179,8 @@ public class MainActivity extends BaseActivity {
} }
@Override @Override
public void onTabReselected(TabLayout.Tab tab) {} public void onTabReselected(TabLayout.Tab tab) {
}
}); });
Intent intent = getIntent(); Intent intent = getIntent();
@ -289,23 +290,28 @@ public class MainActivity extends BaseActivity {
R.drawable.ic_mute_24dp, getTheme()); R.drawable.ic_mute_24dp, getTheme());
ThemeUtils.setDrawableTint(this, muteDrawable, R.attr.toolbar_icon_tint); ThemeUtils.setDrawableTint(this, muteDrawable, R.attr.toolbar_icon_tint);
List<IDrawerItem> listItem = new ArrayList<>();
listItem.add(new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_EDIT_PROFILE).withName(getString(R.string.action_edit_profile)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_person));
listItem.add(new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_FAVOURITES).withName(getString(R.string.action_view_favourites)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_star));
listItem.add(new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_MUTED_USERS).withName(getString(R.string.action_view_mutes)).withSelectable(false).withIcon(muteDrawable));
listItem.add(new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_BLOCKED_USERS).withName(getString(R.string.action_view_blocks)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_block));
listItem.add(new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_SEARCH).withName(getString(R.string.action_search)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_search));
listItem.add(new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_SAVED_TOOT).withName(getString(R.string.action_access_saved_toot)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_save));
listItem.add(new DividerDrawerItem());
listItem.add(new SecondaryDrawerItem().withIdentifier(DRAWER_ITEM_PREFERENCES).withName(getString(R.string.action_view_preferences)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_settings));
listItem.add(new SecondaryDrawerItem().withIdentifier(DRAWER_ITEM_ABOUT).withName(getString(R.string.about_title_activity)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_info));
listItem.add(new SecondaryDrawerItem().withIdentifier(DRAWER_ITEM_LOG_OUT).withName(getString(R.string.action_logout)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_exit_to_app));
IDrawerItem[] array = new IDrawerItem[listItem.size()];
listItem.toArray(array); // fill the array
drawer = new DrawerBuilder() drawer = new DrawerBuilder()
.withActivity(this) .withActivity(this)
//.withToolbar(toolbar) //.withToolbar(toolbar)
.withAccountHeader(headerResult) .withAccountHeader(headerResult)
.withHasStableIds(true) .withHasStableIds(true)
.withSelectedItem(-1) .withSelectedItem(-1)
.addDrawerItems( .addDrawerItems(array)
new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_EDIT_PROFILE).withName(getString(R.string.action_edit_profile)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_person),
new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_FAVOURITES).withName(getString(R.string.action_view_favourites)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_star),
new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_MUTED_USERS).withName(getString(R.string.action_view_mutes)).withSelectable(false).withIcon(muteDrawable),
new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_BLOCKED_USERS).withName(getString(R.string.action_view_blocks)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_block),
new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_SEARCH).withName(getString(R.string.action_search)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_search),
new DividerDrawerItem(),
new SecondaryDrawerItem().withIdentifier(DRAWER_ITEM_PREFERENCES).withName(getString(R.string.action_view_preferences)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_settings),
new SecondaryDrawerItem().withIdentifier(DRAWER_ITEM_ABOUT).withName(getString(R.string.about_title_activity)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_info),
new SecondaryDrawerItem().withIdentifier(DRAWER_ITEM_LOG_OUT).withName(getString(R.string.action_logout)).withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_exit_to_app)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override @Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
@ -341,6 +347,9 @@ public class MainActivity extends BaseActivity {
Intent intent = new Intent(MainActivity.this, AccountListActivity.class); Intent intent = new Intent(MainActivity.this, AccountListActivity.class);
intent.putExtra("type", AccountListActivity.Type.FOLLOW_REQUESTS); intent.putExtra("type", AccountListActivity.Type.FOLLOW_REQUESTS);
startActivity(intent); startActivity(intent);
} else if (drawerItemIdentifier == DRAWER_ITEM_SAVED_TOOT) {
Intent intent = new Intent(MainActivity.this, SavedTootActivity.class);
startActivity(intent);
} }
} }
@ -469,9 +478,9 @@ public class MainActivity extends BaseActivity {
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if(drawer != null && drawer.isDrawerOpen()) { if (drawer != null && drawer.isDrawerOpen()) {
drawer.closeDrawer(); drawer.closeDrawer();
} else if(pageHistory.size() < 2) { } else if (pageHistory.size() < 2) {
super.onBackPressed(); super.onBackPressed();
} else { } else {
pageHistory.pop(); pageHistory.pop();

Loading…
Cancel
Save