Display user tag on user page.

This commit is contained in:
Pierre HUBERT 2018-09-03 13:56:41 +02:00
parent 0f60453c97
commit 2a266aaa7a
4 changed files with 84 additions and 54 deletions

View File

@ -432,6 +432,7 @@ public class GetUsersHelper {
userInfos.setFirstName(userObject.getString("firstName"));
userInfos.setLastName(userObject.getString("lastName"));
userInfos.setAccountImageURL(userObject.getString("accountImage"));
userInfos.setVirtualDirectory(userObject.getString("virtualDirectory"));
} catch (JSONException e){
e.printStackTrace();

View File

@ -12,12 +12,13 @@ import org.communiquons.android.comunic.client.ui.utils.UiUtils;
public class UserInfo {
/**
* Informations about the user
* Information about the user
*/
private int id;
private String firstName;
private String lastName;
private String accountImageURL;
private String virtualDirectory;
/**
* Set the ID of the user
@ -108,4 +109,20 @@ public class UserInfo {
public String getAcountImageURL() {
return accountImageURL;
}
public String getVirtualDirectory() {
return virtualDirectory;
}
public boolean hasVirtualDirectory(){
return virtualDirectory != null;
}
public void setVirtualDirectory(String virtualDirectory) {
this.virtualDirectory = virtualDirectory;
if(virtualDirectory.equals(""))
this.virtualDirectory = null;
}
}

View File

@ -31,23 +31,12 @@ public class AdvancedUserInfoFragment extends Fragment {
private AdvancedUserInfo mAdvancedUserInfo;
/**
* User account image
* Views
*/
private WebUserAccountImage mUserAccountImage;
/**
* The name of the user
*/
private TextView mUserName;
/**
* Target for the time the user has been a member of the group
*/
private TextView mUserTag;
private TextView mMemberSinceTarget;
/**
* Friendship status
*/
private FriendshipStatusButton mFriendshipStatus;
/**
@ -82,6 +71,7 @@ public class AdvancedUserInfoFragment extends Fragment {
//Get the views
mUserAccountImage = view.findViewById(R.id.user_account_image);
mUserName = view.findViewById(R.id.user_name);
mUserTag = view.findViewById(R.id.userTag);
mMemberSinceTarget = view.findViewById(R.id.member_since_value);
mFriendshipStatus = view.findViewById(R.id.friendship_status);
}
@ -95,6 +85,8 @@ public class AdvancedUserInfoFragment extends Fragment {
mUserName.setText(mAdvancedUserInfo.getDisplayFullName());
mMemberSinceTarget.setText(TimeUtils.TimeToString(getActivity(),
TimeUtils.time() - mAdvancedUserInfo.getAccount_creation_time()));
mUserTag.setText(mAdvancedUserInfo.hasVirtualDirectory() ?
"@" + mAdvancedUserInfo.getVirtualDirectory() : "");
}
@Override

View File

@ -14,11 +14,12 @@
android:paddingStart="16dp"
android:paddingTop="16dp">
<!-- Head layout -->
<android.support.constraint.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="83dp"
android:layout_marginBottom="32dp"
android:layout_height="wrap_content"
android:layout_marginBottom="64dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toTopOf="@+id/scrollView2"
app:layout_constraintEnd_toEndOf="parent"
@ -29,9 +30,11 @@
android:id="@+id/user_account_image"
android:layout_width="@dimen/account_image_default_width"
android:layout_height="@dimen/account_image_default_height"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:src="@drawable/default_account_image"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -39,54 +42,71 @@
android:id="@+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
app:layout_constraintBottom_toBottomOf="@+id/user_account_image"
app:layout_constraintStart_toEndOf="@+id/user_account_image"
app:layout_constraintTop_toTopOf="@+id/user_account_image"
tools:text="User name" />
</android.support.constraint.ConstraintLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:layout_editor_absoluteX="134dp"
tools:layout_editor_absoluteY="96dp">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/member_for"
android:textAlignment="center" />
<TextView
android:id="@+id/member_since_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAlignment="center"
tools:layout_editor_absoluteX="88dp"
tools:layout_editor_absoluteY="167dp"
tools:text="6 Months" />
</LinearLayout>
</LinearLayout>
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/user_account_image"
tools:text="User name" />
<org.communiquons.android.comunic.client.ui.views.FriendshipStatusButton
android:id="@+id/friendship_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"/>
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/userTag" />
<TextView
android:id="@+id/userTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="@+id/user_name"
app:layout_constraintStart_toStartOf="@+id/user_name"
app:layout_constraintTop_toBottomOf="@+id/user_name"
tools:text="\@user" />
</android.support.constraint.ConstraintLayout>
<!-- User info layout -->
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:text="@string/member_for"
android:textAlignment="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/member_since_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="6 Months" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</ScrollView>