|
@ -83,13 +83,14 @@ public abstract class BaseActivity extends AppCompatActivity |
|
|
//TODO: move stuff below (?)
|
|
|
//TODO: move stuff below (?)
|
|
|
//------------------------------------------DRAWER STUFF----------------------------------------
|
|
|
//------------------------------------------DRAWER STUFF----------------------------------------
|
|
|
protected static final int HOME_ID=0; |
|
|
protected static final int HOME_ID=0; |
|
|
protected static final int LOG_ID =1; |
|
|
protected static final int DOWNLOADS_ID=1; |
|
|
protected static final int ABOUT_ID=2; |
|
|
protected static final int LOG_ID =2; |
|
|
|
|
|
protected static final int ABOUT_ID=3; |
|
|
|
|
|
|
|
|
private AccountHeader accountHeader; |
|
|
private AccountHeader accountHeader; |
|
|
private ProfileDrawerItem profileDrawerItem; |
|
|
private ProfileDrawerItem profileDrawerItem; |
|
|
private PrimaryDrawerItem homeItem, loginLogoutItem, aboutItem; |
|
|
private PrimaryDrawerItem homeItem, downloadsItem, loginLogoutItem, aboutItem; |
|
|
private IconicsDrawable homeIcon, homeIconSelected, loginIcon, logoutIcon, |
|
|
private IconicsDrawable homeIcon, homeIconSelected, downloadsIcon, downloadsIconSelected, loginIcon, logoutIcon, |
|
|
aboutIcon, aboutIconSelected; |
|
|
aboutIcon, aboutIconSelected; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -110,6 +111,14 @@ public abstract class BaseActivity extends AppCompatActivity |
|
|
.icon(FontAwesome.Icon.faw_home) |
|
|
.icon(FontAwesome.Icon.faw_home) |
|
|
.color(selectedSecondaryColor); |
|
|
.color(selectedSecondaryColor); |
|
|
|
|
|
|
|
|
|
|
|
downloadsIcon =new IconicsDrawable(this) |
|
|
|
|
|
.icon(FontAwesome.Icon.faw_download) |
|
|
|
|
|
.color(primaryColor); |
|
|
|
|
|
|
|
|
|
|
|
downloadsIconSelected =new IconicsDrawable(this) |
|
|
|
|
|
.icon(FontAwesome.Icon.faw_download) |
|
|
|
|
|
.color(selectedSecondaryColor); |
|
|
|
|
|
|
|
|
loginIcon =new IconicsDrawable(this) |
|
|
loginIcon =new IconicsDrawable(this) |
|
|
.icon(FontAwesome.Icon.faw_sign_in) |
|
|
.icon(FontAwesome.Icon.faw_sign_in) |
|
|
.color(primaryColor); |
|
|
.color(primaryColor); |
|
@ -136,21 +145,34 @@ public abstract class BaseActivity extends AppCompatActivity |
|
|
.withIcon(homeIcon) |
|
|
.withIcon(homeIcon) |
|
|
.withSelectedIcon(homeIconSelected); |
|
|
.withSelectedIcon(homeIconSelected); |
|
|
|
|
|
|
|
|
if (!sessionManager.isLoggedIn()) //When logged out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sessionManager.isLoggedIn()) //When logged in
|
|
|
|
|
|
{ |
|
|
loginLogoutItem = new PrimaryDrawerItem() |
|
|
loginLogoutItem = new PrimaryDrawerItem() |
|
|
.withTextColor(primaryColor) |
|
|
.withTextColor(primaryColor) |
|
|
.withSelectedColor(selectedSecondaryColor) |
|
|
.withSelectedColor(selectedSecondaryColor) |
|
|
.withIdentifier(LOG_ID).withName(R.string.login) |
|
|
.withIdentifier(LOG_ID) |
|
|
.withIcon(loginIcon) |
|
|
.withName(R.string.logout) |
|
|
|
|
|
.withIcon(logoutIcon) |
|
|
.withSelectable(false); |
|
|
.withSelectable(false); |
|
|
|
|
|
downloadsItem = new PrimaryDrawerItem() |
|
|
|
|
|
.withTextColor(primaryColor) |
|
|
|
|
|
.withSelectedColor(selectedPrimaryColor) |
|
|
|
|
|
.withSelectedTextColor(selectedSecondaryColor) |
|
|
|
|
|
.withIdentifier(DOWNLOADS_ID) |
|
|
|
|
|
.withName(R.string.downloads) |
|
|
|
|
|
.withIcon(downloadsIcon) |
|
|
|
|
|
.withSelectedIcon(downloadsIconSelected); |
|
|
|
|
|
} |
|
|
else |
|
|
else |
|
|
loginLogoutItem = new PrimaryDrawerItem() |
|
|
loginLogoutItem = new PrimaryDrawerItem() |
|
|
.withTextColor(primaryColor) |
|
|
.withTextColor(primaryColor) |
|
|
.withSelectedColor(selectedSecondaryColor) |
|
|
.withSelectedColor(selectedSecondaryColor) |
|
|
.withIdentifier(LOG_ID) |
|
|
.withIdentifier(LOG_ID).withName(R.string.login) |
|
|
.withName(R.string.logout) |
|
|
.withIcon(loginIcon) |
|
|
.withIcon(logoutIcon) |
|
|
|
|
|
.withSelectable(false); |
|
|
.withSelectable(false); |
|
|
|
|
|
|
|
|
aboutItem = new PrimaryDrawerItem() |
|
|
aboutItem = new PrimaryDrawerItem() |
|
|
.withTextColor(primaryColor) |
|
|
.withTextColor(primaryColor) |
|
|
.withSelectedColor(selectedPrimaryColor) |
|
|
.withSelectedColor(selectedPrimaryColor) |
|
@ -195,13 +217,12 @@ public abstract class BaseActivity extends AppCompatActivity |
|
|
.build(); |
|
|
.build(); |
|
|
|
|
|
|
|
|
//Drawer
|
|
|
//Drawer
|
|
|
drawer = new DrawerBuilder() |
|
|
DrawerBuilder drawerBuilder = new DrawerBuilder() |
|
|
.withActivity(this) |
|
|
.withActivity(this) |
|
|
.withToolbar(toolbar) |
|
|
.withToolbar(toolbar) |
|
|
.withDrawerWidthDp((int)BaseApplication.getInstance().getDpWidth()/2) |
|
|
.withDrawerWidthDp((int)BaseApplication.getInstance().getDpWidth()/2) |
|
|
.withSliderBackgroundColor(ContextCompat.getColor(this, R.color.primary_light)) |
|
|
.withSliderBackgroundColor(ContextCompat.getColor(this, R.color.primary_light)) |
|
|
.withAccountHeader(accountHeader) |
|
|
.withAccountHeader(accountHeader) |
|
|
.addDrawerItems(homeItem,loginLogoutItem,aboutItem) |
|
|
|
|
|
.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) { |
|
@ -213,6 +234,14 @@ public abstract class BaseActivity extends AppCompatActivity |
|
|
startActivity(i); |
|
|
startActivity(i); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
// else if(drawerItem.equals(DOWNLOADS_ID))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// if (sessionManager.isLoggedIn()) //When logged out or if user is guest
|
|
|
|
|
|
// {
|
|
|
|
|
|
// Intent i = new Intent(BaseActivity.this, DownloadsActivity.class);
|
|
|
|
|
|
// startActivity(i);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
else if(drawerItem.equals(LOG_ID)) |
|
|
else if(drawerItem.equals(LOG_ID)) |
|
|
{ |
|
|
{ |
|
|
if (!sessionManager.isLoggedIn()) //When logged out or if user is guest
|
|
|
if (!sessionManager.isLoggedIn()) //When logged out or if user is guest
|
|
@ -238,8 +267,14 @@ public abstract class BaseActivity extends AppCompatActivity |
|
|
drawer.closeDrawer(); |
|
|
drawer.closeDrawer(); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
}) |
|
|
}); |
|
|
.build(); |
|
|
|
|
|
|
|
|
if(sessionManager.isLoggedIn()) |
|
|
|
|
|
drawerBuilder.addDrawerItems(homeItem,downloadsItem,loginLogoutItem,aboutItem); |
|
|
|
|
|
else |
|
|
|
|
|
drawerBuilder.addDrawerItems(homeItem,loginLogoutItem,aboutItem); |
|
|
|
|
|
|
|
|
|
|
|
drawer = drawerBuilder.build(); |
|
|
|
|
|
|
|
|
drawer.getActionBarDrawerToggle().setDrawerIndicatorEnabled(false); |
|
|
drawer.getActionBarDrawerToggle().setDrawerIndicatorEnabled(false); |
|
|
drawer.setOnDrawerNavigationListener(new Drawer.OnDrawerNavigationListener() { |
|
|
drawer.setOnDrawerNavigationListener(new Drawer.OnDrawerNavigationListener() { |
|
@ -257,6 +292,7 @@ public abstract class BaseActivity extends AppCompatActivity |
|
|
{ |
|
|
{ |
|
|
if (!sessionManager.isLoggedIn()) //When logged out or if user is guest
|
|
|
if (!sessionManager.isLoggedIn()) //When logged out or if user is guest
|
|
|
{ |
|
|
{ |
|
|
|
|
|
drawer.removeItem(DOWNLOADS_ID); |
|
|
loginLogoutItem.withName(R.string.login).withIcon(loginIcon); //Swap logout with login
|
|
|
loginLogoutItem.withName(R.string.login).withIcon(loginIcon); //Swap logout with login
|
|
|
profileDrawerItem.withName(sessionManager.getUsername()).withIcon(new IconicsDrawable(this) |
|
|
profileDrawerItem.withName(sessionManager.getUsername()).withIcon(new IconicsDrawable(this) |
|
|
.icon(FontAwesome.Icon.faw_user) |
|
|
.icon(FontAwesome.Icon.faw_user) |
|
|