Commit e6dfc6cee4748b702c9718c16b77e73c977e7f98
1 parent
f6ada598
1 新增音箱被他人绑定后拨打电话的功能
Showing
6 changed files
with
77 additions
and
7 deletions
config.gradle
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/SelectWifiFragmentView.java
| @@ -218,7 +218,7 @@ public class SelectWifiFragmentView implements MvpView { | @@ -218,7 +218,7 @@ public class SelectWifiFragmentView implements MvpView { | ||
| 218 | public void onConnectFail(BleDevice bleDevice, BleException exception) { | 218 | public void onConnectFail(BleDevice bleDevice, BleException exception) { |
| 219 | QMUITipDialogUtil.dismessDialog(); | 219 | QMUITipDialogUtil.dismessDialog(); |
| 220 | AlertUtil.showDeftToast(getContext(), "连接无响应,请稍后重试"); | 220 | AlertUtil.showDeftToast(getContext(), "连接无响应,请稍后重试"); |
| 221 | - EventBus.getDefault().post(new EventMsg(EventMsg.DEVICE_NOT_RESPONSE,"")); | 221 | + EventBus.getDefault().post(new EventMsg(EventMsg.DEVICE_NOT_RESPONSE, "")); |
| 222 | } | 222 | } |
| 223 | 223 | ||
| 224 | // 连接成功,BleDevice即为所连接的BLE设备 | 224 | // 连接成功,BleDevice即为所连接的BLE设备 |
| @@ -273,7 +273,7 @@ public class SelectWifiFragmentView implements MvpView { | @@ -273,7 +273,7 @@ public class SelectWifiFragmentView implements MvpView { | ||
| 273 | try { | 273 | try { |
| 274 | String result = new String(data, "UTF-8"); | 274 | String result = new String(data, "UTF-8"); |
| 275 | Log.e(TAG, "onCharacteristicChanged: " + result); | 275 | Log.e(TAG, "onCharacteristicChanged: " + result); |
| 276 | - if (result.indexOf(BlufiConstants.BIND_SUCCESS) != -1||result.indexOf(BlufiConstants.BIND_FAIL) != -1) { | 276 | + if (result.indexOf(BlufiConstants.BIND_SUCCESS) != -1 || result.indexOf(BlufiConstants.BIND_FAIL) != -1) { |
| 277 | isSetNetSuccess = true; | 277 | isSetNetSuccess = true; |
| 278 | BleManager.getInstance().stopNotify(bleDevice, BlufiConstants.UUID_WIFI_SERVICE.toString(), BlufiConstants.UUID_NOTIFY_CHARACTERISTIC.toString()); | 278 | BleManager.getInstance().stopNotify(bleDevice, BlufiConstants.UUID_WIFI_SERVICE.toString(), BlufiConstants.UUID_NOTIFY_CHARACTERISTIC.toString()); |
| 279 | BleManager.getInstance().disconnect(bleDevice); | 279 | BleManager.getInstance().disconnect(bleDevice); |
| @@ -296,7 +296,11 @@ public class SelectWifiFragmentView implements MvpView { | @@ -296,7 +296,11 @@ public class SelectWifiFragmentView implements MvpView { | ||
| 296 | EventBus.getDefault().post(new EventMsg(EventMsg.CLOSE_BLUETOOTH_ACTIVITY, null)); | 296 | EventBus.getDefault().post(new EventMsg(EventMsg.CLOSE_BLUETOOTH_ACTIVITY, null)); |
| 297 | ConnBluetoothSuccessActivity.startActivity(getContext(), networkResultBean); | 297 | ConnBluetoothSuccessActivity.startActivity(getContext(), networkResultBean); |
| 298 | } else { | 298 | } else { |
| 299 | - ConnFailActivity.startActivity(getContext(), networkResultBean.getBindtel()); | 299 | + if (!TextUtils.isEmpty(networkResultBean.getPhone())) { |
| 300 | + ConnFailActivity.startActivity(getContext(), networkResultBean.getPhone()); | ||
| 301 | + }else { | ||
| 302 | + ConnFailActivity.startActivity(getContext(), networkResultBean.getBindtel()); | ||
| 303 | + } | ||
| 300 | } | 304 | } |
| 301 | } | 305 | } |
| 302 | }); | 306 | }); |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/netWork/bean/NetworkResultBean.java
| @@ -28,6 +28,15 @@ public class NetworkResultBean implements Serializable { | @@ -28,6 +28,15 @@ public class NetworkResultBean implements Serializable { | ||
| 28 | private boolean isFirstBinded; | 28 | private boolean isFirstBinded; |
| 29 | private boolean isBinded; | 29 | private boolean isBinded; |
| 30 | private String bindtel; | 30 | private String bindtel; |
| 31 | + private String phone; | ||
| 32 | + | ||
| 33 | + public String getPhone() { | ||
| 34 | + return phone; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public void setPhone(String phone) { | ||
| 38 | + this.phone = phone; | ||
| 39 | + } | ||
| 31 | 40 | ||
| 32 | public String getMainctl() { | 41 | public String getMainctl() { |
| 33 | return mainctl; | 42 | return mainctl; |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/activity/ConnBluetoothSuccessActivity.java
| @@ -92,7 +92,7 @@ public class ConnBluetoothSuccessActivity extends AppCompatActivity { | @@ -92,7 +92,7 @@ public class ConnBluetoothSuccessActivity extends AppCompatActivity { | ||
| 92 | binding.btnInvitFriend.setOnClickListener(new View.OnClickListener() { | 92 | binding.btnInvitFriend.setOnClickListener(new View.OnClickListener() { |
| 93 | @Override | 93 | @Override |
| 94 | public void onClick(View view) { | 94 | public void onClick(View view) { |
| 95 | - SelectIMFriendActivity.startActivity(ConnBluetoothSuccessActivity.this, XiaoJIaCommInfo.getFamilyId(ConnBluetoothSuccessActivity.this)); | 95 | + UserManagerActivity.StartActivity(ConnBluetoothSuccessActivity.this, XiaoJIaCommInfo.getFamilyId(ConnBluetoothSuccessActivity.this)); |
| 96 | } | 96 | } |
| 97 | }); | 97 | }); |
| 98 | //修改音箱名称 | 98 | //修改音箱名称 |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/activity/ConnFailActivity.java
| @@ -3,9 +3,11 @@ package com.cnlive.strike.xiaojiaspeaker.ui.activity; | @@ -3,9 +3,11 @@ package com.cnlive.strike.xiaojiaspeaker.ui.activity; | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | import android.content.Intent; | 4 | import android.content.Intent; |
| 5 | import android.databinding.DataBindingUtil; | 5 | import android.databinding.DataBindingUtil; |
| 6 | +import android.net.Uri; | ||
| 6 | import android.support.v4.content.ContextCompat; | 7 | import android.support.v4.content.ContextCompat; |
| 7 | import android.support.v7.app.AppCompatActivity; | 8 | import android.support.v7.app.AppCompatActivity; |
| 8 | import android.os.Bundle; | 9 | import android.os.Bundle; |
| 10 | +import android.text.TextUtils; | ||
| 9 | import android.view.View; | 11 | import android.view.View; |
| 10 | 12 | ||
| 11 | import com.cnlive.libs.base.util.StatusBarUtil; | 13 | import com.cnlive.libs.base.util.StatusBarUtil; |
| @@ -15,16 +17,30 @@ import com.cnlive.strike.xiaojiaspeaker.databinding.ActivityConnFailBinding; | @@ -15,16 +17,30 @@ import com.cnlive.strike.xiaojiaspeaker.databinding.ActivityConnFailBinding; | ||
| 15 | 17 | ||
| 16 | public class ConnFailActivity extends AppCompatActivity { | 18 | public class ConnFailActivity extends AppCompatActivity { |
| 17 | private ActivityConnFailBinding binding; | 19 | private ActivityConnFailBinding binding; |
| 20 | + private String phone; | ||
| 18 | 21 | ||
| 19 | @Override | 22 | @Override |
| 20 | protected void onCreate(Bundle savedInstanceState) { | 23 | protected void onCreate(Bundle savedInstanceState) { |
| 21 | super.onCreate(savedInstanceState); | 24 | super.onCreate(savedInstanceState); |
| 22 | binding = DataBindingUtil.setContentView(this, R.layout.activity_conn_fail); | 25 | binding = DataBindingUtil.setContentView(this, R.layout.activity_conn_fail); |
| 23 | - initTopBar(); | ||
| 24 | if (null != getIntent().getExtras()) { | 26 | if (null != getIntent().getExtras()) { |
| 25 | - String phone = getIntent().getExtras().getString("phone"); | 27 | + phone = getIntent().getExtras().getString("phone"); |
| 28 | + } | ||
| 29 | + if (!TextUtils.isEmpty(phone)) { | ||
| 26 | binding.tvTip.setText("该设备已被" + phone + "绑定"); | 30 | binding.tvTip.setText("该设备已被" + phone + "绑定"); |
| 27 | } | 31 | } |
| 32 | + if (phone.indexOf("X") != -1 || phone.indexOf("x") != -1 || phone.indexOf("*") != -1) { | ||
| 33 | + binding.llCallView.setVisibility(View.GONE); | ||
| 34 | + } else { | ||
| 35 | + binding.llCallView.setVisibility(View.VISIBLE); | ||
| 36 | + } | ||
| 37 | + binding.btnCall.setOnClickListener(new View.OnClickListener() { | ||
| 38 | + @Override | ||
| 39 | + public void onClick(View v) { | ||
| 40 | + call(phone); | ||
| 41 | + } | ||
| 42 | + }); | ||
| 43 | + initTopBar(); | ||
| 28 | } | 44 | } |
| 29 | 45 | ||
| 30 | private void initTopBar() { | 46 | private void initTopBar() { |
| @@ -46,4 +62,15 @@ public class ConnFailActivity extends AppCompatActivity { | @@ -46,4 +62,15 @@ public class ConnFailActivity extends AppCompatActivity { | ||
| 46 | intent.putExtra("phone", phone); | 62 | intent.putExtra("phone", phone); |
| 47 | activity.startActivity(intent); | 63 | activity.startActivity(intent); |
| 48 | } | 64 | } |
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * 调用拨号界面 | ||
| 68 | + * | ||
| 69 | + * @param phone 电话号码 | ||
| 70 | + */ | ||
| 71 | + private void call(String phone) { | ||
| 72 | + Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phone)); | ||
| 73 | + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
| 74 | + startActivity(intent); | ||
| 75 | + } | ||
| 49 | } | 76 | } |
module_xiaojiaSoundBox/src/main/res/layout/activity_conn_fail.xml
| @@ -40,5 +40,35 @@ | @@ -40,5 +40,35 @@ | ||
| 40 | android:layout_marginTop="100dp" | 40 | android:layout_marginTop="100dp" |
| 41 | android:textColor="@color/color_999999" | 41 | android:textColor="@color/color_999999" |
| 42 | android:textSize="15sp" /> | 42 | android:textSize="15sp" /> |
| 43 | + | ||
| 44 | + <LinearLayout | ||
| 45 | + android:id="@+id/ll_call_view" | ||
| 46 | + android:layout_width="match_parent" | ||
| 47 | + android:layout_height="wrap_content" | ||
| 48 | + android:gravity="center" | ||
| 49 | + android:orientation="vertical" | ||
| 50 | + android:visibility="gone" | ||
| 51 | + > | ||
| 52 | + | ||
| 53 | + <TextView | ||
| 54 | + android:layout_width="wrap_content" | ||
| 55 | + android:layout_height="wrap_content" | ||
| 56 | + android:layout_gravity="center" | ||
| 57 | + android:layout_marginTop="20dp" | ||
| 58 | + android:text="请联系对方删除此设备或添加你为音箱“使用者”" | ||
| 59 | + android:textColor="@color/color_999999" | ||
| 60 | + android:textSize="15sp" /> | ||
| 61 | + | ||
| 62 | + <Button | ||
| 63 | + android:id="@+id/btn_call" | ||
| 64 | + android:layout_width="100dp" | ||
| 65 | + android:layout_height="35dp" | ||
| 66 | + android:layout_marginTop="30dp" | ||
| 67 | + android:background="@drawable/selector_xiaojia_btn_green" | ||
| 68 | + android:text="联系" | ||
| 69 | + android:textColor="@color/white" | ||
| 70 | + android:textSize="16sp" | ||
| 71 | + android:textStyle="bold" /> | ||
| 72 | + </LinearLayout> | ||
| 43 | </LinearLayout> | 73 | </LinearLayout> |
| 44 | </layout> | 74 | </layout> |
| 45 | \ No newline at end of file | 75 | \ No newline at end of file |