diff --git a/app/build.gradle b/app/build.gradle index 86ee00e2..31cf954f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,7 +15,7 @@ if (versionPropsFile.exists()) { android { buildToolsVersion '30.0.3' - compileSdkVersion 30 + compileSdkVersion 31 compileOptions { sourceCompatibility 11 targetCompatibility 11 @@ -23,7 +23,7 @@ android { defaultConfig { applicationId "com.idormy.sms.forwarder" minSdkVersion 21 - targetSdkVersion 30 + targetSdkVersion 31 versionCode versionProps['versionCode'].toInteger() versionName versionProps['versionName'] testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' @@ -127,24 +127,26 @@ void cmdExecute(String cmd) { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'androidx.appcompat:appcompat:1.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.2' - implementation 'com.google.firebase:firebase-crashlytics-buildtools:2.5.2' - testImplementation 'junit:junit:4.+' + implementation 'com.google.firebase:firebase-crashlytics-buildtools:2.8.1' + testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' //okhttp - implementation 'com.squareup.okhttp3:okhttp:4.9.1' - implementation 'com.squareup.okio:okio:2.10.0' + //noinspection GradleDependency + implementation 'com.squareup.okhttp3:okhttp:4.9.3' + implementation 'com.squareup.okio:okio:3.0.0' //fastjson - implementation "com.alibaba:fastjson:1.2.78" + implementation "com.alibaba:fastjson:1.2.79" //友盟统计SDK - implementation 'com.umeng.umsdk:common:9.4.4'// 必选 - implementation 'com.umeng.umsdk:asms:1.4.1'// 必选 - //implementation 'com.umeng.umsdk:apm:1.4.2' // 错误分析升级为独立SDK,看crash数据请一定集成,可选 + implementation 'com.umeng.umsdk:common:9.4.4'// (必选) + implementation 'com.umeng.umsdk:asms:1.5.0'// asms包依赖必选 + //implementation 'com.umeng.umsdk:abtest:1.0.0'//使用U-App中ABTest能力,可选 + implementation 'com.umeng.umsdk:apm:1.5.2'// U-APM产品包依赖(必选) //XUpdate implementation 'com.github.xuexiangjys:XUpdate:2.1.1' @@ -156,11 +158,11 @@ dependencies { //Lombok //noinspection AnnotationProcessorOnCompilePath - compileOnly 'org.projectlombok:lombok:1.18.20' - annotationProcessor 'org.projectlombok:lombok:1.18.20' + compileOnly 'org.projectlombok:lombok:1.18.22' + annotationProcessor 'org.projectlombok:lombok:1.18.22' //RxJava - implementation 'io.reactivex.rxjava3:rxjava:3.1.1' + implementation 'io.reactivex.rxjava3:rxjava:3.1.3' //AndroidAsync implementation 'com.koushikdutta.async:androidasync:3.1.0' diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index c88393ae..41a6b773 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -21,6 +21,10 @@ #-renamesourcefileattribute SourceFile -keep class com.idormy.sms.forwarder.model.**{*;} +-keep public class com.idormy.sms.forwarder.R$*{ +public static final int *; +} + -keep class com.umeng.** {*;} -keepclassmembers class * { public (org.json.JSONObject); diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b81ab50a..d428ad3c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -52,7 +52,12 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" - android:usesCleartextTraffic="true"> + android:usesCleartextTraffic="true" + tools:targetApi="m"> + + @@ -74,6 +80,7 @@ @@ -89,22 +96,28 @@ @@ -114,6 +127,7 @@ @@ -123,6 +137,7 @@ @@ -139,7 +154,8 @@ android:name=".service.NotifyService" android:enabled="true" android:label="@string/app_name" - android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"> + android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" + android:exported="false"> diff --git a/app/src/main/java/com/idormy/sms/forwarder/MainActivity.java b/app/src/main/java/com/idormy/sms/forwarder/MainActivity.java index 53a572b3..27e6cbb3 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/MainActivity.java +++ b/app/src/main/java/com/idormy/sms/forwarder/MainActivity.java @@ -1,6 +1,7 @@ package com.idormy.sms.forwarder; import android.annotation.SuppressLint; +import android.app.Dialog; import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; @@ -8,6 +9,8 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.util.Log; +import android.view.Gravity; +import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -31,9 +34,11 @@ import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.NetUtil; import com.idormy.sms.forwarder.utils.PhoneUtils; import com.idormy.sms.forwarder.utils.SettingUtil; +import com.idormy.sms.forwarder.utils.SharedPreferencesHelper; import com.idormy.sms.forwarder.utils.SmsUtil; import com.idormy.sms.forwarder.utils.TimeUtil; import com.umeng.analytics.MobclickAgent; +import com.umeng.commonsdk.UMConfigure; import java.lang.reflect.Method; import java.util.ArrayList; @@ -49,6 +54,10 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I private Intent serviceIntent; private String currentType = "sms"; + View inflate; + Dialog dialog; + SharedPreferencesHelper sharedPreferencesHelper; + @Override protected void onCreate(Bundle savedInstanceState) { @@ -93,6 +102,14 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I super.onStart(); Log.d(TAG, "onStart"); + /* sp中uminit为1已经同意隐私协议*/ + sharedPreferencesHelper = new SharedPreferencesHelper(this, "umeng"); + String isAllowed = String.valueOf(sharedPreferencesHelper.getSharedPreference("uminit", "")); + if (isAllowed.equals("") || isAllowed.equals("0")) { + dialog(); + return; + } + //是否关闭页面提示 TextView help_tip = findViewById(R.id.help_tip); help_tip.setVisibility(MyApplication.showHelpTip ? View.VISIBLE : View.GONE); @@ -163,6 +180,7 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I @Override protected void onResume() { super.onResume(); + MobclickAgent.onPageStart(TAG); MobclickAgent.onResume(this); //第一次打开,未授权无法获取SIM信息,尝试在此重新获取 @@ -206,6 +224,7 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I @Override protected void onPause() { super.onPause(); + MobclickAgent.onPageEnd(TAG); MobclickAgent.onPause(this); try { if (serviceIntent != null) startService(serviceIntent); @@ -396,4 +415,49 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I return super.onMenuOpened(featureId, menu); } + /*** 隐私协议授权弹窗*/ + @SuppressLint({"ResourceType", "InflateParams"}) + public void dialog() { + dialog = new Dialog(this, R.style.dialog); + inflate = LayoutInflater.from(MainActivity.this).inflate(R.layout.diaologlayout, null); + TextView succsebtn = (TextView) inflate.findViewById(R.id.succsebtn); + TextView canclebtn = (TextView) inflate.findViewById(R.id.caclebtn); + + succsebtn.setOnClickListener(v -> { + /* uminit为1时代表已经同意隐私协议,sp记录当前状态*/ + sharedPreferencesHelper.put("uminit", "1"); + UMConfigure.submitPolicyGrantResult(getApplicationContext(), true); + /* 友盟sdk正式初始化*/ + UmInitConfig umInitConfig = new UmInitConfig(); + umInitConfig.UMinit(getApplicationContext()); + //关闭弹窗 + dialog.dismiss(); + + //跳转到HomeActivity + final Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName()); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + + //杀掉以前进程 + android.os.Process.killProcess(android.os.Process.myPid()); + + finish(); + }); + + canclebtn.setOnClickListener(v -> { + dialog.dismiss(); + + UMConfigure.submitPolicyGrantResult(getApplicationContext(), false); + //不同意隐私协议,退出app + android.os.Process.killProcess(android.os.Process.myPid()); + + }); + + dialog.setContentView(inflate); + Window dialogWindow = dialog.getWindow(); + dialogWindow.setGravity(Gravity.CENTER); + + dialog.setCancelable(false); + dialog.show(); + } } diff --git a/app/src/main/java/com/idormy/sms/forwarder/MyApplication.java b/app/src/main/java/com/idormy/sms/forwarder/MyApplication.java index b13bc7b4..42b0f834 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/MyApplication.java +++ b/app/src/main/java/com/idormy/sms/forwarder/MyApplication.java @@ -11,12 +11,11 @@ import android.util.Log; import com.idormy.sms.forwarder.sender.SendHistory; import com.idormy.sms.forwarder.service.BatteryService; import com.idormy.sms.forwarder.service.FrontService; -import com.idormy.sms.forwarder.utils.CommonUtil; import com.idormy.sms.forwarder.utils.Define; import com.idormy.sms.forwarder.utils.PhoneUtils; import com.idormy.sms.forwarder.utils.SettingUtil; +import com.idormy.sms.forwarder.utils.SharedPreferencesHelper; import com.smailnet.emailkit.EmailKit; -import com.umeng.analytics.MobclickAgent; import com.umeng.commonsdk.UMConfigure; import java.util.ArrayList; @@ -28,6 +27,7 @@ public class MyApplication extends Application { public static List SimInfoList = new ArrayList<>(); //是否关闭页面提示 public static boolean showHelpTip = true; + SharedPreferencesHelper sharedPreferencesHelper; @Override protected void attachBaseContext(Context base) { @@ -40,14 +40,6 @@ public class MyApplication extends Application { super.onCreate(); try { - //初始化组件化基础库, 所有友盟业务SDK都必须调用此初始化接口。 - //建议在宿主App的Application.onCreate函数中调用基础组件库初始化函数。 - UMConfigure.init(this, "60254fc7425ec25f10f4293e", CommonUtil.getChannelName(this), UMConfigure.DEVICE_TYPE_PHONE, ""); - // 选用LEGACY_AUTO页面采集模式 - MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.LEGACY_MANUAL); - //pro close log - UMConfigure.setLogEnabled(true); - //前台服务 Intent intent = new Intent(this, FrontService.class); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { @@ -77,6 +69,20 @@ public class MyApplication extends Application { //电池状态监听 Intent batteryServiceIntent = new Intent(this, BatteryService.class); startService(batteryServiceIntent); + + //友盟统计 + sharedPreferencesHelper = new SharedPreferencesHelper(this, "umeng"); + //设置LOG开关,默认为false + //UMConfigure.setLogEnabled(true); + //友盟预初始化 + UMConfigure.preInit(getApplicationContext(), "60254fc7425ec25f10f4293e", "Umeng"); + + //判断是否同意隐私协议,uminit为1时为已经同意,直接初始化umsdk + if (sharedPreferencesHelper.getSharedPreference("uminit", "").equals("1")) { + //友盟正式初始化 + UmInitConfig umInitConfig = new UmInitConfig(); + umInitConfig.UMinit(getApplicationContext()); + } } catch (Exception e) { Log.e(TAG, "onCreate:", e); } diff --git a/app/src/main/java/com/idormy/sms/forwarder/RuleActivity.java b/app/src/main/java/com/idormy/sms/forwarder/RuleActivity.java index fe550a69..97fff669 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/RuleActivity.java +++ b/app/src/main/java/com/idormy/sms/forwarder/RuleActivity.java @@ -592,12 +592,14 @@ public class RuleActivity extends AppCompatActivity { @Override protected void onResume() { super.onResume(); + MobclickAgent.onPageStart(TAG); MobclickAgent.onResume(this); } @Override protected void onPause() { super.onPause(); + MobclickAgent.onPageEnd(TAG); MobclickAgent.onPause(this); } diff --git a/app/src/main/java/com/idormy/sms/forwarder/SenderActivity.java b/app/src/main/java/com/idormy/sms/forwarder/SenderActivity.java index b931db1d..0000f140 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/SenderActivity.java +++ b/app/src/main/java/com/idormy/sms/forwarder/SenderActivity.java @@ -1476,12 +1476,14 @@ public class SenderActivity extends AppCompatActivity { @Override protected void onResume() { super.onResume(); + MobclickAgent.onPageStart(TAG); MobclickAgent.onResume(this); } @Override protected void onPause() { super.onPause(); + MobclickAgent.onPageEnd(TAG); MobclickAgent.onPause(this); } diff --git a/app/src/main/java/com/idormy/sms/forwarder/UmInitConfig.java b/app/src/main/java/com/idormy/sms/forwarder/UmInitConfig.java new file mode 100644 index 00000000..855b82bb --- /dev/null +++ b/app/src/main/java/com/idormy/sms/forwarder/UmInitConfig.java @@ -0,0 +1,59 @@ +package com.idormy.sms.forwarder; + +import android.content.Context; + +import com.umeng.analytics.MobclickAgent; +import com.umeng.commonsdk.UMConfigure; + + +public class UmInitConfig { + + private static final String TAG = "MyApplication"; + + public void UMinit(Context context) { + + //初始化组件化基础库, 统计SDK/推送SDK/分享SDK都必须调用此初始化接口 + UMConfigure.init(context, "60254fc7425ec25f10f4293e", "Umeng", UMConfigure.DEVICE_TYPE_PHONE, ""); + + //集成umeng-crash-vx.x.x.aar,则需要关闭原有统计SDK异常捕获功能 + MobclickAgent.setCatchUncaughtExceptions(false); + + //统计SDK是否支持采集在子进程中打点的自定义事件,默认不支持 + UMConfigure.setProcessEvent(true);//支持多进程打点 + + // 页面数据采集模式 + // setPageCollectionMode接口参数说明: + // 1. MobclickAgent.PageMode.AUTO: 建议大多数用户使用本采集模式,SDK在此模式下自动采集Activity + // 页面访问路径,开发者不需要针对每一个Activity在onResume/onPause函数中进行手动埋点。在此模式下, + // 开发者如需针对Fragment、CustomView等自定义页面进行页面统计,直接调用MobclickAgent.onPageStart/ + // MobclickAgent.onPageEnd手动埋点即可。此采集模式简化埋点工作,唯一缺点是在Android 4.0以下设备中 + // 统计不到Activity页面数据和各类基础指标(提示:目前Android 4.0以下设备市场占比已经极小)。 + + // 2. MobclickAgent.PageMode.MANUAL:对于要求在Android 4.0以下设备中也能正常采集数据的App,可以使用 + // 本模式,开发者需要在每一个Activity的onResume函数中手动调用MobclickAgent.onResume接口,在Activity的 + // onPause函数中手动调用MobclickAgent.onPause接口。在此模式下,开发者如需针对Fragment、CustomView等 + // 自定义页面进行页面统计,直接调用MobclickAgent.onPageStart/MobclickAgent.onPageEnd手动埋点即可。 + + // 如下两种LEGACY模式不建议首次集成友盟统计SDK的新用户选用。 + // 如果您是友盟统计SDK的老用户,App需要从老版本统计SDK升级到8.0.0版本统计SDK, + // 并且:您的App之前MobclickAgent.onResume/onPause接口埋点分散在所有Activity + // 中,逐个删除修改工作量很大且易出错。 + // 若您的App符合以上特征,可以选用如下两种LEGACY模式,否则不建议继续使用LEGACY模式。 + // 简单来说,升级SDK的老用户,如果不需要手动统计页面路径,选用LEGACY_AUTO模式。 + // 如果需要手动统计页面路径,选用LEGACY_MANUAL模式。 + // 3. MobclickAgent.PageMode.LEGACY_AUTO: 本模式适合不需要对Fragment、CustomView + // 等自定义页面进行页面访问统计的开发者,SDK仅对App中所有Activity进行页面统计,开发者需要在 + // 每一个Activity的onResume函数中手动调用MobclickAgent.onResume接口,在Activity的 + // onPause函数中手动调用MobclickAgent.onPause接口。此模式下MobclickAgent.onPageStart + // ,MobclickAgent.onPageEnd这两个接口无效。 + + // 4. MobclickAgent.PageMode.LEGACY_MANUAL: 本模式适合需要对Fragment、CustomView + // 等自定义页面进行手动页面统计的开发者,开发者如需针对Fragment、CustomView等 + // 自定义页面进行页面统计,直接调用MobclickAgent.onPageStart/MobclickAgent.onPageEnd + // 手动埋点即可。开发者还需要在每一个Activity的onResume函数中手动调用MobclickAgent.onResume接口, + // 在Activity的onPause函数中手动调用MobclickAgent.onPause接口。 + MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO); + + } + +} diff --git a/app/src/main/java/com/idormy/sms/forwarder/receiver/SmsBroadcastReceiver.java b/app/src/main/java/com/idormy/sms/forwarder/receiver/SmsBroadcastReceiver.java index cdf1ba43..62ac1436 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/receiver/SmsBroadcastReceiver.java +++ b/app/src/main/java/com/idormy/sms/forwarder/receiver/SmsBroadcastReceiver.java @@ -3,10 +3,13 @@ package com.idormy.sms.forwarder.receiver; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.os.Build; import android.os.Bundle; import android.telephony.SmsMessage; import android.util.Log; +import androidx.annotation.RequiresApi; + import com.idormy.sms.forwarder.model.vo.SmsVo; import com.idormy.sms.forwarder.sender.SendUtil; import com.idormy.sms.forwarder.utils.SettingUtil; @@ -21,6 +24,7 @@ import java.util.Objects; public class SmsBroadcastReceiver extends BroadcastReceiver { + @RequiresApi(api = Build.VERSION_CODES.M) @Override public void onReceive(Context context, Intent intent) { diff --git a/app/src/main/java/com/idormy/sms/forwarder/sender/SenderSmsMsg.java b/app/src/main/java/com/idormy/sms/forwarder/sender/SenderSmsMsg.java index a9e32678..f4e4ea9f 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/sender/SenderSmsMsg.java +++ b/app/src/main/java/com/idormy/sms/forwarder/sender/SenderSmsMsg.java @@ -1,5 +1,6 @@ package com.idormy.sms.forwarder.sender; +import android.annotation.SuppressLint; import android.os.Handler; import android.util.Log; @@ -11,6 +12,7 @@ public class SenderSmsMsg extends SenderBaseMsg { static final String TAG = "SenderSmsMsg"; + @SuppressLint("NewApi") public static void sendMsg(final long logId, final Handler handError, int simSlot, String mobiles, Boolean onlyNoNetwork, String from, String text) throws Exception { Log.i(TAG, "sendMsg simSlot:" + simSlot + " mobiles:" + mobiles + " onlyNoNetwork:" + onlyNoNetwork + " from:" + from + " text:" + text); diff --git a/app/src/main/java/com/idormy/sms/forwarder/utils/CommonUtil.java b/app/src/main/java/com/idormy/sms/forwarder/utils/CommonUtil.java index 3de12192..9f4ef297 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/utils/CommonUtil.java +++ b/app/src/main/java/com/idormy/sms/forwarder/utils/CommonUtil.java @@ -6,10 +6,8 @@ import android.app.Activity; import android.content.ComponentName; import android.content.Context; import android.content.Intent; -import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; import androidx.core.app.NotificationManagerCompat; @@ -27,40 +25,6 @@ public class CommonUtil { public static final int NOTIFICATION_REQUEST_CODE = 9527; private static final String ACTION_NOTIFICATION_LISTENER_SETTINGS = "android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"; - /** - * - * - * - * @param ctx 上下文 - * @return 渠道名称 - */ - // 获取渠道工具函数 - public static String getChannelName(Context ctx) { - if (ctx == null) { - return null; - } - String channelName = null; - try { - PackageManager packageManager = ctx.getPackageManager(); - if (packageManager != null) { - //注意此处为ApplicationInfo 而不是 ActivityInfo,因为友盟设置的meta-data是在application标签中,而不是activity标签中,所以用ApplicationInfo - ApplicationInfo applicationInfo = packageManager.getApplicationInfo(ctx.getPackageName(), PackageManager.GET_META_DATA); - if (applicationInfo.metaData != null) { - channelName = applicationInfo.metaData.get("UMENG_CHANNEL") + ""; - } - } - } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - } - if (TextUtils.isEmpty(channelName)) { - channelName = "Unknown"; - } - - return channelName; - } - //是否启用通知监听服务 public static boolean isNotificationListenerServiceEnabled(Context context) { Set packageNames = NotificationManagerCompat.getEnabledListenerPackages(context); diff --git a/app/src/main/java/com/idormy/sms/forwarder/utils/PhoneUtils.java b/app/src/main/java/com/idormy/sms/forwarder/utils/PhoneUtils.java index 93140862..71bdefb3 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/utils/PhoneUtils.java +++ b/app/src/main/java/com/idormy/sms/forwarder/utils/PhoneUtils.java @@ -329,7 +329,7 @@ public class PhoneUtils { * * @return 多Sim卡的具体信息 */ - @SuppressLint("ObsoleteSdkInt") + @SuppressLint({"ObsoleteSdkInt", "Range"}) public static List getSimMultiInfo() { List infos = new ArrayList<>(); Log.d(TAG, "Build.VERSION.SDK_INT = " + Build.VERSION.SDK_INT); @@ -533,6 +533,7 @@ public class PhoneUtils { /** * 获取后一条通话记录 */ + @SuppressLint("Range") public static CallInfo getLastCallInfo(String phoneNumber) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { return null; diff --git a/app/src/main/java/com/idormy/sms/forwarder/utils/SharedPreferencesHelper.java b/app/src/main/java/com/idormy/sms/forwarder/utils/SharedPreferencesHelper.java new file mode 100644 index 00000000..c1c98722 --- /dev/null +++ b/app/src/main/java/com/idormy/sms/forwarder/utils/SharedPreferencesHelper.java @@ -0,0 +1,87 @@ +package com.idormy.sms.forwarder.utils; + +import android.content.Context; +import android.content.SharedPreferences; + +import java.util.Map; + +public class SharedPreferencesHelper { + + private final SharedPreferences sharedPreferences; + private final SharedPreferences.Editor editor; + + public SharedPreferencesHelper(Context context, String FILE_NAME) { + sharedPreferences = context.getSharedPreferences(FILE_NAME, + Context.MODE_PRIVATE); + editor = sharedPreferences.edit(); + } + + /** + * 存储 + */ + public void put(String key, Object object) { + if (object instanceof String) { + editor.putString(key, (String) object); + } else if (object instanceof Integer) { + editor.putInt(key, (Integer) object); + } else if (object instanceof Boolean) { + editor.putBoolean(key, (Boolean) object); + } else if (object instanceof Float) { + editor.putFloat(key, (Float) object); + } else if (object instanceof Long) { + editor.putLong(key, (Long) object); + } else { + editor.putString(key, object.toString()); + } + editor.commit(); + } + + /** + * 获取保存的数据 + */ + public Object getSharedPreference(String key, Object defaultObject) { + if (defaultObject instanceof String) { + return sharedPreferences.getString(key, (String) defaultObject); + } else if (defaultObject instanceof Integer) { + return sharedPreferences.getInt(key, (Integer) defaultObject); + } else if (defaultObject instanceof Boolean) { + return sharedPreferences.getBoolean(key, (Boolean) defaultObject); + } else if (defaultObject instanceof Float) { + return sharedPreferences.getFloat(key, (Float) defaultObject); + } else if (defaultObject instanceof Long) { + return sharedPreferences.getLong(key, (Long) defaultObject); + } else { + return sharedPreferences.getString(key, null); + } + } + + /** + * 移除某个key值已经对应的值 + */ + public void remove(String key) { + editor.remove(key); + editor.commit(); + } + + /** + * 清除所有数据 + */ + public void clear() { + editor.clear(); + editor.commit(); + } + + /** + * 查询某个key是否存在 + */ + public Boolean contain(String key) { + return sharedPreferences.contains(key); + } + + /** + * 返回所有的键值对 + */ + public Map getAll() { + return sharedPreferences.getAll(); + } +} diff --git a/app/src/main/res/layout/activity_setting.xml b/app/src/main/res/layout/activity_setting.xml index 35f5d654..d2ac7f0b 100644 --- a/app/src/main/res/layout/activity_setting.xml +++ b/app/src/main/res/layout/activity_setting.xml @@ -702,7 +702,7 @@ android:gravity="end" android:text="@string/enable_exclude_from_recents_tips" android:textSize="9sp" - tools:ignore="SmallSp" /> + tools:ignore="SmallSp,TooManyViews" /> + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 76e1e0eb..f0bff7f7 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -265,4 +265,8 @@ Proxy Authenticator Username Password + Privacy Policy + Agree + Disagree + SmsForwarder, this software is 100% free, open source, Github online compiled and release, will not collect any of your privacy data!\n\n The software version information will be reported in the following situations: \n 1. When starting the software, the version information will be sent to "Umeng +· U-APP Mobile Statistics" for analyzing the statistics of user version retention and software crash;\n 2. When manually checking the update, send the version number to check the new version;\n Other than that, there is no data!!\n\n The software will collect and use version information in accordance with the Privacy Policy, but will not collect bundled information because you have agreed to the Privacy Policy. diff --git a/app/src/main/res/values-en/styles.xml b/app/src/main/res/values-en/styles.xml index 45fa69ab..bbad0cda 100644 --- a/app/src/main/res/values-en/styles.xml +++ b/app/src/main/res/values-en/styles.xml @@ -41,4 +41,12 @@ @drawable/txt_select_selector + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3cceee33..ce420643 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -264,4 +264,8 @@ 代理身份验证 用户 密码 + 隐私政策 + 同意 + 不同意 + SmsForwarder-短信转发器(下称本软件) 100% 免费开源,Github 在线编译发版,绝不会收集您的任何隐私数据! \n\n以下情形会上报本软件版本信息: \n 1、启动本软件时,发送版本信息发送到《友盟+·U-App移动统计》,用于分析本软件的用户版本留存与软件奔溃统计; \n 2、手动检查更新时,发送版本号用于检查新版本; \n除此之外,没有任何数据!!! \n\n本软件会遵循《隐私政策》收集、使用版本信息,但不会因为您同意了《隐私政策》而进行强制捆绑式的信息收集。 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 537b9e03..3c231574 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -43,4 +43,13 @@ 0.1 @drawable/txt_select_selector + + diff --git a/build.gradle b/build.gradle index 4cb3b375..ce1afdd9 100644 --- a/build.gradle +++ b/build.gradle @@ -2,21 +2,25 @@ buildscript { repositories { + maven { url 'https://maven.aliyun.com/repository/google' } + maven { url 'https://maven.aliyun.com/repository/central' } + maven { url 'https://maven.aliyun.com/repository/public' } google() - jcenter() maven { url "https://jitpack.io" } maven { url 'https://repo1.maven.org/maven2/' } } dependencies { - classpath 'com.android.tools.build:gradle:7.0.3' + classpath 'com.android.tools.build:gradle:7.0.4' classpath 'com.chenenyu:img-optimizer:1.2.0' } } allprojects { repositories { + maven { url 'https://maven.aliyun.com/repository/google' } + maven { url 'https://maven.aliyun.com/repository/central' } + maven { url 'https://maven.aliyun.com/repository/public' } google() - jcenter() maven { url "https://jitpack.io" } maven { url 'https://repo1.maven.org/maven2/' } } diff --git a/version.properties b/version.properties index 9547b211..47f2b63c 100644 --- a/version.properties +++ b/version.properties @@ -1,3 +1,3 @@ #Fri Jul 16 10:33:23 CST 2021 -versionName=2.3.0 -versionCode=32 +versionName=2.4.0 +versionCode=33