5454import static com .zoffcc .applications .trifa .MainActivity .PREF__dark_mode_pref ;
5555import static com .zoffcc .applications .trifa .MainActivity .context_s ;
5656import static com .zoffcc .applications .trifa .MainActivity .main_handler_s ;
57+ import static com .zoffcc .applications .trifa .MainActivity .tox_group_disconnect ;
5758import static com .zoffcc .applications .trifa .MainActivity .tox_group_get_name ;
5859import static com .zoffcc .applications .trifa .MainActivity .tox_group_is_connected ;
5960import static com .zoffcc .applications .trifa .MainActivity .tox_group_leave ;
@@ -355,7 +356,7 @@ public boolean onMenuItemClick(MenuItem item)
355356 break ;
356357 case R .id .item_leave :
357358 // leave group -----------------
358- // TODO: write me
359+ show_confirm_group_leave_dialog ( v , f2 );
359360 // leave group -----------------
360361 break ;
361362 case R .id .item_dummy01 :
@@ -377,6 +378,65 @@ public boolean onMenuItemClick(MenuItem item)
377378
378379 }
379380
381+ public void show_confirm_group_leave_dialog (final View view , final GroupDB f2 )
382+ {
383+ AlertDialog .Builder builder = new AlertDialog .Builder (view .getContext ());
384+ builder .setTitle ("Leave Group?" );
385+ builder .setMessage ("Do you want to leave this Group?" );
386+
387+ builder .setNegativeButton ("Cancel" , null );
388+ builder .setPositiveButton ("Yes" , new DialogInterface .OnClickListener ()
389+ {
390+ @ Override
391+ public void onClick (DialogInterface dialog , int which )
392+ {
393+ if (f2 .group_identifier != null )
394+ {
395+ final long group_num = tox_group_by_groupid__wrapper (f2 .group_identifier );
396+ tox_group_disconnect (group_num );
397+ update_savedata_file_wrapper (); // after leaving a conference
398+ }
399+
400+ Runnable myRunnable2 = new Runnable ()
401+ {
402+ @ Override
403+ public void run ()
404+ {
405+ try
406+ {
407+ try
408+ {
409+ if (MainActivity .friend_list_fragment != null )
410+ {
411+ // reload friendlist
412+ MainActivity .friend_list_fragment .add_all_friends_clear (0 );
413+ }
414+ }
415+ catch (Exception e )
416+ {
417+ e .printStackTrace ();
418+ }
419+ }
420+ catch (Exception e )
421+ {
422+ e .printStackTrace ();
423+ Log .i (TAG , "onMenuItemClick:8:EE:" + e .getMessage ());
424+ }
425+ }
426+ };
427+
428+ // TODO: use own handler
429+ if (main_handler_s != null )
430+ {
431+ main_handler_s .post (myRunnable2 );
432+ }
433+ }
434+ });
435+
436+ AlertDialog dialog = builder .create ();
437+ dialog .show ();
438+ }
439+
380440 public void show_confirm_group_del_dialog (final View view , final GroupDB f2 )
381441 {
382442 AlertDialog .Builder builder = new AlertDialog .Builder (view .getContext ());
0 commit comments