Skip to content

Commit fb1f94d

Browse files
committed
Show avatars in navigate to dialog
1 parent 3e16ab4 commit fb1f94d

File tree

2 files changed

+113
-21
lines changed

2 files changed

+113
-21
lines changed

app/res/layout/nav_dialog.xml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2013 GitHub Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:layout_width="wrap_content"
19+
android:layout_height="wrap_content" >
20+
21+
<LinearLayout
22+
android:layout_width="match_parent"
23+
android:layout_height="wrap_content"
24+
android:orientation="vertical" >
25+
26+
<LinearLayout
27+
android:id="@+id/ll_user_area"
28+
style="@style/ListItem"
29+
android:layout_width="match_parent"
30+
android:layout_height="wrap_content"
31+
android:clickable="true"
32+
android:gravity="center_vertical"
33+
android:orientation="horizontal" >
34+
35+
<ImageView
36+
android:id="@+id/iv_user_avatar"
37+
style="@style/AvatarLarge"
38+
android:contentDescription="@string/avatar" />
39+
40+
<TextView
41+
android:id="@+id/tv_login"
42+
style="@style/ListTitleText"
43+
android:layout_width="match_parent"
44+
android:includeFontPadding="true"
45+
android:paddingBottom="0dp"
46+
android:paddingLeft="10dp"
47+
android:singleLine="true"
48+
android:textStyle="normal" />
49+
</LinearLayout>
50+
51+
<View style="@style/Separator" />
52+
53+
<LinearLayout
54+
android:id="@+id/ll_repo_area"
55+
style="@style/ListItem"
56+
android:layout_width="match_parent"
57+
android:layout_height="wrap_content"
58+
android:clickable="true"
59+
android:gravity="center_vertical"
60+
android:orientation="horizontal" >
61+
62+
<ImageView
63+
android:id="@+id/iv_repo_avatar"
64+
style="@style/AvatarLarge"
65+
android:contentDescription="@string/avatar" />
66+
67+
<TextView
68+
android:id="@+id/tv_repo_name"
69+
style="@style/ListTitleText"
70+
android:layout_width="match_parent"
71+
android:includeFontPadding="true"
72+
android:paddingBottom="0dp"
73+
android:paddingLeft="10dp"
74+
android:singleLine="true"
75+
android:textStyle="normal" />
76+
</LinearLayout>
77+
</LinearLayout>
78+
79+
</ScrollView>

app/src/main/java/com/github/mobile/ui/NewsFragment.java

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,19 @@
2020
import static org.eclipse.egit.github.core.event.Event.TYPE_COMMIT_COMMENT;
2121
import static org.eclipse.egit.github.core.event.Event.TYPE_DOWNLOAD;
2222
import static org.eclipse.egit.github.core.event.Event.TYPE_PUSH;
23-
import android.content.DialogInterface;
24-
import android.content.DialogInterface.OnClickListener;
23+
import android.app.AlertDialog;
2524
import android.content.Intent;
2625
import android.net.Uri;
2726
import android.os.Bundle;
2827
import android.text.TextUtils;
2928
import android.view.View;
29+
import android.view.View.OnClickListener;
3030
import android.widget.ListView;
3131

3232
import com.github.kevinsawicki.wishlist.SingleTypeAdapter;
33+
import com.github.kevinsawicki.wishlist.ViewFinder;
34+
import com.github.mobile.R.id;
35+
import com.github.mobile.R.layout;
3336
import com.github.mobile.R.string;
3437
import com.github.mobile.core.gist.GistEventMatcher;
3538
import com.github.mobile.core.issue.IssueEventMatcher;
@@ -144,7 +147,8 @@ public void onListItemClick(ListView l, View v, int position, long id) {
144147
}
145148

146149
@Override
147-
public boolean onListItemLongClick(ListView l, View v, int position, long id) {
150+
public boolean onListItemLongClick(ListView l, View v, int position,
151+
long itemId) {
148152
if (!isUsable())
149153
return false;
150154

@@ -154,26 +158,35 @@ public boolean onListItemLongClick(ListView l, View v, int position, long id) {
154158
final User user = event.getActor();
155159

156160
if (repo != null && user != null) {
157-
final CharSequence[] items = { user.getLogin(),
158-
event.getRepo().getName() };
159-
160-
final LightAlertDialog.Builder builder = LightAlertDialog.Builder
161-
.create(getActivity());
162-
builder.setTitle(string.navigate_to);
163-
builder.setItems(items, new OnClickListener() {
164-
@Override
165-
public void onClick(DialogInterface dialog, int which) {
166-
switch (which) {
167-
case 0:
168-
viewUser(user);
169-
break;
170-
case 1:
171-
viewRepository(repo);
172-
break;
173-
}
161+
final AlertDialog dialog = LightAlertDialog.create(getActivity());
162+
dialog.setTitle(string.navigate_to);
163+
dialog.setCanceledOnTouchOutside(true);
164+
165+
View view = getActivity().getLayoutInflater().inflate(
166+
layout.nav_dialog, null);
167+
ViewFinder finder = new ViewFinder(view);
168+
avatars.bind(finder.imageView(id.iv_user_avatar), user);
169+
avatars.bind(finder.imageView(id.iv_repo_avatar), repo.getOwner());
170+
finder.setText(id.tv_login, user.getLogin());
171+
finder.setText(id.tv_repo_name, repo.generateId());
172+
finder.onClick(id.ll_user_area, new OnClickListener() {
173+
174+
public void onClick(View v) {
175+
dialog.dismiss();
176+
177+
viewUser(user);
174178
}
175179
});
176-
builder.create().show();
180+
finder.onClick(id.ll_repo_area, new OnClickListener() {
181+
182+
public void onClick(View v) {
183+
dialog.dismiss();
184+
185+
viewRepository(repo);
186+
}
187+
});
188+
dialog.setView(view);
189+
dialog.show();
177190

178191
return true;
179192
}

0 commit comments

Comments
 (0)