|
@ -17,10 +17,14 @@ import com.franmontiel.persistentcookiejar.cache.SetCookieCache; |
|
|
import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor; |
|
|
import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor; |
|
|
import com.mikepenz.fontawesome_typeface_library.FontAwesome; |
|
|
import com.mikepenz.fontawesome_typeface_library.FontAwesome; |
|
|
import com.mikepenz.iconics.IconicsDrawable; |
|
|
import com.mikepenz.iconics.IconicsDrawable; |
|
|
|
|
|
import com.mikepenz.materialdrawer.AccountHeader; |
|
|
|
|
|
import com.mikepenz.materialdrawer.AccountHeaderBuilder; |
|
|
import com.mikepenz.materialdrawer.Drawer; |
|
|
import com.mikepenz.materialdrawer.Drawer; |
|
|
import com.mikepenz.materialdrawer.DrawerBuilder; |
|
|
import com.mikepenz.materialdrawer.DrawerBuilder; |
|
|
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; |
|
|
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; |
|
|
|
|
|
import com.mikepenz.materialdrawer.model.ProfileDrawerItem; |
|
|
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; |
|
|
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; |
|
|
|
|
|
import com.mikepenz.materialdrawer.model.interfaces.IProfile; |
|
|
|
|
|
|
|
|
import gr.thmmy.mthmmy.R; |
|
|
import gr.thmmy.mthmmy.R; |
|
|
import gr.thmmy.mthmmy.activities.main.MainActivity; |
|
|
import gr.thmmy.mthmmy.activities.main.MainActivity; |
|
@ -66,6 +70,13 @@ public class BaseActivity extends AppCompatActivity |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected void onPause() { |
|
|
|
|
|
super.onPause(); |
|
|
|
|
|
if(drawer!=null) //temporary solution to solve drawer animation closing after returning to activity
|
|
|
|
|
|
drawer.closeDrawer(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public static OkHttpClient getClient() |
|
|
public static OkHttpClient getClient() |
|
|
{ |
|
|
{ |
|
|
return client; |
|
|
return client; |
|
@ -73,40 +84,67 @@ public 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 LOG_ID =1; |
|
|
protected static final int ABOUT_ID=2; |
|
|
protected static final int ABOUT_ID=2; |
|
|
|
|
|
|
|
|
protected PrimaryDrawerItem home,loginLogout, about; |
|
|
private AccountHeader accountHeader; |
|
|
protected IconicsDrawable homeIcon,loginIcon,logoutIcon, aboutIcon; |
|
|
private ProfileDrawerItem profileDrawerItem; |
|
|
|
|
|
private PrimaryDrawerItem homeItem, loginLogoutItem, aboutItem; |
|
|
|
|
|
private IconicsDrawable homeIcon,loginIcon,logoutIcon, aboutIcon; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Call only after initializing Toolbar |
|
|
* Call only after initializing Toolbar |
|
|
*/ |
|
|
*/ |
|
|
protected void createDrawer()//TODO
|
|
|
protected void createDrawer()//TODO
|
|
|
{ |
|
|
{ |
|
|
|
|
|
//Drawer Icons
|
|
|
homeIcon =new IconicsDrawable(this) |
|
|
homeIcon =new IconicsDrawable(this) |
|
|
.icon(FontAwesome.Icon.faw_home) |
|
|
.icon(FontAwesome.Icon.faw_home) |
|
|
.color(Color.BLACK) |
|
|
.color(Color.BLACK); |
|
|
.sizeDp(24); |
|
|
|
|
|
loginIcon =new IconicsDrawable(this) |
|
|
loginIcon =new IconicsDrawable(this) |
|
|
.icon(FontAwesome.Icon.faw_sign_in) |
|
|
.icon(FontAwesome.Icon.faw_sign_in) |
|
|
.color(Color.BLACK) |
|
|
.color(Color.BLACK); |
|
|
.sizeDp(24); |
|
|
|
|
|
logoutIcon =new IconicsDrawable(this) |
|
|
logoutIcon =new IconicsDrawable(this) |
|
|
.icon(FontAwesome.Icon.faw_sign_out) |
|
|
.icon(FontAwesome.Icon.faw_sign_out) |
|
|
.color(Color.BLACK) |
|
|
.color(Color.BLACK); |
|
|
.sizeDp(24); |
|
|
|
|
|
aboutIcon =new IconicsDrawable(this) |
|
|
aboutIcon =new IconicsDrawable(this) |
|
|
.icon(FontAwesome.Icon.faw_info_circle) |
|
|
.icon(FontAwesome.Icon.faw_info_circle) |
|
|
.color(Color.BLACK) |
|
|
.color(Color.BLACK); |
|
|
.sizeDp(24); |
|
|
|
|
|
home = new PrimaryDrawerItem().withIdentifier(HOME_ID).withName(R.string.home).withIcon(homeIcon); |
|
|
//Drawer Items
|
|
|
loginLogout = new PrimaryDrawerItem().withIdentifier(LOG_ID).withName(R.string.logout).withIcon(logoutIcon); |
|
|
homeItem = new PrimaryDrawerItem().withIdentifier(HOME_ID).withName(R.string.home).withIcon(homeIcon); |
|
|
about = new PrimaryDrawerItem().withIdentifier(ABOUT_ID).withName(R.string.about).withIcon(aboutIcon); |
|
|
loginLogoutItem = new PrimaryDrawerItem().withIdentifier(LOG_ID).withName(R.string.logout).withIcon(logoutIcon); |
|
|
drawer = new DrawerBuilder().withActivity(this) |
|
|
aboutItem = new PrimaryDrawerItem().withIdentifier(ABOUT_ID).withName(R.string.about).withIcon(aboutIcon); |
|
|
|
|
|
|
|
|
|
|
|
//Profile
|
|
|
|
|
|
profileDrawerItem = new ProfileDrawerItem().withName(sessionManager.getUsername()); //TODO: set profile picture
|
|
|
|
|
|
|
|
|
|
|
|
//AccountHeader
|
|
|
|
|
|
accountHeader = new AccountHeaderBuilder() |
|
|
|
|
|
.withActivity(this) |
|
|
|
|
|
.withCompactStyle(true) |
|
|
|
|
|
.withSelectionListEnabledForSingleProfile(false) |
|
|
|
|
|
.withHeaderBackground(R.color.primary) |
|
|
|
|
|
.addProfiles(profileDrawerItem) |
|
|
|
|
|
.withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) { |
|
|
|
|
|
//TODO: display profile stuff
|
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.build(); |
|
|
|
|
|
|
|
|
|
|
|
//Drawer
|
|
|
|
|
|
drawer = new DrawerBuilder() |
|
|
|
|
|
.withActivity(this) |
|
|
.withToolbar(toolbar) |
|
|
.withToolbar(toolbar) |
|
|
.addDrawerItems(home,loginLogout,about) |
|
|
.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) { |
|
@ -139,7 +177,8 @@ public class BaseActivity extends AppCompatActivity |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
drawer.closeDrawer(); |
|
|
else |
|
|
|
|
|
drawer.closeDrawer(); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
@ -160,17 +199,14 @@ public class BaseActivity extends AppCompatActivity |
|
|
if(drawer!=null) |
|
|
if(drawer!=null) |
|
|
{ |
|
|
{ |
|
|
if (sessionManager.getLogStatus()!= LOGGED_IN) //When logged out or if user is guest
|
|
|
if (sessionManager.getLogStatus()!= LOGGED_IN) //When logged out or if user is guest
|
|
|
{ |
|
|
loginLogoutItem.withName(R.string.login).withIcon(loginIcon); //Swap logout with login
|
|
|
//Swap logout with login
|
|
|
|
|
|
loginLogout.withName(R.string.login).withIcon(loginIcon); |
|
|
|
|
|
drawer.updateItem(loginLogout); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
else |
|
|
{ |
|
|
loginLogoutItem.withName(R.string.logout).withIcon(logoutIcon); //Swap login with logout
|
|
|
//Swap login with logout
|
|
|
|
|
|
loginLogout.withName(R.string.logout).withIcon(logoutIcon); |
|
|
ProfileDrawerItem p = new ProfileDrawerItem().withName(sessionManager.getUsername()); //TODO: set profile picture
|
|
|
drawer.updateItem(loginLogout); |
|
|
accountHeader.updateProfile(p); |
|
|
} |
|
|
drawer.updateItem(loginLogoutItem); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|