6
6
import android .annotation .TargetApi ;
7
7
import android .app .AlertDialog ;
8
8
import android .app .DatePickerDialog ;
9
+ import android .app .DialogFragment ;
9
10
import android .app .NotificationManager ;
10
11
import android .app .PendingIntent ;
11
12
import android .app .SearchManager ;
110
111
import com .zulip .android .util .CommonProgressDialog ;
111
112
import com .zulip .android .util .Constants ;
112
113
import com .zulip .android .util .FileUtils ;
114
+ import com .zulip .android .util .ListDialog ;
113
115
import com .zulip .android .util .MutedTopics ;
114
116
import com .zulip .android .util .RemoveViewsOnScroll ;
115
117
import com .zulip .android .util .SwipeRemoveLinearLayout ;
143
145
* messages
144
146
*/
145
147
public class ZulipActivity extends BaseActivity implements
146
- MessageListFragment .Listener , NarrowListener , SwipeRemoveLinearLayout .leftToRightSwipeListener {
148
+ MessageListFragment .Listener , NarrowListener , SwipeRemoveLinearLayout .leftToRightSwipeListener ,
149
+ ListDialog .ListDialogListener {
147
150
148
151
private static final String NARROW = "narrow" ;
149
152
private static final String PARAMS = "params" ;
@@ -209,7 +212,6 @@ public void onReceive(Context contenxt, Intent intent) {
209
212
private List <PeopleDrawerList > recentPeopleDrawerList ;
210
213
private List <PeopleDrawerList > filteredRecentPeopleDrawerList ;
211
214
private Uri mFileUri ;
212
- private ImageView cameraBtn ;
213
215
private String mCurrentPhotoPath ;
214
216
private Menu menu ;
215
217
private Calendar calendar ;
@@ -220,6 +222,7 @@ public void onReceive(Context contenxt, Intent intent) {
220
222
private Toast toast ;
221
223
private RecyclerView peopleDrawer ;
222
224
private List <PeopleDrawerList > peopleDrawerList ;
225
+ private ImageView addFileBtn ;
223
226
//
224
227
private String streamSearchFilterKeyword = "" ;
225
228
private RefreshableCursorAdapter peopleAdapter ;
@@ -344,7 +347,7 @@ public void onClick(View v) {
344
347
messageEt = (AutoCompleteTextView ) findViewById (R .id .message_et );
345
348
textView = (TextView ) findViewById (R .id .textView );
346
349
sendBtn = (ImageView ) findViewById (R .id .send_btn );
347
- cameraBtn = (ImageView ) findViewById (R .id .camera_btn );
350
+ addFileBtn = (ImageView ) findViewById (R .id .add_btn );
348
351
appBarLayout = (AppBarLayout ) findViewById (R .id .appBarLayout );
349
352
boolean isCurrentThemeNight = (AppCompatDelegate .getDefaultNightMode () == AppCompatDelegate .MODE_NIGHT_YES );
350
353
etSearchPeople = (EditText ) findViewById (R .id .people_drawer_search );
@@ -443,14 +446,15 @@ public void onClick(View v) {
443
446
}
444
447
});
445
448
446
- // set onClick listener on camera button to dispatch camera intent when clicked
447
- cameraBtn .setOnClickListener (new View .OnClickListener () {
449
+ /**
450
+ * set click listener on add file button to open custom list dialog {@link ListDialog}
451
+ */
452
+ addFileBtn .setOnClickListener (new View .OnClickListener () {
448
453
@ Override
449
- public void onClick (View view ) {
450
- dispatchTakePictureIntent ();
454
+ public void onClick (View v ) {
455
+ showListDialog ();
451
456
}
452
457
});
453
-
454
458
composeStatus = (LinearLayout ) findViewById (R .id .composeStatus );
455
459
setUpAdapter ();
456
460
streamActv .setAdapter (streamActvAdapter );
@@ -553,17 +557,36 @@ public Cursor runQuery(CharSequence charSequence) {
553
557
handleSentFile ((Uri ) intent .getParcelableExtra (Intent .EXTRA_STREAM ));
554
558
}
555
559
}
556
- // if device doesn't have camera, disable camera button
557
- if (!getPackageManager ().hasSystemFeature (PackageManager .FEATURE_CAMERA )) {
558
- cameraBtn .setEnabled (false );
559
- }
560
560
handleOnFragmentChange ();
561
561
calendar = Calendar .getInstance ();
562
562
setupSnackBar ();
563
563
//Hides Keyboard if it was open with focus on an editText before restart of the activity
564
564
this .getWindow ().setSoftInputMode (WindowManager .LayoutParams .SOFT_INPUT_STATE_HIDDEN );
565
565
}
566
566
567
+ public void showListDialog () {
568
+ // Create an instance of the dialog fragment and show it
569
+ DialogFragment dialog = new ListDialog ();
570
+ dialog .show (getFragmentManager (), "ListDialogFragment" );
571
+ }
572
+
573
+ // The dialog fragment receives a reference to this Activity through the
574
+ // Fragment.onAttach() callback, which it uses to call the following methods
575
+ // defined by the ListDialogFragment.ListDialogListener interface
576
+ @ Override
577
+ public void onDialogPhotoClick (DialogFragment dialog ) {
578
+ // User touched the dialog's "Take picture" button
579
+ dialog .dismiss ();
580
+ dispatchTakePictureIntent ();
581
+ }
582
+
583
+ @ Override
584
+ public void onDialogFileClick (DialogFragment dialog ) {
585
+ // User touched the dialog's "Pick a file" button
586
+ dialog .dismiss ();
587
+ dispatchPickIntent ();
588
+ }
589
+
567
590
/**
568
591
* Updates recentPMPersons in ZulipApp
569
592
*/
@@ -1632,7 +1655,7 @@ private void sendingMessage(boolean isSending, String message) {
1632
1655
messageEt .setEnabled (!isSending );
1633
1656
topicActv .setEnabled (!isSending );
1634
1657
sendBtn .setEnabled (!isSending );
1635
- cameraBtn .setEnabled (!isSending );
1658
+ addFileBtn .setEnabled (!isSending );
1636
1659
togglePrivateStreamBtn .setEnabled (!isSending );
1637
1660
if (isSending ) {
1638
1661
TextView msg = (TextView ) composeStatus .findViewById (R .id .sending_message );
@@ -2319,9 +2342,6 @@ public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
2319
2342
case R .id .legal :
2320
2343
openLegal ();
2321
2344
break ;
2322
- case R .id .attach :
2323
- dispatchPickIntent ();
2324
- break ;
2325
2345
default :
2326
2346
return super .onOptionsItemSelected (item );
2327
2347
}
@@ -2341,6 +2361,8 @@ private void dispatchPickIntent() {
2341
2361
2342
2362
if (intent .resolveActivity (getPackageManager ()) != null ) {
2343
2363
startActivityForResult (intent , REQUEST_PICK_FILE );
2364
+ // activity transition animation
2365
+ ActivityTransitionAnim .transition (ZulipActivity .this );
2344
2366
}
2345
2367
}
2346
2368
0 commit comments