import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
+import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
private SignalView signalView;
private BatteryView batteryView;
private TextView batteryValueTv;
+ private View wifiView;
+ private View locationView;
+ private View btView;
+ private View connectedView;
+ private View warningMsgUnReadView;
+ private View alarmView;
+ private View newMsgView;
+ private View wearView;
+ private View phoneView;
public StatusBarView(@NonNull Context context) {
this(context, null);
signalView = findViewById(R.id.signal_view);
signalView.noNetwork();
batteryView = findViewById(R.id.right_battery_view);
- batteryView.updateCurrentLev(30);
batteryValueTv = findViewById(R.id.battery_value);
- batteryValueTv.setText(30 + "%");
- MarqueeView marqueeView = findViewById(R.id.mar_queue_view);
+ //MarqueeView marqueeView = findViewById(R.id.mar_queue_view);
+ wifiView = findViewById(R.id.top_icon_wifi);
+ locationView = findViewById(R.id.top_icon_location);
+ btView = findViewById(R.id.top_icon_bt);
+ connectedView = findViewById(R.id.top_icon_connected);
+ warningMsgUnReadView = findViewById(R.id.top_warning_msg_un_read);
+ alarmView = findViewById(R.id.top_icon_alarm);
+ newMsgView = findViewById(R.id.top_icon_new_msg);
+ wearView = findViewById(R.id.top_icon_wear);
+ phoneView = findViewById(R.id.top_icon_phone);
+ phoneView.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ phoneView.setVisibility(GONE);
+ }
+ }, 10 * 1000);
}
public void initPresenter(LifecycleOwner lifecycleOwner) {
statusBarPresenter = StatusBarPresenter.getInstance(getContext());
statusBarPresenter.alarmState.observe(lifecycleOwner, isAlarmOpen -> {
//设置闹钟图标显示还是隐藏
- //TODO:
+ // alarmView.setVisibility(isAlarmOpen ? VISIBLE : GONE);
});
statusBarPresenter.btState.observe(lifecycleOwner, isOpen -> {
- //TODO:蓝牙是否显示
+ //蓝牙是否显示
+ //btView.setVisibility(isOpen ? VISIBLE : GONE);
});
statusBarPresenter.gpsState.observe(lifecycleOwner, isOpen -> {
//GPS定位是否打开
+ locationView.setVisibility(isOpen ? VISIBLE : GONE);
});
statusBarPresenter.icTalkMsgState.observe(lifecycleOwner, hasIcTalkMsg -> {
//是否有微聊消息
+ //TODO:缺少图标
});
statusBarPresenter.isWifiOpen.observe(lifecycleOwner, isWifiOpen -> {
//wifi是否打开
+ wifiView.setVisibility(isWifiOpen ? VISIBLE : GONE);
});
statusBarPresenter.missCallState.observe(lifecycleOwner, hasMiss -> {
//是否有未接电话
+ phoneView.setVisibility(hasMiss ? VISIBLE : GONE);
});
statusBarPresenter.wearState.observe(lifecycleOwner, hasWear -> {
//是否有穿戴
+ wearView.setVisibility(hasWear ? VISIBLE : GONE);
});
statusBarPresenter.msgUnReadState.observe(lifecycleOwner, hasRead -> {
//消息是否有读
+ newMsgView.setVisibility(hasRead ? VISIBLE : GONE);
});
statusBarPresenter.warningReadState.observe(lifecycleOwner, hasRead -> {
- //警告消息是否有读
+ //警告消息是否有没阅读
+ warningMsgUnReadView.setVisibility(hasRead ? VISIBLE : GONE);
});
statusBarPresenter.silentState.observe(lifecycleOwner, isSilent -> {
//是不是静音状态
+ //TODO:缺少
});
statusBarPresenter.batteryLev.observe(lifecycleOwner, lev -> {
//电量还有多少
+ if (lev != null) {
+ batteryValueTv.setText(lev + "%");
+ batteryView.updateCurrentLev(lev);
+ } else {
+ batteryValueTv.setText("0%");
+ batteryView.updateCurrentLev(0);
+ }
});
statusBarPresenter.signalLev.observe(lifecycleOwner, lev -> {
//信号强度
+ if (lev == null) {
+ signalView.updateLev(0);
+ } else {
+ signalView.updateLev(lev);
+ }
});
statusBarPresenter.isCharging.observe(lifecycleOwner, isCharging -> {
//是否在充电
});
+ statusBarPresenter.isServerConnected.observe(lifecycleOwner, isConnected -> {
+ //是否已经链接到服务器
+ connectedView.setVisibility(isConnected ? VISIBLE : GONE);
+ });
}
}
android:src="@mipmap/top_icon_connected"
android:visibility="gone" />
+ <ImageView
+ android:id="@+id/top_icon_wear"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="5dp"
+ android:paddingBottom="5dp"
+ android:src="@mipmap/top_icon_wear"
+ android:visibility="gone" />
+
<ImageView
android:id="@+id/top_warning_msg_un_read"
android:layout_width="wrap_content"
android:layout_marginRight="5dp"
android:text="100%"
android:textColor="@color/white"
+ android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@id/right_battery_view"