Skip to content
Snippets Groups Projects
Commit e746fb9e authored by Jawnnypoo's avatar Jawnnypoo
Browse files

Improve the drawer logged in state.

parent 6d1af9a9
No related branches found
No related tags found
No related merge requests found
Showing
with 135 additions and 25 deletions
Loading
Loading
@@ -106,7 +106,7 @@ public class MainActivity extends BaseActivity {
startActivity(new Intent(this, LoginActivity.class));
}
else {
navigationView.setUserId(Prefs.getUserId(this));
navigationView.loadCurrentUser();
connect();
}
Loading
Loading
Loading
Loading
@@ -118,6 +118,12 @@ public interface GitLab {
 
@GET(API_VERSION + "/users/{id}")
Call<User> getUser(@Path("id") long userId);
/**
* Get currently authenticated user
*/
@GET(API_VERSION + "/user")
Call<User> getUser();
@GET(API_VERSION + "/groups/{id}/members?per_page=100")
Call<List<User>> getGroupMembers(@Path("id") long groupId);
Loading
Loading
Loading
Loading
@@ -7,6 +7,7 @@ import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
 
import com.commit451.gitlab.R;
import com.commit451.gitlab.adapter.ProjectsAdapter;
Loading
Loading
@@ -21,6 +22,7 @@ import java.util.List;
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import fr.tkeunebr.gravatar.Gravatar;
import retrofit.Callback;
import retrofit.Response;
import timber.log.Timber;
Loading
Loading
@@ -32,6 +34,8 @@ import timber.log.Timber;
public class GitLabNavigationView extends FrameLayout{
 
@Bind(R.id.profile_image) ImageView profileImage;
@Bind(R.id.profile_user) TextView userName;
@Bind(R.id.profile_email) TextView userEmail;
@Bind(R.id.list) RecyclerView projectList;
ProjectsAdapter mAdapter;
 
Loading
Loading
@@ -47,11 +51,7 @@ public class GitLabNavigationView extends FrameLayout{
if (!response.isSuccess()) {
return;
}
if (getContext() != null) {
Picasso.with(getContext())
.load(response.body().getAvatarUrl())
.into(profileImage);
}
bindUser(response.body());
}
 
@Override
Loading
Loading
@@ -93,7 +93,25 @@ public class GitLabNavigationView extends FrameLayout{
mAdapter.setData(projects);
}
 
public void setUserId(long userId) {
GitLabClient.instance().getUser(userId).enqueue(userCallback);
public void loadCurrentUser() {
GitLabClient.instance().getUser().enqueue(userCallback);
}
private void bindUser(User user) {
if (getContext() == null) {
return;
}
if (user.getUsername() != null) {
userName.setText(user.getUsername());
}
int size = getResources().getDimensionPixelSize(R.dimen.larger_image_size);
String url = "http://www.gravatar.com/avatar/00000000000000000000000000000000?s=" + size;
if(user.getEmail() != null) {
url = Gravatar.init().with(user.getEmail()).size(size).build();
userEmail.setText(user.getEmail());
}
Picasso.with(getContext())
.load(url)
.into(profileImage);
}
}
app/src/main/res/drawable-hdpi/ic_arrow_down.png

363 B

app/src/main/res/drawable-mdpi/ic_arrow_down.png

222 B

app/src/main/res/drawable-xhdpi/ic_arrow_down.png

421 B

app/src/main/res/drawable-xxhdpi/ic_arrow_down.png

718 B

app/src/main/res/drawable-xxxhdpi/ic_arrow_down.png

895 B

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="?android:attr/listPreferredItemHeight"
android:background="?attr/selectableItemBackground">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add"
android:layout_gravity="center_vertical"
android:contentDescription="@null"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/add_account"
android:layout_gravity="center_vertical"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">
 
<FrameLayout
android:id="@+id/drawer_header"
android:layout_width="match_parent"
android:layout_height="192dp"
android:layout_height="148dp"
android:foreground="?attr/selectableItemBackground">
<ImageView
android:layout_width="match_parent"
android:layout_height="192dp"
android:src="@drawable/header"
android:scaleType="centerCrop"
android:contentDescription="@null"/>
 
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image"
android:layout_width="@dimen/image_size"
android:layout_height="@dimen/image_size"
android:layout_margin="16dp"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
android:scaleType="fitXY"
android:src="@drawable/header" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image"
android:layout_width="@dimen/larger_image_size"
android:layout_height="@dimen/larger_image_size"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="?attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/profile_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/window_background_color"
android:singleLine="true"
android:ellipsize="end"
tools:text="Jawnnypew" />
<TextView
android:id="@+id/profile_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/window_background_color"
android:singleLine="true"
android:ellipsize="end"
tools:text="poop123@aol.com" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:contentDescription="@null"
android:src="@drawable/ic_arrow_down"
android:tint="@color/window_background_color"/>
</FrameLayout>
</LinearLayout>
 
</FrameLayout>
 
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent" />
 
</LinearLayout>
\ No newline at end of file
Loading
Loading
@@ -14,6 +14,7 @@
<dimen name="actionbarSize">56dp</dimen>
<dimen name="doubleActionbarSize">112dp</dimen>
<dimen name="image_size">48dp</dimen>
<dimen name="larger_image_size">72dp</dimen>
<dimen name="border_size">2dp</dimen>
<dimen name="circle_size">96dp</dimen>
</resources>
\ No newline at end of file
Loading
Loading
@@ -111,4 +111,7 @@
<string name="source_url">https://github.com/Commit451/GitLabAndroid</string>
<string name="failed_to_load_contributors">Failed to load contributors :(</string>
 
<!-- Account -->
<string name="add_account">Add account</string>
</resources>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment