Commit 09ff24fa by jeffrey

1.2

parent 83c066c0
...@@ -22,8 +22,8 @@ android { ...@@ -22,8 +22,8 @@ android {
applicationId "com.xf.weixinclick" applicationId "com.xf.weixinclick"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 25 targetSdkVersion 25
versionCode 1 versionCode 3
versionName "1.0" versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild { externalNativeBuild {
cmake { cmake {
......
package com.xf.weixinclick;
import android.annotation.TargetApi;
import android.os.BatteryManager;
import android.os.Build;
import android.text.TextUtils;
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.xf.weixinclick.http.HttpClientApi;
import com.xf.weixinclick.utils.SP;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.Subscriber;
import static android.content.Context.BATTERY_SERVICE;
/**
* 创建日期:2018/3/20 on 10:26
* 描述:
* 作者:Li
*/
public class HeartBeatAction {
private static HeartBeatAction heartBeatAction;
private boolean isRunning = false;
public static HeartBeatAction get(){
if (heartBeatAction == null){
heartBeatAction = new HeartBeatAction();
}
return heartBeatAction;
}
public void start(){
if (isRunning){
return;
}
isRunning = true;
startHeartBeat();
}
private void startHeartBeat(){
Observable.interval(60, TimeUnit.SECONDS)
.subscribe(new Subscriber<Long>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(Long aLong) {
String name = (String) SP.getParam("divice", "");
if (TextUtils.isEmpty(name)){
return;
}
HttpClientApi.heartBat(name,
PushServiceFactory.getCloudPushService().getDeviceId(),getBattery());
}
});
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static int getBattery(){
BatteryManager batteryManager = (BatteryManager) myApplication.getInstence().getSystemService(BATTERY_SERVICE);
int capacity = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
return capacity;
}
}
package com.xf.weixinclick; package com.xf.weixinclick;
import android.annotation.TargetApi;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.BatteryManager;
import android.os.Build;
import android.support.v7.app.NotificationCompat; import android.support.v7.app.NotificationCompat;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView;
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory; import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.google.gson.Gson; import com.google.gson.Gson;
...@@ -24,9 +31,12 @@ import org.greenrobot.eventbus.EventBus; ...@@ -24,9 +31,12 @@ import org.greenrobot.eventbus.EventBus;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.logging.Handler; import java.util.logging.Handler;
import butterknife.BindView; import butterknife.BindView;
import rx.Observable;
import rx.Subscriber;
/** /**
* Created by X-FAN on 2017/01/01. * Created by X-FAN on 2017/01/01.
...@@ -42,6 +52,8 @@ public class MainActivity extends BaseActivity { ...@@ -42,6 +52,8 @@ public class MainActivity extends BaseActivity {
@BindView(R.id.cet_bind_user) @BindView(R.id.cet_bind_user)
EditText cet_bind_user; EditText cet_bind_user;
@BindView(R.id.tv_version_name)
TextView tv_version_name;
@Override @Override
int getContentView() { int getContentView() {
return R.layout.activity_main; return R.layout.activity_main;
...@@ -50,7 +62,7 @@ public class MainActivity extends BaseActivity { ...@@ -50,7 +62,7 @@ public class MainActivity extends BaseActivity {
@Override @Override
void initAction() { void initAction() {
HeartBeatAction.get().start();
cet_bind_user.setText(SP.getParam("divice", "").toString()); cet_bind_user.setText(SP.getParam("divice", "").toString());
...@@ -64,12 +76,15 @@ public class MainActivity extends BaseActivity { ...@@ -64,12 +76,15 @@ public class MainActivity extends BaseActivity {
} }
}); });
tv_version_name.setText("版本号 :" + getLocalVersionName(this));
tv_bind.setOnClickListener(new View.OnClickListener() { tv_bind.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
final String d_name = cet_bind_user.getText().toString(); final String d_name = cet_bind_user.getText().toString();
HttpClientApi.devices(d_name, HttpClientApi.devices(d_name,
PushServiceFactory.getCloudPushService().getDeviceId(), PushServiceFactory.getCloudPushService().getDeviceId(),
HeartBeatAction.getBattery(),
new HttpSubscriber<String>() { new HttpSubscriber<String>() {
@Override @Override
public void onCompleted() { public void onCompleted() {
...@@ -123,7 +138,8 @@ public class MainActivity extends BaseActivity { ...@@ -123,7 +138,8 @@ public class MainActivity extends BaseActivity {
e.printStackTrace(); e.printStackTrace();
} }
ReceiverMsg msg = new ReceiverMsg(); ReceiverMsg msg = new ReceiverMsg();
msg.setQr_addr("https://weapp-dev.wangjia.com/qr.jpg?dd=1"); msg.setQr_addr("http://test.mp-watch.checheng.net/qr-addr?url=http%253A%252F%252Ftest.mp-watch.checheng.net%252Ftemp%252Fspider%252Fgh_4e07defd60d4%252Flogin_qrcode.png?1522133567961");
// msg.setQr_addr("https://weapp-dev.wangjia.com/qr.jpg?dd=1");
msg.setUnique_id("1111111111111"); msg.setUnique_id("1111111111111");
msg.setTime_config(new Gson().fromJson("{\"qrcode_timeout\":60,\"after_open_weixin_index_delay\":2000,\"after_open_weixin_file_helper_delay\":6000,\"after_paste_message_delay\":2000,\"after_send_message_delay\":2000,\"after_click_message_delay\":5000,\"long_press_qrcode_delay\":4000,\"after_click_decode_button_delay\":5000,\"after_click_confirm_button_delay\":3000}", DelayBean.class)); msg.setTime_config(new Gson().fromJson("{\"qrcode_timeout\":60,\"after_open_weixin_index_delay\":2000,\"after_open_weixin_file_helper_delay\":6000,\"after_paste_message_delay\":2000,\"after_send_message_delay\":2000,\"after_click_message_delay\":5000,\"long_press_qrcode_delay\":4000,\"after_click_decode_button_delay\":5000,\"after_click_confirm_button_delay\":3000}", DelayBean.class));
EventBus.getDefault().post(msg); EventBus.getDefault().post(msg);
...@@ -135,4 +151,20 @@ public class MainActivity extends BaseActivity { ...@@ -135,4 +151,20 @@ public class MainActivity extends BaseActivity {
} }
public static String getLocalVersionName(Context ctx) {
String localVersion = "";
try {
PackageInfo packageInfo = ctx.getApplicationContext()
.getPackageManager()
.getPackageInfo(ctx.getPackageName(), 0);
localVersion = packageInfo.versionName;
Log.d("TAG", "本软件的版本名。。" + localVersion);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return localVersion;
}
} }
...@@ -165,8 +165,13 @@ public class NewService extends AccessibilityService { ...@@ -165,8 +165,13 @@ public class NewService extends AccessibilityService {
@Override @Override
public void delayMethord() { public void delayMethord() {
if (WeChatStatus.status[0] ) { if (WeChatStatus.status[0] ) {
Log.d("fei ", "进入文件传输详情页面"); Log.d("fei ", "进入文件传输详情页面");
if (fill()) { if (fill()) {
//填充完了 有时候发送不出现,那就再点击下文字 ,点完了要变下空白区域 让输入框消失
execShellCmd("input tap " + dip2px(130) + " " + dip2px(600));
execShellCmd("input tap " + dip2px(10) + " " + dip2px(200));
Log.d("fei ", "文件传输详情页面_填充成功准备发送"); Log.d("fei ", "文件传输详情页面_填充成功准备发送");
delayDeal(delayBean.getAfter_paste_message_delay(), new IDelayMethord() { delayDeal(delayBean.getAfter_paste_message_delay(), new IDelayMethord() {
@Override @Override
......
package com.xf.weixinclick.http; package com.xf.weixinclick.http;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.xf.weixinclick.http.stringfactory.StringConverterFactory; import com.xf.weixinclick.http.stringfactory.StringConverterFactory;
...@@ -119,16 +120,44 @@ public class HttpClientApi { ...@@ -119,16 +120,44 @@ public class HttpClientApi {
.subscribe(subscriber); .subscribe(subscriber);
} }
public static void devices(String name, String code, Subscriber subscriber) { public static void devices(String name, String code,int battery, Subscriber subscriber) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>(3);
map.put("name", name); map.put("name", name);
map.put("code", code); map.put("code", code);
map.put("battery", String.valueOf(battery));
getInstance().devices(map) getInstance().devices(map)
.subscribeOn(io) .subscribeOn(io)
.observeOn(main) .observeOn(main)
.subscribe(subscriber); .subscribe(subscriber);
} }
public static void heartBat(String name, String code,int battery){
Map<String, String> map = new HashMap<>(3);
map.put("name", name);
map.put("code", code);
map.put("battery", String.valueOf(battery));
getInstance().devices(map)
.subscribeOn(io)
.observeOn(io)
.subscribe(new Subscriber<String>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
Log.d("fei","heartBat error " + e);
}
@Override
public void onNext(String s) {
Log.d("fei","heartBat result " + s);
}
});
}
public static void devicesScan(String device_code, int is_success, String message_id, Subscriber subscriber) { public static void devicesScan(String device_code, int is_success, String message_id, Subscriber subscriber) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("device_code", device_code); map.put("device_code", device_code);
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
android:textColor="#ff00ff" android:textColor="#ff00ff"
android:gravity="center" android:gravity="center"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="150dp" /> android:layout_height="100dp" />
<TextView <TextView
android:id="@+id/chat_view" android:id="@+id/chat_view"
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
android:textSize="50sp" android:textSize="50sp"
android:textColor="#000" android:textColor="#000"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="150dp" android:layout_height="100dp"
android:background="#fff000"/> android:background="#fff000"/>
<TextView <TextView
...@@ -45,8 +45,16 @@ ...@@ -45,8 +45,16 @@
android:textSize="50sp" android:textSize="50sp"
android:textColor="#fff" android:textColor="#fff"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="150dp" android:layout_height="100dp"
android:background="#ff6600"/> android:background="#ff6600"/>
<TextView
android:id="@+id/tv_version_name"
android:layout_marginTop="@dimen/text_margin"
android:layout_marginLeft="@dimen/text_margin"
android:layout_width="match_parent"
android:layout_height="20dp"
tools:text="版本号" />
</LinearLayout> </LinearLayout>
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment