mirror of
https://github.com/pppscn/SmsForwarder
synced 2025-08-03 01:17:41 +08:00
优化:未同意隐私协议前不进行任何组件初始化
修复:部分机型 Android 12 启动前端服务奔溃 优化:StepBar控件
This commit is contained in:
parent
5b55c7f845
commit
c6a4f4ccdc
@ -63,10 +63,6 @@ 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) {
|
||||
Log.d(TAG, "onCreate");
|
||||
@ -74,6 +70,9 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
//是否同意隐私协议
|
||||
if (!MyApplication.allowPrivacyPolicy) return;
|
||||
|
||||
//获取SIM信息
|
||||
PhoneUtils.init(this);
|
||||
|
||||
@ -132,10 +131,8 @@ 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")) {
|
||||
//是否同意隐私协议
|
||||
if (!MyApplication.allowPrivacyPolicy) {
|
||||
dialog();
|
||||
return;
|
||||
}
|
||||
@ -144,11 +141,10 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
||||
PackageManager pm = getPackageManager();
|
||||
CommonUtil.CheckPermission(pm, this);
|
||||
|
||||
//是否关闭页面提示 & 计算浮动按钮位置
|
||||
TextView help_tip = findViewById(R.id.help_tip);
|
||||
//计算浮动按钮位置
|
||||
FloatingActionButton btnFloat = findViewById(R.id.btnCleanLog);
|
||||
RefreshListView viewList = findViewById(R.id.list_view_log);
|
||||
CommonUtil.calcMarginBottom(this, help_tip, btnFloat, viewList, null);
|
||||
CommonUtil.calcMarginBottom(this, btnFloat, viewList, null);
|
||||
|
||||
//清空日志
|
||||
btnFloat.setOnClickListener(v -> {
|
||||
@ -214,12 +210,8 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
||||
});
|
||||
|
||||
//步骤完成状态校验
|
||||
boolean checkStep1 = SettingUtil.getSwitchEnableSms() || SettingUtil.getSwitchEnablePhone() || SettingUtil.getSwitchEnableAppNotify();
|
||||
boolean checkStep2 = SenderUtil.countSender("1", null) > 0;
|
||||
boolean checkStep3 = RuleUtil.countRule("1", null, null) > 0;
|
||||
boolean checkStep4 = LogUtil.countLog("2", null, null) > 0;
|
||||
StepBar stepBar = findViewById(R.id.stepBar);
|
||||
stepBar.setHighlight(checkStep1, checkStep2, checkStep3, checkStep4);
|
||||
stepBar.setHighlight();
|
||||
}
|
||||
|
||||
private int getTypeCheckId(String currentType) {
|
||||
@ -240,6 +232,9 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
||||
MobclickAgent.onPageStart(TAG);
|
||||
MobclickAgent.onResume(this);
|
||||
|
||||
//是否同意隐私协议
|
||||
if (!MyApplication.allowPrivacyPolicy) return;
|
||||
|
||||
//第一次打开,未授权无法获取SIM信息,尝试在此重新获取
|
||||
if (MyApplication.SimInfoList.isEmpty()) {
|
||||
MyApplication.SimInfoList = PhoneUtils.getSimMultiInfo();
|
||||
@ -271,6 +266,10 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
//是否同意隐私协议
|
||||
if (!MyApplication.allowPrivacyPolicy) return;
|
||||
|
||||
try {
|
||||
if (serviceIntent != null) startService(serviceIntent);
|
||||
} catch (Exception e) {
|
||||
@ -282,6 +281,10 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
||||
protected void onPause() {
|
||||
overridePendingTransition(0, 0);
|
||||
super.onPause();
|
||||
|
||||
//是否同意隐私协议
|
||||
if (!MyApplication.allowPrivacyPolicy) return;
|
||||
|
||||
MobclickAgent.onPageEnd(TAG);
|
||||
MobclickAgent.onPause(this);
|
||||
try {
|
||||
@ -294,6 +297,10 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
//是否同意隐私协议
|
||||
if (!MyApplication.allowPrivacyPolicy) return;
|
||||
|
||||
if (requestCode == CommonUtil.NOTIFICATION_REQUEST_CODE) {
|
||||
if (CommonUtil.isNotificationListenerServiceEnabled(this)) {
|
||||
Toast.makeText(this, R.string.notification_listener_service_enabled, Toast.LENGTH_SHORT).show();
|
||||
@ -448,13 +455,14 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
||||
/*** 隐私协议授权弹窗*/
|
||||
@SuppressLint({"ResourceType", "InflateParams"})
|
||||
public void dialog() {
|
||||
dialog = new Dialog(this, R.style.dialog);
|
||||
inflate = LayoutInflater.from(MainActivity.this).inflate(R.layout.diaolog_privacy_policy, null);
|
||||
Dialog dialog = new Dialog(this, R.style.dialog);
|
||||
View inflate = LayoutInflater.from(MainActivity.this).inflate(R.layout.diaolog_privacy_policy, null);
|
||||
TextView succsebtn = inflate.findViewById(R.id.succsebtn);
|
||||
TextView canclebtn = inflate.findViewById(R.id.caclebtn);
|
||||
|
||||
succsebtn.setOnClickListener(v -> {
|
||||
/* uminit为1时代表已经同意隐私协议,sp记录当前状态*/
|
||||
SharedPreferencesHelper sharedPreferencesHelper = new SharedPreferencesHelper(this, "umeng");
|
||||
sharedPreferencesHelper.put("uminit", "1");
|
||||
UMConfigure.submitPolicyGrantResult(getApplicationContext(), true);
|
||||
/* 友盟sdk正式初始化*/
|
||||
@ -479,6 +487,7 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
||||
UMConfigure.submitPolicyGrantResult(getApplicationContext(), false);
|
||||
//不同意隐私协议,退出app
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
finish();
|
||||
});
|
||||
|
||||
dialog.setContentView(inflate);
|
||||
|
@ -30,6 +30,8 @@ public class MyApplication extends Application {
|
||||
//是否关闭页面提示
|
||||
public static boolean showHelpTip = true;
|
||||
SharedPreferencesHelper sharedPreferencesHelper;
|
||||
//是否同意隐私协议
|
||||
public static boolean allowPrivacyPolicy = false;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static Context context;
|
||||
|
||||
@ -44,11 +46,29 @@ public class MyApplication extends Application {
|
||||
super.onCreate();
|
||||
context = getApplicationContext();
|
||||
|
||||
//异常捕获类
|
||||
CrashHandler crashHandler = CrashHandler.getInstance();
|
||||
crashHandler.init(getApplicationContext());
|
||||
|
||||
try {
|
||||
//异常捕获类
|
||||
CrashHandler crashHandler = CrashHandler.getInstance();
|
||||
crashHandler.init(getApplicationContext());
|
||||
|
||||
//友盟统计
|
||||
sharedPreferencesHelper = new SharedPreferencesHelper(this, "umeng");
|
||||
//设置LOG开关,默认为false
|
||||
//UMConfigure.setLogEnabled(true);
|
||||
//友盟预初始化
|
||||
UMConfigure.preInit(getApplicationContext(), "60254fc7425ec25f10f4293e", "Umeng");
|
||||
|
||||
//判断是否同意隐私协议,uminit为1时为已经同意,直接初始化umsdk
|
||||
if (sharedPreferencesHelper.getSharedPreference("uminit", "").equals("1")) {
|
||||
allowPrivacyPolicy = true;
|
||||
//友盟正式初始化
|
||||
UmInitConfig umInitConfig = new UmInitConfig();
|
||||
umInitConfig.UMinit(getApplicationContext());
|
||||
}
|
||||
|
||||
//是否同意隐私协议
|
||||
if (!MyApplication.allowPrivacyPolicy) return;
|
||||
|
||||
//前台服务
|
||||
Intent intent = new Intent(this, FrontService.class);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
@ -82,19 +102,6 @@ public class MyApplication extends Application {
|
||||
IntentFilter simStateFilter = new IntentFilter(SimStateReceiver.ACTION_SIM_STATE_CHANGED);
|
||||
registerReceiver(new SimStateReceiver(), simStateFilter);
|
||||
|
||||
//友盟统计
|
||||
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);
|
||||
}
|
||||
|
@ -133,20 +133,16 @@ public class RuleActivity extends AppCompatActivity {
|
||||
});
|
||||
|
||||
|
||||
//是否关闭页面提示
|
||||
TextView help_tip = findViewById(R.id.help_tip);
|
||||
//计算浮动按钮位置
|
||||
FloatingActionButton btnFloat = findViewById(R.id.btnFloat);
|
||||
CommonUtil.calcMarginBottom(this, help_tip, btnFloat, listView, null);
|
||||
CommonUtil.calcMarginBottom(this, btnFloat, listView, null);
|
||||
|
||||
//添加规则
|
||||
btnFloat.setOnClickListener(v -> setRule(null, false));
|
||||
|
||||
//步骤完成状态校验
|
||||
boolean checkStep1 = SettingUtil.getSwitchEnableSms() || SettingUtil.getSwitchEnablePhone() || SettingUtil.getSwitchEnableAppNotify();
|
||||
boolean checkStep2 = SenderUtil.countSender("1", null) > 0;
|
||||
boolean checkStep3 = RuleUtil.countRule("1", null, null) > 0;
|
||||
boolean checkStep4 = LogUtil.countLog("2", null, null) > 0;
|
||||
StepBar stepBar = findViewById(R.id.stepBar);
|
||||
stepBar.setHighlight(checkStep1, checkStep2, checkStep3, checkStep4);
|
||||
stepBar.setHighlight();
|
||||
}
|
||||
|
||||
private int getTypeCheckId(String curType) {
|
||||
|
@ -32,7 +32,6 @@ import android.widget.ListView;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
@ -71,7 +70,6 @@ import com.idormy.sms.forwarder.sender.SenderWebNotifyMsg;
|
||||
import com.idormy.sms.forwarder.utils.CommonUtil;
|
||||
import com.idormy.sms.forwarder.utils.LogUtil;
|
||||
import com.idormy.sms.forwarder.utils.RuleUtil;
|
||||
import com.idormy.sms.forwarder.utils.SettingUtil;
|
||||
import com.idormy.sms.forwarder.view.ClearEditText;
|
||||
import com.idormy.sms.forwarder.view.StepBar;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
@ -250,10 +248,10 @@ public class SenderActivity extends AppCompatActivity {
|
||||
});
|
||||
|
||||
|
||||
//是否关闭页面提示
|
||||
TextView help_tip = findViewById(R.id.help_tip);
|
||||
//计算浮动按钮位置
|
||||
FloatingActionButton btnFloat = findViewById(R.id.btnAddSender);
|
||||
CommonUtil.calcMarginBottom(this, help_tip, btnFloat, listView, null);
|
||||
CommonUtil.calcMarginBottom(this, btnFloat, listView, null);
|
||||
|
||||
//添加发送通道
|
||||
btnFloat.setOnClickListener(v -> {
|
||||
|
||||
@ -317,12 +315,8 @@ public class SenderActivity extends AppCompatActivity {
|
||||
});
|
||||
|
||||
//步骤完成状态校验
|
||||
boolean checkStep1 = SettingUtil.getSwitchEnableSms() || SettingUtil.getSwitchEnablePhone() || SettingUtil.getSwitchEnableAppNotify();
|
||||
boolean checkStep2 = SenderUtil.countSender("1", null) > 0;
|
||||
boolean checkStep3 = RuleUtil.countRule("1", null, null) > 0;
|
||||
boolean checkStep4 = LogUtil.countLog("2", null, null) > 0;
|
||||
StepBar stepBar = findViewById(R.id.stepBar);
|
||||
stepBar.setHighlight(checkStep1, checkStep2, checkStep3, checkStep4);
|
||||
stepBar.setHighlight();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,9 +74,8 @@ public class SettingActivity extends AppCompatActivity {
|
||||
Log.d(TAG, "onStart");
|
||||
|
||||
//是否关闭页面提示
|
||||
TextView help_tip = findViewById(R.id.help_tip);
|
||||
ScrollView scrollView = findViewById(R.id.scrollView);
|
||||
CommonUtil.calcMarginBottom(this, help_tip, null, null, scrollView);
|
||||
CommonUtil.calcMarginBottom(this, null, null, scrollView);
|
||||
|
||||
//转发短信广播
|
||||
switchEnableSms(findViewById(R.id.switch_enable_sms));
|
||||
@ -119,12 +118,8 @@ public class SettingActivity extends AppCompatActivity {
|
||||
SwitchHelpTip(findViewById(R.id.switch_help_tip));
|
||||
|
||||
//步骤完成状态校验
|
||||
boolean checkStep1 = SettingUtil.getSwitchEnableSms() || SettingUtil.getSwitchEnablePhone() || SettingUtil.getSwitchEnableAppNotify();
|
||||
boolean checkStep2 = SenderUtil.countSender("1", null) > 0;
|
||||
boolean checkStep3 = RuleUtil.countRule("1", null, null) > 0;
|
||||
boolean checkStep4 = LogUtil.countLog("2", null, null) > 0;
|
||||
StepBar stepBar = findViewById(R.id.stepBar);
|
||||
stepBar.setHighlight(checkStep1, checkStep2, checkStep3, checkStep4);
|
||||
stepBar.setHighlight();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -769,8 +764,9 @@ public class SettingActivity extends AppCompatActivity {
|
||||
Log.d(TAG, "onCheckedChanged:" + isChecked);
|
||||
|
||||
TextView help_tip = findViewById(R.id.help_tip);
|
||||
help_tip.setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||
ScrollView scrollView = findViewById(R.id.scrollView);
|
||||
CommonUtil.calcMarginBottom(this, help_tip, null, null, scrollView);
|
||||
CommonUtil.calcMarginBottom(this, null, null, scrollView);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import android.os.BatteryManager;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import com.idormy.sms.forwarder.MyApplication;
|
||||
import com.idormy.sms.forwarder.model.vo.SmsHubVo;
|
||||
import com.idormy.sms.forwarder.model.vo.SmsVo;
|
||||
import com.idormy.sms.forwarder.sender.SendUtil;
|
||||
@ -32,6 +33,10 @@ public class BatteryService extends Service {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Log.i(TAG, "onCreate--------------");
|
||||
|
||||
//是否同意隐私协议
|
||||
if (!MyApplication.allowPrivacyPolicy) return;
|
||||
|
||||
IntentFilter batteryfilter = new IntentFilter();
|
||||
batteryfilter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||
registerReceiver(batteryReceiver, batteryfilter);
|
||||
@ -52,6 +57,10 @@ public class BatteryService extends Service {
|
||||
public void onDestroy() {
|
||||
Log.i(TAG, "onDestroy--------------");
|
||||
super.onDestroy();
|
||||
|
||||
//是否同意隐私协议
|
||||
if (!MyApplication.allowPrivacyPolicy) return;
|
||||
|
||||
this.unregisterReceiver(batteryReceiver);
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,10 @@ public class FrontService extends Service {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Log.i(TAG, "onCreate");
|
||||
|
||||
//是否同意隐私协议
|
||||
if (!MyApplication.allowPrivacyPolicy) return;
|
||||
|
||||
Notification.Builder builder = new Notification.Builder(this);
|
||||
builder.setSmallIcon(R.drawable.ic_forwarder);
|
||||
builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher));
|
||||
@ -44,7 +48,8 @@ public class FrontService extends Service {
|
||||
}
|
||||
builder.setContentText(getString(R.string.notification_content));
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
@SuppressLint("UnspecifiedImmutableFlag") PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
int flags = Build.VERSION.SDK_INT >= 30 ? PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT;
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, flags);
|
||||
builder.setContentIntent(pendingIntent);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
@ -83,12 +88,16 @@ public class FrontService extends Service {
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
//是否同意隐私协议
|
||||
if (!MyApplication.allowPrivacyPolicy) return;
|
||||
|
||||
//进行自动重启
|
||||
Intent intent = new Intent(FrontService.this, FrontService.class);
|
||||
//重新开启服务
|
||||
startService(intent);
|
||||
stopForeground(true);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,6 +8,7 @@ import android.util.Log;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.idormy.sms.forwarder.MyApplication;
|
||||
import com.idormy.sms.forwarder.model.vo.SmsHubVo;
|
||||
import com.idormy.sms.forwarder.model.vo.SmsVo;
|
||||
import com.idormy.sms.forwarder.sender.SendUtil;
|
||||
@ -32,6 +33,9 @@ public class NotifyService extends NotificationListenerService {
|
||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
||||
@Override
|
||||
public void onNotificationPosted(StatusBarNotification sbn) {
|
||||
//是否同意隐私协议
|
||||
if (!MyApplication.allowPrivacyPolicy) return;
|
||||
|
||||
//未开启转发
|
||||
if (!SettingUtil.getSwitchEnableAppNotify()) return;
|
||||
//异常通知跳过
|
||||
|
@ -9,12 +9,10 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
@ -167,11 +165,7 @@ public class CommonUtil {
|
||||
}
|
||||
|
||||
//计算浮动按钮位置
|
||||
public static void calcMarginBottom(Context context, TextView help_tip, FloatingActionButton btnFloat, ListView viewList, ScrollView scrollView) {
|
||||
|
||||
if (help_tip != null) {
|
||||
help_tip.setVisibility(MyApplication.showHelpTip ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
public static void calcMarginBottom(Context context, FloatingActionButton btnFloat, ListView viewList, ScrollView scrollView) {
|
||||
|
||||
int marginBottom = MyApplication.showHelpTip ? 85 : 65;
|
||||
if (btnFloat != null) {
|
||||
|
@ -12,10 +12,15 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.idormy.sms.forwarder.MainActivity;
|
||||
import com.idormy.sms.forwarder.MyApplication;
|
||||
import com.idormy.sms.forwarder.R;
|
||||
import com.idormy.sms.forwarder.RuleActivity;
|
||||
import com.idormy.sms.forwarder.SenderActivity;
|
||||
import com.idormy.sms.forwarder.SettingActivity;
|
||||
import com.idormy.sms.forwarder.sender.SenderUtil;
|
||||
import com.idormy.sms.forwarder.utils.LogUtil;
|
||||
import com.idormy.sms.forwarder.utils.RuleUtil;
|
||||
import com.idormy.sms.forwarder.utils.SettingUtil;
|
||||
|
||||
@SuppressWarnings("FieldCanBeLocal")
|
||||
public class StepBar extends LinearLayout {
|
||||
@ -23,7 +28,9 @@ public class StepBar extends LinearLayout {
|
||||
private TypedArray mTypedArray;
|
||||
//自定义参数
|
||||
private String current_step;
|
||||
private String help_tip;
|
||||
//控件
|
||||
private TextView txHelpTip;
|
||||
private TextView txStep1;
|
||||
private TextView txStep2;
|
||||
private TextView txStep3;
|
||||
@ -67,6 +74,8 @@ public class StepBar extends LinearLayout {
|
||||
if (mTypedArray != null) {
|
||||
current_step = mTypedArray.getString(R.styleable.StepBar_current_step);
|
||||
System.out.println("current_step = " + current_step);
|
||||
help_tip = mTypedArray.getString(R.styleable.StepBar_help_tip);
|
||||
System.out.println("help_tip = " + help_tip);
|
||||
mTypedArray.recycle();
|
||||
}
|
||||
}
|
||||
@ -75,6 +84,12 @@ public class StepBar extends LinearLayout {
|
||||
//初始化界面
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.step_bar, this);
|
||||
|
||||
txHelpTip = findViewById(R.id.txHelpTip);
|
||||
if (txHelpTip != null) {
|
||||
txHelpTip.setText(help_tip);
|
||||
txHelpTip.setVisibility(MyApplication.showHelpTip ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
//步骤1
|
||||
txStep1 = findViewById(R.id.txStep1);
|
||||
tvStep1 = findViewById(R.id.tvStep1);
|
||||
@ -151,7 +166,22 @@ public class StepBar extends LinearLayout {
|
||||
}
|
||||
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
public void setHighlight(boolean Step1, boolean Step2, boolean Step3, boolean Step4) {
|
||||
public void setHighlight() {
|
||||
SettingUtil.init(mContext);
|
||||
SenderUtil.init(mContext);
|
||||
RuleUtil.init(mContext);
|
||||
LogUtil.init(mContext);
|
||||
|
||||
boolean Step1 = SettingUtil.getSwitchEnableSms() || SettingUtil.getSwitchEnablePhone() || SettingUtil.getSwitchEnableAppNotify();
|
||||
boolean Step2 = SenderUtil.countSender("1", null) > 0;
|
||||
boolean Step3 = RuleUtil.countRule("1", null, null) > 0;
|
||||
boolean Step4 = LogUtil.countLog("2", null, null) > 0;
|
||||
|
||||
//页面提示文本
|
||||
if (MyApplication.showHelpTip && current_step.equals("main") && txHelpTip != null) {
|
||||
txHelpTip.setText(Step1 ? R.string.log_tips : R.string.setting_tips);
|
||||
}
|
||||
|
||||
if (Step1) txStep1.setBackground(mContext.getResources().getDrawable(R.drawable.step_circle_current));
|
||||
if (Step2) txStep2.setBackground(mContext.getResources().getDrawable(R.drawable.step_circle_current));
|
||||
if (Step3) txStep3.setBackground(mContext.getResources().getDrawable(R.drawable.step_circle_current));
|
||||
|
@ -69,29 +69,13 @@
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginBottom="85dp" />
|
||||
|
||||
<LinearLayout
|
||||
<com.idormy.sms.forwarder.view.StepBar
|
||||
android:id="@+id/stepBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/help_tip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#10000000"
|
||||
android:gravity="center"
|
||||
android:padding="2dp"
|
||||
android:text="@string/log_tips"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<com.idormy.sms.forwarder.view.StepBar
|
||||
android:id="@+id/stepBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:current_step="main" />
|
||||
</LinearLayout>
|
||||
app:current_step="main"
|
||||
app:help_tip="@string/log_tips" />
|
||||
|
||||
</RelativeLayout>
|
@ -79,30 +79,13 @@
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginBottom="85dp" />
|
||||
|
||||
<LinearLayout
|
||||
<com.idormy.sms.forwarder.view.StepBar
|
||||
android:id="@+id/stepBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/help_tip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#10000000"
|
||||
android:gravity="center"
|
||||
android:padding="3dp"
|
||||
android:text="@string/rule_tips"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<com.idormy.sms.forwarder.view.StepBar
|
||||
android:id="@+id/stepBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:current_step="rule" />
|
||||
|
||||
</LinearLayout>
|
||||
app:current_step="rule"
|
||||
app:help_tip="@string/log_tips" />
|
||||
|
||||
</RelativeLayout>
|
@ -29,29 +29,13 @@
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginBottom="85dp" />
|
||||
|
||||
<LinearLayout
|
||||
<com.idormy.sms.forwarder.view.StepBar
|
||||
android:id="@+id/stepBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/help_tip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#10000000"
|
||||
android:gravity="center"
|
||||
android:padding="3dp"
|
||||
android:text="@string/sender_tips"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<com.idormy.sms.forwarder.view.StepBar
|
||||
android:id="@+id/stepBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:current_step="sender" />
|
||||
</LinearLayout>
|
||||
app:current_step="sender"
|
||||
app:help_tip="@string/sender_tips" />
|
||||
|
||||
</RelativeLayout>
|
@ -1051,30 +1051,13 @@
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<LinearLayout
|
||||
<com.idormy.sms.forwarder.view.StepBar
|
||||
android:id="@+id/stepBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/help_tip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#10000000"
|
||||
android:gravity="center"
|
||||
android:padding="2dp"
|
||||
android:text="@string/setting_tips"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<com.idormy.sms.forwarder.view.StepBar
|
||||
android:id="@+id/stepBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:current_step="setting" />
|
||||
|
||||
</LinearLayout>
|
||||
app:current_step="setting"
|
||||
app:help_tip="@string/setting_tips" />
|
||||
|
||||
</RelativeLayout>
|
@ -6,6 +6,17 @@
|
||||
android:background="#ffffff"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txHelpTip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#10000000"
|
||||
android:gravity="center"
|
||||
android:padding="2dp"
|
||||
android:text="@string/log_tips"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
|
@ -79,5 +79,6 @@
|
||||
|
||||
<declare-styleable name="StepBar">
|
||||
<attr name="current_step" format="string" />
|
||||
<attr name="help_tip" format="string" />
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
@ -82,5 +82,6 @@
|
||||
|
||||
<declare-styleable name="StepBar">
|
||||
<attr name="current_step" format="string" />
|
||||
<attr name="help_tip" format="string" />
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user