update:2019.04.22
fix:增加绑定确认 add:
This commit is contained in:
@@ -15,8 +15,8 @@ android {
|
|||||||
applicationId "com.info.sn"
|
applicationId "com.info.sn"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 17
|
versionCode 18
|
||||||
versionName "1.1.7"
|
versionName "1.1.8"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
ndk {
|
ndk {
|
||||||
@@ -132,9 +132,9 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'com.alibaba:fastjson:1.2.21'
|
implementation 'com.alibaba:fastjson:1.2.21'
|
||||||
|
|
||||||
// implementation 'com.blankj:utilcode:1.26.0'
|
implementation 'com.blankj:utilcode:1.26.0'
|
||||||
implementation 'com.arialyy.aria:core:3.7.10'
|
implementation 'com.arialyy.aria:core:3.8.5'
|
||||||
annotationProcessor 'com.arialyy.aria:compiler:3.7.10'
|
annotationProcessor 'com.arialyy.aria:compiler:3.8.5'
|
||||||
|
|
||||||
implementation "org.java-websocket:Java-WebSocket:1.4.1"
|
implementation "org.java-websocket:Java-WebSocket:1.4.1"
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".service.APKinstallReceiver"
|
android:name=".receiver.APKinstallReceiver"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@@ -167,7 +167,7 @@
|
|||||||
<service android:name=".service.StepService" />
|
<service android:name=".service.StepService" />
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".service.BootReceiver"
|
android:name=".receiver.BootReceiver"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter android:priority="1000">
|
<intent-filter android:priority="1000">
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ import static com.info.sn.jpush.TagAliasOperatorHelper.TagAliasBean;
|
|||||||
import static com.info.sn.jpush.TagAliasOperatorHelper.sequence;
|
import static com.info.sn.jpush.TagAliasOperatorHelper.sequence;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
public static final String REFRESHACTION = BuildConfig.APPLICATION_ID + ".REFRESH";
|
||||||
public static boolean isForeground = false;
|
public static boolean isForeground = false;
|
||||||
private ImageView imageView, exit;
|
private ImageView imageView, exit;
|
||||||
private TextView tv_note, tv_devsn, tv_username, tv_school, tv_grade, tv_version;
|
private TextView tv_note, tv_devsn, tv_username, tv_school, tv_grade, tv_version;
|
||||||
@@ -70,6 +71,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
private int DeviceInfo;
|
private int DeviceInfo;
|
||||||
private long mExitTime;
|
private long mExitTime;
|
||||||
|
|
||||||
|
private RefreshReceiver mRefreshReceiver;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -82,6 +85,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
pm.setApplicationEnabledSetting("com.info.sn", PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
pm.setApplicationEnabledSetting("com.info.sn", PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
||||||
requestPermission();
|
requestPermission();
|
||||||
registerMessageReceiver(); // used for receive msg
|
registerMessageReceiver(); // used for receive msg
|
||||||
|
registerRefreshReceiver();
|
||||||
String rid = JPushInterface.getRegistrationID(getApplicationContext());
|
String rid = JPushInterface.getRegistrationID(getApplicationContext());
|
||||||
if (!rid.isEmpty()) {
|
if (!rid.isEmpty()) {
|
||||||
ToastUtil.debugShow("RegId:" + rid);
|
ToastUtil.debugShow("RegId:" + rid);
|
||||||
@@ -98,6 +102,23 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
startService(new Intent(MainActivity.this, MyDownloadService.class));
|
startService(new Intent(MainActivity.this, MyDownloadService.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void registerRefreshReceiver() {
|
||||||
|
mRefreshReceiver = new RefreshReceiver();
|
||||||
|
IntentFilter filter = new IntentFilter();
|
||||||
|
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||||
|
filter.addAction(REFRESHACTION);
|
||||||
|
registerReceiver(mRefreshReceiver, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RefreshReceiver extends BroadcastReceiver {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (REFRESHACTION.equals(intent.getAction())) {
|
||||||
|
HTTPInterface.checkDevicesInfo(handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initView() {
|
private void initView() {
|
||||||
tv_note = findViewById(R.id.tv_note);
|
tv_note = findViewById(R.id.tv_note);
|
||||||
imageView = findViewById(R.id.imageView);
|
imageView = findViewById(R.id.imageView);
|
||||||
@@ -491,7 +512,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
//for receive customer msg from jpush server
|
//for receive customer msg from jpush server
|
||||||
private MessageReceiver mMessageReceiver;
|
private MessageReceiver mMessageReceiver;
|
||||||
public static final String MESSAGE_RECEIVED_ACTION = "com.example.jpushdemo.MESSAGE_RECEIVED_ACTION";
|
public static final String MESSAGE_RECEIVED_ACTION = "com.info.sn.MESSAGE_RECEIVED_ACTION";
|
||||||
public static final String KEY_TITLE = "title";
|
public static final String KEY_TITLE = "title";
|
||||||
public static final String KEY_MESSAGE = "message";
|
public static final String KEY_MESSAGE = "message";
|
||||||
public static final String KEY_EXTRAS = "extras";
|
public static final String KEY_EXTRAS = "extras";
|
||||||
@@ -524,4 +545,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
unregisterReceiver(mRefreshReceiver);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,49 @@
|
|||||||
package com.info.sn;
|
package com.info.sn;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.app.usage.UsageStats;
|
import android.app.usage.UsageStats;
|
||||||
import android.app.usage.UsageStatsManager;
|
import android.app.usage.UsageStatsManager;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.arialyy.annotations.Download;
|
import com.arialyy.annotations.Download;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.arialyy.aria.core.task.DownloadTask;
|
import com.arialyy.aria.core.task.DownloadTask;
|
||||||
|
import com.blankj.utilcode.util.ToastUtils;
|
||||||
|
import com.info.sn.jpush.LocalBroadcastManager;
|
||||||
|
import com.info.sn.network.UrlPath;
|
||||||
import com.info.sn.network.api.HTTPInterface;
|
import com.info.sn.network.api.HTTPInterface;
|
||||||
|
import com.info.sn.service.MyDownloadService;
|
||||||
import com.info.sn.utils.ApkUtils;
|
import com.info.sn.utils.ApkUtils;
|
||||||
import com.info.sn.utils.LogUtils;
|
import com.info.sn.utils.LogUtils;
|
||||||
import com.info.sn.utils.SPUtils;
|
import com.info.sn.utils.SPUtils;
|
||||||
import com.info.sn.utils.ToastUtil;
|
import com.info.sn.utils.ToastUtil;
|
||||||
|
import com.info.sn.utils.Utils;
|
||||||
|
import com.info.sn.view.CustomDialog;
|
||||||
|
import com.info.sn.view.InfoDialog;
|
||||||
import com.lzy.okgo.OkGo;
|
import com.lzy.okgo.OkGo;
|
||||||
|
import com.lzy.okgo.callback.StringCallback;
|
||||||
|
import com.lzy.okgo.model.Response;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
@@ -49,7 +67,6 @@ public class MyApplication extends Application {
|
|||||||
OkGo.getInstance().init(this);
|
OkGo.getInstance().init(this);
|
||||||
// NetworkUtils.registerNetworkStatusChangedListener(this);
|
// NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||||
Aria.init(this);
|
Aria.init(this);
|
||||||
Aria.download(this).register();
|
|
||||||
Aria.download(this).resumeAllTask();
|
Aria.download(this).resumeAllTask();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -80,7 +97,7 @@ public class MyApplication extends Application {
|
|||||||
public static String getTaskPackname() {
|
public static String getTaskPackname() {
|
||||||
String currentApp = "CurrentNULL";
|
String currentApp = "CurrentNULL";
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||||
UsageStatsManager usm = (UsageStatsManager) context.getSystemService("usagestats");
|
@SuppressLint("WrongConstant") UsageStatsManager usm = (UsageStatsManager) context.getSystemService("usagestats");
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
List<UsageStats> appList = usm.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, time - 1000 * 1000, time);
|
List<UsageStats> appList = usm.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, time - 1000 * 1000, time);
|
||||||
if (appList != null && appList.size() > 0) {
|
if (appList != null && appList.size() > 0) {
|
||||||
@@ -139,6 +156,7 @@ public class MyApplication extends Application {
|
|||||||
private static final String JIGUANG_APP_LOCKEDSTATE = "8";
|
private static final String JIGUANG_APP_LOCKEDSTATE = "8";
|
||||||
private static final String JIGUANG_FORCE_INSTALLAPK = "9";
|
private static final String JIGUANG_FORCE_INSTALLAPK = "9";
|
||||||
private static final String JIGUANG_FORCE_UNINSTALLAPK = "10";
|
private static final String JIGUANG_FORCE_UNINSTALLAPK = "10";
|
||||||
|
private static final String JIGUANG_BIND_DEVIVES = "11";
|
||||||
|
|
||||||
|
|
||||||
synchronized public void manageCustomMessage(CustomMessage customMessage) {
|
synchronized public void manageCustomMessage(CustomMessage customMessage) {
|
||||||
@@ -184,6 +202,8 @@ public class MyApplication extends Application {
|
|||||||
case JIGUANG_FORCE_UNINSTALLAPK:
|
case JIGUANG_FORCE_UNINSTALLAPK:
|
||||||
unintallApk(EXTRA);
|
unintallApk(EXTRA);
|
||||||
break;
|
break;
|
||||||
|
case JIGUANG_BIND_DEVIVES:
|
||||||
|
bindService(EXTRA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -320,11 +340,11 @@ public class MyApplication extends Application {
|
|||||||
String package0 = extra.getString("package0");
|
String package0 = extra.getString("package0");
|
||||||
String package1 = extra.getString("package1");
|
String package1 = extra.getString("package1");
|
||||||
if (package0.length() != 0) {
|
if (package0.length() != 0) {
|
||||||
boolean qch_jgy_network_disallow = Settings.System.putString(getContentResolver(), "qch_jgy_network_allow", package0);
|
boolean qch_jgy_network_allow = Settings.System.putString(getContentResolver(), "qch_jgy_network_allow", package0);
|
||||||
LogUtils.e("fht", "setAppNetworkstate::" + qch_jgy_network_disallow + ":" + Settings.System.getString(getContentResolver(), "qch_jgy_network_allow"));
|
LogUtils.e("fht", "setAppNetworkstate::" + qch_jgy_network_allow + ":" + Settings.System.getString(getContentResolver(), "qch_jgy_network_allow"));
|
||||||
} else {
|
} else {
|
||||||
boolean qch_jgy_network_disallow = Settings.System.putString(getContentResolver(), "qch_jgy_network_allow", "invalid");
|
boolean qch_jgy_network_allow = Settings.System.putString(getContentResolver(), "qch_jgy_network_allow", "invalid");
|
||||||
LogUtils.e("fht", "setAppNetworkstate::" + qch_jgy_network_disallow + ":" + Settings.System.getString(getContentResolver(), "qch_jgy_network_allow"));
|
LogUtils.e("fht", "setAppNetworkstate::" + qch_jgy_network_allow + ":" + Settings.System.getString(getContentResolver(), "qch_jgy_network_allow"));
|
||||||
}
|
}
|
||||||
if (package1.length() != 0) {
|
if (package1.length() != 0) {
|
||||||
boolean qch_jgy_network_disallow = Settings.System.putString(getContentResolver(), "qch_jgy_network_disallow", package1);
|
boolean qch_jgy_network_disallow = Settings.System.putString(getContentResolver(), "qch_jgy_network_disallow", package1);
|
||||||
@@ -369,11 +389,21 @@ public class MyApplication extends Application {
|
|||||||
|
|
||||||
//静默安装应用,使用okgo,断网会出现问题,等待修改使用aria
|
//静默安装应用,使用okgo,断网会出现问题,等待修改使用aria
|
||||||
synchronized private void intallApk(String jsondata) {
|
synchronized private void intallApk(String jsondata) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONObject extra = new JSONObject(jsondata);
|
JSONObject extra = new JSONObject(jsondata);
|
||||||
final String packages = extra.getString("package");
|
final String packages = extra.getString("package");
|
||||||
ToastUtil.debugShow("收到应用安装消息:包名" + packages);
|
ToastUtil.debugShow("收到应用安装消息:包名" + packages);
|
||||||
String url = extra.getString("url");
|
String url = extra.getString("url");
|
||||||
|
|
||||||
|
if (Aria.download(this).taskExists(url)) {
|
||||||
|
|
||||||
|
List<DownloadEntity> entity = Aria.download(this).getDownloadEntity(url);
|
||||||
|
for (DownloadEntity downloadEntity : entity) {
|
||||||
|
Aria.download(this).load(downloadEntity.getId()).cancel(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
File file = new File(Environment.getExternalStoragePublicDirectory("Download") + "/Sninfo/apk");
|
File file = new File(Environment.getExternalStoragePublicDirectory("Download") + "/Sninfo/apk");
|
||||||
file.mkdirs();
|
file.mkdirs();
|
||||||
Aria.download(this)
|
Aria.download(this)
|
||||||
@@ -402,7 +432,7 @@ public class MyApplication extends Application {
|
|||||||
// LogUtils.e("downloadProgress", "已下载:" + progress.currentSize + ",总大小:" + progress.totalSize + ",进度:" + progress.fraction + ",当前网速:" + progress.speed);
|
// LogUtils.e("downloadProgress", "已下载:" + progress.currentSize + ",总大小:" + progress.totalSize + ",进度:" + progress.fraction + ",当前网速:" + progress.speed);
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
Aria.download(this).resumeAllTask();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
LogUtils.e("intallApk", e.getMessage());
|
LogUtils.e("intallApk", e.getMessage());
|
||||||
@@ -430,6 +460,97 @@ public class MyApplication extends Application {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized void bindService(String json) {
|
||||||
|
ToastUtil.debugShow("收到绑定设备请求");
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSONObject object = new JSONObject(json);
|
||||||
|
String userName = object.getString("member_name");
|
||||||
|
final String id = object.getString("id");
|
||||||
|
String phoneNum = object.getString("member_phone");
|
||||||
|
final CustomDialog dialog = new CustomDialog(getAppContext());
|
||||||
|
dialog.setMessage(phoneNum + "的用户请求绑定你的平板")
|
||||||
|
.setTitle("绑定请求")
|
||||||
|
.setPositive("允许")
|
||||||
|
.setNegtive("拒绝")
|
||||||
|
// .setSingle(true)
|
||||||
|
.setOnClickBottomListener(new CustomDialog.OnClickBottomListener() {
|
||||||
|
@Override
|
||||||
|
public void onPositiveClick() {
|
||||||
|
bind(id);
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNegtiveClick() {
|
||||||
|
ToastUtil.show("设备取消绑定");
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
// AlertDialog.Builder builder = new AlertDialog.Builder(this)
|
||||||
|
// .setTitle("设备绑定")
|
||||||
|
// .setIcon(R.mipmap.ic_launcher)
|
||||||
|
// .setCancelable(false)
|
||||||
|
// .setMessage("用户:“" + userName + "”" + "\n手机:“" + phoneNum + "”" + "\n请求绑定此设备")
|
||||||
|
// .setPositiveButton("确认绑定", new DialogInterface.OnClickListener() {
|
||||||
|
// @Override
|
||||||
|
// public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
// bind(id);
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// .setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||||
|
// @Override
|
||||||
|
// public void onClick(DialogInterface dialog, int which) {
|
||||||
|
// dialog.dismiss();
|
||||||
|
// ToastUtil.show("设备取消绑定");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// AlertDialog ad = builder.create();
|
||||||
|
// ad.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
|
||||||
|
// ad.setCanceledOnTouchOutside(false); //点击外面区域不会让dialog消失
|
||||||
|
// ad.show();
|
||||||
|
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
LogUtils.e("bindService", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized private void bind(String id) {
|
||||||
|
OkGo.<String>post(UrlPath.BIND_DEVICES)
|
||||||
|
.params("id", id)
|
||||||
|
.params("sn", Utils.getSerial())
|
||||||
|
.execute(new StringCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Response<String> response) {
|
||||||
|
String s = response.body();
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = new JSONObject(s);
|
||||||
|
int code = jsonObject.getInt("code");
|
||||||
|
String msg = jsonObject.getString("msg");
|
||||||
|
if (code == 200) {
|
||||||
|
ToastUtil.show("绑定成功");
|
||||||
|
} else {
|
||||||
|
ToastUtil.show(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
Intent intent = new Intent(MainActivity.REFRESHACTION);
|
||||||
|
sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Response<String> response) {
|
||||||
|
super.onError(response);
|
||||||
|
Log.e("bind", response.getException().getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
// @Override
|
// @Override
|
||||||
// public void onDisconnected() {
|
// public void onDisconnected() {
|
||||||
// LogUtils.e("onDisconnected", "网络断开");
|
// LogUtils.e("onDisconnected", "网络断开");
|
||||||
@@ -443,15 +564,4 @@ public class MyApplication extends Application {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
//在这里处理任务执行中的状态,如进度进度条的刷新
|
|
||||||
@Download.onTaskRunning
|
|
||||||
protected void running(DownloadTask task) {
|
|
||||||
Log.e("aria running", task.getState() + "--" + task.getPercent() + "--" + task.getExtendField());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Download.onTaskComplete
|
|
||||||
void taskComplete(DownloadTask task) {
|
|
||||||
//在这里处理任务完成的状态
|
|
||||||
ApkUtils.installApkInSilence(task.getFilePath(), task.getExtendField());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.info.sn.service;
|
package com.info.sn.network;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -19,6 +19,9 @@ public class UrlPath {
|
|||||||
//获取当前最顶层应用和电量
|
//获取当前最顶层应用和电量
|
||||||
public final static String SEND_DRIVE_STATE = HOMEPATHRUL + "Online/online";
|
public final static String SEND_DRIVE_STATE = HOMEPATHRUL + "Online/online";
|
||||||
|
|
||||||
public final static String GET_ALL_PACKAGENAME = HOMEPATHRUL + "/App/allPackage";
|
public final static String GET_ALL_PACKAGENAME = HOMEPATHRUL + "App/allPackage";
|
||||||
//获取所有应用包名
|
//获取所有应用包名
|
||||||
|
public final static String BIND_DEVICES = HOMEPATHRUL + "Member/binding";
|
||||||
|
//绑定设备消息
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.info.sn.service;
|
package com.info.sn.receiver;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
package com.info.sn.service;
|
package com.info.sn.receiver;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.info.sn.service.GuardService;
|
||||||
|
import com.info.sn.service.MyDownloadService;
|
||||||
|
import com.info.sn.service.StepService;
|
||||||
|
|
||||||
|
|
||||||
public class BootReceiver extends BroadcastReceiver {
|
public class BootReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
@@ -18,6 +18,11 @@ import android.view.WindowManager;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.arialyy.annotations.Download;
|
||||||
|
import com.arialyy.aria.core.Aria;
|
||||||
|
import com.arialyy.aria.core.task.DownloadTask;
|
||||||
|
import com.blankj.utilcode.util.NetworkUtils;
|
||||||
|
import com.blankj.utilcode.util.ToastUtils;
|
||||||
import com.info.sn.BuildConfig;
|
import com.info.sn.BuildConfig;
|
||||||
import com.info.sn.R;
|
import com.info.sn.R;
|
||||||
import com.info.sn.network.api.HTTPInterface;
|
import com.info.sn.network.api.HTTPInterface;
|
||||||
@@ -28,9 +33,10 @@ import com.lzy.okgo.model.Progress;
|
|||||||
import com.lzy.okgo.model.Response;
|
import com.lzy.okgo.model.Response;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
// 下载管理服务
|
// 下载管理服务
|
||||||
public class MyDownloadService extends Service {
|
public class MyDownloadService extends Service implements NetworkUtils.OnNetworkStatusChangedListener {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -46,6 +52,10 @@ public class MyDownloadService extends Service {
|
|||||||
CheckUpdateByPackageName("com.uiuios.updatetools", handler);
|
CheckUpdateByPackageName("com.uiuios.updatetools", handler);
|
||||||
//静默升级更新工具
|
//静默升级更新工具
|
||||||
HTTPInterface.getAllAppPackageName(handler);
|
HTTPInterface.getAllAppPackageName(handler);
|
||||||
|
Aria.download(this).register();
|
||||||
|
|
||||||
|
Aria.download(this).resumeAllTask();
|
||||||
|
//恢复所有未完成的下载任务
|
||||||
return super.onStartCommand(intent, flags, startId);
|
return super.onStartCommand(intent, flags, startId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,4 +275,31 @@ public class MyDownloadService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisconnected() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||||
|
Aria.download(this).resumeAllTask();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//在这里处理任务执行中的状态,如进度进度条的刷新
|
||||||
|
@Download.onTaskRunning
|
||||||
|
protected void running(DownloadTask task) {
|
||||||
|
ToastUtils.showShort("正在下载:" + task.getExtendField() + "-" + task.getPercent() + "%");
|
||||||
|
Log.e("aria running", "正在下载:" + task.getState() + "--" + task.getPercent() + "--" + task.getExtendField());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Download.onTaskComplete
|
||||||
|
void taskComplete(DownloadTask task) {
|
||||||
|
//在这里处理任务完成的状态
|
||||||
|
ApkUtils.installApp(MyDownloadService.this, task.getFilePath());
|
||||||
|
Log.e("taskComplete", task.getExtendField());
|
||||||
|
Aria.download(this).load(task.getDownloadEntity().getId()).cancel();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import android.util.Log;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.info.sn.KeepAliveConnection;
|
import com.info.sn.KeepAliveConnection;
|
||||||
|
import com.info.sn.network.JWebSocketClient;
|
||||||
import com.info.sn.utils.LogUtils;
|
import com.info.sn.utils.LogUtils;
|
||||||
import com.info.sn.utils.ServiceAliveUtils;
|
import com.info.sn.utils.ServiceAliveUtils;
|
||||||
import com.info.sn.utils.Utils;
|
import com.info.sn.utils.Utils;
|
||||||
|
|||||||
241
app/src/main/java/com/info/sn/view/CustomDialog.java
Normal file
241
app/src/main/java/com/info/sn/view/CustomDialog.java
Normal file
@@ -0,0 +1,241 @@
|
|||||||
|
package com.info.sn.view;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.info.sn.R;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* description:自定义dialog
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CustomDialog extends Dialog {
|
||||||
|
/**
|
||||||
|
* 显示的图片
|
||||||
|
*/
|
||||||
|
private ImageView imageIv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示的标题
|
||||||
|
*/
|
||||||
|
private TextView titleTv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示的消息
|
||||||
|
*/
|
||||||
|
private TextView messageTv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认和取消按钮
|
||||||
|
*/
|
||||||
|
private Button negtiveBn, positiveBn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按钮之间的分割线
|
||||||
|
*/
|
||||||
|
private View columnLineView;
|
||||||
|
|
||||||
|
public CustomDialog(Context context) {
|
||||||
|
super(context, R.style.CustomDialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 都是内容数据
|
||||||
|
*/
|
||||||
|
private String message;
|
||||||
|
private String title;
|
||||||
|
private String positive, negtive;
|
||||||
|
private int imageResId = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 底部是否只有一个按钮
|
||||||
|
*/
|
||||||
|
private boolean isSingle = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.custom_dialog);
|
||||||
|
//按空白处不能取消动画
|
||||||
|
setCanceledOnTouchOutside(false);
|
||||||
|
getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
|
||||||
|
//初始化界面控件
|
||||||
|
initView();
|
||||||
|
//初始化界面数据
|
||||||
|
refreshView();
|
||||||
|
//初始化界面控件的事件
|
||||||
|
initEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化界面的确定和取消监听器
|
||||||
|
*/
|
||||||
|
private void initEvent() {
|
||||||
|
//设置确定按钮被点击后,向外界提供监听
|
||||||
|
positiveBn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (onClickBottomListener != null) {
|
||||||
|
onClickBottomListener.onPositiveClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//设置取消按钮被点击后,向外界提供监听
|
||||||
|
negtiveBn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (onClickBottomListener != null) {
|
||||||
|
onClickBottomListener.onNegtiveClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化界面控件的显示数据
|
||||||
|
*/
|
||||||
|
private void refreshView() {
|
||||||
|
//如果用户自定了title和message
|
||||||
|
if (!TextUtils.isEmpty(title)) {
|
||||||
|
titleTv.setText(title);
|
||||||
|
titleTv.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
titleTv.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
if (!TextUtils.isEmpty(message)) {
|
||||||
|
messageTv.setText(message);
|
||||||
|
}
|
||||||
|
//如果设置按钮的文字
|
||||||
|
if (!TextUtils.isEmpty(positive)) {
|
||||||
|
positiveBn.setText(positive);
|
||||||
|
} else {
|
||||||
|
positiveBn.setText("确定");
|
||||||
|
}
|
||||||
|
if (!TextUtils.isEmpty(negtive)) {
|
||||||
|
negtiveBn.setText(negtive);
|
||||||
|
} else {
|
||||||
|
negtiveBn.setText("取消");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imageResId != -1) {
|
||||||
|
imageIv.setImageResource(imageResId);
|
||||||
|
imageIv.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
imageIv.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 只显示一个按钮的时候隐藏取消按钮,回掉只执行确定的事件
|
||||||
|
*/
|
||||||
|
if (isSingle) {
|
||||||
|
columnLineView.setVisibility(View.GONE);
|
||||||
|
negtiveBn.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
negtiveBn.setVisibility(View.VISIBLE);
|
||||||
|
columnLineView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
super.show();
|
||||||
|
refreshView();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化界面控件
|
||||||
|
*/
|
||||||
|
private void initView() {
|
||||||
|
negtiveBn = findViewById(R.id.negtive);
|
||||||
|
positiveBn = findViewById(R.id.positive);
|
||||||
|
titleTv = findViewById(R.id.title);
|
||||||
|
messageTv = findViewById(R.id.message);
|
||||||
|
imageIv = findViewById(R.id.image);
|
||||||
|
columnLineView = findViewById(R.id.column_line);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置确定取消按钮的回调
|
||||||
|
*/
|
||||||
|
public OnClickBottomListener onClickBottomListener;
|
||||||
|
|
||||||
|
public CustomDialog setOnClickBottomListener(OnClickBottomListener onClickBottomListener) {
|
||||||
|
this.onClickBottomListener = onClickBottomListener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnClickBottomListener {
|
||||||
|
/**
|
||||||
|
* 点击确定按钮事件
|
||||||
|
*/
|
||||||
|
void onPositiveClick();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击取消按钮事件
|
||||||
|
*/
|
||||||
|
void onNegtiveClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomDialog setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomDialog setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPositive() {
|
||||||
|
return positive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomDialog setPositive(String positive) {
|
||||||
|
this.positive = positive;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNegtive() {
|
||||||
|
return negtive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomDialog setNegtive(String negtive) {
|
||||||
|
this.negtive = negtive;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getImageResId() {
|
||||||
|
return imageResId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSingle() {
|
||||||
|
return isSingle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomDialog setSingle(boolean single) {
|
||||||
|
isSingle = single;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomDialog setImageResId(int imageResId) {
|
||||||
|
this.imageResId = imageResId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
109
app/src/main/java/com/info/sn/view/InfoDialog.java
Normal file
109
app/src/main/java/com/info/sn/view/InfoDialog.java
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
package com.info.sn.view;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.info.sn.R;
|
||||||
|
|
||||||
|
|
||||||
|
public class InfoDialog extends Dialog {
|
||||||
|
|
||||||
|
private InfoDialog(Context context, int themeResId) {
|
||||||
|
super(context, themeResId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private View mLayout;
|
||||||
|
|
||||||
|
private ImageView mIcon;
|
||||||
|
private TextView mTitle;
|
||||||
|
private TextView mMessage;
|
||||||
|
private Button mButton;
|
||||||
|
|
||||||
|
private View.OnClickListener mButtonClickListener;
|
||||||
|
|
||||||
|
private InfoDialog mDialog;
|
||||||
|
|
||||||
|
public Builder(Context context) {
|
||||||
|
mDialog = new InfoDialog(context, R.style.Theme_AppCompat_Dialog);
|
||||||
|
LayoutInflater inflater =
|
||||||
|
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
//加载布局文件
|
||||||
|
mLayout = inflater.inflate(R.layout.dialog, null, false);
|
||||||
|
//添加布局文件到 Dialog
|
||||||
|
mDialog.addContentView(mLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
|
mIcon = mLayout.findViewById(R.id.dialog_icon);
|
||||||
|
mTitle = mLayout.findViewById(R.id.dialog_title);
|
||||||
|
mMessage = mLayout.findViewById(R.id.dialog_message);
|
||||||
|
mButton = mLayout.findViewById(R.id.dialog_button);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过 ID 设置 Dialog 图标
|
||||||
|
*/
|
||||||
|
public Builder setIcon(int resId) {
|
||||||
|
mIcon.setImageResource(resId);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用 Bitmap 作为 Dialog 图标
|
||||||
|
*/
|
||||||
|
public Builder setIcon(Bitmap bitmap) {
|
||||||
|
mIcon.setImageBitmap(bitmap);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 Dialog 标题
|
||||||
|
*/
|
||||||
|
public Builder setTitle(@NonNull String title) {
|
||||||
|
mTitle.setText(title);
|
||||||
|
mTitle.setVisibility(View.VISIBLE);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 Message
|
||||||
|
*/
|
||||||
|
public Builder setMessage(@NonNull String message) {
|
||||||
|
mMessage.setText(message);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置按钮文字和监听
|
||||||
|
*/
|
||||||
|
public Builder setButton(@NonNull String text, View.OnClickListener listener) {
|
||||||
|
mButton.setText(text);
|
||||||
|
mButtonClickListener = listener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InfoDialog create() {
|
||||||
|
mButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
mDialog.dismiss();
|
||||||
|
mButtonClickListener.onClick(view);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mDialog.setContentView(mLayout);
|
||||||
|
mDialog.setCancelable(true); //用户可以点击后退键关闭 Dialog
|
||||||
|
mDialog.setCanceledOnTouchOutside(false); //用户不可以点击外部来关闭 Dialog
|
||||||
|
return mDialog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
app/src/main/res/drawable/bg_dialog.xml
Normal file
9
app/src/main/res/drawable/bg_dialog.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="#ffffff" />
|
||||||
|
<stroke
|
||||||
|
android:width="0.8dp"
|
||||||
|
android:color="#ffffff" />
|
||||||
|
<!-- 圆角 -->
|
||||||
|
<corners android:radius="6dp" />
|
||||||
|
</shape>
|
||||||
BIN
app/src/main/res/drawable/bind.png
Normal file
BIN
app/src/main/res/drawable/bind.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
108
app/src/main/res/layout/custom_dialog.xml
Normal file
108
app/src/main/res/layout/custom_dialog.xml
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minWidth="260dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:background="@drawable/bg_dialog"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/image"
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:maxWidth="80dp"
|
||||||
|
android:maxHeight="80dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:visibility="visible"
|
||||||
|
tools:src="@drawable/bind" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textColor="#333333"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:visibility="visible"
|
||||||
|
tools:text="消息提示" />
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/message"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center|left"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:lineSpacingExtra="3dp"
|
||||||
|
android:lineSpacingMultiplier="1.2"
|
||||||
|
android:textSize="16dp"
|
||||||
|
android:textColor="#999999"
|
||||||
|
tools:text="提示消息提示消息提示消息提示消息提示消息提示消息提示消息提示消息" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1px"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:background="#E4E4E4" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/negtive"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@null"
|
||||||
|
android:gravity="center"
|
||||||
|
android:singleLine="true"
|
||||||
|
tools:text="No"
|
||||||
|
android:textColor="#999999"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/column_line"
|
||||||
|
android:layout_width="1px"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="#E4E4E4" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/positive"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:background="@null"
|
||||||
|
android:gravity="center"
|
||||||
|
android:singleLine="true"
|
||||||
|
tools:text="Yes"
|
||||||
|
android:textColor="#38ADFF"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
75
app/src/main/res/layout/dialog.xml
Normal file
75
app/src/main/res/layout/dialog.xml
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="#ffffff">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/dialog_header"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="220dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
|
<!-- Icon -->
|
||||||
|
<ImageView
|
||||||
|
android:contentDescription="@id/dialog_title"
|
||||||
|
android:id="@+id/dialog_icon"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:src="@drawable/bind" />
|
||||||
|
|
||||||
|
<!-- Title(default is gone) -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dialog_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="#ffffff"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/dialog_header"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent">
|
||||||
|
|
||||||
|
<!-- Dialog Message -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dialog_message"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="8dp"
|
||||||
|
tools:text="Dialog Message" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/dialog_button"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="42dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:textColor="#ffffff"
|
||||||
|
android:text="xx"
|
||||||
|
>
|
||||||
|
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -7,5 +7,17 @@
|
|||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
<item name="colorAccent">@color/colorAccent</item>
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
</style>
|
</style>
|
||||||
|
<style name="CustomDialog" parent="android:style/Theme.Dialog">
|
||||||
|
<!--背景颜色及和透明程度-->
|
||||||
|
<item name="android:windowBackground">@android:color/transparent</item>
|
||||||
|
<!--是否去除标题 -->
|
||||||
|
<item name="android:windowNoTitle">true</item>
|
||||||
|
<!--是否去除边框-->
|
||||||
|
<item name="android:windowFrame">@null</item>
|
||||||
|
<!--是否浮现在activity之上-->
|
||||||
|
<item name="android:windowIsFloating">true</item>
|
||||||
|
<!--是否模糊-->
|
||||||
|
<item name="android:backgroundDimEnabled">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user