mirror of
https://github.com/pppscn/SmsForwarder
synced 2025-08-03 09:27:41 +08:00
整理:code review
This commit is contained in:
parent
9c54d33391
commit
e0142ed351
@ -55,7 +55,7 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:targetApi="m">
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
|
@ -229,6 +229,7 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
try {
|
||||
//是否同意隐私协议
|
||||
if (!MyApplication.allowPrivacyPolicy) return;
|
||||
|
||||
@ -253,7 +254,6 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (serviceIntent != null) startService(serviceIntent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "onResume:", e);
|
||||
|
@ -12,7 +12,7 @@ import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
@SuppressWarnings({"ResultOfMethodCallIgnored", "CommentedOutCode"})
|
||||
public class BackupDbTask {
|
||||
private static final String TAG = "BackupDbTask";
|
||||
public static final String COMMAND_BACKUP = "backupDatabase";
|
||||
@ -88,7 +88,6 @@ public class BackupDbTask {
|
||||
Log.d(TAG, "restore success! 数据库文件名:" + dbFile.getName() + "\t" + backup_version);
|
||||
|
||||
try {
|
||||
//noinspection BusyWait
|
||||
Thread.sleep(1000);
|
||||
} catch (final InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
|
@ -1,9 +1,12 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
@ -37,16 +40,17 @@ public class DownloadUtil {
|
||||
Request request = new Request.Builder().url(url).addHeader("Connection", "close").build();
|
||||
okHttpClient.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
public void onFailure(@NonNull Call call, @NonNull IOException e) {
|
||||
// 下载失败监听回调
|
||||
listener.onDownloadFailed(e);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
|
||||
InputStream is = null;
|
||||
byte[] buf = new byte[2048];
|
||||
int len = 0;
|
||||
int len;
|
||||
FileOutputStream fos = null;
|
||||
|
||||
// 储存下载文件的目录
|
||||
@ -57,8 +61,8 @@ public class DownloadUtil {
|
||||
if (file.exists()) file.delete();
|
||||
|
||||
try {
|
||||
is = response.body().byteStream();
|
||||
long total = response.body().contentLength();
|
||||
is = Objects.requireNonNull(response.body()).byteStream();
|
||||
long total = Objects.requireNonNull(response.body()).contentLength();
|
||||
fos = new FileOutputStream(file);
|
||||
long sum = 0;
|
||||
while ((len = is.read(buf)) != -1) {
|
||||
@ -78,6 +82,7 @@ public class DownloadUtil {
|
||||
if (is != null) is.close();
|
||||
if (fos != null) fos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,6 @@
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:current_step="rule"
|
||||
app:help_tip="@string/log_tips" />
|
||||
app:help_tip="@string/rule_tips" />
|
||||
|
||||
</RelativeLayout>
|
@ -30,7 +30,7 @@
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="text"
|
||||
android:singleLine="true"
|
||||
tools:ignore="LabelFor" />
|
||||
tools:ignore="LabelFor,TextFields" />
|
||||
|
||||
<Switch
|
||||
android:id="@+id/switchEmailEnable"
|
||||
|
@ -201,7 +201,6 @@
|
||||
<string name="battery_setting">Battery Optimization</string>
|
||||
<string name="battery_setting_tips">Set it to manual management, including automatic startup, associated startup, and background running</string>
|
||||
<string name="unknown_number">Unknown Number</string>
|
||||
<string name="calling">Incoming telegram</string>
|
||||
<string name="unsupport">Your phone does not support this setting</string>
|
||||
<string name="isIgnored">Set successfully!</string>
|
||||
<string name="isIgnored2">Can not directly operate the system power saving optimization Settings</string>
|
||||
@ -232,7 +231,6 @@
|
||||
<string name="sender_cannot_receive">This mobile phone is the SOURCE and cannot receive files.</string>
|
||||
<string name="no_wifi_network">Http Server does NOT work without Wi-Fi connection.</string>
|
||||
<string name="invalid_server_ip">Please enter a valid server IP address</string>
|
||||
<string name="download_success">Download Success</string>
|
||||
<string name="on_wireless_network">A Wireless network connected.</string>
|
||||
<string name="on_mobile_network">A Mobile network connected.</string>
|
||||
<string name="no_network">Not connected to a network.</string>
|
||||
|
@ -201,7 +201,6 @@
|
||||
<string name="battery_setting">忽略电池优化设置</string>
|
||||
<string name="battery_setting_tips">请设置为手动管理:允许自启动、允许关联启动、允许后台运行</string>
|
||||
<string name="unknown_number">未知号码</string>
|
||||
<string name="calling">的来电未接</string>
|
||||
<string name="unsupport">您的手机不支持此设置</string>
|
||||
<string name="isIgnored">已将省电优化设置为无限制(不优化)!</string>
|
||||
<string name="isIgnored2">本界面无法直接操作系统的省电优化设置</string>
|
||||
@ -231,7 +230,6 @@
|
||||
<string name="sender_cannot_receive">本手机是发送端,不可接收文件,请先停止服务端!</string>
|
||||
<string name="no_wifi_network">未接入Wifi网络,不可使用 HttpServer 功能!</string>
|
||||
<string name="invalid_server_ip">请输入服务端IP</string>
|
||||
<string name="download_success">下载成功</string>
|
||||
<string name="on_wireless_network">当前处于无线网络</string>
|
||||
<string name="on_mobile_network">当前处于移动网络</string>
|
||||
<string name="no_network">当前没有网络</string>
|
||||
@ -382,10 +380,10 @@
|
||||
<string name="tips_compatible_solution">兼容方案</string>
|
||||
<string name="tips_wait_3_seconds">点击启动后请等待3秒</string>
|
||||
<string name="tips_clone_done">一键克隆操作完成!\n请检查·通用设置·各项开关是否已开启!</string>
|
||||
<string name="tips_download_done">下载完成,正准备还原数据...</string>
|
||||
<string name="tips_download_done">下载完成,正准备还原数据…</string>
|
||||
<string name="tips_download_failed">下载失败:</string>
|
||||
<string name="tips_downloading">正在下载</string>
|
||||
<string name="tips_please_wait">请稍后...</string>
|
||||
<string name="tips_please_wait">请稍后…</string>
|
||||
<string name="tips_clone_failed">一键克隆失败:</string>
|
||||
<string name="tips_versions_inconsistent">发送端与接收端的APP版本不一致,无法一键克隆!</string>
|
||||
<string name="tips_get_info_failed">从发送端获取一键克隆信息失败</string>
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<base-config cleartextTrafficPermitted="true" />
|
||||
<network-security-config xmlns:tools="http://schemas.android.com/tools">
|
||||
<base-config
|
||||
cleartextTrafficPermitted="true"
|
||||
tools:ignore="InsecureBaseConfiguration" />
|
||||
<debug-overrides>
|
||||
<trust-anchors>
|
||||
<!-- Trust user added CAs while debuggable only -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user