24
24
import static com .github .mobile .RequestCodes .ISSUE_ASSIGNEE_UPDATE ;
25
25
import static com .github .mobile .RequestCodes .ISSUE_LABELS_UPDATE ;
26
26
import static com .github .mobile .RequestCodes .ISSUE_MILESTONE_UPDATE ;
27
+ import android .accounts .Account ;
27
28
import android .content .Intent ;
28
29
import android .os .Bundle ;
29
30
import android .text .Editable ;
30
31
import android .text .TextUtils ;
32
+ import android .util .Log ;
31
33
import android .view .View ;
32
34
import android .view .View .OnClickListener ;
33
35
import android .widget .EditText ;
43
45
import com .github .mobile .R .layout ;
44
46
import com .github .mobile .R .menu ;
45
47
import com .github .mobile .R .string ;
48
+ import com .github .mobile .accounts .AccountUtils ;
49
+ import com .github .mobile .accounts .AuthenticatedUserTask ;
46
50
import com .github .mobile .core .issue .IssueUtils ;
47
51
import com .github .mobile .ui .DialogFragmentActivity ;
52
+ import com .github .mobile .ui .ProgressDialogTask ;
48
53
import com .github .mobile .ui .StyledText ;
49
54
import com .github .mobile .ui .TextWatcherAdapter ;
50
55
import com .github .mobile .util .AvatarLoader ;
@@ -100,6 +105,8 @@ public static Intent createIntent(final Issue issue,
100
105
return builder .toIntent ();
101
106
}
102
107
108
+ private static final String TAG = "EditIssueActivity" ;
109
+
103
110
private EditText titleText ;
104
111
105
112
private EditText bodyText ;
@@ -155,6 +162,8 @@ protected void onCreate(Bundle savedInstanceState) {
155
162
assigneeText = finder .find (id .tv_assignee_name );
156
163
labelsText = finder .find (id .tv_labels );
157
164
165
+ checkCollaboratorStatus ();
166
+
158
167
Intent intent = getIntent ();
159
168
160
169
if (savedInstanceState != null )
@@ -181,6 +190,64 @@ protected void onCreate(Bundle savedInstanceState) {
181
190
actionBar .setSubtitle (repository .generateId ());
182
191
avatars .bind (actionBar , (User ) intent .getSerializableExtra (EXTRA_USER ));
183
192
193
+ titleText .addTextChangedListener (new TextWatcherAdapter () {
194
+
195
+ @ Override
196
+ public void afterTextChanged (Editable s ) {
197
+ updateSaveMenu (s );
198
+ }
199
+ });
200
+
201
+ updateSaveMenu ();
202
+ updateView ();
203
+ }
204
+
205
+ private void checkCollaboratorStatus () {
206
+ new AuthenticatedUserTask <Boolean >(this ) {
207
+
208
+ @ Override
209
+ public Boolean run (Account account ) throws Exception {
210
+ return collaboratorService .isCollaborator (repository , AccountUtils .getLogin (EditIssueActivity .this ));
211
+ }
212
+
213
+ @ Override
214
+ protected void onSuccess (Boolean isCollaborator ) throws Exception {
215
+ super .onSuccess (isCollaborator );
216
+
217
+ showMainContent ();
218
+
219
+ if (isCollaborator )
220
+ showCollaboratorOptions ();
221
+ }
222
+
223
+ @ Override
224
+ protected void onException (Exception e ) throws RuntimeException {
225
+ super .onException (e );
226
+
227
+ Log .d (TAG , "Error loading collaborators for issue editing" , e );
228
+ showMainContent ();
229
+ }
230
+
231
+ @ Override
232
+ public void execute () {
233
+ super .execute ();
234
+ }
235
+
236
+ private void showMainContent () {
237
+ finder .find (id .sv_issue_content ).setVisibility (View .VISIBLE );
238
+ finder .find (id .pb_loading ).setVisibility (View .GONE );
239
+ }
240
+ }.execute ();
241
+ }
242
+
243
+ private void showCollaboratorOptions () {
244
+ finder .find (id .tv_milestone_label ).setVisibility (View .VISIBLE );
245
+ finder .find (id .ll_milestone ).setVisibility (View .VISIBLE );
246
+ finder .find (id .tv_labels_label ).setVisibility (View .VISIBLE );
247
+ finder .find (id .ll_labels ).setVisibility (View .VISIBLE );
248
+ finder .find (id .tv_assignee_label ).setVisibility (View .VISIBLE );
249
+ finder .find (id .ll_assignee ).setVisibility (View .VISIBLE );
250
+
184
251
findViewById (id .ll_milestone ).setOnClickListener (new OnClickListener () {
185
252
186
253
@ Override
@@ -215,17 +282,6 @@ public void onClick(View v) {
215
282
labelsDialog .show (issue .getLabels ());
216
283
}
217
284
});
218
-
219
- titleText .addTextChangedListener (new TextWatcherAdapter () {
220
-
221
- @ Override
222
- public void afterTextChanged (Editable s ) {
223
- updateSaveMenu (s );
224
- }
225
- });
226
-
227
- updateSaveMenu ();
228
- updateView ();
229
285
}
230
286
231
287
@ Override
0 commit comments