mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 22:09:30 +00:00
Preliminary version of drawer
This commit is contained in:
parent
36cba023af
commit
1ac52e6cfd
@ -2,14 +2,17 @@ package org.communiquons.android.comunic.client.ui.activities;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.BottomNavigationView;
|
import android.support.design.widget.NavigationView;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.support.v4.view.GravityCompat;
|
||||||
|
import android.support.v4.widget.DrawerLayout;
|
||||||
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -22,27 +25,27 @@ import org.communiquons.android.comunic.client.R;
|
|||||||
import org.communiquons.android.comunic.client.crashreporter.CrashReporter;
|
import org.communiquons.android.comunic.client.crashreporter.CrashReporter;
|
||||||
import org.communiquons.android.comunic.client.data.helpers.APIRequestHelper;
|
import org.communiquons.android.comunic.client.data.helpers.APIRequestHelper;
|
||||||
import org.communiquons.android.comunic.client.data.helpers.AccountHelper;
|
import org.communiquons.android.comunic.client.data.helpers.AccountHelper;
|
||||||
import org.communiquons.android.comunic.client.data.helpers.DebugHelper;
|
|
||||||
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
|
|
||||||
import org.communiquons.android.comunic.client.data.helpers.DatabaseHelper;
|
|
||||||
import org.communiquons.android.comunic.client.data.helpers.ConversationsListHelper;
|
import org.communiquons.android.comunic.client.data.helpers.ConversationsListHelper;
|
||||||
|
import org.communiquons.android.comunic.client.data.helpers.DatabaseHelper;
|
||||||
|
import org.communiquons.android.comunic.client.data.helpers.DebugHelper;
|
||||||
import org.communiquons.android.comunic.client.data.runnables.FriendRefreshLoopRunnable;
|
import org.communiquons.android.comunic.client.data.runnables.FriendRefreshLoopRunnable;
|
||||||
import org.communiquons.android.comunic.client.data.services.NotificationsService;
|
import org.communiquons.android.comunic.client.data.services.NotificationsService;
|
||||||
|
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
|
||||||
import org.communiquons.android.comunic.client.data.utils.PreferencesUtils;
|
import org.communiquons.android.comunic.client.data.utils.PreferencesUtils;
|
||||||
|
import org.communiquons.android.comunic.client.ui.fragments.ConversationFragment;
|
||||||
|
import org.communiquons.android.comunic.client.ui.fragments.ConversationsListFragment;
|
||||||
|
import org.communiquons.android.comunic.client.ui.fragments.FriendsListFragment;
|
||||||
import org.communiquons.android.comunic.client.ui.fragments.LatestPostsFragment;
|
import org.communiquons.android.comunic.client.ui.fragments.LatestPostsFragment;
|
||||||
|
import org.communiquons.android.comunic.client.ui.fragments.NotificationsFragment;
|
||||||
import org.communiquons.android.comunic.client.ui.fragments.SinglePostFragment;
|
import org.communiquons.android.comunic.client.ui.fragments.SinglePostFragment;
|
||||||
|
import org.communiquons.android.comunic.client.ui.fragments.UpdateConversationFragment;
|
||||||
import org.communiquons.android.comunic.client.ui.fragments.UserAccessDeniedFragment;
|
import org.communiquons.android.comunic.client.ui.fragments.UserAccessDeniedFragment;
|
||||||
|
import org.communiquons.android.comunic.client.ui.fragments.UserPageFragment;
|
||||||
import org.communiquons.android.comunic.client.ui.listeners.onOpenUsersPageListener;
|
import org.communiquons.android.comunic.client.ui.listeners.onOpenUsersPageListener;
|
||||||
import org.communiquons.android.comunic.client.ui.listeners.onPostOpenListener;
|
import org.communiquons.android.comunic.client.ui.listeners.onPostOpenListener;
|
||||||
import org.communiquons.android.comunic.client.ui.listeners.openConversationListener;
|
import org.communiquons.android.comunic.client.ui.listeners.openConversationListener;
|
||||||
import org.communiquons.android.comunic.client.ui.listeners.updateConversationListener;
|
import org.communiquons.android.comunic.client.ui.listeners.updateConversationListener;
|
||||||
import org.communiquons.android.comunic.client.ui.utils.UiUtils;
|
import org.communiquons.android.comunic.client.ui.utils.UiUtils;
|
||||||
import org.communiquons.android.comunic.client.ui.fragments.ConversationFragment;
|
|
||||||
import org.communiquons.android.comunic.client.ui.fragments.ConversationsListFragment;
|
|
||||||
import org.communiquons.android.comunic.client.ui.fragments.FriendsListFragment;
|
|
||||||
import org.communiquons.android.comunic.client.ui.fragments.NotificationsFragment;
|
|
||||||
import org.communiquons.android.comunic.client.ui.fragments.UpdateConversationFragment;
|
|
||||||
import org.communiquons.android.comunic.client.ui.fragments.UserPageFragment;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,7 +53,8 @@ import org.communiquons.android.comunic.client.ui.fragments.UserPageFragment;
|
|||||||
*
|
*
|
||||||
* @author Pierre HUBERT
|
* @author Pierre HUBERT
|
||||||
*/
|
*/
|
||||||
public class MainActivity extends AppCompatActivity implements openConversationListener,
|
public class MainActivity extends AppCompatActivity implements
|
||||||
|
NavigationView.OnNavigationItemSelectedListener, openConversationListener,
|
||||||
updateConversationListener, onOpenUsersPageListener, onPostOpenListener {
|
updateConversationListener, onOpenUsersPageListener, onPostOpenListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,7 +95,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
/**
|
/**
|
||||||
* Bottom navigation view
|
* Bottom navigation view
|
||||||
*/
|
*/
|
||||||
private BottomNavigationView navigationView;
|
private DrawerLayout mDrawer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -107,7 +111,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
accountHelper = new AccountHelper(this);
|
accountHelper = new AccountHelper(this);
|
||||||
|
|
||||||
//Check if user is signed in or not
|
//Check if user is signed in or not
|
||||||
if(!accountHelper.signed_in()){
|
if (!accountHelper.signed_in()) {
|
||||||
//Open the login activity
|
//Open the login activity
|
||||||
startActivity(new Intent(this, LoginActivity.class));
|
startActivity(new Intent(this, LoginActivity.class));
|
||||||
return;
|
return;
|
||||||
@ -116,11 +120,11 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
//Set the content of the activity
|
//Set the content of the activity
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
//Enable bottom navigation menu
|
//Enable drawer
|
||||||
init_bottom_menu();
|
init_drawer();
|
||||||
|
|
||||||
//Check for connectivity
|
//Check for connectivity
|
||||||
if(!APIRequestHelper.isAPIavailable(this)){
|
if (!APIRequestHelper.isAPIavailable(this)) {
|
||||||
Toast.makeText(this, R.string.err_no_internet_connection, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.err_no_internet_connection, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +135,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
conversationsListHelper = new ConversationsListHelper(this, dbHelper);
|
conversationsListHelper = new ConversationsListHelper(this, dbHelper);
|
||||||
|
|
||||||
//If it is the first time the application is launched, open notifications fragment
|
//If it is the first time the application is launched, open notifications fragment
|
||||||
if(savedInstanceState == null){
|
if (savedInstanceState == null) {
|
||||||
openNotificationsFragment();
|
openNotificationsFragment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,7 +145,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
||||||
//Check if user is signed in or not
|
//Check if user is signed in or not
|
||||||
if(!accountHelper.signed_in()){
|
if (!accountHelper.signed_in()) {
|
||||||
//Open the login activity
|
//Open the login activity
|
||||||
startActivity(new Intent(this, LoginActivity.class));
|
startActivity(new Intent(this, LoginActivity.class));
|
||||||
return;
|
return;
|
||||||
@ -162,10 +166,14 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
super.onStop();
|
super.onStop();
|
||||||
|
|
||||||
//Stop the friends list refresh thread
|
//Stop the friends list refresh thread
|
||||||
if(friendsListRefreshRunnable != null)
|
if (friendsListRefreshRunnable != null)
|
||||||
friendsListRefreshRunnable.interrupt();
|
friendsListRefreshRunnable.interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Top menu creation
|
* Top menu creation
|
||||||
*/
|
*/
|
||||||
@ -174,7 +182,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
getMenuInflater().inflate(R.menu.main_menu, menu);
|
getMenuInflater().inflate(R.menu.main_menu, menu);
|
||||||
|
|
||||||
//Check if the debug menu has to be shown or not
|
//Check if the debug menu has to be shown or not
|
||||||
if(PreferencesUtils.getBoolean(this, "enable_debug_mode", false)) {
|
if (PreferencesUtils.getBoolean(this, "enable_debug_mode", false)) {
|
||||||
SubMenu debugMenu = menu.addSubMenu(R.string.menu_debug_title);
|
SubMenu debugMenu = menu.addSubMenu(R.string.menu_debug_title);
|
||||||
getMenuInflater().inflate(R.menu.debug_menu, debugMenu);
|
getMenuInflater().inflate(R.menu.debug_menu, debugMenu);
|
||||||
}
|
}
|
||||||
@ -189,43 +197,43 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
//To go backward
|
//To go backward
|
||||||
if(id == android.R.id.home){
|
if (id == android.R.id.home) {
|
||||||
getSupportFragmentManager().popBackStack();
|
toggleDrawer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//To search a user
|
//To search a user
|
||||||
if(id == R.id.action_search_user){
|
if (id == R.id.action_search_user) {
|
||||||
searchUser();
|
searchUser();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//To display the personal page of the user
|
//To display the personal page of the user
|
||||||
if(id == R.id.action_open_user_page){
|
if (id == R.id.action_open_user_page) {
|
||||||
openUserPage(AccountUtils.getID(MainActivity.this));
|
openUserPage(AccountUtils.getID(MainActivity.this));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//To display the list of friends
|
//To display the list of friends
|
||||||
if(id == R.id.action_friends_list){
|
if (id == R.id.action_friends_list) {
|
||||||
openFriendsFragment();
|
openFriendsFragment();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//To open settings fragment
|
//To open settings fragment
|
||||||
if(id == R.id.action_settings){
|
if (id == R.id.action_settings) {
|
||||||
openSettingsFragment();
|
openSettingsFragment();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check for logout request
|
//Check for logout request
|
||||||
if(id == R.id.action_logout){
|
if (id == R.id.action_logout) {
|
||||||
confirmUserLogout();
|
confirmUserLogout();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if user wants to clear database
|
//Check if user wants to clear database
|
||||||
if(id == R.id.action_clear_local_db){
|
if (id == R.id.action_clear_local_db) {
|
||||||
clearLocalDatabase();
|
clearLocalDatabase();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -234,6 +242,66 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drawer menu
|
||||||
|
*/
|
||||||
|
void init_drawer() {
|
||||||
|
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
mDrawer = findViewById(R.id.drawer_layout);
|
||||||
|
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||||
|
this, mDrawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||||
|
mDrawer.addDrawerListener(toggle);
|
||||||
|
toggle.syncState();
|
||||||
|
|
||||||
|
NavigationView navigationView = findViewById(R.id.nav_view);
|
||||||
|
navigationView.setNavigationItemSelectedListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (mDrawer.isDrawerOpen(GravityCompat.START)) {
|
||||||
|
mDrawer.closeDrawer(GravityCompat.START);
|
||||||
|
} else {
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the currently selected item in the drawer
|
||||||
|
*
|
||||||
|
* @param item The ID of the item
|
||||||
|
*/
|
||||||
|
public void setSelectedNavigationItem(int item) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle drawer state
|
||||||
|
*/
|
||||||
|
void toggleDrawer(){
|
||||||
|
if (mDrawer.isDrawerOpen(GravityCompat.START)) {
|
||||||
|
mDrawer.closeDrawer(GravityCompat.START);
|
||||||
|
} else {
|
||||||
|
mDrawer.openDrawer(GravityCompat.START);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
|
||||||
@ -241,9 +309,9 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
//Check if the request was to search a user
|
//Check if the request was to search a user
|
||||||
if(resultCode == Activity.RESULT_OK){
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
|
|
||||||
switch (requestCode){
|
switch (requestCode) {
|
||||||
|
|
||||||
case SEARCH_USER_INTENT:
|
case SEARCH_USER_INTENT:
|
||||||
assert data.getData() != null;
|
assert data.getData() != null;
|
||||||
@ -256,65 +324,10 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Bottom menu creation
|
|
||||||
*/
|
|
||||||
void init_bottom_menu(){
|
|
||||||
navigationView = (BottomNavigationView) findViewById(R.id.main_bottom_navigation);
|
|
||||||
navigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
|
||||||
|
|
||||||
//Check which option was selected
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
|
|
||||||
//If the user clicked to show the friends list
|
|
||||||
/*case R.id.main_bottom_navigation_friends_list:
|
|
||||||
openFriendsFragment();
|
|
||||||
return true;*/
|
|
||||||
|
|
||||||
//If the user wants to open notifications
|
|
||||||
case R.id.main_bottom_navigation_notif:
|
|
||||||
openNotificationsFragment();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
//If the user chose to show information about him
|
|
||||||
case R.id.main_bottom_navigation_me_view:
|
|
||||||
|
|
||||||
//Old versions
|
|
||||||
//openUserInfosFragment();
|
|
||||||
//openUserPage(AccountUtils.getID(MainActivity.this));
|
|
||||||
|
|
||||||
//New version
|
|
||||||
openLatestPostsFragment();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
//If the user wants to switch to the conversation fragment
|
|
||||||
case R.id.main_bottom_navigation_conversations:
|
|
||||||
openConversationsListFragment();
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Selected element not found
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the currently selected item in the bottom navigation view
|
|
||||||
*
|
|
||||||
* @param item The ID of the item
|
|
||||||
*/
|
|
||||||
public void setSelectedNavigationItem(int item){
|
|
||||||
navigationView.getMenu().findItem(item).setChecked(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ask user to confirm if he really what to sign out or not
|
* Ask user to confirm if he really what to sign out or not
|
||||||
*/
|
*/
|
||||||
void confirmUserLogout(){
|
void confirmUserLogout() {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(R.string.popup_signout_title)
|
builder.setTitle(R.string.popup_signout_title)
|
||||||
.setMessage(R.string.popup_signout_message)
|
.setMessage(R.string.popup_signout_message)
|
||||||
@ -346,7 +359,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
/**
|
/**
|
||||||
* Open the friends list fragment
|
* Open the friends list fragment
|
||||||
*/
|
*/
|
||||||
void openFriendsFragment(){
|
void openFriendsFragment() {
|
||||||
|
|
||||||
FriendsListFragment friendsListFragment = new FriendsListFragment();
|
FriendsListFragment friendsListFragment = new FriendsListFragment();
|
||||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
@ -359,7 +372,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
/**
|
/**
|
||||||
* Open settings activity
|
* Open settings activity
|
||||||
*/
|
*/
|
||||||
void openSettingsFragment(){
|
void openSettingsFragment() {
|
||||||
Intent intent = new Intent(this, SettingsActivity.class);
|
Intent intent = new Intent(this, SettingsActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
@ -367,7 +380,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
/**
|
/**
|
||||||
* Open notifications fragment
|
* Open notifications fragment
|
||||||
*/
|
*/
|
||||||
void openNotificationsFragment(){
|
void openNotificationsFragment() {
|
||||||
NotificationsFragment notifications = new NotificationsFragment();
|
NotificationsFragment notifications = new NotificationsFragment();
|
||||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
transaction.replace(R.id.main_fragment, notifications);
|
transaction.replace(R.id.main_fragment, notifications);
|
||||||
@ -381,7 +394,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
* @param userID The ID of the user to open
|
* @param userID The ID of the user to open
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void openUserPage(int userID){
|
public void openUserPage(int userID) {
|
||||||
|
|
||||||
//Prepare arguments
|
//Prepare arguments
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
@ -431,7 +444,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
/**
|
/**
|
||||||
* Open the conversation list fragment
|
* Open the conversation list fragment
|
||||||
*/
|
*/
|
||||||
void openConversationsListFragment(){
|
void openConversationsListFragment() {
|
||||||
ConversationsListFragment conversationsListFragment = new ConversationsListFragment();
|
ConversationsListFragment conversationsListFragment = new ConversationsListFragment();
|
||||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
transaction.replace(R.id.main_fragment, conversationsListFragment);
|
transaction.replace(R.id.main_fragment, conversationsListFragment);
|
||||||
@ -449,7 +462,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
|
|
||||||
//Set the arguments for the conversation
|
//Set the arguments for the conversation
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt(ConversationFragment.ARG_CONVERSATION_ID ,id);
|
args.putInt(ConversationFragment.ARG_CONVERSATION_ID, id);
|
||||||
|
|
||||||
//Create the fragment
|
//Create the fragment
|
||||||
ConversationFragment conversationFragment = new ConversationFragment();
|
ConversationFragment conversationFragment = new ConversationFragment();
|
||||||
@ -472,7 +485,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
final AlertDialog dialog = UiUtils.create_loading_dialog(this);
|
final AlertDialog dialog = UiUtils.create_loading_dialog(this);
|
||||||
|
|
||||||
//Get conversation ID in the background
|
//Get conversation ID in the background
|
||||||
new AsyncTask<Integer, Void, Integer>(){
|
new AsyncTask<Integer, Void, Integer>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Integer doInBackground(Integer... params) {
|
protected Integer doInBackground(Integer... params) {
|
||||||
@ -485,7 +498,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
//Close loading dialog
|
//Close loading dialog
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
if(integer != null)
|
if (integer != null)
|
||||||
openConversation(integer);
|
openConversation(integer);
|
||||||
else
|
else
|
||||||
Toast.makeText(MainActivity.this, R.string.err_get_private_conversation,
|
Toast.makeText(MainActivity.this, R.string.err_get_private_conversation,
|
||||||
@ -538,7 +551,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
/**
|
/**
|
||||||
* Open latest posts fragment
|
* Open latest posts fragment
|
||||||
*/
|
*/
|
||||||
public void openLatestPostsFragment(){
|
public void openLatestPostsFragment() {
|
||||||
|
|
||||||
//Create the fragment
|
//Create the fragment
|
||||||
LatestPostsFragment latestPostsFragment = new LatestPostsFragment();
|
LatestPostsFragment latestPostsFragment = new LatestPostsFragment();
|
||||||
@ -555,7 +568,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
*/
|
*/
|
||||||
private void clearLocalDatabase() {
|
private void clearLocalDatabase() {
|
||||||
|
|
||||||
if(!new DebugHelper(this).clearLocalDatabase())
|
if (!new DebugHelper(this).clearLocalDatabase())
|
||||||
Toast.makeText(this, R.string.err_clear_local_db, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.err_clear_local_db, Toast.LENGTH_SHORT).show();
|
||||||
else
|
else
|
||||||
Toast.makeText(this, R.string.success_clear_local_db, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.success_clear_local_db, Toast.LENGTH_SHORT).show();
|
||||||
@ -565,7 +578,7 @@ public class MainActivity extends AppCompatActivity implements openConversationL
|
|||||||
/**
|
/**
|
||||||
* Open a search activity to find a user
|
* Open a search activity to find a user
|
||||||
*/
|
*/
|
||||||
private void searchUser(){
|
private void searchUser() {
|
||||||
|
|
||||||
//Make intent
|
//Make intent
|
||||||
Intent intent = new Intent(this, SearchUserActivity.class);
|
Intent intent = new Intent(this, SearchUserActivity.class);
|
||||||
|
9
app/src/main/res/drawable/side_nav_bar.xml
Normal file
9
app/src/main/res/drawable/side_nav_bar.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<gradient
|
||||||
|
android:angle="135"
|
||||||
|
android:centerColor="#009688"
|
||||||
|
android:endColor="#00695C"
|
||||||
|
android:startColor="#4DB6AC"
|
||||||
|
android:type="linear" />
|
||||||
|
</shape>
|
@ -1,23 +1,34 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/drawer_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
android:fitsSystemWindows="false"
|
||||||
android:orientation="vertical">
|
tools:openDrawer="start">
|
||||||
|
|
||||||
|
|
||||||
|
<android.support.design.widget.CoordinatorLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/main_fragment"
|
android:id="@+id/main_fragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="2" />
|
android:layout_weight="2" />
|
||||||
|
|
||||||
<android.support.design.widget.BottomNavigationView
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
android:id="@+id/main_bottom_navigation"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:background="?android:attr/windowBackground"
|
|
||||||
app:menu="@menu/main_bottom_navigation" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
<android.support.design.widget.NavigationView
|
||||||
|
android:id="@+id/nav_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
app:headerLayout="@layout/nav_header_main"
|
||||||
|
app:menu="@menu/activity_main_drawer" />
|
||||||
|
|
||||||
|
</android.support.v4.widget.DrawerLayout>
|
36
app/src/main/res/layout/nav_header_main.xml
Normal file
36
app/src/main/res/layout/nav_header_main.xml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/nav_header_height"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:background="@drawable/side_nav_bar"
|
||||||
|
android:gravity="bottom"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_vertical_margin"
|
||||||
|
android:theme="@style/ThemeOverlay.AppCompat.Dark">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imageView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:contentDescription="@string/nav_header_desc"
|
||||||
|
android:paddingTop="@dimen/nav_header_vertical_spacing"
|
||||||
|
android:src="@drawable/default_account_image" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/nav_header_vertical_spacing"
|
||||||
|
tools:text="User name"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:text="email@example.com" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -6,17 +6,17 @@
|
|||||||
android:title="@string/navigation_bottom_notif_item"
|
android:title="@string/navigation_bottom_notif_item"
|
||||||
android:icon="@drawable/ic_notif"/>
|
android:icon="@drawable/ic_notif"/>
|
||||||
|
|
||||||
<!--<item
|
<item
|
||||||
android:id="@+id/main_bottom_navigation_friends_list"
|
android:id="@+id/main_bottom_navigation_friends_list"
|
||||||
android:title="@string/navigation_bottom_friends_item"
|
android:title="@string/navigation_bottom_friends_item"
|
||||||
android:icon="@drawable/ic_menu_allfriends"
|
android:icon="@drawable/ic_menu_allfriends"
|
||||||
/>-->
|
/>
|
||||||
|
|
||||||
<!--<item
|
<item
|
||||||
android:id="@+id/main_bottom_navigation_users_view"
|
android:id="@+id/main_bottom_navigation_users_view"
|
||||||
android:title="@string/navigation_bottom_user_item"
|
android:title="@string/navigation_bottom_user_item"
|
||||||
android:icon="@drawable/perm_group_personal_info"
|
android:icon="@drawable/perm_group_personal_info"
|
||||||
android:visible="false" />-->
|
android:visible="false" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/main_bottom_navigation_me_view"
|
android:id="@+id/main_bottom_navigation_me_view"
|
@ -1,4 +1,11 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||||
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||||
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||||
|
<dimen name="nav_header_vertical_spacing">8dp</dimen>
|
||||||
|
<dimen name="nav_header_height">176dp</dimen>
|
||||||
|
<dimen name="fab_margin">16dp</dimen>
|
||||||
|
|
||||||
<!-- The default size of an account image -->
|
<!-- The default size of an account image -->
|
||||||
<dimen name="account_image_default_width">64dp</dimen>
|
<dimen name="account_image_default_width">64dp</dimen>
|
||||||
<dimen name="account_image_default_height">64dp</dimen>
|
<dimen name="account_image_default_height">64dp</dimen>
|
||||||
|
@ -196,4 +196,7 @@
|
|||||||
<string name="tab_posts">Posts</string>
|
<string name="tab_posts">Posts</string>
|
||||||
<string name="member_for">Member for</string>
|
<string name="member_for">Member for</string>
|
||||||
<string name="action_create_post">Create a new post</string>
|
<string name="action_create_post">Create a new post</string>
|
||||||
|
<string name="nav_header_desc">Navigation header</string>
|
||||||
|
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||||
|
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
|
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||||
|
|
||||||
|
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||||
|
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
|
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
|
Loading…
Reference in New Issue
Block a user