<action android:name="com.ic.action.message_sent" />
<action android:name="com.ic.action.temp_result" />
<action android:name="com.ic.action.set_sit_range" />
+ <action android:name="com.ic.dialog.action.DIALOG_RESPONSE" />
<!-- <action android:name="com.eqc.heartrate.action.SILENT_START" /> -->
</intent-filter>
</receiver>
Uri CM_SERVICE_SETTING = Uri.parse("content://com.cmcm.service/cmsetting");
String DIALOG_ACTION = "com.enqualcomm.support.DIALOG";
+ String DIALOG_ACTION_WITH_IC_RESPONSE = "com.ic.dialog.action.DIALOG_RESPONSE";
int ENTER_SILENT_MODE = 212;
import static com.enqualcomm.support.Constants.ActionReceivePushTxt;
import static com.enqualcomm.support.Constants.ActionSrvPushTxt;
import static com.enqualcomm.support.Constants.DIALOG_ACTION;
+import static com.enqualcomm.support.Constants.DIALOG_ACTION_WITH_IC_RESPONSE;
public class ContextProxy {
private static final long ONE_WEEK = 604800000L;
}
public static void sendMsgBroadcast(Context _context, String msg, int msgType) {
-
+ ICLogger.d("sendMsgBroadcast ==> " + msg + " msgType==> " + msgType);
if (msgType == 0) {
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- //本应用弹出消息框
- if (!Config.noPushTxtNotifyDialog) {
- Intent intent = new Intent();
- intent.setAction(DIALOG_ACTION);
- intent.putExtra("pushtxt", msg);
- _context.sendBroadcast(intent);
- } else {
- WakeLockUtil.ScreenOnWakeLockTemperary(_context);
- play_waning_notify(_context);
- VibrateUtil.getInstance(_context).VibrateOnOnce(true);
- Util.mSleep(2000);
- }
- //launcher 弹出消息
- if (!Config.noBroadCastPushTxtNotify) {
- Intent intent = new Intent(ActionSrvPushTxt);
- intent.putExtra("msgType", msgType); //0 代表 server下发消息,1代表 SMS消息
- intent.putExtra("txtMsg", msg);
- intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
- _context.sendBroadcast(intent);
- }
+ mHandler.postDelayed(() -> {
+ //本应用弹出消息框
+ if (!Config.noPushTxtNotifyDialog) {
+ Intent intent = new Intent();
+ intent.setAction(DIALOG_ACTION);
+ intent.putExtra("pushtxt", msg);
+ _context.sendBroadcast(intent);
+ } else {
+ WakeLockUtil.ScreenOnWakeLockTemperary(_context);
+ play_waning_notify(_context);
+ VibrateUtil.getInstance(_context).VibrateOnOnce(true);
+ Util.mSleep(2000);
+ }
+ //launcher 弹出消息
+ if (!Config.noBroadCastPushTxtNotify) {
+ Intent intent = new Intent(ActionSrvPushTxt);
+ intent.putExtra("msgType", msgType); //0 代表 server下发消息,1代表 SMS消息
+ intent.putExtra("txtMsg", msg);
+ intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
+ _context.sendBroadcast(intent);
}
}, 50);
} else if (msgType == 2) {
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- //本应用弹出消息框
- if (Config.noPushTxtNotifyDialog == false) {
- Intent intent = new Intent();
- intent.setAction(DIALOG_ACTION);
- intent.putExtra("pushtxt", msg);
- _context.sendBroadcast(intent);
- } else {
- WakeLockUtil.ScreenOnWakeLockTemperary(_context);
- play_waning_notify(_context);
- VibrateUtil.getInstance(_context).VibrateOnOnce(true);
- Util.mSleep(2000);
- }
- //launcher 弹出消息
- if (Config.noBroadCastPushTxtNotify == false) {
- Intent intent = new Intent(ActionSrvPushTxt);
- intent.putExtra("msgType", msgType); //0 代表 server下发消息,1代表 SMS消息,2代表有提示音的消息
- intent.putExtra("txtMsg", msg);
- intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
- _context.sendBroadcast(intent);
- }
+ mHandler.postDelayed(() -> {
+ //本应用弹出消息框
+ if (!Config.noPushTxtNotifyDialog) {
+ Intent intent = new Intent();
+ intent.setAction(DIALOG_ACTION);
+ intent.putExtra("pushtxt", msg);
+ _context.sendBroadcast(intent);
+ } else {
+ WakeLockUtil.ScreenOnWakeLockTemperary(_context);
+ play_waning_notify(_context);
+ VibrateUtil.getInstance(_context).VibrateOnOnce(true);
+ Util.mSleep(2000);
+ }
+ //launcher 弹出消息
+ if (!Config.noBroadCastPushTxtNotify) {
+ Intent intent = new Intent(ActionSrvPushTxt);
+ intent.putExtra("msgType", msgType); //0 代表 server下发消息,1代表 SMS消息,2代表有提示音的消息
+ intent.putExtra("txtMsg", msg);
+ intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
+ _context.sendBroadcast(intent);
}
}, 50);
} else if (msgType == 3) { //专门给需要回复的消息
-
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- //本应用弹出消息框
- if (Config.noPushTxtNotifyDialog == false) {
- Intent intent = new Intent();
- intent.setAction(DIALOG_ACTION);
- intent.putExtra("pushtxt", msg);
- intent.putExtra("needreply", true);
- _context.sendBroadcast(intent);
- } else {
- WakeLockUtil.ScreenOnWakeLockTemperary(_context);
- play_waning_notify(_context);
- VibrateUtil.getInstance(_context).VibrateOnOnce(true);
- Util.mSleep(2000);
- }
-
+ mHandler.postDelayed(() -> {
+ //本应用弹出消息框
+ if (!Config.noPushTxtNotifyDialog) {
+ Intent intent = new Intent();
+ intent.setAction(DIALOG_ACTION);
+ intent.putExtra("pushtxt", msg);
+ intent.putExtra("needreply", true);
+ _context.sendBroadcast(intent);
+ } else {
+ WakeLockUtil.ScreenOnWakeLockTemperary(_context);
+ play_waning_notify(_context);
+ VibrateUtil.getInstance(_context).VibrateOnOnce(true);
+ Util.mSleep(2000);
}
}, 50);
+ } else if (msgType == 123) {
+ mHandler.postDelayed(() -> {
+ //判断是否有弹窗,如查已经弹窗了,那么亮屏即可
+ Intent intent = new Intent();
+ intent.setAction(DIALOG_ACTION_WITH_IC_RESPONSE);
+ intent.putExtra("pushTxt", msg);
+ intent.putExtra("needReply", true);
+ _context.sendBroadcast(intent);
+ ICLogger.d("s123 send broadcast...");
+ WakeLockUtil.ScreenOnWakeLockTemperary(_context);
+ play_waning_notify(_context);
+ VibrateUtil.getInstance(_context).VibrateOnOnce(true);
+ }, 50);
} else {
-
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- //本应用弹出消息框
- if (Config.noSMSNotifyDialog == false) {
- Intent intent = new Intent();
- intent.setAction(DIALOG_ACTION);
- intent.putExtra("sms", msg);
- _context.sendBroadcast(intent);
- } else {
- WakeLockUtil.ScreenOnWakeLockTemperary(_context);
- play_waning_notify(_context);
- VibrateUtil.getInstance(_context).VibrateOnOnce(true);
- Util.mSleep(2000);
- }
- //launcher 弹出消息
- if (Config.noBroadCastPushTxtNotify == false) {
- Intent intent = new Intent(ActionSrvPushTxt);
- intent.putExtra("msgType", msgType); //0 代表 server下发消息,1代表 SMS消息,2代表有提示音的消息
- intent.putExtra("txtMsg", msg);
- intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
- _context.sendBroadcast(intent);
- }
+ mHandler.postDelayed(() -> {
+ //本应用弹出消息框
+ if (!Config.noSMSNotifyDialog) {
+ Intent intent = new Intent();
+ intent.setAction(DIALOG_ACTION);
+ intent.putExtra("sms", msg);
+ _context.sendBroadcast(intent);
+ } else {
+ WakeLockUtil.ScreenOnWakeLockTemperary(_context);
+ play_waning_notify(_context);
+ VibrateUtil.getInstance(_context).VibrateOnOnce(true);
+ Util.mSleep(2000);
+ }
+ //launcher 弹出消息
+ if (!Config.noBroadCastPushTxtNotify) {
+ Intent intent = new Intent(ActionSrvPushTxt);
+ intent.putExtra("msgType", msgType); //0 代表 server下发消息,1代表 SMS消息,2代表有提示音的消息
+ intent.putExtra("txtMsg", msg);
+ intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
+ _context.sendBroadcast(intent);
}
}, 50);
}
import com.enqualcomm.support.service.Deliver;
import com.enqualcomm.support.service.HeartRateManager;
import com.ic.protocols.protocolAPIHelper;
+import com.ic.view.webmsgresponse.WebMsgView;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.os.PowerManager.ACQUIRE_CAUSES_WAKEUP;
import static com.enqualcomm.support.Constants.ACTION_SET_SIT_RANGE;
import static com.enqualcomm.support.Constants.ACTION_SHUTDOWN;
import static com.enqualcomm.support.Constants.DIALOG_ACTION;
+import static com.enqualcomm.support.Constants.DIALOG_ACTION_WITH_IC_RESPONSE;
import static com.enqualcomm.support.Constants.FROM_SERVER;
import static com.enqualcomm.support.Constants.KEY_MESSAGE_FROM;
import static com.enqualcomm.support.Constants.KEY_MESSAGE_TYPE;
*/
if (msgType.equals("voice")) {
//创建voiceConent并添加到数据
- final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom,"0000", msgUrl, 1, 3);
+ final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom, "0000", msgUrl, 1, 3);
// 把voiceContent拆解成1024的分包
- Util.parseToVoicePacketSent(voiceContent,1024);
+ Util.parseToVoicePacketSent(voiceContent, 1024);
//trigger 分包发送
if (CoreService.getInstance().getConnection() != null)
CoreService.getInstance().getConnection().DeliverCMDMessageToSystem("SentVoicePacket", "");
} else if (msgType.equals("pic")) {
//创建voiceConent并添加到数据
- final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom,"0000", msgUrl, 2, 3);
+ final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom, "0000", msgUrl, 2, 3);
// 把voiceContent拆解成1024的分包
- Util.parseToVoicePacketSent(voiceContent,1024);
+ Util.parseToVoicePacketSent(voiceContent, 1024);
//trigger 分包发送
if (CoreService.getInstance().getConnection() != null) {
String msgUrl = paramIntent.getStringExtra("filepath");
ICLogger.i("receive taken photo to send " + msgUrl);
//创建voiceConent并添加到数据
- final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom,"0000", msgUrl, 2, 2);
+ final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom, "0000", msgUrl, 2, 2);
// 把voiceContent拆解成1024的分包
- Util.parseToVoicePacketSent(voiceContent,1024);
+ Util.parseToVoicePacketSent(voiceContent, 1024);
//trigger 分包发送
if (CoreService.getInstance().getConnection() != null) {
Runtime.lastSitCheckStepCount = CoreService.getInstance().getRuntime().getTotalStepCount();
Runtime.lastSitCheckTiimeyyyyMMddHHmmss = TimeUtil.getSystemTime3();
}
+ } else if (DIALOG_ACTION_WITH_IC_RESPONSE.equals(str)) {
+ ICLogger.d("show response ble dialog..");
+ //弹出一个需要回复的弹窗
+ WebMsgView webMsgView = WebMsgView.getInstance();
+ webMsgView.showMsgDialog();
+ String pushTxt = paramIntent.getStringExtra("pushTxt");
+ ICLogger.d("pushTxt ==> " + pushTxt);
+ webMsgView.setShowMsg(pushTxt);
} else {
//如果来电了,还有未读的消息,干脆关掉,防止影响接电话。
if (mCustomDialog != null && mCustomDialog.isShowing()) {
mCustomDialog.dismiss();
}
-
if (this.mCustomNotification != null && this.mCustomNotification.isShowing()) {
this.mCustomNotification.dismiss();
}
return sb.toString();
}
+ /**
+ * 16进制直接转换成为字符串(无需Unicode解码)
+ *
+ * @param hex Byte字符串(Byte之间无分隔符
+ * @return 对应的字符串
+ * @author xxs
+ */
+ public static String hexStr2Str(String hex, String charSet) {
+ String hexStr = "";
+ String str = "0123456789ABCDEF"; //16进制能用到的所有字符 0-15
+ for (int i = 0; i < hex.length(); i++) {
+ String s = hex.substring(i, i + 1);
+ if (s.equals("a") || s.equals("b") || s.equals("c") || s.equals("d") || s.equals("e") || s.equals("f")) {
+ s = s.toUpperCase().substring(0, 1);
+ }
+ hexStr += s;
+ }
+
+ char[] hexs = hexStr.toCharArray();//toCharArray() 方法将字符串转换为字符数组。
+ int length = (hexStr.length() / 2);//1个byte数值 -> 两个16进制字符
+ byte[] bytes = new byte[length];
+ int n;
+ for (int i = 0; i < bytes.length; i++) {
+ int position = i * 2;//两个16进制字符 -> 1个byte数值
+ n = str.indexOf(hexs[position]) * 16;
+ n += str.indexOf(hexs[position + 1]);
+ // 保持二进制补码的一致性 因为byte类型字符是8bit的 而int为32bit 会自动补齐高位1 所以与上0xFF之后可以保持高位一致性
+ //当byte要转化为int的时候,高的24位必然会补1,这样,其二进制补码其实已经不一致了,&0xff可以将高的24位置为0,低8位保持原样,这样做的目的就是为了保证二进制数据的一致性。
+ bytes[i] = (byte) (n & 0xff);
+ }
+ String name = "";
+ try {
+ name = new String(bytes, charSet);
+ } catch (UnsupportedEncodingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return name;
+ }
+
/**
* 此函数专门给L02 协议使用 ,解析名字用
*
//IWAP94,123456,1,XXXXXXXXXXXXXXXX
//以下这部分内容由UI给到数据库再给过来
//123456,1,XXXXXXXXXXXXXXXX
- //TODO:
+ String[] split = value.split(CMDSPLIT);
+ if (split.length == 3) {
+ //对数据进行编码
+ genStringMessage(cmdMap.get(CMD_TYPE.AP94),
+ new StringBuilder()
+ .append(CMDHEADER)
+ .append(cmdMap.get(CMD_TYPE.AP94))
+ .append(CMDSPLIT).append(split[0])
+ .append(CMDSPLIT).append(split[1])
+ .append(CMDSPLIT).append(Util.utf8ToUnicode(split[2]))
+ .append(CMDEND)
+ .toString());
+ } else {
+ ICLogger.d("parse send msg error==> " + value);
+ }
}
public enum CMD_TYPE {
String[] cmdlist = cmd.split(",");
if (cmdlist.length == 6) {
-
-
log("com.ic.work mode " + cmdlist[3]);
try {
int mod = Integer.parseInt(cmdlist[3]);
ICLogger.d("cmd == > " + cmd);
//这里的切割,如查是云图的后台,会有问题,如果文本内容里有,那么就会切割出错了。所以需要后台去解决这个问题。
String[] cmdlist = cmd.split(",");
- ICLogger.d("cmdlist length == > " + cmdlist);
- if (cmdlist.length == 4) {
- String cmdindex = cmdlist[2];
- String txtmsg = cmdlist[3];
- StringBuilder sb = new StringBuilder();
- Runtime.PushtxtMsg_srv_index = cmdindex;//给回复AP94用
- sb.append(cmdindex).append(CMDSPLIT).append(TimeUtil.getSystemTimeyyyyMMddHHmmss()).append(CMDSPLIT).append(txtmsg);
- if (Config.custom_name.equals("VitracK")) {
-
- } else if (Util.getSystemProperties("persist.sys.pushtxt_encode", "gb2312").equals("utf-8")) {
- // txtmsg = Util.decodeUnicode2Utf8(txtmsg);
+ ICLogger.d("cmdlist length == > " + cmdlist.length);
+ if (cmdlist.length == 5) {
+ String cmdIndex = cmdlist[2];
+ //新增加的类型
+ //TODO:
+ String type = cmdlist[3];
+ ICLogger.d("web msg type ==> " + type);
+ String txtMsg = Util.hexStr2Str(cmdlist[4], "gb2312");
+ if ("2".equals(type)) {
+ //文本消息
+ StringBuilder sb = new StringBuilder();
+ Runtime.PushtxtMsg_srv_index = cmdIndex;//给回复AP94用
+ sb.append(cmdIndex).append(CMDSPLIT).append(TimeUtil.getSystemTimeyyyyMMddHHmmss()).append(CMDSPLIT).append(txtMsg);
+ if (Config.custom_name.equals("VitracK")) {
+
+ } else if (Util.getSystemProperties("persist.sys.pushtxt_encode", "gb2312").equals("utf-8")) {
+ // txtmsg = Util.decodeUnicode2Utf8(txtmsg);
// txtmsg = Util.UrlGB2312ToUTF8(txtmsg);
- txtmsg = Util.UrlUTF8ToStrUTF8(txtmsg);
- } else {
- txtmsg = Util.UrlGB2312ToUTF8(txtmsg);
- }
- StringMessage msg = AP40(cmdindex, 1);
- //设定当前工作模式及循环频率
- connection.send(msg);
- ICLogger.i("received Txt Msg " + txtmsg);
- if (!Config.noPushTxtReadReply) {
- Config.setLastUnReadMessage(runtime.getContextProxy().context, sb.toString());
- runtime.getContextProxy().sendMsgBroadcast(txtmsg, 3);//msgType 3需要回复,0不需要回复
- } else {
- //读取一个变量值,判断是否强制弹窗
- String forceReadMsg = Util.getSystemProperties("persist.sys.forcereadmsg");
- ICLogger.d("forceReadMsg == > " + forceReadMsg);
- if (!TextUtils.isEmpty(forceReadMsg)) {
- //强制阅读的话,弹窗显示
- MsgMustReadDialog instance = MsgMustReadDialog.getInstance();
- instance.showMsgDialog();
- List<String> list = new ArrayList<>();
- list.add(txtmsg);
- instance.addData(list);
+ txtMsg = Util.UrlUTF8ToStrUTF8(txtMsg);
} else {
- //msgType 3需要回复,0不需要回复
- runtime.getContextProxy().sendMsgBroadcast(txtmsg, 0);
+ txtMsg = Util.UrlGB2312ToUTF8(txtMsg);
}
+ StringMessage msg = AP40(cmdIndex, 1);
+ //设定当前工作模式及循环频率
+ connection.send(msg);
+ ICLogger.i("received Txt Msg " + txtMsg);
+ if (!Config.noPushTxtReadReply) {
+ Config.setLastUnReadMessage(runtime.getContextProxy().context, sb.toString());
+ runtime.getContextProxy().sendMsgBroadcast(txtMsg, 3);//msgType 3需要回复,0不需要回复
+ } else {
+ //读取一个变量值,判断是否强制弹窗
+ String forceReadMsg = Util.getSystemProperties("persist.sys.forcereadmsg");
+ ICLogger.d("forceReadMsg == > " + forceReadMsg);
+ if (!TextUtils.isEmpty(forceReadMsg)) {
+ //强制阅读的话,弹窗显示
+ MsgMustReadDialog instance = MsgMustReadDialog.getInstance();
+ instance.showMsgDialog();
+ List<String> list = new ArrayList<>();
+ list.add(txtMsg);
+ instance.addData(list);
+ } else {
+ //msgType 3需要回复,0不需要回复
+ //123表示s123的,需要回复已读,或者回复文本消息
+ runtime.getContextProxy().sendMsgBroadcast(txtMsg, 123);
+ }
+ }
+ //保存到云短信的库里
+ ContentResolver resolver = runtime.getContextProxy().getResolver();
+ ContentValues contentValues = new ContentValues();
+ contentValues.put(ICDatabaseHelper.web_sms_content, txtMsg);
+ //弹窗表示已阅读了
+ contentValues.put(ICDatabaseHelper.web_sms_has_read, 1);
+ contentValues.put(ICDatabaseHelper.web_sms_create_time, System.currentTimeMillis());
+ resolver.insert(Uri.parse(WebSmsProvider.WEB_MSG), contentValues);
+ //保存到数据库里,以下是原来的做法
+ //runtime.getContextProxy().saveMstToSMSDB(txtmsg);
}
- //保存到云短信的库里
- ContentResolver resolver = runtime.getContextProxy().getResolver();
- ContentValues contentValues = new ContentValues();
- contentValues.put(ICDatabaseHelper.web_sms_content, txtmsg);
- //弹窗表示已阅读了
- contentValues.put(ICDatabaseHelper.web_sms_has_read, 1);
- contentValues.put(ICDatabaseHelper.web_sms_create_time, System.currentTimeMillis());
- resolver.insert(Uri.parse(WebSmsProvider.WEB_MSG), contentValues);
- //保存到数据库里,以下是原来的做法
- //runtime.getContextProxy().saveMstToSMSDB(txtmsg);
} else {
ICLogger.i("BP40 format error!");
}
break;
case BP40:
//服务器推送文本
- handleBP40(mConnection, mRuntime, cmd);
ICLogger.i("收到服务器推送文本消息");
+ handleBP40(mConnection, mRuntime, cmd);
mConnection.DeliverCMDMessageToSystem("showTxt", cmd);//通知下面线程状态变化
break;
case BPXL:
- handleBPXL(cmd, mConnection);
ICLogger.i("收到服务器心率检测命令");
+ handleBPXL(cmd, mConnection);
if (mRuntime.check_stat_do_ppg_test()) {
HeartRateManager.getInstance().triggerPPGTest(FROM_SERVER);
}
--- /dev/null
+package com.ic.view.webmsgresponse;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.enqualcomm.support.R;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ShootItemAdapter extends RecyclerView.Adapter<ShootItemAdapter.InnerHolder> {
+
+ private final List<String> dataList = new ArrayList<>();
+ private OnItemClickListener mItemClickListener;
+
+ @Override
+ public InnerHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_shoot, parent, false);
+ return new InnerHolder(itemView);
+ }
+
+ @Override
+ public void onBindViewHolder(InnerHolder holder, int position) {
+ TextView itemTextView = (TextView) holder.itemView.findViewById(R.id.shoot_item_tv);
+ String itemText = dataList.get(position);
+ itemTextView.setText(itemText);
+ //设置点击事件
+ holder.itemView.setOnClickListener(v -> {
+ if (mItemClickListener != null) {
+ mItemClickListener.onItemClick(itemText);
+ }
+ });
+ }
+
+ @Override
+ public int getItemCount() {
+ return dataList.size();
+ }
+
+ public void updateData(List<String> dataList) {
+ this.dataList.clear();
+ this.dataList.addAll(dataList);
+ notifyDataSetChanged();
+ }
+
+
+ public void setOnItemClickListener(OnItemClickListener listener) {
+ this.mItemClickListener = listener;
+ }
+
+ public interface OnItemClickListener {
+ void onItemClick(String text);
+ }
+
+
+ public class InnerHolder extends RecyclerView.ViewHolder {
+ public InnerHolder(View itemView) {
+ super(itemView);
+ }
+ }
+}
--- /dev/null
+package com.ic.view.webmsgresponse;
+
+import android.graphics.Rect;
+import android.support.v4.view.PagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.enqualcomm.support.R;
+
+import java.util.List;
+
+public class WebMessageAdapter extends PagerAdapter {
+
+ private final ViewPager mViewPager;
+ private TextView webMsgView;
+ private RecyclerView shootListView;
+ private String mCurrentText;
+ private ShootItemAdapter shootItemAdapter;
+ private List<String> mResponseTextList;
+ private View replyBtn;
+
+ public WebMessageAdapter(ViewPager msgPage) {
+ this.mViewPager = msgPage;
+ }
+
+ @Override
+ public Object instantiateItem(ViewGroup container, int position) {
+ //根据位置来加载内容
+ View item;
+ if (position == 0) {
+ item = View.inflate(container.getContext(), R.layout.web_msg_item_content, null);
+ webMsgView = (TextView) item.findViewById(R.id.web_msg_tv);
+ if (TextUtils.isEmpty(mCurrentText)) {
+ webMsgView.setText(mCurrentText);
+ }
+ replyBtn = item.findViewById(R.id.reply_btn);
+ //设置点击事件
+ replyBtn.setOnClickListener(v -> {
+ //跳转到列表页面
+ if (mViewPager != null) {
+ //第二个页面是数据选择的页面
+ mViewPager.setCurrentItem(1);
+ }
+ });
+ } else if (position == 1) {
+ item = View.inflate(container.getContext(), R.layout.web_msg_item_shoot, null);
+ shootListView = (RecyclerView) item.findViewById(R.id.shoot_list_view);
+ if (shootItemAdapter == null) {
+ shootItemAdapter = new ShootItemAdapter();
+ }
+ shootListView.setLayoutManager(new LinearLayoutManager(container.getContext()));
+ shootListView.addItemDecoration(new RecyclerView.ItemDecoration() {
+ @Override
+ public void getItemOffsets(Rect outRect, View view,
+ RecyclerView parent,
+ RecyclerView.State state) {
+ outRect.top = 1;
+ outRect.bottom = 1;
+ }
+ });
+ //设置适配器
+ shootListView.setAdapter(shootItemAdapter);
+ if (mResponseTextList != null) {
+ shootItemAdapter.updateData(mResponseTextList);
+ }
+ } else if (position == 2) {
+ item = View.inflate(container.getContext(), R.layout.web_msg_item_success, null);
+ } else {
+ item = View.inflate(container.getContext(), R.layout.web_msg_item_fail, null);
+ }
+ container.addView(item);
+ return item;
+ }
+
+ @Override
+ public void destroyItem(ViewGroup container, int position, Object object) {
+ container.removeView((View) object);
+ }
+
+ @Override
+ public int getCount() {
+ return 4;//4个页面,
+ //一个是消息页面,
+ //一个是快捷回复页面
+ //一个是成功页面
+ //一个是失败页面
+ }
+
+ @Override
+ public boolean isViewFromObject(View view, Object object) {
+ return view == object;
+ }
+
+ @Override
+ public int getItemPosition(Object object) {
+ return POSITION_NONE;
+ }
+
+ public void updateShootList(List<String> responseText) {
+ this.mResponseTextList = responseText;
+ if (shootItemAdapter != null) {
+ shootItemAdapter.updateData(responseText);
+ }
+ }
+
+ public void updateMsgText(String text) {
+ this.mCurrentText = text;
+ if (webMsgView != null) {
+ webMsgView.setText(text);
+ }
+ }
+}
--- /dev/null
+package com.ic.view.webmsgresponse;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+import android.support.v4.view.ViewPager;
+import android.text.TextUtils;
+import android.view.Gravity;
+import android.view.View;
+import android.view.WindowManager;
+
+import com.enqualcomm.support.ICApplication;
+import com.enqualcomm.support.R;
+import com.enqualcomm.support.provider.ShootTextProvider;
+import com.enqualcomm.support.utils.ICLogger;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 云消息&短信弹窗
+ * 直接塞到Window里
+ * 要求:不阅读完,不可以关闭
+ * 交互:阅读完,有下一页的按钮,最后一页才有关闭按钮。
+ */
+public class WebMsgView {
+
+ private WindowManager windowManager;
+ private WebMessageAdapter messageAdapter;
+ private ViewPager msgPage;
+ private ExecutorService executorService;
+ private ContentResolver contentResolver;
+ private View view;
+ private String currentText;
+
+ private WebMsgView() {
+ //获取到数据库里的数据,显示快捷回复列表
+ executorService = Executors.newSingleThreadExecutor();
+ }
+
+ private final List<String> responseText = new ArrayList<>();
+
+ private void initShootData() {
+ executorService.execute(() -> {
+ responseText.clear();
+ contentResolver = ICApplication.sContext.getContentResolver();
+ Cursor query = contentResolver.query(Uri.parse(ShootTextProvider.SHOOT_TEXT),
+ new String[]{"_id", "value"},
+ "type=?", new String[]{"3"}, null);
+ if (query != null) {
+ while (query.moveToNext()) {
+ String text = query.getString(1);
+ ICLogger.d("text ==> " + text);
+ responseText.add(text);
+ }
+ query.close();
+ }
+ if (view != null && messageAdapter != null) {
+ view.post(() -> {
+ messageAdapter.updateShootList(responseText);
+ });
+ }
+ });
+ }
+
+ private static WebMsgView sInstance;
+
+ public static WebMsgView getInstance() {
+ if (sInstance == null) {
+ sInstance = new WebMsgView();
+ }
+ return sInstance;
+ }
+
+ private boolean isShow = false;
+
+ public void showMsgDialog() {
+ ICLogger.d("showMsgDialog..." + isShow);
+ if (isShow) {
+ return;
+ }
+ isShow = true;
+ Context context = ICApplication.sContext;
+ windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ //设置属性
+ WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
+ layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
+ //这个是针对S123的屏幕,如果要适配其他,可以动态获取屏幕宽度,高度,再以百分比的形式计算即可。
+ layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
+ layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
+ layoutParams.packageName = context.getPackageName();
+ layoutParams.gravity = Gravity.CENTER;
+ //加载布局
+ view = View.inflate(context, R.layout.msg_dialog_layout, null);
+ //设置适配器
+ initView(view);
+ //准备数据
+ //添加到Window里
+ initShootData();
+ windowManager.addView(view, layoutParams);
+ }
+
+ public void setShowMsg(String text) {
+ this.currentText = text;
+ //设置要显示的消息
+ if (messageAdapter != null) {
+ messageAdapter.updateMsgText(text);
+ }
+ }
+
+ public void dismiss() {
+ executorService.shutdown();
+ executorService = null;
+ sInstance = null;
+ contentResolver = null;
+ }
+
+
+ private void initView(final View view) {
+ msgPage = (ViewPager) view.findViewById(R.id.msg_pager);
+ msgPage.setOffscreenPageLimit(2);
+ //设置适配器
+ messageAdapter = new WebMessageAdapter(msgPage);
+ if (!TextUtils.isEmpty(currentText)) {
+ messageAdapter.updateMsgText(currentText);
+ }
+ msgPage.setAdapter(messageAdapter);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:drawable="@drawable/shape_item_bg_press" android:state_pressed="true" />
+ <item android:drawable="@drawable/shape_item_bg_normal" />
+</selector>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="#E7E5E5" />
+</shape>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+
+
+ <solid android:color="#B7B5B6" />
+
+
+</shape>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+
+ <corners android:radius="10dp" />
+
+ <solid android:color="#A6A6A6" />
+
+</shape>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/shoot_item_tv"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@drawable/selector_item_bg"
+ android:paddingLeft="10dp"
+ android:paddingTop="20dp"
+ android:paddingBottom="20dp"
+ android:textColor="@android:color/background_dark"
+ android:textSize="20sp"
+ android:textStyle="bold"
+ app:layout_constraintTop_toTopOf="parent">
+
+</TextView>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#ffffff">
+
+
+ <LinearLayout
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="#117CFD"
+ android:gravity="center_horizontal"
+ android:padding="10dp"
+ android:text="@string/web_sms_title_text"
+ android:textColor="@android:color/black"
+ android:textSize="20sp"
+ app:layout_constraintBottom_toTopOf="@id/container" />
+
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1">
+
+ <TextView
+ android:id="@+id/web_msg_tv"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="left|top"
+ android:padding="10dp"
+ android:textColor="#000"
+ android:textSize="20sp"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ </ScrollView>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="#117CFD"
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/reply_btn"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:padding="10dp"
+ android:text="@string/reply_text"
+ android:textColor="#fff"
+ android:textSize="26sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/read_btn"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:padding="10dp"
+ android:text="@string/read_text"
+ android:textColor="#fff"
+ android:textSize="26sp"
+ android:textStyle="bold" />
+
+ </LinearLayout>
+
+ </LinearLayout>
+
+
+</android.support.constraint.ConstraintLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+
+ <ImageView
+ android:id="@+id/top_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="30dp"
+ android:src="@mipmap/icon_failed"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dp"
+ android:layout_marginTop="10dp"
+ android:layout_marginRight="10dp"
+ android:background="@drawable/shape_text_bg"
+ android:gravity="center"
+ android:padding="20dp"
+ android:text="@string/send_msg_error_tips_text"
+ android:textColor="@android:color/background_dark"
+ android:textSize="20sp"
+ android:textStyle="bold"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/top_icon" />
+
+
+</android.support.constraint.ConstraintLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+
+ <LinearLayout
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#ffffff"
+ android:orientation="vertical"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="#117CFD"
+ android:gravity="center_horizontal"
+ android:padding="10dp"
+ android:text="@string/web_sms_title_text"
+ android:textColor="@android:color/black"
+ android:textSize="26sp"
+ app:layout_constraintBottom_toTopOf="@id/container" />
+
+
+ <android.support.v7.widget.RecyclerView
+ android:id="@+id/shoot_list_view"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="#117CFD"
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/reply_btn"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:padding="10dp"
+ android:text="@string/back_text"
+ android:textColor="#fff"
+ android:textSize="26sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/read_btn"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:padding="10dp"
+ android:text="@string/send_text"
+ android:textColor="#fff"
+ android:textSize="26sp"
+ android:textStyle="bold" />
+
+ </LinearLayout>
+
+ </LinearLayout>
+
+
+</android.support.constraint.ConstraintLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+
+ <ImageView
+ android:id="@+id/top_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="30dp"
+ android:src="@mipmap/icon_success"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dp"
+ android:layout_marginTop="15dp"
+ android:layout_marginRight="10dp"
+ android:background="@drawable/shape_text_bg"
+ android:gravity="center"
+ android:padding="24dp"
+ android:text="@string/send_success_tips_text"
+ android:textColor="@android:color/background_dark"
+ android:textSize="20sp"
+ android:textStyle="bold"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/top_icon" />
+
+</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<string name="low_power_warning_text">低电量报警</string>\r
<string name="sos_warning_msg_text">SOS紧急报警</string>\r
<string name="sos_sms_content_text">%s发出了SOS信号。%s</string>\r
+ <string name="read_text">已阅读</string>\r
+ <string name="reply_text">回复</string>\r
+ <string name="send_msg_error_tips_text">发送失败请重试</string>\r
+ <string name="send_success_tips_text">发送成功</string>\r
+ <string name="back_text">返回</string>\r
+ <string name="send_text">发送</string>\r
</resources>\r
<string name="low_power_warning_text">低电量报警</string>\r
<string name="sos_warning_msg_text">SOS紧急报警</string>\r
<string name="sos_sms_content_text">%s发出了SOS信号。%s</string>\r
+ <string name="read_text">已阅读</string>\r
+ <string name="reply_text">回复</string>\r
+ <string name="send_msg_error_tips_text">发送失败请重试</string>\r
+ <string name="send_success_tips_text">发送成功</string>\r
+ <string name="back_text">返回</string>\r
+ <string name="send_text">发送</string>\r
</resources>\r
<string name="low_power_warning_text">低电量报警</string>\r
<string name="sos_warning_msg_text">SOS紧急报警</string>\r
<string name="sos_sms_content_text">%s发出了SOS信号。%s</string>\r
+ <string name="read_text">已阅读</string>\r
+ <string name="reply_text">回复</string>\r
+ <string name="send_msg_error_tips_text">发送失败请重试</string>\r
+ <string name="send_success_tips_text">发送成功</string>\r
+ <string name="back_text">返回</string>\r
+ <string name="send_text">发送</string>\r
</resources>\r
<string name="low_power_warning_text">低電力アラート</string>
<string name="sos_warning_msg_text">緊急SOS</string>
<string name="sos_sms_content_text">%sからSOSが発信されました。%s</string>
+ <string name="read_text">已阅读</string>
+ <string name="reply_text">回复</string>
+ <string name="send_msg_error_tips_text">发送失败请重试</string>
+ <string name="send_success_tips_text">发送成功</string>
+ <string name="back_text">返回</string>
+ <string name="send_text">发送</string>
</resources>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="read_text">已阅读</string>
+ <string name="reply_text">回复</string>
+ <string name="send_msg_error_tips_text">发送失败请重试</string>
+ <string name="send_success_tips_text">发送成功</string>
+ <string name="back_text">返回</string>
+ <string name="send_text">发送</string>
+</resources>
\ No newline at end of file
<string name="low_power_warning_text">低电量报警</string>
<string name="sos_warning_msg_text">SOS紧急报警</string>
<string name="sos_sms_content_text">%s发出了SOS信号。%s</string>
+ <string name="read_text">已阅读</string>
+ <string name="reply_text">回复</string>
+ <string name="send_msg_error_tips_text">发送失败请重试</string>
+ <string name="send_success_tips_text">发送成功</string>
+ <string name="back_text">返回</string>
+ <string name="send_text">发送</string>
</resources>
<string name="sos_warning_msg_text">SOS紧急报警</string>
<string name="sos_sms_content_text">SOS was sent from "%s". %s</string>
+ <string name="read_text">已阅读</string>
+ <string name="reply_text">回复</string>
+ <string name="send_msg_error_tips_text">发送失败请重试</string>
+ <string name="send_success_tips_text">发送成功</string>
+ <string name="back_text">返回</string>
+ <string name="send_text">发送</string>
</resources>