11package com .idormy .sms .forwarder ;
22
3+ import android .annotation .SuppressLint ;
34import android .content .DialogInterface ;
45import android .os .Bundle ;
56import android .os .Handler ;
@@ -144,7 +145,15 @@ private void setRule(final RuleModel ruleModel) {
144145 if (ruleModel != null ) radioGroupRuleFiled .check (ruleModel .getRuleFiledCheckId ());
145146
146147 final RadioGroup radioGroupRuleCheck = (RadioGroup ) view1 .findViewById (R .id .radioGroupRuleCheck );
147- if (ruleModel != null ) radioGroupRuleCheck .check (ruleModel .getRuleCheckCheckId ());
148+ final RadioGroup radioGroupRuleCheck2 = (RadioGroup ) view1 .findViewById (R .id .radioGroupRuleCheck2 );
149+ if (ruleModel != null ) {
150+ int ruleCheckCheckId = ruleModel .getRuleCheckCheckId ();
151+ if (ruleCheckCheckId == R .id .btnIs || ruleCheckCheckId == R .id .btnNotIs || ruleCheckCheckId == R .id .btnContain ) {
152+ radioGroupRuleCheck .check (ruleCheckCheckId );
153+ } else {
154+ radioGroupRuleCheck2 .check (ruleCheckCheckId );
155+ }
156+ }
148157
149158 final RadioGroup radioGroupSimSlot = (RadioGroup ) view1 .findViewById (R .id .radioGroupSimSlot );
150159 if (ruleModel != null ) radioGroupSimSlot .check (ruleModel .getRuleSimSlotCheckId ());
@@ -174,7 +183,7 @@ public void onClick(View view) {
174183 //当更新选择的字段的时候,更新之下各个选项的状态
175184 final LinearLayout matchTypeLayout = (LinearLayout ) view1 .findViewById (R .id .matchTypeLayout );
176185 final LinearLayout matchValueLayout = (LinearLayout ) view1 .findViewById (R .id .matchValueLayout );
177- refreshSelectRadioGroupRuleFiled (radioGroupRuleFiled , radioGroupRuleCheck , editTextRuleValue , tv_mu_rule_tips , matchTypeLayout , matchValueLayout );
186+ refreshSelectRadioGroupRuleFiled (radioGroupRuleFiled , radioGroupRuleCheck , radioGroupRuleCheck2 , editTextRuleValue , tv_mu_rule_tips , matchTypeLayout , matchValueLayout );
178187
179188 Button buttonruleok = view1 .findViewById (R .id .buttonruleok );
180189 Button buttonruledel = view1 .findViewById (R .id .buttonruledel );
@@ -189,10 +198,12 @@ public void onClick(View view) {
189198 @ Override
190199 public void onClick (View view ) {
191200 Object senderId = ruleSenderTv .getTag ();
201+ int radioGroupRuleCheckId = Math .max (radioGroupRuleCheck .getCheckedRadioButtonId (), radioGroupRuleCheck2 .getCheckedRadioButtonId ());
202+ Log .d (TAG , "XXXX " + radioGroupRuleCheck .getCheckedRadioButtonId () + " " + radioGroupRuleCheck2 .getCheckedRadioButtonId () + " " + radioGroupRuleCheckId );
192203 if (ruleModel == null ) {
193204 RuleModel newRuleModel = new RuleModel ();
194205 newRuleModel .setFiled (RuleModel .getRuleFiledFromCheckId (radioGroupRuleFiled .getCheckedRadioButtonId ()));
195- newRuleModel .setCheck (RuleModel .getRuleCheckFromCheckId (radioGroupRuleCheck . getCheckedRadioButtonId () ));
206+ newRuleModel .setCheck (RuleModel .getRuleCheckFromCheckId (radioGroupRuleCheckId ));
196207 newRuleModel .setSimSlot (RuleModel .getRuleSimSlotFromCheckId (radioGroupSimSlot .getCheckedRadioButtonId ()));
197208 newRuleModel .setValue (editTextRuleValue .getText ().toString ());
198209 if (senderId != null ) {
@@ -203,7 +214,7 @@ public void onClick(View view) {
203214 adapter .add (ruleModels );
204215 } else {
205216 ruleModel .setFiled (RuleModel .getRuleFiledFromCheckId (radioGroupRuleFiled .getCheckedRadioButtonId ()));
206- ruleModel .setCheck (RuleModel .getRuleCheckFromCheckId (radioGroupRuleCheck . getCheckedRadioButtonId () ));
217+ ruleModel .setCheck (RuleModel .getRuleCheckFromCheckId (radioGroupRuleCheckId ));
207218 ruleModel .setSimSlot (RuleModel .getRuleSimSlotFromCheckId (radioGroupSimSlot .getCheckedRadioButtonId ()));
208219 ruleModel .setValue (editTextRuleValue .getText ().toString ());
209220 if (senderId != null ) {
@@ -237,18 +248,19 @@ public void onClick(View view) {
237248 if (senderId == null ) {
238249 Toast .makeText (RuleActivity .this , "请先创建选择发送方" , Toast .LENGTH_LONG ).show ();
239250 } else {
251+ int radioGroupRuleCheckId = Math .max (radioGroupRuleCheck .getCheckedRadioButtonId (), radioGroupRuleCheck2 .getCheckedRadioButtonId ());
240252 if (ruleModel == null ) {
241253 RuleModel newRuleModel = new RuleModel ();
242254 newRuleModel .setFiled (RuleModel .getRuleFiledFromCheckId (radioGroupRuleFiled .getCheckedRadioButtonId ()));
243- newRuleModel .setCheck (RuleModel .getRuleCheckFromCheckId (radioGroupRuleCheck . getCheckedRadioButtonId () ));
255+ newRuleModel .setCheck (RuleModel .getRuleCheckFromCheckId (radioGroupRuleCheckId ));
244256 newRuleModel .setSimSlot (RuleModel .getRuleSimSlotFromCheckId (radioGroupSimSlot .getCheckedRadioButtonId ()));
245257 newRuleModel .setValue (editTextRuleValue .getText ().toString ());
246258 newRuleModel .setSenderId (Long .valueOf (senderId .toString ()));
247259
248260 testRule (newRuleModel , Long .valueOf (senderId .toString ()));
249261 } else {
250262 ruleModel .setFiled (RuleModel .getRuleFiledFromCheckId (radioGroupRuleFiled .getCheckedRadioButtonId ()));
251- ruleModel .setCheck (RuleModel .getRuleCheckFromCheckId (radioGroupRuleCheck . getCheckedRadioButtonId () ));
263+ ruleModel .setCheck (RuleModel .getRuleCheckFromCheckId (radioGroupRuleCheckId ));
252264 ruleModel .setSimSlot (RuleModel .getRuleSimSlotFromCheckId (radioGroupSimSlot .getCheckedRadioButtonId ()));
253265 ruleModel .setValue (editTextRuleValue .getText ().toString ());
254266 ruleModel .setSenderId (Long .valueOf (senderId .toString ()));
@@ -264,18 +276,57 @@ public void onClick(View view) {
264276 //当更新选择的字段的时候,更新之下各个选项的状态
265277 // 如果设置了转发全部,禁用选择模式和匹配值输入
266278 // 如果设置了多重规则,选择模式置为是
267- private void refreshSelectRadioGroupRuleFiled (RadioGroup radioGroupRuleFiled , final RadioGroup radioGroupRuleCheck , final EditText editTextRuleValue , final TextView tv_mu_rule_tips , final LinearLayout matchTypeLayout , final LinearLayout matchValueLayout ) {
268- refreshSelectRadioGroupRuleFiledAction (radioGroupRuleFiled .getCheckedRadioButtonId (), radioGroupRuleCheck , editTextRuleValue , tv_mu_rule_tips , matchTypeLayout , matchValueLayout );
279+ private void refreshSelectRadioGroupRuleFiled (RadioGroup radioGroupRuleFiled , final RadioGroup radioGroupRuleCheck , final RadioGroup radioGroupRuleCheck2 , final EditText editTextRuleValue , final TextView tv_mu_rule_tips , final LinearLayout matchTypeLayout , final LinearLayout matchValueLayout ) {
280+ refreshSelectRadioGroupRuleFiledAction (radioGroupRuleFiled .getCheckedRadioButtonId (), radioGroupRuleCheck , radioGroupRuleCheck2 , editTextRuleValue , tv_mu_rule_tips , matchTypeLayout , matchValueLayout );
269281
282+ radioGroupRuleCheck .setOnCheckedChangeListener (new RadioGroup .OnCheckedChangeListener () {
283+ @ SuppressLint ("ResourceType" )
284+ @ Override
285+ public void onCheckedChanged (RadioGroup group , int checkedId ) {
286+ Log .d (TAG , String .valueOf (group ));
287+ Log .d (TAG , String .valueOf (checkedId ));
288+ if (group != null && checkedId > 0 ) {
289+ if (group == radioGroupRuleCheck ) {
290+ radioGroupRuleCheck2 .clearCheck ();
291+ } else if (group == radioGroupRuleCheck2 ) {
292+ radioGroupRuleCheck .clearCheck ();
293+ }
294+ group .check (checkedId );
295+ }
296+ }
297+ });
298+ radioGroupRuleCheck2 .setOnCheckedChangeListener (new RadioGroup .OnCheckedChangeListener () {
299+ @ SuppressLint ("ResourceType" )
300+ @ Override
301+ public void onCheckedChanged (RadioGroup group , int checkedId ) {
302+ Log .d (TAG , String .valueOf (group ));
303+ Log .d (TAG , String .valueOf (checkedId ));
304+ if (group != null && checkedId > 0 ) {
305+ if (group == radioGroupRuleCheck ) {
306+ radioGroupRuleCheck2 .clearCheck ();
307+ } else if (group == radioGroupRuleCheck2 ) {
308+ radioGroupRuleCheck .clearCheck ();
309+ }
310+ group .check (checkedId );
311+ }
312+ }
313+ });
270314 radioGroupRuleFiled .setOnCheckedChangeListener (new RadioGroup .OnCheckedChangeListener () {
271315 @ Override
272316 public void onCheckedChanged (RadioGroup group , int checkedId ) {
273- refreshSelectRadioGroupRuleFiledAction (checkedId , radioGroupRuleCheck , editTextRuleValue , tv_mu_rule_tips , matchTypeLayout , matchValueLayout );
317+ Log .d (TAG , String .valueOf (group ));
318+ Log .d (TAG , String .valueOf (checkedId ));
319+ if (group == radioGroupRuleCheck ) {
320+ radioGroupRuleCheck2 .clearCheck ();
321+ } else if (group == radioGroupRuleCheck2 ) {
322+ radioGroupRuleCheck .clearCheck ();
323+ }
324+ refreshSelectRadioGroupRuleFiledAction (checkedId , radioGroupRuleCheck , radioGroupRuleCheck2 , editTextRuleValue , tv_mu_rule_tips , matchTypeLayout , matchValueLayout );
274325 }
275326 });
276327 }
277328
278- private void refreshSelectRadioGroupRuleFiledAction (int checkedRuleFiledId , final RadioGroup radioGroupRuleCheck , final EditText editTextRuleValue , final TextView tv_mu_rule_tips , final LinearLayout matchTypeLayout , final LinearLayout matchValueLayout ) {
329+ private void refreshSelectRadioGroupRuleFiledAction (int checkedRuleFiledId , final RadioGroup radioGroupRuleCheck , final RadioGroup radioGroupRuleCheck2 , final EditText editTextRuleValue , final TextView tv_mu_rule_tips , final LinearLayout matchTypeLayout , final LinearLayout matchValueLayout ) {
279330 tv_mu_rule_tips .setVisibility (View .GONE );
280331 matchTypeLayout .setVisibility (View .VISIBLE );
281332 matchValueLayout .setVisibility (View .VISIBLE );
@@ -285,6 +336,9 @@ private void refreshSelectRadioGroupRuleFiledAction(int checkedRuleFiledId, fina
285336 for (int i = 0 ; i < radioGroupRuleCheck .getChildCount (); i ++) {
286337 ((RadioButton ) radioGroupRuleCheck .getChildAt (i )).setEnabled (false );
287338 }
339+ for (int i = 0 ; i < radioGroupRuleCheck2 .getChildCount (); i ++) {
340+ ((RadioButton ) radioGroupRuleCheck2 .getChildAt (i )).setEnabled (false );
341+ }
288342 editTextRuleValue .setEnabled (false );
289343 matchTypeLayout .setVisibility (View .GONE );
290344 matchValueLayout .setVisibility (View .GONE );
@@ -293,6 +347,9 @@ private void refreshSelectRadioGroupRuleFiledAction(int checkedRuleFiledId, fina
293347 for (int i = 0 ; i < radioGroupRuleCheck .getChildCount (); i ++) {
294348 ((RadioButton ) radioGroupRuleCheck .getChildAt (i )).setEnabled (false );
295349 }
350+ for (int i = 0 ; i < radioGroupRuleCheck2 .getChildCount (); i ++) {
351+ ((RadioButton ) radioGroupRuleCheck2 .getChildAt (i )).setEnabled (false );
352+ }
296353 editTextRuleValue .setEnabled (true );
297354 matchTypeLayout .setVisibility (View .GONE );
298355 tv_mu_rule_tips .setVisibility (MyApplication .showHelpTip ? View .VISIBLE : View .GONE );
@@ -301,6 +358,9 @@ private void refreshSelectRadioGroupRuleFiledAction(int checkedRuleFiledId, fina
301358 for (int i = 0 ; i < radioGroupRuleCheck .getChildCount (); i ++) {
302359 ((RadioButton ) radioGroupRuleCheck .getChildAt (i )).setEnabled (true );
303360 }
361+ for (int i = 0 ; i < radioGroupRuleCheck2 .getChildCount (); i ++) {
362+ ((RadioButton ) radioGroupRuleCheck2 .getChildAt (i )).setEnabled (true );
363+ }
304364 editTextRuleValue .setEnabled (true );
305365 break ;
306366 }
0 commit comments