2525import android .os .Bundle ;
2626import android .util .Log ;
2727import android .view .View ;
28+ import android .widget .AdapterView ;
29+ import android .widget .ArrayAdapter ;
2830import android .widget .Button ;
2931import android .widget .EditText ;
3032import android .widget .TextView ;
3638
3739import androidx .appcompat .app .AlertDialog ;
3840import androidx .appcompat .app .AppCompatActivity ;
41+ import androidx .appcompat .widget .AppCompatButton ;
42+ import androidx .appcompat .widget .AppCompatSpinner ;
3943import androidx .appcompat .widget .Toolbar ;
4044
4145import static com .zoffcc .applications .trifa .CameraWrapper .YUV420rotate90 ;
4246import static com .zoffcc .applications .trifa .HelperGeneric .display_toast ;
4347import static com .zoffcc .applications .trifa .HelperGeneric .update_savedata_file_wrapper ;
48+ import static com .zoffcc .applications .trifa .HelperGroup .get_group_peernum_from_peer_pubkey ;
4449import static com .zoffcc .applications .trifa .HelperGroup .tox_group_by_groupid__wrapper ;
50+ import static com .zoffcc .applications .trifa .HelperGroup .update_group_in_groupmessagelist ;
51+ import static com .zoffcc .applications .trifa .HelperGroup .update_group_peer_in_db ;
4552import static com .zoffcc .applications .trifa .MainActivity .SD_CARD_ENC_FILES_EXPORT_DIR ;
4653import static com .zoffcc .applications .trifa .MainActivity .context_s ;
4754import static com .zoffcc .applications .trifa .MainActivity .main_handler_s ;
4855import static com .zoffcc .applications .trifa .MainActivity .tox_group_founder_set_peer_limit ;
56+ import static com .zoffcc .applications .trifa .MainActivity .tox_group_founder_set_voice_state ;
4957import static com .zoffcc .applications .trifa .MainActivity .tox_group_get_name ;
5058import static com .zoffcc .applications .trifa .MainActivity .tox_group_get_peer_limit ;
59+ import static com .zoffcc .applications .trifa .MainActivity .tox_group_get_voice_state ;
5160import static com .zoffcc .applications .trifa .MainActivity .tox_group_is_connected ;
61+ import static com .zoffcc .applications .trifa .MainActivity .tox_group_mod_set_role ;
5262import static com .zoffcc .applications .trifa .MainActivity .tox_group_offline_peer_count ;
5363import static com .zoffcc .applications .trifa .MainActivity .tox_group_peer_count ;
5464import static com .zoffcc .applications .trifa .MainActivity .tox_group_peer_get_name ;
@@ -79,6 +89,9 @@ public class GroupInfoActivity extends AppCompatActivity
7989 Button group_reconnect_button = null ;
8090 Button group_dumpofflinepeers_button = null ;
8191 Button group_del_sysmsgs_button = null ;
92+ AppCompatSpinner group_voicestate_select = null ;
93+ private AppCompatButton group_voicestate_set_button = null ;
94+ private String [] tox_ngc_group_voicestate_items ;
8295 String group_id = "-1" ;
8396
8497 @ Override
@@ -103,6 +116,93 @@ protected void onCreate(Bundle savedInstanceState)
103116 group_reconnect_button = (Button ) findViewById (R .id .group_reconnect_button );
104117 group_dumpofflinepeers_button = (Button ) findViewById (R .id .group_dumpofflinepeers_button );
105118 group_del_sysmsgs_button = (Button ) findViewById (R .id .group_del_sysmsgs_button );
119+ group_voicestate_select = findViewById (R .id .group_voicestate_select );
120+ group_voicestate_set_button = findViewById (R .id .group_voicestate_set_button );
121+
122+ this .tox_ngc_group_voicestate_items = new String []{"---" , "FOUNDER" , "MODERATOR" , "ALL" };
123+ ArrayAdapter <CharSequence > adapter = new ArrayAdapter <>(this , android .R .layout .simple_spinner_item ,
124+ tox_ngc_group_voicestate_items );
125+ adapter .setDropDownViewResource (android .R .layout .simple_spinner_dropdown_item );
126+ group_voicestate_select .setAdapter (adapter );
127+
128+ int current_voicestate = 0 ;
129+ try
130+ {
131+ current_voicestate = tox_group_get_voice_state (tox_group_by_groupid__wrapper (group_id ));
132+ Log .i (TAG , "current_voicestate:" + current_voicestate );
133+ if (current_voicestate == ToxVars .Tox_Group_Voice_State .TOX_GROUP_VOICE_STATE_FOUNDER .value )
134+ {
135+ group_voicestate_select .setSelection (1 );
136+ }
137+ else if (current_voicestate == ToxVars .Tox_Group_Voice_State .TOX_GROUP_VOICE_STATE_MODERATOR .value )
138+ {
139+ group_voicestate_select .setSelection (2 );
140+ }
141+ else if (current_voicestate == ToxVars .Tox_Group_Voice_State .TOX_GROUP_VOICE_STATE_ALL .value )
142+ {
143+ group_voicestate_select .setSelection (3 );
144+ }
145+ else
146+ {
147+ // nothing valid selected
148+ group_voicestate_select .setSelection (0 );
149+ }
150+ }
151+ catch (Exception e )
152+ {
153+ }
154+
155+ group_voicestate_select .setOnItemSelectedListener (new AdapterView .OnItemSelectedListener ()
156+ {
157+ @ Override
158+ public void onItemSelected (AdapterView <?> parent , View view , int position , long id )
159+ {
160+ Log .i (TAG , "selected_new_voicestate:" + parent .getItemAtPosition (position ));
161+ }
162+
163+ @ Override
164+ public void onNothingSelected (AdapterView <?> parent )
165+ {
166+
167+ }
168+ });
169+
170+ group_voicestate_set_button .setOnClickListener (new View .OnClickListener ()
171+ {
172+ @ Override
173+ public void onClick (View view )
174+ {
175+ try
176+ {
177+ String role_str = (String ) group_voicestate_select .getSelectedItem ();
178+ int new_role = ToxVars .Tox_Group_Voice_State .TOX_GROUP_VOICE_STATE_ALL .value ;
179+ if (role_str .equals ("FOUNDER" ))
180+ {
181+ new_role = ToxVars .Tox_Group_Voice_State .TOX_GROUP_VOICE_STATE_FOUNDER .value ;
182+ }
183+ else if (role_str .equals ("MODERATOR" ))
184+ {
185+ new_role = ToxVars .Tox_Group_Voice_State .TOX_GROUP_VOICE_STATE_MODERATOR .value ;
186+ }
187+ else if (role_str .equals ("ALL" ))
188+ {
189+ new_role = ToxVars .Tox_Group_Voice_State .TOX_GROUP_VOICE_STATE_ALL .value ;
190+ }
191+ else
192+ {
193+ // nothing valid selected
194+ return ;
195+ }
196+
197+ int result = tox_group_founder_set_voice_state (tox_group_by_groupid__wrapper (group_id ), new_role );
198+ Log .i (TAG , "setting new voicestate to: " + new_role + " result=" + result );
199+ update_savedata_file_wrapper ();
200+ }
201+ catch (Exception ignored )
202+ {
203+ }
204+ }
205+ });
106206
107207 try
108208 {
0 commit comments