Parcourir la source

增加耳机双击群留言功能使能开关

weizhengliang il y a 2 ans
Parent
commit
42f94da9f7

+ 23 - 0
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WatchUserSettingActivity.java

@@ -44,6 +44,8 @@ public class WatchUserSettingActivity extends Activity {
 
     private RadioGroup callGroup;
     private RadioButton callYes, callNo;
+    private RadioGroup imChannelGroup;
+    private RadioButton imChannelYes, imChannelNo;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -71,6 +73,10 @@ public class WatchUserSettingActivity extends Activity {
         callYes = findViewById(R.id.rb_call_yes);
         callNo = findViewById(R.id.rb_call_no);
 
+        imChannelGroup = findViewById(R.id.group_im_channel);
+        imChannelYes = findViewById(R.id.rb_im_channel_yes);
+        imChannelNo = findViewById(R.id.rb_im_channel_no);
+
         tvAppVersion.setText(CommonUtils.getAppVersionName(BaseApplication.appContext) + "_" + BuildConfig.BUILD_TIME);
         tvDeviceId.setText("" + Constants.Companion.getDeviceId());
         tvDeviceImei.setText(Constants.Companion.getImei());
@@ -85,6 +91,12 @@ public class WatchUserSettingActivity extends Activity {
             callNo.setChecked(true);
         }
 
+        if (SettingConfig.getImChannel(BaseApplication.appContext) == SettingConfig.IM_CHANNEL_ON) {
+            imChannelYes.setChecked(true);
+        } else {
+            imChannelNo.setChecked(true);
+        }
+
         int mode = SettingConfig.getLanguageMode(BaseApplication.appContext);
         RadioGroup languageMode = findViewById(R.id.group_language_mode);
         RadioButton languageYes = findViewById(R.id.rb_language_yes);
@@ -184,6 +196,17 @@ public class WatchUserSettingActivity extends Activity {
             }
         });
 
+        imChannelGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                if (checkedId == R.id.rb_im_channel_yes) {
+                    SettingConfig.setImChannel(BaseApplication.appContext, SettingConfig.IM_CHANNEL_ON);
+                } else {
+                    SettingConfig.setImChannel(BaseApplication.appContext, SettingConfig.IM_CHANNEL_OFF);
+                }
+            }
+        });
+
 
         Button update = findViewById(R.id.btn_update_contact);
         update.setOnClickListener(new View.OnClickListener() {

+ 11 - 0
home/src/main/code/com/wdkl/ncs/android/component/home/settingconfig/SettingConfig.java

@@ -20,6 +20,9 @@ public class SettingConfig {
     private static final String KEY_SP_SMS_CMD = "KEY_SP_SMS_CMD";
     private static final String KEY_SP_OPERATOR_NUMBER = "KEY_SP_OPERATOR_NUMBER";
 
+    private static final String KEY_SP_IM_CHANNEL = "KEY_SP_IM_CHANNEL";
+    public static final int IM_CHANNEL_ON = 1;
+    public static final int IM_CHANNEL_OFF = 2;
 
     //默认语言
     private static final String KEY_LANGUAGE_ID = "KEY_LANGUAGE_ID";
@@ -86,6 +89,14 @@ public class SettingConfig {
         getEditor(context).putString(KEY_SP_OPERATOR_NUMBER, number).apply();
     }
 
+    public static int getImChannel(Context context) {
+        return getSP(context).getInt(KEY_SP_IM_CHANNEL, -1);
+    }
+
+    public static void setImChannel(Context context, int value) {
+        getEditor(context).putInt(KEY_SP_IM_CHANNEL, value).apply();
+    }
+
 
     private static SharedPreferences getSP(Context context) {
         return context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);

+ 2 - 4
home/src/main/res/layout/user_setting_layout.xml

@@ -322,8 +322,7 @@
                     android:layout_below="@id/tv_call_title"
                     android:layout_marginTop="16dp"
                     android:text="@string/media_button_message"
-                    android:textSize="16sp"
-                    android:visibility="gone"/>
+                    android:textSize="16sp" />
 
                 <RadioGroup
                     android:id="@+id/group_im_channel"
@@ -331,8 +330,7 @@
                     android:layout_height="wrap_content"
                     android:layout_below="@id/tv_im_channel_title"
                     android:layout_marginTop="10dp"
-                    android:orientation="horizontal"
-                    android:visibility="gone">
+                    android:orientation="horizontal">
                     <RadioButton
                         android:id="@+id/rb_im_channel_yes"
                         android:layout_width="wrap_content"