diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/GetUsersHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/GetUsersHelper.java
index c125c37..47e3a7a 100644
--- a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/GetUsersHelper.java
+++ b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/GetUsersHelper.java
@@ -56,7 +56,7 @@ public class GetUsersHelper {
* @param udbHelper User database helper
*/
public GetUsersHelper(@NonNull Context context, @NonNull UsersInfosDbHelper udbHelper){
- mContext = context;
+ mContext = context.getApplicationContext();
this.udbHelper = udbHelper;
}
@@ -304,11 +304,11 @@ public class GetUsersHelper {
//Convert the IDs into a string
- String id_string = "";
+ StringBuilder id_string = new StringBuilder();
for(int id : IDs) {
- id_string += id + ",";
+ id_string.append(id).append(",");
}
- requestParameters.addString("usersID", id_string);
+ requestParameters.addString("usersID", id_string.toString());
try {
diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java
index f12e108..dd84981 100644
--- a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java
+++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java
@@ -18,6 +18,7 @@ import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
+import android.widget.TextView;
import android.widget.Toast;
import org.communiquons.android.comunic.client.BuildConfig;
@@ -28,6 +29,8 @@ import org.communiquons.android.comunic.client.data.helpers.AccountHelper;
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.helpers.GetUsersHelper;
+import org.communiquons.android.comunic.client.data.models.UserInfo;
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.utils.AccountUtils;
@@ -46,6 +49,7 @@ 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.updateConversationListener;
import org.communiquons.android.comunic.client.ui.utils.UiUtils;
+import org.communiquons.android.comunic.client.ui.views.WebUserAccountImage;
/**
@@ -72,11 +76,6 @@ public class MainActivity extends AppCompatActivity implements
*/
private AccountHelper accountHelper;
- /**
- * Account utils object
- */
- private AccountUtils aUtils;
-
/**
* Friends list refresh thread
*/
@@ -251,6 +250,44 @@ public class MainActivity extends AppCompatActivity implements
NavigationView navigationView = findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
+
+ //Get information about the user
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ final UserInfo info = new GetUsersHelper(getApplicationContext()).getSingle(
+ new AccountUtils(getApplicationContext()).get_current_user_id(), false);
+
+ //Apply user information
+ if(mDrawer != null){
+ mDrawer.post(new Runnable() {
+ @Override
+ public void run() {
+ applyUserInfoInDrawer(info);
+ }
+ });
+ }
+ }
+ }).start();
+ }
+
+ /**
+ * Apply current user information in the drawer
+ *
+ * @param info Information about the user to apply
+ */
+ private void applyUserInfoInDrawer(@Nullable UserInfo info){
+
+ //Check for errors
+ if(info == null){
+ Toast.makeText(MainActivity.this, R.string.err_get_user_info,
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ //Apply user information
+ ((TextView)findViewById(R.id.current_user_name)).setText(info.getDisplayFullName());
+ ((WebUserAccountImage)findViewById(R.id.current_user_account_image)).setUser(info);
}
@Override
diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/AdvancedUserInfoFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/AdvancedUserInfoFragment.java
index 7ca7e9e..5d800fa 100644
--- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/AdvancedUserInfoFragment.java
+++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/AdvancedUserInfoFragment.java
@@ -54,6 +54,13 @@ public class AdvancedUserInfoFragment extends Fragment {
this.mAdvancedUserInfo = advancedUserInfo;
}
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setRetainInstance(true);
+ }
+
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
diff --git a/app/src/main/res/layout/nav_header_main.xml b/app/src/main/res/layout/nav_header_main.xml
index 4ce8bbf..3380580 100644
--- a/app/src/main/res/layout/nav_header_main.xml
+++ b/app/src/main/res/layout/nav_header_main.xml
@@ -12,8 +12,8 @@
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
-