diff --git a/app/build.gradle b/app/build.gradle index 61a7eea..e57f60c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,4 @@ apply plugin: 'com.android.application' -apply plugin: "com.tencent.android.tpns" def appName() { return "AIOS系统" @@ -16,8 +15,8 @@ android { applicationId "com.uiuios.aios" minSdkVersion 24 targetSdkVersion 29 - versionCode 26 - versionName "3.5" + versionCode 27 + versionName "3.6" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -49,6 +48,14 @@ android { } signingConfigs { + tuixin { + storeFile file("keystore/tuixin.jks") + storePassword "123456" + keyAlias "universal" + keyPassword "123456" + v2SigningEnabled false + } + zhanRui { storeFile file("keystore/zhanxun.keystore") storePassword "123456" @@ -95,41 +102,41 @@ android { } buildTypes { - MTK8183Debug.initWith(debug) - MTK8183Debug { - versionNameSuffix "-debug" - debuggable true - signingConfig signingConfigs.MTK8183 - } - - MTK8183Release.initWith(release) - MTK8183Release { - signingConfig signingConfigs.MTK8183 - } - - G10PDebug.initWith(debug) - G10PDebug { - versionNameSuffix "-debug" - debuggable true - signingConfig signingConfigs.G10P - } - - G10PRelease.initWith(release) - G10PRelease { - signingConfig signingConfigs.G10P - } - - zhanRuiRelease.initWith(release) - zhanRuiRelease { - signingConfig signingConfigs.zhanRui - } - - zhanRuiDebug.initWith(debug) - zhanRuiDebug { - versionNameSuffix "-debug" - debuggable true - signingConfig signingConfigs.zhanRui - } +// MTK8183Debug.initWith(debug) +// MTK8183Debug { +// versionNameSuffix "-debug" +// debuggable true +// signingConfig signingConfigs.MTK8183 +// } +// +// MTK8183Release.initWith(release) +// MTK8183Release { +// signingConfig signingConfigs.MTK8183 +// } +// +// G10PDebug.initWith(debug) +// G10PDebug { +// versionNameSuffix "-debug" +// debuggable true +// signingConfig signingConfigs.G10P +// } +// +// G10PRelease.initWith(release) +// G10PRelease { +// signingConfig signingConfigs.G10P +// } +// +// zhanRuiRelease.initWith(release) +// zhanRuiRelease { +// signingConfig signingConfigs.zhanRui +// } +// +// zhanRuiDebug.initWith(debug) +// zhanRuiDebug { +// versionNameSuffix "-debug" +// debuggable true +// signingConfig signingConfigs.zhanRui +// } debug { // 显示Log @@ -137,7 +144,7 @@ android { minifyEnabled false //Zipalign优化 zipAlignEnabled true - signingConfig signingConfigs.mtk + signingConfig signingConfigs.tuixin applicationVariants.all { variant -> variant.outputs.each { output -> if (outputFile != null) { @@ -157,7 +164,7 @@ android { //前一部分代表系统默认的android程序的混淆文件,该文件已经包含了基本的混淆声明,后一个文件是自己的定义混淆文件 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' //签名 - signingConfig signingConfigs.mtk + signingConfig signingConfigs.tuixin // 将release版本的包名重命名,加上版本及日期 applicationVariants.all { variant -> variant.outputs.each { output -> @@ -174,9 +181,10 @@ android { dependencies { // implementation fileTree(dir: 'libs', include: ['*.jar']) - compileOnly files('libs/framework.jar') +// compileOnly files('libs/framework.jar') implementation files('libs/QWeather_Public_Android_V4.9.jar') implementation project(path: ':niceimageview') + implementation project(path: ':verification-view') //保持1.3.1 更新会报错 implementation 'androidx.appcompat:appcompat:1.3.1' @@ -230,8 +238,6 @@ dependencies { // implementation 'com.baidu.lbsyun:BaiduMapSDK_Location:9.1.8' //MMKV implementation 'com.tencent:mmkv-static:1.2.14' - //腾讯移动推送 TPNS - implementation 'com.tencent.tpns:tpns:1.3.8.0-release' //阿里云推送 implementation 'com.aliyun.ams:alicloud-android-push:3.8.0' //状态栏透明 @@ -255,6 +261,8 @@ dependencies { // implementation 'com.jacktuotuo.customview:verificationcodeview:1.0.5' implementation 'com.contrarywind:Android-PickerView:4.1.9' implementation 'com.github.ForgetAll:LoadingDialog:v1.1.2' + //动态权限框架 + implementation 'com.github.getActivity:XXPermissions:16.6' } preBuild { diff --git a/app/keystore/tuixin.jks b/app/keystore/tuixin.jks new file mode 100644 index 0000000..d7ecbad Binary files /dev/null and b/app/keystore/tuixin.jks differ diff --git a/app/libs/framework.jar b/app/libs/framework.jar deleted file mode 100644 index fefe7ec..0000000 Binary files a/app/libs/framework.jar and /dev/null differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6e049ad..998f53a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,10 +1,8 @@ + package="com.uiuios.aios"> - @@ -43,15 +41,8 @@ - - - - - @@ -74,15 +65,6 @@ android:restoreAnyVersion="true" android:supportsRtl="true" android:theme="@style/AppTheme"> - - - - - - @@ -105,6 +86,15 @@ + + + + + + + + @@ -221,149 +216,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - getHideAPP(); - //获取禁止打开的APP - List getForbidAPP(); - - //获取app设置 - String getAppTimeControl(); - //获取整机设置 - String getSnTimeControl(); - //获取系统设置 - String getSetting(); - //获取定位结果 + /*获取定位结果*/ String getMapResult(); -} + /*获取WiFi名*/ + String getWifiSsid(); + /*获取蓝牙名*/ + String getBluetoothSsid(); + /*写入系统数据库*/ + boolean SystemPutInt(String name, int value); + /*结束进程*/ + void killBackgroundProcesses(String pkg); + /*设置launcher3为默认*/ + void openLauncher3(); + /*设置默认桌面*/ + void setDefaultDesktop(String pkgName, String className); + +} \ No newline at end of file diff --git a/app/src/main/java/com/uiuios/aios/activity/ControlActivity.java b/app/src/main/java/com/uiuios/aios/activity/ControlActivity.java index a5def82..5b925c2 100644 --- a/app/src/main/java/com/uiuios/aios/activity/ControlActivity.java +++ b/app/src/main/java/com/uiuios/aios/activity/ControlActivity.java @@ -59,18 +59,11 @@ public class ControlActivity extends BaseActivity { @BindView(R.id.iv_back) ImageView iv_back; - @BindView(R.id.tv_wifi) TextView tv_wifi; - @BindView(R.id.tv_wifi_ssid) - TextView tv_wifi_ssid; @BindView(R.id.tv_bt) TextView tv_bt; - @BindView(R.id.tv_bt_ssid) - TextView tv_bt_ssid; - // @BindView(R.id.tv_font_size) -// TextView tv_font_size; @BindView(R.id.seekBar) RulerSeekBar seekBar; @BindView(R.id.seekbar_brightness) @@ -80,21 +73,14 @@ public class ControlActivity extends BaseActivity { @BindView(R.id.tv_sound) TextView tv_sound; - @BindView(R.id.tv_battery) TextView tv_battery; - @BindView(R.id.tv_electricity) - TextView tv_electricity; @BindView(R.id.tv_flashlight) TextView tv_flashlight; - @BindView(R.id.tv_flashlight_switch) - TextView tv_flashlight_switch; - @BindView(R.id.tv_brightness) TextView tv_brightness; @BindView(R.id.tv_location) TextView tv_location; - @BindView(R.id.cl_wifi) ConstraintLayout cl_wifi; @BindView(R.id.cl_bt) @@ -153,6 +139,12 @@ public class ControlActivity extends BaseActivity { } } }); + cl_battery.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS)); + } + }); } @Override @@ -164,15 +156,15 @@ public class ControlActivity extends BaseActivity { cl_wifi.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { -// startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); - startActivity(new Intent(ControlActivity.this, WiFiManagerActivity.class)); + startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); +// startActivity(new Intent(ControlActivity.this, WiFiManagerActivity.class)); } }); if (isWifiEnabled()) { - tv_wifi_ssid.setText(getConnectWifiSsid()); +// tv_wifi_ssid.setText(getConnectWifiSsid()); cl_wifi.setBackground(getDrawable(R.drawable.control_background_item)); } else { - tv_wifi_ssid.setText("未连接"); +// tv_wifi_ssid.setText("未连接"); cl_wifi.setBackground(getDrawable(R.drawable.control_background_item_dis)); } } @@ -205,8 +197,6 @@ public class ControlActivity extends BaseActivity { filter.addAction(WifiManager.RSSI_CHANGED_ACTION); filter.addAction(WifiManager.NETWORK_IDS_CHANGED_ACTION); filter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); - filter.addAction(WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION); - filter.addAction(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION); filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(mWifiReceiver, filter); @@ -226,14 +216,14 @@ public class ControlActivity extends BaseActivity { NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); if (info.getState().equals(NetworkInfo.State.DISCONNECTED)) { Log.e(TAG, "wifi断开"); - tv_wifi_ssid.setText("未连接"); +// tv_wifi_ssid.setText("未连接"); cl_wifi.setBackground(getDrawable(R.drawable.control_background_item_dis)); } else if (info.getState().equals(NetworkInfo.State.CONNECTED)) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); //获取当前wifi名称 String newSSID = wifiInfo.getSSID(); - tv_wifi_ssid.setText(newSSID.replaceAll("\"", "")); +// tv_wifi_ssid.setText(getConnectWifiSsid()); cl_wifi.setBackground(getDrawable(R.drawable.control_background_item)); } break; @@ -242,7 +232,7 @@ public class ControlActivity extends BaseActivity { int wifistate = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED); if (wifistate == WifiManager.WIFI_STATE_DISABLED) { Log.e(TAG, "系统关闭wifi"); - tv_wifi_ssid.setText("关"); +// tv_wifi_ssid.setText("关"); cl_wifi.setBackground(getDrawable(R.drawable.control_background_item_dis)); } else if (wifistate == WifiManager.WIFI_STATE_ENABLED) { Log.e(TAG, "系统开启wifi"); @@ -271,17 +261,17 @@ public class ControlActivity extends BaseActivity { } private String getConnectWifiSsid() { - WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE); - WifiInfo wifiInfo = wifiManager.getConnectionInfo(); -// //去掉带引号的字符串方法一 -// String wifiInfo1 = wifiInfo.getSSID(); -// if (wifiInfo1.contains("\"")) { -// wifiInfo1 = wifiInfo1.substring(1, wifiInfo1.length() - 1); -// } -//去掉带引号的字符串方法二 - String wifiSSID = wifiInfo.getSSID(); - String wifiInfo1 = wifiSSID.replaceAll("\"", ""); - return wifiInfo1; +// WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE); +// WifiInfo wifiInfo = wifiManager.getConnectionInfo(); +//// //去掉带引号的字符串方法一 +//// String wifiInfo1 = wifiInfo.getSSID(); +//// if (wifiInfo1.contains("\"")) { +//// wifiInfo1 = wifiInfo1.substring(1, wifiInfo1.length() - 1); +//// } +////去掉带引号的字符串方法二 +// String wifiSSID = wifiInfo.getSSID(); +// String wifiInfo1 = wifiSSID.replaceAll("\"", ""); + return RemoteManager.getInstance().getConnectWifiSsid(); } private BluetoothAdapter bluetoothAdapter; @@ -289,16 +279,16 @@ public class ControlActivity extends BaseActivity { private void getBluetooth() { bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (bluetoothAdapter.isEnabled()) { - if (isConnected()) { - cl_bt.setBackground(getDrawable(R.drawable.control_background_item)); - tv_bt_ssid.setText(getBluetoothDeviceName()); - } else { - cl_bt.setBackground(getDrawable(R.drawable.control_background_item_dis)); - tv_bt_ssid.setText("未连接"); - } +// if (isConnected()) { +// cl_bt.setBackground(getDrawable(R.drawable.control_background_item)); +// tv_bt_ssid.setText(getBluetoothDeviceName()); +// } else { +// cl_bt.setBackground(getDrawable(R.drawable.control_background_item_dis)); +// tv_bt_ssid.setText("未连接"); +// } } else { cl_bt.setBackground(getDrawable(R.drawable.control_background_item_dis)); - tv_bt_ssid.setText("已关闭"); +// tv_bt_ssid.setText("已关闭"); } getConnectedDevicesV1(); cl_bt.setOnClickListener(new View.OnClickListener() { @@ -309,31 +299,31 @@ public class ControlActivity extends BaseActivity { }); } - public boolean isConnected() { - Set bondedDevices = bluetoothAdapter.getBondedDevices(); - List deviceList = bondedDevices.stream().filter(new Predicate() { - @Override - public boolean test(BluetoothDevice bluetoothDevice) { - return bluetoothDevice.isConnected(); - } - }).collect(Collectors.toList()); - return deviceList.size() > 0; - } +// public boolean isConnected() { +// Set bondedDevices = bluetoothAdapter.getBondedDevices(); +// List deviceList = bondedDevices.stream().filter(new Predicate() { +// @Override +// public boolean test(BluetoothDevice bluetoothDevice) { +// return bluetoothDevice.isConnected(); +// } +// }).collect(Collectors.toList()); +// return deviceList.size() > 0; +// } - public String getBluetoothDeviceName() { - Set bondedDevices = bluetoothAdapter.getBondedDevices(); - List deviceList = bondedDevices.stream().filter(new Predicate() { - @Override - public boolean test(BluetoothDevice bluetoothDevice) { - return bluetoothDevice.isConnected(); - } - }).collect(Collectors.toList()); - if (deviceList.size() == 0) { - return "未连接"; - } else { - return deviceList.get(0).getName(); - } - } +// public String getBluetoothDeviceName() { +// Set bondedDevices = bluetoothAdapter.getBondedDevices(); +// List deviceList = bondedDevices.stream().filter(new Predicate() { +// @Override +// public boolean test(BluetoothDevice bluetoothDevice) { +// return bluetoothDevice.isConnected(); +// } +// }).collect(Collectors.toList()); +// if (deviceList.size() == 0) { +// return "未连接"; +// } else { +// return deviceList.get(0).getName(); +// } +// } //TODO 根据mac地址判断是否已连接(这里参数可以直接用BluetoothDevice对象) //但这么写其实更通用。 @@ -437,30 +427,30 @@ public class ControlActivity extends BaseActivity { int blueState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, 0); switch (blueState) { case BluetoothAdapter.STATE_TURNING_ON: - tv_bt_ssid.setText("正在打开"); +// tv_bt_ssid.setText("正在打开"); cl_bt.setBackground(getDrawable(R.drawable.control_background_item)); break; case BluetoothAdapter.STATE_ON: - tv_bt_ssid.setText("已打开"); +// tv_bt_ssid.setText("已打开"); cl_bt.setBackground(getDrawable(R.drawable.control_background_item)); break; case BluetoothAdapter.STATE_TURNING_OFF: - tv_bt_ssid.setText("正在关闭"); +// tv_bt_ssid.setText("正在关闭"); cl_bt.setBackground(getDrawable(R.drawable.control_background_item)); break; case BluetoothAdapter.STATE_OFF: - tv_bt_ssid.setText("已关闭"); +// tv_bt_ssid.setText("已关闭"); cl_bt.setBackground(getDrawable(R.drawable.control_background_item_dis)); break; default: } break; case BluetoothDevice.ACTION_ACL_CONNECTED: - tv_bt_ssid.setText(getBluetoothDeviceName()); +// tv_bt_ssid.setText(getBluetoothDeviceName()); cl_bt.setBackground(getDrawable(R.drawable.control_background_item)); break; case BluetoothDevice.ACTION_ACL_DISCONNECTED: - tv_bt_ssid.setText("未连接"); +// tv_bt_ssid.setText("未连接"); cl_bt.setBackground(getDrawable(R.drawable.control_background_item_dis)); break; default: @@ -471,7 +461,7 @@ public class ControlActivity extends BaseActivity { } private void getBattery() { - tv_electricity.setText(getBatteryCapacity() + "%"); +// tv_electricity.setText(getBatteryCapacity() + "%"); if (isBatteryCharging()) { cl_battery.setBackground(getDrawable(R.drawable.control_background_item)); } else { @@ -523,7 +513,7 @@ public class ControlActivity extends BaseActivity { filter.addAction(Intent.ACTION_POWER_CONNECTED); filter.addAction(Intent.ACTION_POWER_DISCONNECTED); filter.addAction(Intent.ACTION_BATTERY_CHANGED); - filter.addAction(Intent.ACTION_BATTERY_LEVEL_CHANGED); +// filter.addAction(Intent.ACTION_BATTERY_LEVEL_CHANGED); filter.addAction(Intent.ACTION_BATTERY_LOW); filter.addAction(Intent.ACTION_BATTERY_OKAY); registerReceiver(mBatteryReceiver, filter); @@ -546,9 +536,9 @@ public class ControlActivity extends BaseActivity { case Intent.ACTION_POWER_DISCONNECTED: cl_battery.setBackground(getDrawable(R.drawable.control_background_item_dis)); break; - case Intent.ACTION_BATTERY_LEVEL_CHANGED: - tv_electricity.setText(getBatteryCapacity() + "%"); - break; +// case Intent.ACTION_BATTERY_LEVEL_CHANGED: +// tv_electricity.setText(getBatteryCapacity() + "%"); +// break; default: } } @@ -707,9 +697,9 @@ public class ControlActivity extends BaseActivity { return null; } - private boolean isFlashlightEnabled() { - return Settings.Secure.getInt(crv, Settings.Secure.FLASHLIGHT_ENABLED, 0) == 1; - } +// private boolean isFlashlightEnabled() { +// return Settings.Secure.getInt(crv, Settings.Secure.FLASHLIGHT_ENABLED, 0) == 1; +// } private void getFontSize() { float fontScale = Settings.System.getFloat(crv, Settings.System.FONT_SCALE, 0.0f); @@ -775,7 +765,7 @@ public class ControlActivity extends BaseActivity { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { Log.e(TAG, "onProgressChanged: i = " + i); - Settings.System.putInt(crv, Settings.System.SCREEN_BRIGHTNESS, i); + RemoteManager.getInstance().putSystemInt(Settings.System.SCREEN_BRIGHTNESS, i); int gamma = BrightnessUtils.convertLinearToGamma(i, 1, 255); Log.e(TAG, "onProgressChanged: gamma = " + gamma); long percentage = Math.round((((double) gamma / 65535) * 100f)); diff --git a/app/src/main/java/com/uiuios/aios/activity/EmergencyActivity.java b/app/src/main/java/com/uiuios/aios/activity/EmergencyActivity.java index 5f76b53..dc70a23 100644 --- a/app/src/main/java/com/uiuios/aios/activity/EmergencyActivity.java +++ b/app/src/main/java/com/uiuios/aios/activity/EmergencyActivity.java @@ -167,7 +167,7 @@ public class EmergencyActivity extends AppCompatActivity { if (phoneListSet == null || phoneListSet.size() == 0) { return; } - Handler.getMain().postDelayed(new Runnable() { + new Handler().postDelayed(new Runnable() { @Override public void run() { Intent intent1 = new Intent(Intent.ACTION_CALL); diff --git a/app/src/main/java/com/uiuios/aios/activity/ScreenLockActivity.java b/app/src/main/java/com/uiuios/aios/activity/ScreenLockActivity.java new file mode 100644 index 0000000..47e6bf4 --- /dev/null +++ b/app/src/main/java/com/uiuios/aios/activity/ScreenLockActivity.java @@ -0,0 +1,197 @@ +package com.uiuios.aios.activity; + +import android.content.Context; +import android.media.AudioAttributes; +import android.media.SoundPool; +import android.os.Bundle; +import android.os.Handler; +import android.provider.Settings; +import android.text.TextUtils; +import android.util.Log; +import android.view.View; +import android.view.WindowManager; +import android.view.inputmethod.InputMethodManager; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.Nullable; + +import com.tuo.customview.VerificationCodeView; +import com.uiuios.aios.R; +import com.uiuios.aios.base.BaseActivity; +import com.uiuios.aios.config.CommonConfig; +import com.uiuios.aios.manager.RemoteManager; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class ScreenLockActivity extends BaseActivity { + + private static final String TAG = ScreenLockActivity.class.getSimpleName(); + + + @BindView(R.id.iv_back) + ImageView iv_back; + @BindView(R.id.bt_0) + TextView bt0; + @BindView(R.id.bt_1) + TextView bt1; + @BindView(R.id.bt_2) + TextView bt2; + @BindView(R.id.bt_3) + TextView bt3; + @BindView(R.id.bt_4) + TextView bt4; + @BindView(R.id.bt_5) + TextView bt5; + @BindView(R.id.bt_6) + TextView bt6; + @BindView(R.id.bt_7) + TextView bt7; + @BindView(R.id.bt_8) + TextView bt8; + @BindView(R.id.bt_9) + TextView bt9; + @BindView(R.id.bt_del) + TextView bt_del; + @BindView(R.id.bt_confirm) + TextView bt_confirm; + + @BindView(R.id.textView) + TextView textView; + @BindView(R.id.tv_hint) + TextView tv_hint; + @BindView(R.id.ll_keyboard) + LinearLayout ll_keyboard; + @BindView(R.id.icv) + VerificationCodeView codeView; + + private SoundPool soundPool; + private int soundId; + + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); + AudioAttributes attr = new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_GAME) // 设置音效使用场景 + .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build(); // 设置音效的类型 + soundPool = new SoundPool.Builder().setAudioAttributes(attr) // 设置音效池的属性 + .setMaxStreams(1) // 设置最多可容纳10个音频流 + .build(); // ① + // load方法加载指定音频文件,并返回所加载的音效ID + // 此处使用HashMap来管理这些音频流 + soundId = soundPool.load(this, R.raw.click, 1); + } + + @Override + public int getLayoutId() { + return R.layout.activity_screen_lock; + } + + @Override + public void initView() { + ButterKnife.bind(this); + InputMethodManager imm = (InputMethodManager) ScreenLockActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(codeView.getWindowToken(), 0); + codeView.getEditText().setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ll_keyboard.setVisibility(View.VISIBLE); + } + }); + codeView.setInputCompleteListener(new VerificationCodeView.InputCompleteListener() { + @Override + public void inputComplete() { + checkPasswd(); + } + + @Override + public void deleteContent() { + + } + }); + + bt_del.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + tv_hint.setText(""); + codeView.clearInputContent(); + } + }); + bt_confirm.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + checkPasswd(); + } + }); + iv_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); + bt0.setOnClickListener(view1 -> add(codeView, "0")); + bt1.setOnClickListener(view1 -> add(codeView, "1")); + bt2.setOnClickListener(view1 -> add(codeView, "2")); + bt3.setOnClickListener(view1 -> add(codeView, "3")); + bt4.setOnClickListener(view1 -> add(codeView, "4")); + bt5.setOnClickListener(view1 -> add(codeView, "5")); + bt6.setOnClickListener(view1 -> add(codeView, "6")); + bt7.setOnClickListener(view1 -> add(codeView, "7")); + bt8.setOnClickListener(view1 -> add(codeView, "8")); + bt9.setOnClickListener(view1 -> add(codeView, "9")); + } + + private void checkPasswd() { + String content = codeView.getInputContent(); + if (TextUtils.isEmpty(content) || content.length() != 4) { + return; + } + Log.e(TAG, "inputComplete: " + content); + String password = Settings.Global.getString(getContentResolver(), CommonConfig.LOCK_SCREEN_PASSWORD); + if ((!TextUtils.isEmpty(content) && !TextUtils.isEmpty(password))) { + if (password.equals(content)) { + exitDesktop(); + } else { + setEmpty(); + tv_hint.setText("密码错误"); + } + } else if (CommonConfig.DEFAULT_PASSWORD.equals(content)) { + exitDesktop(); + } else { + setEmpty(); + tv_hint.setText("密码错误"); + } + } + + private void setEmpty() { + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + codeView.clearInputContent(); + tv_hint.setText(""); + } + }, 1000); + } + + @Override + public void initData() { + + } + + private void add(VerificationCodeView codeView, String text) { + Log.e(TAG, "add: text = " + text); + String oldText = codeView.getEditText().getText().toString(); + Log.e(TAG, "add: " + oldText); + codeView.getEditText().setText(text); +// soundPool.play(soundId, 1, 1, 0, 0, 1); + } + + private void exitDesktop() { + RemoteManager.getInstance().openLauncher3(); + finish(); + System.exit(0); + } +} diff --git a/app/src/main/java/com/uiuios/aios/activity/alarm/AlarmClockAddActivity.java b/app/src/main/java/com/uiuios/aios/activity/alarm/AlarmClockAddActivity.java index 3d36d25..5e7f6c0 100644 --- a/app/src/main/java/com/uiuios/aios/activity/alarm/AlarmClockAddActivity.java +++ b/app/src/main/java/com/uiuios/aios/activity/alarm/AlarmClockAddActivity.java @@ -37,6 +37,7 @@ import com.uiuios.aios.alarm.AlarmUtils; import com.uiuios.aios.base.GlideEngine; import com.uiuios.aios.bean.AlarmClockId; import com.uiuios.aios.bean.BaseResponse; +import com.uiuios.aios.manager.RemoteManager; import com.uiuios.aios.network.NetInterfaceManager; import com.uiuios.aios.utils.FFmpegUtils; import com.uiuios.aios.utils.FileUtil; @@ -318,7 +319,7 @@ public class AlarmClockAddActivity extends BaseLifecycleActivity { alarmClockData.setIs_onoff(1); Map params = new HashMap<>(); - params.put("sn", Utils.getSerial()); + params.put("sn", RemoteManager.getInstance().getSerial()); params.put("time", timeStamp); params.put("type", String.valueOf(mType)); params.put("title", et_activation.getText().toString()); @@ -365,7 +366,6 @@ public class AlarmClockAddActivity extends BaseLifecycleActivity { public void onError(@NonNull Throwable e) { Log.e("checkContent", "onError: " + e.getMessage()); ToastUtil.show("已保存到本地"); - ToastUtil.show("添加成功"); ThreadLocalRandom random = ThreadLocalRandom.current(); int fakeId = random.nextInt(Integer.MAX_VALUE); Log.e(TAG, "onError: fakeId = " + fakeId); diff --git a/app/src/main/java/com/uiuios/aios/activity/alarm/AlarmClockEditActivity.java b/app/src/main/java/com/uiuios/aios/activity/alarm/AlarmClockEditActivity.java index ce35f5d..04a56e2 100644 --- a/app/src/main/java/com/uiuios/aios/activity/alarm/AlarmClockEditActivity.java +++ b/app/src/main/java/com/uiuios/aios/activity/alarm/AlarmClockEditActivity.java @@ -46,6 +46,7 @@ import com.uiuios.aios.alarm.AlarmClockData; import com.uiuios.aios.alarm.AlarmUtils; import com.uiuios.aios.base.GlideEngine; import com.uiuios.aios.bean.BaseResponse; +import com.uiuios.aios.manager.RemoteManager; import com.uiuios.aios.network.NetInterfaceManager; import com.uiuios.aios.utils.FFmpegUtils; import com.uiuios.aios.utils.FileUtil; @@ -432,7 +433,7 @@ public class AlarmClockEditActivity extends AppCompatActivity implements Lifecyc Map params = new HashMap<>(); - params.put("sn", Utils.getSerial()); + params.put("sn", RemoteManager.getInstance().getSerial()); params.put("id", String.valueOf(mId)); params.put("type", String.valueOf(mType)); params.put("time", timeStamp); diff --git a/app/src/main/java/com/uiuios/aios/activity/contact/AddContactActivity.java b/app/src/main/java/com/uiuios/aios/activity/contact/AddContactActivity.java index ef5b8fa..266e979 100644 --- a/app/src/main/java/com/uiuios/aios/activity/contact/AddContactActivity.java +++ b/app/src/main/java/com/uiuios/aios/activity/contact/AddContactActivity.java @@ -25,6 +25,7 @@ import com.uiuios.aios.R; import com.uiuios.aios.base.BaseLightActivity; import com.uiuios.aios.base.GlideEngine; import com.uiuios.aios.bean.BaseResponse; +import com.uiuios.aios.manager.RemoteManager; import com.uiuios.aios.network.NetInterfaceManager; import com.uiuios.aios.utils.GlideLoadUtils; import com.uiuios.aios.utils.ToastUtil; @@ -149,7 +150,7 @@ public class AddContactActivity extends BaseLightActivity { RequestBody requestBody = RequestBody.Companion.create(avatarFile, mediaType); MultipartBody.Part body = MultipartBody.Part.createFormData("avatar", avatarFile.getName(), requestBody); Map params = new HashMap<>(); - params.put("sn", Utils.getSerial()); + params.put("sn", RemoteManager.getInstance().getSerial()); params.put("name", name); params.put("mobile", phone); params.put("is_urgent", String.valueOf(toggleButton.isToggleOn())); diff --git a/app/src/main/java/com/uiuios/aios/activity/main/MainActivity.java b/app/src/main/java/com/uiuios/aios/activity/main/MainActivity.java index b15ff02..64c609f 100644 --- a/app/src/main/java/com/uiuios/aios/activity/main/MainActivity.java +++ b/app/src/main/java/com/uiuios/aios/activity/main/MainActivity.java @@ -10,6 +10,7 @@ import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.graphics.Color; +import android.os.Build; import android.os.IBinder; import android.os.RemoteException; import android.provider.Settings; @@ -26,15 +27,20 @@ import androidx.viewpager.widget.ViewPager; import com.alarmclock.uiui.IAlarmAidlInterface; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; +import com.hjq.permissions.OnPermissionCallback; +import com.hjq.permissions.Permission; +import com.hjq.permissions.XXPermissions; import com.uiuios.aios.BuildConfig; import com.uiuios.aios.R; import com.uiuios.aios.base.BaseActivity; import com.uiuios.aios.bean.AlarmItem; import com.uiuios.aios.bean.DesktopIcon; +import com.uiuios.aios.config.CommonConfig; import com.uiuios.aios.fragment.AppListFragment; import com.uiuios.aios.base.BaseFragmentPagerAdapter; import com.uiuios.aios.fragment.custom.CustomFragment; import com.uiuios.aios.fragment.second.SecondFragment; +import com.uiuios.aios.manager.RemoteManager; import com.uiuios.aios.service.NotificationService; import com.uiuios.aios.utils.ApkUtils; import com.uiuios.aios.utils.AppUsedTimeUtils; @@ -100,13 +106,13 @@ public class MainActivity extends BaseActivity implements MainContact.MainView { // fragmentTransaction.add(R.id.viewPager, appListFragment); // fragmentTransaction.commit(); - is_twoscreen = Settings.Global.getInt(getContentResolver(), "is_twoscreen", 1) == 1; - if (is_twoscreen) { - appListIndex = 2; - defaultCurrent = 1; - mSecondFragment = new SecondFragment(); - mFragments.add(mSecondFragment); - } +// is_twoscreen = Settings.Global.getInt(getContentResolver(), "is_twoscreen", 1) == 1; +// if (is_twoscreen) { +// appListIndex = 2; +// defaultCurrent = 1; +// mSecondFragment = new SecondFragment(); +// mFragments.add(mSecondFragment); +// } mCustomFragment = new CustomFragment(); mFragments.add(mCustomFragment); @@ -167,6 +173,12 @@ public class MainActivity extends BaseActivity implements MainContact.MainView { } }; bindAlarmService(); + RemoteManager.getInstance().setListener(new RemoteManager.ConnectedListener() { + @Override + public void onConnected() { + setDefaultDesktop(); + } + }); } private ServiceConnection mAlarmServiceConnection; @@ -301,10 +313,76 @@ public class MainActivity extends BaseActivity implements MainContact.MainView { if (!isNotificationListenersEnabled()) { ToastUtil.show("请授予\"" + getString(R.string.app_name) + "\"使用通知权"); gotoNotificationAccessSetting(this); + } else { + getPermission(); } - addData(); } + public static final String Launcher3 = "com.android.launcher3"; + public static final String Launcher3Class = "com.android.launcher3.Launcher"; + public static final String Launcher3QuickstepClass = "com.android.launcher3.uioverrides.QuickstepLauncher"; + + private void setDefaultDesktop() { + int is_activation = Settings.Global.getInt(getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, 0); + Log.e(TAG, "onResume: is_activation = " + is_activation); + if (is_activation == 1) { + RemoteManager.getInstance().setDefaultDesktop(BuildConfig.APPLICATION_ID, this.getClass().getName()); + } else { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) { + RemoteManager.getInstance().setDefaultDesktop(Launcher3, Launcher3QuickstepClass); + } else { + RemoteManager.getInstance().setDefaultDesktop(Launcher3, Launcher3Class); + } + } + } + + + private String[] permission = new String[]{ + Permission.CALL_PHONE, +// Permission.REQUEST_INSTALL_PACKAGES, + Permission.WRITE_EXTERNAL_STORAGE, + Permission.READ_PHONE_STATE, + Permission.WRITE_SETTINGS, + }; + + private void getPermission() { + XXPermissions.with(this) + // 申请单个权限 +// .permission(Permission.RECORD_AUDIO) + // 申请多个权限 + .permission(permission) + // 设置权限请求拦截器(局部设置) + //.interceptor(new PermissionInterceptor()) + // 设置不触发错误检测机制(局部设置) + //.unchecked() + .request(new OnPermissionCallback() { + + @Override + public void onGranted(@NonNull List permissions, boolean allGranted) { + if (!allGranted) { + ToastUtil.show("获取部分权限成功,但部分权限未正常授予"); + return; + } +// ToastUtil.show("获取录音和日历权限成功"); + Log.e(TAG, "onGranted: 获取存储权限成功"); + addData(); + } + + @Override + public void onDenied(@NonNull List permissions, boolean doNotAskAgain) { + if (doNotAskAgain) { + ToastUtil.show("被永久拒绝授权,请手动授予存储权限"); + // 如果是被永久拒绝就跳转到应用权限系统设置页面 + XXPermissions.startPermissionActivity(MainActivity.this, permissions); + } else { +// ToastUtil.show("获取录音和日历权限失败"); + Log.e(TAG, "onGranted: 获取存储权限权限失败"); + } + } + }); + } + + private static final String ENABLED_NOTIFICATION_LISTENERS = "enabled_notification_listeners"; private boolean isNotificationListenersEnabled() { diff --git a/app/src/main/java/com/uiuios/aios/activity/main/MainPresenter.java b/app/src/main/java/com/uiuios/aios/activity/main/MainPresenter.java index 181ff77..6ed2b18 100644 --- a/app/src/main/java/com/uiuios/aios/activity/main/MainPresenter.java +++ b/app/src/main/java/com/uiuios/aios/activity/main/MainPresenter.java @@ -12,6 +12,7 @@ import com.uiuios.aios.BuildConfig; import com.uiuios.aios.bean.BaseResponse; import com.uiuios.aios.bean.Contact; import com.uiuios.aios.bean.NetDesktopIcon; +import com.uiuios.aios.manager.RemoteManager; import com.uiuios.aios.network.NetInterfaceManager; import com.uiuios.aios.utils.ApkUtils; import com.uiuios.aios.utils.AppUsedTimeUtils; @@ -122,7 +123,7 @@ public class MainPresenter implements MainContact.Presenter { Log.e(TAG, "onRestart: " + ApkUtils.getAppNameByPackage(mContext, packagename)); Log.e(TAG, "onRestart: " + packagename); NetInterfaceManager.getInstance().getAppUsageRecordControl() - .sendappUsageRecord(Utils.getSerial(), + .sendappUsageRecord(RemoteManager.getInstance().getSerial(), ApkUtils.getAppNameByPackage(mContext, packagename), packagename, AppUsedTimeUtils.getInstance().getStartTime() / 1000, diff --git a/app/src/main/java/com/uiuios/aios/activity/weather/WeatherPresenter.java b/app/src/main/java/com/uiuios/aios/activity/weather/WeatherPresenter.java index d8f3f88..3e6e1ba 100644 --- a/app/src/main/java/com/uiuios/aios/activity/weather/WeatherPresenter.java +++ b/app/src/main/java/com/uiuios/aios/activity/weather/WeatherPresenter.java @@ -25,7 +25,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject; */ public class WeatherPresenter implements WeatherContact.Presenter { private static final String TAG = WeatherPresenter.class.getSimpleName(); - private static final String WEATHER_DAILY_KEY = "WEATHER_DAILY_JSON_STRING"; + public static final String WEATHER_DAILY_KEY = "WEATHER_DAILY_JSON_STRING"; private WeatherContact.WeatherView mView; private Context mContext; private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE); diff --git a/app/src/main/java/com/uiuios/aios/adapter/NotificationAdapter.java b/app/src/main/java/com/uiuios/aios/adapter/NotificationAdapter.java index 251d3ab..48529b1 100644 --- a/app/src/main/java/com/uiuios/aios/adapter/NotificationAdapter.java +++ b/app/src/main/java/com/uiuios/aios/adapter/NotificationAdapter.java @@ -58,7 +58,7 @@ public class NotificationAdapter extends RecyclerView.Adapter 5) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); @@ -109,9 +109,9 @@ public class NotificationAdapter extends RecyclerView.Adapter accountInfoList = new ArrayList<>(); - accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial())); - XGPushManager.upsertAccounts(getApplicationContext(), accountInfoList, new XGIOperateCallback() { - @Override - public void onSuccess(Object data, int flag) { - Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag); - } - - @Override - public void onFail(Object data, int errCode, String msg) { - Log.e("TPush", "onFail, data:" + data + ", code:" + errCode + ", msg:" + msg); - } - }); - } - - @Override - public void onFail(Object data, int errCode, String msg) { - Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg); - } - }); - } - private void aliyunPushInit() { PushServiceFactory.init(this); final CloudPushService pushService = PushServiceFactory.getCloudPushService(); @@ -105,7 +66,7 @@ public class BaseApplication extends Application { public void onSuccess(String response) { Log.e("AliyunPush", "init cloudchannel success"); Log.e("AliyunPush", "init cloudchannel success " + pushService.getDeviceId()); - String sn = Utils.getSerial(); + String sn = RemoteManager.getInstance().getSerial(); if (TextUtils.isEmpty(sn)) { return; } diff --git a/app/src/main/java/com/uiuios/aios/bean/DesktopIcon.java b/app/src/main/java/com/uiuios/aios/bean/DesktopIcon.java index 543bfbb..3246f10 100644 --- a/app/src/main/java/com/uiuios/aios/bean/DesktopIcon.java +++ b/app/src/main/java/com/uiuios/aios/bean/DesktopIcon.java @@ -23,15 +23,15 @@ public class DesktopIcon implements Serializable, Parcelable { } private DesktopIcon(Parcel in) { - packageName = in.readStringNoHelper(); - lable = in.readStringNoHelper(); + packageName = in.readString(); + lable = in.readString(); position = in.readInt(); } @Override public void writeToParcel(Parcel dest, int flags) { - dest.writeStringNoHelper(packageName); - dest.writeStringNoHelper(lable); + dest.writeString(packageName); + dest.writeString(lable); dest.writeInt(position); } diff --git a/app/src/main/java/com/uiuios/aios/bean/UserAvatarInfo.java b/app/src/main/java/com/uiuios/aios/bean/UserAvatarInfo.java index 1ed238e..6167750 100644 --- a/app/src/main/java/com/uiuios/aios/bean/UserAvatarInfo.java +++ b/app/src/main/java/com/uiuios/aios/bean/UserAvatarInfo.java @@ -5,17 +5,19 @@ import java.io.Serializable; public class UserAvatarInfo implements Serializable { private static final long serialVersionUID = 7700643058775210597L; - String username; - String avatar; - String gread; int id; + String avatar; + String mobile; + String sn_name; + String class_name; + String username; - public String getUsername() { - return username; + public int getId() { + return id; } - public void setUsername(String username) { - this.username = username; + public void setId(int id) { + this.id = id; } public String getAvatar() { @@ -26,19 +28,35 @@ public class UserAvatarInfo implements Serializable { this.avatar = avatar; } - public String getGread() { - return gread; + public String getMobile() { + return mobile; } - public void setGread(String gread) { - this.gread = gread; + public void setMobile(String mobile) { + this.mobile = mobile; } - public int getId() { - return id; + public String getSn_name() { + return sn_name; } - public void setId(int id) { - this.id = id; + public void setSn_name(String sn_name) { + this.sn_name = sn_name; + } + + public String getClass_name() { + return class_name; + } + + public void setClass_name(String class_name) { + this.class_name = class_name; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; } } diff --git a/app/src/main/java/com/uiuios/aios/config/CommonConfig.java b/app/src/main/java/com/uiuios/aios/config/CommonConfig.java index dd20f58..ee8b6cb 100644 --- a/app/src/main/java/com/uiuios/aios/config/CommonConfig.java +++ b/app/src/main/java/com/uiuios/aios/config/CommonConfig.java @@ -9,6 +9,9 @@ public class CommonConfig { public static final String MAP_ADDRESS_KEY = "map_address_key"; public static final String MAP_ERROR_KEY = "map_error_key"; + public static final String LOCK_SCREEN_PASSWORD ="aios_lockScreenPasswordKey"; + public static final String DEFAULT_PASSWORD = "6666"; + /*是否激活接口请求缓存*/ public static final String ACTIVATION_BEAN_KEY = "AIOS_UIUI_ACTIVATION_BEAN_KEY"; /*是否激活*/ diff --git a/app/src/main/java/com/uiuios/aios/fragment/AppListFragment.java b/app/src/main/java/com/uiuios/aios/fragment/AppListFragment.java index d968b23..8228819 100644 --- a/app/src/main/java/com/uiuios/aios/fragment/AppListFragment.java +++ b/app/src/main/java/com/uiuios/aios/fragment/AppListFragment.java @@ -23,6 +23,7 @@ import com.trello.rxlifecycle4.RxLifecycle; import com.trello.rxlifecycle4.android.FragmentEvent; import com.uiuios.aios.R; import com.uiuios.aios.activity.DailyAppActivity; +import com.uiuios.aios.activity.ScreenLockActivity; import com.uiuios.aios.base.BaseFragment; import com.uiuios.aios.bean.BaseResponse; import com.uiuios.aios.bean.DesktopIcon; @@ -30,6 +31,7 @@ import com.uiuios.aios.config.CommonConfig; import com.uiuios.aios.dialog.CustomDialog; import com.uiuios.aios.dialog.DailyAppDialog; import com.uiuios.aios.manager.AppStatusManager; +import com.uiuios.aios.manager.RemoteManager; import com.uiuios.aios.network.NetInterfaceManager; import com.uiuios.aios.service.NotificationService; import com.uiuios.aios.utils.ApkUtils; @@ -201,6 +203,13 @@ public class AppListFragment extends BaseFragment { startActivity(new Intent(mContext, DailyAppActivity.class)); break; case "aios.exit": + int is_activation = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, 0); + if (is_activation == 0) { + RemoteManager.getInstance().openLauncher3(); + } else { + startScreenLockActivity(); + } + break; case "aios.family": // startActivity(new Intent(mContext, FamilySpaceActivity.class)); ApkUtils.openApp(mContext, "com.uiui.videoplayer"); @@ -297,6 +306,11 @@ public class AppListFragment extends BaseFragment { }); } + private void startScreenLockActivity() { + Intent intent = new Intent(mContext, ScreenLockActivity.class); + mContext.startActivity(intent); + } + private void showHideDialog(DesktopIcon desktopIcon) { String label = desktopIcon.getLable(); String pkg = desktopIcon.getPackageName(); diff --git a/app/src/main/java/com/uiuios/aios/fragment/custom/CustomContact.java b/app/src/main/java/com/uiuios/aios/fragment/custom/CustomContact.java index d9eb455..f79b142 100644 --- a/app/src/main/java/com/uiuios/aios/fragment/custom/CustomContact.java +++ b/app/src/main/java/com/uiuios/aios/fragment/custom/CustomContact.java @@ -3,6 +3,7 @@ package com.uiuios.aios.fragment.custom; import com.uiuios.aios.base.BasePresenter; import com.uiuios.aios.base.BaseView; import com.uiuios.aios.bean.SnInfo; +import com.uiuios.aios.bean.UserAvatarInfo; public class CustomContact { public interface Presenter extends BasePresenter { @@ -10,6 +11,6 @@ public class CustomContact { } public interface CustomView extends BaseView { - void setSnInfo(SnInfo snInfo); + void setSnInfo(UserAvatarInfo userAvatarInfo); } } diff --git a/app/src/main/java/com/uiuios/aios/fragment/custom/CustomFragment.java b/app/src/main/java/com/uiuios/aios/fragment/custom/CustomFragment.java index d637c04..271ceaf 100644 --- a/app/src/main/java/com/uiuios/aios/fragment/custom/CustomFragment.java +++ b/app/src/main/java/com/uiuios/aios/fragment/custom/CustomFragment.java @@ -43,6 +43,7 @@ import com.king.view.circleprogressview.CircleProgressView; import com.qweather.sdk.bean.base.Code; import com.qweather.sdk.bean.base.Lang; import com.qweather.sdk.bean.base.Unit; +import com.qweather.sdk.bean.weather.WeatherDailyBean; import com.qweather.sdk.bean.weather.WeatherHourlyBean; import com.qweather.sdk.bean.weather.WeatherNowBean; import com.qweather.sdk.view.QWeather; @@ -56,6 +57,7 @@ import com.uiuios.aios.activity.alarm.AlarmClockActivity; import com.uiuios.aios.activity.code.FamilySpaceActivity; import com.uiuios.aios.activity.contact.ContactActivity; import com.uiuios.aios.activity.weather.WeatherActivity; +import com.uiuios.aios.activity.weather.WeatherPresenter; import com.uiuios.aios.activity.wifi.WiFiManagerActivity; import com.uiuios.aios.adapter.NotificationAdapter; import com.uiuios.aios.adapter.SOSNnmberAdapter; @@ -66,14 +68,17 @@ import com.uiuios.aios.bean.AlarmItem; import com.uiuios.aios.bean.Contact; import com.uiuios.aios.bean.HealthCode; import com.uiuios.aios.bean.SnInfo; +import com.uiuios.aios.bean.UserAvatarInfo; import com.uiuios.aios.config.CommonConfig; import com.uiuios.aios.dialog.PasswordDialog; import com.uiuios.aios.dialog.SingleDialog; import com.uiuios.aios.disklrucache.CacheHelper; +import com.uiuios.aios.gson.GsonUtils; import com.uiuios.aios.manager.RemoteManager; import com.uiuios.aios.network.NetInterfaceManager; import com.uiuios.aios.network.UrlAddress; import com.uiuios.aios.push.PushManager; +import com.uiuios.aios.service.main.MainService; import com.uiuios.aios.utils.ApkUtils; import com.uiuios.aios.utils.AppUtil; import com.uiuios.aios.utils.BitmapUtils; @@ -84,7 +89,11 @@ import com.uiuios.aios.utils.Utils; import java.lang.reflect.Method; import java.lang.reflect.Type; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; import java.util.List; import butterknife.BindView; @@ -97,8 +106,6 @@ import butterknife.ButterKnife; * create an instance of this fragment. */ public class CustomFragment extends BaseFragment implements CustomContact.CustomView, NetworkUtils.OnNetworkStatusChangedListener { -// @BindView(R.id.cl_alarm) -// ConstraintLayout cl_alarm; @BindView(R.id.cl_weather) ConstraintLayout cl_weather; @@ -122,15 +129,12 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom ConstraintLayout cl_wifi; @BindView(R.id.cl_activation) ConstraintLayout cl_activation; - - // @BindView(R.id.cl_exit) -// ConstraintLayout cl_exit; @BindView(R.id.cl_control) ConstraintLayout cl_control; - // @BindView(R.id.cl_battery) -// ConstraintLayout cl_battery; - // @BindView(R.id.tv_add) -// TextView tv_add; + @BindView(R.id.tv_time) + TextView tv_time; + @BindView(R.id.tv_data) + TextView tv_data; @BindView(R.id.tv_battery) TextView tv_battery; @BindView(R.id.tv_location) @@ -143,12 +147,8 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom TextView tv_temp; @BindView(R.id.cpv) CircleProgressView cpv; - // @BindView(R.id.iv_charging) -// ImageView iv_charging; @BindView(R.id.rv_noti) RecyclerView rv_noti; - // @BindView(R.id.rv_clock) -// RecyclerView rv_clock; @BindView(R.id.iv_wifi) ImageView iv_wifi; @BindView(R.id.wifi_ssid) @@ -159,8 +159,6 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom RecyclerView rv_sos; @BindView(R.id.iv_note_nodata) ImageView iv_note_nodata; - // @BindView(R.id.iv_head) -// ImageView iv_head; @BindView(R.id.tv_name) TextView tv_name; @BindView(R.id.iv_app) @@ -248,9 +246,9 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom if (networkType == NetworkUtils.NetworkType.NETWORK_WIFI) { iv_wifi.setImageDrawable(mContext.getDrawable(R.drawable.wifi_connect)); if (isNetworkOnline1()) { - wifi_ssid.setText(getConnectWifiSsid() + "(已连接)"); + wifi_ssid.setText("已连接"); } else { - wifi_ssid.setText("(未连接)"); + wifi_ssid.setText("未连接"); } } else { wifi_ssid.setText("WiFi未连接"); @@ -326,7 +324,7 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom String action = intent.getAction(); Log.e(TAG, "onReceive: " + action); if (PushManager.SET_ALARMCLOCK.equals(action)) { - Handler.getMain().postDelayed(new Runnable() { + new Handler().postDelayed(new Runnable() { @Override public void run() { getAlarmClock(); @@ -404,6 +402,62 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom } }; + //监听时间和日期变化 + public void registerTimeReceiver() { + mTimeChangedReceiver = new TimeChangedReceiver(); + IntentFilter filter = new IntentFilter(); + filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); + filter.addAction(Intent.ACTION_DATE_CHANGED); + filter.addAction(Intent.ACTION_TIME_CHANGED); + filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); + filter.addAction(Intent.ACTION_TIME_TICK); + mContext.registerReceiver(mTimeChangedReceiver, filter); + } + + private TimeChangedReceiver mTimeChangedReceiver; + + private class TimeChangedReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + if (Intent.ACTION_DATE_CHANGED.equals(intent.getAction())) { + Log.e(TAG, "TimeChangedReceiver:" + "data changed"); + } else if (Intent.ACTION_TIME_CHANGED.equals(intent.getAction())) { + Log.e(TAG, "TimeChangedReceiver:" + "time changed"); + } else if (Intent.ACTION_TIMEZONE_CHANGED.equals(intent.getAction())) { + Log.e(TAG, "TimeChangedReceiver:" + "timezone changed"); + } else if (Intent.ACTION_TIME_TICK.equals(intent.getAction())) { + Log.e(TAG, "TimeChangedReceiver:" + "time tick"); + } + setTiem(); + } + } + + private void setTiem() { + long time = System.currentTimeMillis(); + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); + Date date = new Date(time); + tv_time.setText(sdf.format(date)); + SimpleDateFormat sdf2 = new SimpleDateFormat("MM月-dd日"); + Date date2 = new Date(time); + tv_data.setText(sdf2.format(date2) + "\t" + getWeek()); + } + + /** + * @return 根据日期取得星期几 + */ + public static String getWeek() { + Date date = new Date(); + String[] weeks = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}; + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + int weekIndex = cal.get(Calendar.DAY_OF_WEEK) - 1; + if (weekIndex < 0) { + weekIndex = 0; + } + return weeks[weekIndex]; + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -425,8 +479,9 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom registerRefreshReceiver(); registerBatteryReceiver(); registerAlarmClockReceiver(); + registerTimeReceiver(); wifi_ssid.requestFocus(); - + setTiem(); mContext.registerReceiver(mbatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); if (Settings.Global.getInt(mCRv, "is_aihealth", 0) == 1) { cl_appstore.setVisibility(View.GONE); @@ -472,9 +527,9 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom if (isWifiConnect()) { iv_wifi.setImageDrawable(mContext.getDrawable(R.drawable.wifi_connect)); if (isNetworkOnline1()) { - wifi_ssid.setText(getConnectWifiSsid() + "(已连接)"); + wifi_ssid.setText("已连接"); } else { - wifi_ssid.setText("(未连接)"); + wifi_ssid.setText("未连接"); } } else { wifi_ssid.setText("WiFi未连接"); @@ -568,10 +623,10 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom cl_wifi.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { -// Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS); -// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); -// startActivity(intent); - startActivity(new Intent(mContext, WiFiManagerActivity.class)); + Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); +// startActivity(new Intent(mContext, WiFiManagerActivity.class)); } }); cl_activation.setOnClickListener(new View.OnClickListener() { @@ -596,15 +651,15 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom } @Override - public void setSnInfo(SnInfo snInfo) { - if (snInfo != null) { - if (TextUtils.isEmpty(snInfo.getSn_name())) { -// tv_name.setText("未设置"); + public void setSnInfo(UserAvatarInfo userAvatarInfo) { + if (userAvatarInfo != null) { + if (TextUtils.isEmpty(userAvatarInfo.getSn_name())) { + tv_name.setText("未设置"); } else { -// tv_name.setText(snInfo.getSn_name()); + tv_name.setText(userAvatarInfo.getSn_name()); } } else { -// tv_name.setText("未设置"); + tv_name.setText("未设置"); } } @@ -701,7 +756,7 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom // Log.e("getUserAvatarInfoControl", "onComplete: "); // } // }); -// mCustomPresenter.getSnInfo(); + mCustomPresenter.getSnInfo(); initAmap(); getAlarmCache(); } @@ -728,9 +783,9 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom private void checkActivation() { int activation = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, 0); if (activation == 0) { - tv_name.setText("未激活"); +// tv_name.setText("未激活"); } else { - tv_name.setText("已激活"); +// tv_name.setText("已激活"); } } @@ -856,7 +911,7 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom } private void getAlarmCache() { - String jsonString = mCacheHelper.getAsString(UrlAddress.GET_ALARM_CLOCK); + String jsonString = mMMKV.decodeString(UrlAddress.GET_ALARM_CLOCK); Gson gson = new Gson(); Type type = new TypeToken>() { }.getType(); @@ -865,7 +920,7 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom rv_noti.setVisibility(View.GONE); iv_note_nodata.setVisibility(View.VISIBLE); } else { - notificationAdapter.setDataList(list); + notificationAdapter.setDataList(list.subList(0, 1)); rv_noti.setVisibility(View.VISIBLE); iv_note_nodata.setVisibility(View.GONE); } @@ -937,6 +992,8 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom }); } + private String nowString; + private void getweather(double longitude, double latitude) { String location = longitude + "," + latitude; Log.e(TAG, "getweather: " + location); @@ -963,6 +1020,7 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom // String imageName = "he" + now.getIcon(); // int resId = getResources().getIdentifier(imageName, "drawable", mContext.getPackageName()); // iv_pic.setImageDrawable(mContext.getDrawable(resId)); + nowString = now.getText(); tv_temp.setText(now.getTemp() + "℃"); tv_weather.setText(now.getText()); String iconDay = weatherBean.getNow().getIcon(); @@ -970,11 +1028,13 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom switch (iconDay) { case "100": case "150": - cl_weather.setBackground(ContextCompat.getDrawable(mContext, R.drawable.background_weather_sun)); - break; case "102": case "152": - cl_weather.setBackground(ContextCompat.getDrawable(mContext, R.drawable.background_weather_sunny)); + if (isnight()) { + cl_weather.setBackground(ContextCompat.getDrawable(mContext, R.drawable.background_weather_sun)); + } else { + cl_weather.setBackground(ContextCompat.getDrawable(mContext, R.drawable.background_weather_sun_night)); + } break; default: cl_weather.setBackground(ContextCompat.getDrawable(mContext, R.drawable.background_weather_rain)); @@ -1020,6 +1080,34 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom } } }); + + QWeather.getWeather7D(mContext, location, new QWeather.OnResultWeatherDailyListener() { + @Override + public void onError(Throwable throwable) { + Log.e("getWeather", "onError: " + throwable.getMessage()); + + } + + @Override + public void onSuccess(WeatherDailyBean weatherDailyBean) { + String jsonString = new Gson().toJson(weatherDailyBean); + Log.d("getWeather", "onSuccess: " + jsonString); + mMMKV.encode(WeatherPresenter.WEATHER_DAILY_KEY, jsonString); + List dailyBeans = weatherDailyBean.getDaily(); + if (dailyBeans != null && dailyBeans.size() != 0) { + WeatherDailyBean.DailyBean dailyBean = weatherDailyBean.getDaily().get(0); + tv_weather.setText(nowString + "\t" + dailyBean.getTempMin() + "℃ - " + dailyBean.getTempMax() + "℃"); + } + } + }); + } + + private boolean isnight() { + Calendar calendar = Calendar.getInstance(); + int hour = calendar.get(Calendar.HOUR_OF_DAY); + int minute = calendar.get(Calendar.MINUTE); + int second = calendar.get(Calendar.SECOND); + return hour >= 16 && minute >= 30; } private void killBackgroundApp() { @@ -1032,20 +1120,21 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom } private void killBackgroundProcesses(String packageName) { - ActivityManager activityManager; - try { - activityManager = (ActivityManager) - mContext.getSystemService(Context.ACTIVITY_SERVICE); - activityManager.killBackgroundProcesses(packageName); - Method forceStopPackage = activityManager.getClass() - .getDeclaredMethod("forceStopPackage", String.class); -// Log.e(TAG, "killBackgroundProcesses: " + packageName); - forceStopPackage.setAccessible(true); - forceStopPackage.invoke(activityManager, packageName); - } catch (Exception e) { - Log.e(TAG, "killBackgroundProcesses: " + e.getMessage()); - e.printStackTrace(); - } +// ActivityManager activityManager; +// try { +// activityManager = (ActivityManager) +// mContext.getSystemService(Context.ACTIVITY_SERVICE); +// activityManager.killBackgroundProcesses(packageName); +// Method forceStopPackage = activityManager.getClass() +// .getDeclaredMethod("forceStopPackage", String.class); +//// Log.e(TAG, "killBackgroundProcesses: " + packageName); +// forceStopPackage.setAccessible(true); +// forceStopPackage.invoke(activityManager, packageName); +// } catch (Exception e) { +// Log.e(TAG, "killBackgroundProcesses: " + e.getMessage()); +// e.printStackTrace(); +// } + RemoteManager.getInstance().killBackgroundProcesses(packageName); } private void refreshMemory() { @@ -1075,5 +1164,8 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom if (mAlarmClockReceiver != null) { mContext.unregisterReceiver(mAlarmClockReceiver); } + if (mTimeChangedReceiver != null) { + mContext.unregisterReceiver(mTimeChangedReceiver); + } } } diff --git a/app/src/main/java/com/uiuios/aios/fragment/custom/CustomPresenter.java b/app/src/main/java/com/uiuios/aios/fragment/custom/CustomPresenter.java index a56ed00..5c7429f 100644 --- a/app/src/main/java/com/uiuios/aios/fragment/custom/CustomPresenter.java +++ b/app/src/main/java/com/uiuios/aios/fragment/custom/CustomPresenter.java @@ -8,6 +8,7 @@ import androidx.annotation.NonNull; import com.trello.rxlifecycle4.android.ActivityEvent; import com.trello.rxlifecycle4.android.FragmentEvent; import com.uiuios.aios.bean.SnInfo; +import com.uiuios.aios.bean.UserAvatarInfo; import com.uiuios.aios.network.NetInterfaceManager; import io.reactivex.rxjava3.subjects.BehaviorSubject; @@ -43,11 +44,11 @@ public class CustomPresenter implements CustomContact.Presenter { @Override public void getSnInfo() { -// NetInterfaceManager.getInstance().getSnInfo(new NetInterfaceManager.SnInfoCallback() { -// @Override -// public void setSnInfo(SnInfo snInfo) { -// mView.setSnInfo(snInfo); -// } -// }); + NetInterfaceManager.getInstance().getUserAvatarInfo(lifecycle, new NetInterfaceManager.UserAvatarInfoCallback() { + @Override + public void setUserAvatarInfo(UserAvatarInfo info) { + mView.setSnInfo(info); + } + }); } } diff --git a/app/src/main/java/com/uiuios/aios/manager/RemoteManager.java b/app/src/main/java/com/uiuios/aios/manager/RemoteManager.java index 4a0c7f8..7300623 100644 --- a/app/src/main/java/com/uiuios/aios/manager/RemoteManager.java +++ b/app/src/main/java/com/uiuios/aios/manager/RemoteManager.java @@ -6,6 +6,7 @@ import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.IBinder; +import android.os.RemoteException; import android.text.TextUtils; import android.util.Log; @@ -18,20 +19,26 @@ import com.uiuios.aios.disklrucache.CacheHelper; import com.uiuios.sn.IGetInfoInterface; import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; public class RemoteManager { private static final String TAG = RemoteManager.class.getSimpleName(); + private static final String SN_KEY = "sn_serial_key"; + + @SuppressLint("StaticFieldLeak") private static RemoteManager sInstance; private Context mContext; private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE); private CacheHelper mCacheHelper; - private IGetInfoInterface getInfoInterface; + private IGetInfoInterface mGetInfoInterface; private ServiceConnection mIGetInfoConnection; - private RemoteManager(Context context) { if (context == null) { throw new RuntimeException("Context is NULL"); @@ -42,14 +49,26 @@ public class RemoteManager { @Override public void onServiceConnected(ComponentName name, IBinder service) { Log.e(TAG, "onServiceConnected: mIGetInfoConnection"); - getInfoInterface = IGetInfoInterface.Stub.asInterface(service); + mGetInfoInterface = IGetInfoInterface.Stub.asInterface(service); + for (ConnectedListener listener : mListeners) { + if (listener != null) { + listener.onConnected(); + } + } + try { + String sn = mGetInfoInterface.getSerial(); + mMMKV.encode(SN_KEY, sn); + Log.e(TAG, "onServiceConnected: sn = " + sn); + } catch (RemoteException e) { + e.printStackTrace(); + } getLocation(); } @Override public void onServiceDisconnected(ComponentName name) { Log.e(TAG, "onServiceDisconnected: mIGetInfoConnection"); - getInfoInterface = null; + mGetInfoInterface = null; bindInfoService(); } }; @@ -70,8 +89,21 @@ public class RemoteManager { return sInstance; } + public interface ConnectedListener { + void onConnected(); + } + + Set mListeners = new HashSet<>(); + + public void setListener(ConnectedListener listener) { + mListeners.add(listener); + if (mGetInfoInterface != null) { + listener.onConnected(); + } + } + private void bindInfoService() { - if (getInfoInterface == null) { + if (mGetInfoInterface == null) { //这是连接aidl服务的代码 Intent intent = new Intent(); intent.setAction("com.uiuios.sn.IGetInfoInterface"); @@ -81,10 +113,26 @@ public class RemoteManager { } } - public void getLocation() { - if (getInfoInterface != null) { + /** + * @return 获取sn + */ + public String getSerial() { + if (mGetInfoInterface != null) { try { - String jsonString = getInfoInterface.getMapResult(); + return mGetInfoInterface.getSerial(); + } catch (Exception e) { + Log.e(TAG, "getSerial: " + e.getMessage()); + } + } else { + bindInfoService(); + } + return mMMKV.decodeString(SN_KEY, ""); + } + + public void getLocation() { + if (mGetInfoInterface != null) { + try { + String jsonString = mGetInfoInterface.getMapResult(); mMMKV.encode(CommonConfig.MAP_LOCATION_JSON_KEY, jsonString); } catch (Exception e) { Log.e(TAG, "getMapResult: " + e.getMessage()); @@ -127,7 +175,7 @@ public class RemoteManager { getLocation(); return "北京"; } else { - return mapBean.getCity() + "\t" + mapBean.getDistrict(); + return mapBean.getCity() + "\t" + mapBean.getDistrict(); } } @@ -157,9 +205,82 @@ public class RemoteManager { getLocation(); return "0.0"; } else { - return mapBean.getLongitude() + "," + mapBean.getLatitude(); + return mapBean.getLongitude() + "," + mapBean.getLatitude(); } } + public boolean putSystemInt(String name, int value) { + if (mGetInfoInterface != null) { + try { + return mGetInfoInterface.SystemPutInt(name, value); + } catch (Exception e) { + Log.e(TAG, "putSystemInt: " + e.getMessage()); + } + } else { + bindInfoService(); + } + return false; + } + public void killBackgroundProcesses(String pkg) { + if (mGetInfoInterface != null) { + try { + mGetInfoInterface.killBackgroundProcesses(pkg); + } catch (Exception e) { + Log.e(TAG, "killBackgroundProcesses: " + e.getMessage()); + } + } else { + bindInfoService(); + } + } + + public String getConnectWifiSsid() { + if (mGetInfoInterface != null) { + try { + return mGetInfoInterface.getWifiSsid(); + } catch (Exception e) { + Log.e(TAG, "killBackgroundProcesses: " + e.getMessage()); + } + } else { + bindInfoService(); + } + return "获取失败"; + } + + public String getBluetoothDeviceName() { + if (mGetInfoInterface != null) { + try { + return mGetInfoInterface.getBluetoothSsid(); + } catch (Exception e) { + Log.e(TAG, "killBackgroundProcesses: " + e.getMessage()); + } + } else { + bindInfoService(); + } + return "获取失败"; + } + + public void openLauncher3() { + if (mGetInfoInterface != null) { + try { + mGetInfoInterface.openLauncher3(); + } catch (Exception e) { + Log.e(TAG, "openLauncher3: " + e.getMessage()); + } + } else { + bindInfoService(); + } + } + + public void setDefaultDesktop(String pkgName, String className) { + if (mGetInfoInterface != null) { + try { + mGetInfoInterface.setDefaultDesktop(pkgName, className); + } catch (Exception e) { + Log.e(TAG, "setDefaultDesktop: " + e.getMessage()); + } + } else { + bindInfoService(); + } + } } diff --git a/app/src/main/java/com/uiuios/aios/network/NetInterfaceManager.java b/app/src/main/java/com/uiuios/aios/network/NetInterfaceManager.java index 66e7f6d..a53ff92 100644 --- a/app/src/main/java/com/uiuios/aios/network/NetInterfaceManager.java +++ b/app/src/main/java/com/uiuios/aios/network/NetInterfaceManager.java @@ -30,6 +30,7 @@ import com.uiuios.aios.disklrucache.CacheHelper; import com.uiuios.aios.gson.GsonUtils; import com.uiuios.aios.manager.ConnectManager; import com.uiuios.aios.manager.ConnectMode; +import com.uiuios.aios.manager.RemoteManager; import com.uiuios.aios.network.api.ActivityListApi; import com.uiuios.aios.network.api.AlarmClockAddApi; import com.uiuios.aios.network.api.AlarmClockApi; @@ -175,91 +176,91 @@ public class NetInterfaceManager { */ public Observable> getsnInfoControl() { return mRetrofit.create(SNInfoApi.class) - .getsninfo(Utils.getSerial()) + .getsninfo(RemoteManager.getInstance().getSerial()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } public Observable> getUserAvatarInfoControl() { return mRetrofit.create(UserInfoControl.class) - .getUserAvatarInfo(Utils.getSerial()) + .getUserAvatarInfo(RemoteManager.getInstance().getSerial()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } public Observable getRunningAppObservable(String json) { return mRetrofit.create(RunNewApp.class) - .sendRunningInfo(Utils.getSerial(), json) + .sendRunningInfo(RemoteManager.getInstance().getSerial(), json) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } public Observable> getsettingControl() { return mRetrofit.create(Setting.class) - .getSetting(Utils.getSerial()) + .getSetting(RemoteManager.getInstance().getSerial()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } public Observable getSOSRecordObservable(String longitude, String latitude, String address) { return mRetrofit.create(SOSRecordApi.class) - .sendSOSRecord(Utils.getSerial(), longitude, latitude, address) + .sendSOSRecord(RemoteManager.getInstance().getSerial(), longitude, latitude, address) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } public Observable getUpdateAlarmObservable(int id) { return mRetrofit.create(UpdateAlarmClockApi.class) - .updateAlarm(Utils.getSerial(), id) + .updateAlarm(RemoteManager.getInstance().getSerial(), id) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } public Observable getUpdateDesktopObservable(String jsonArray) { return mRetrofit.create(UpdateDesktopApi.class) - .updateLayout(Utils.getSerial(), jsonArray) + .updateLayout(RemoteManager.getInstance().getSerial(), jsonArray) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } public Observable>> getDesktopLayoutObservable() { return mRetrofit.create(GetDesktopApi.class) - .getDesktopLayout(Utils.getSerial()) + .getDesktopLayout(RemoteManager.getInstance().getSerial()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } public Observable>> getGoodsListObservable() { return mRetrofit.create(GoodsListApi.class) - .getGoodsList(Utils.getSerial()) + .getGoodsList(RemoteManager.getInstance().getSerial()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } public Observable>> getArticleListObservable() { return mRetrofit.create(ArticleListApi.class) - .getArticleList(Utils.getSerial()) + .getArticleList(RemoteManager.getInstance().getSerial()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } public Observable>> getContactListObservable() { return mRetrofit.create(GetMailList.class) - .getContact(Utils.getSerial()) + .getContact(RemoteManager.getInstance().getSerial()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } public Observable getAdminSnSettingObservable() { return mRetrofit.create(GetAdminSnSettingApi.class) - .getAdminSnSetting(Utils.getSerial()) + .getAdminSnSetting(RemoteManager.getInstance().getSerial()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } public Observable getUpdateAppIconObservable(String pkg, String label, int type) { return mRetrofit.create(UpdateAppIconApi.class) - .appIconUpdate(Utils.getSerial(), pkg, type, label) + .appIconUpdate(RemoteManager.getInstance().getSerial(), pkg, type, label) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } @@ -278,7 +279,7 @@ public class NetInterfaceManager { public Observable>> getAlarmClockObservable() { return mRetrofit .create(AlarmClockApi.class) - .getAlarmClockApiApi(Utils.getSerial()) + .getAlarmClockApiApi(RemoteManager.getInstance().getSerial()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } @@ -299,14 +300,14 @@ public class NetInterfaceManager { public Observable> getAlarmClockByIdObservable(int id) { return mRetrofit.create(AlarmClockQueryApi.class) - .getAlarmClockById(Utils.getSerial(), id) + .getAlarmClockById(RemoteManager.getInstance().getSerial(), id) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } public Observable deleteAlarmClockObservable(int id) { return mRetrofit.create(AlarmClockDeleteApi.class) - .alarmClockDelete(Utils.getSerial(), id) + .alarmClockDelete(RemoteManager.getInstance().getSerial(), id) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } @@ -317,7 +318,7 @@ public class NetInterfaceManager { public Observable> getUserIDObservable() { return mRetrofit.create(GetUserIDApi.class) - .getUserID(Utils.getSerial()) + .getUserID(RemoteManager.getInstance().getSerial()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } @@ -384,7 +385,7 @@ public class NetInterfaceManager { public Observable>> getActivityListObservable() { return mRetrofit.create(ActivityListApi.class) - .getActivityList(Utils.getSerial(), 1, 1, getUserId()) + .getActivityList(RemoteManager.getInstance().getSerial(), 1, 1, getUserId()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } @@ -494,7 +495,7 @@ public class NetInterfaceManager { public Observable>> getDemandListObservable() { return mRetrofit.create(DemandListApi.class) - .getDemandList(Utils.getSerial(), 1, 1, getUserId()) + .getDemandList(RemoteManager.getInstance().getSerial(), 1, 1, getUserId()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } @@ -614,7 +615,7 @@ public class NetInterfaceManager { public Observable>> getHealthCodeObservable() { return mRetrofit.create(HealthCodeApi.class) - .getArticleDetails(Utils.getSerial()) + .getArticleDetails(RemoteManager.getInstance().getSerial()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } @@ -1134,5 +1135,78 @@ public class NetInterfaceManager { }; } + public interface UserAvatarInfoCallback { + void setUserAvatarInfo(UserAvatarInfo info); + } +// public void getUserAvatarInfo(boolean refresh, BehaviorSubject lifecycle, UserAvatarInfoCallback callback) { +// ConnectMode connectMode = ConnectMode.ONE_MINUTE; +// if (refresh) { +// connectMode = ConnectMode.DEFAULT; +// } +// if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_USER_AVATAR_INFO, connectMode)) { +// getUserAvatarInfo(lifecycle, callback); +// } else { +// String jsonString = mCacheHelper.getAsString(UrlAddress.GET_USER_AVATAR_INFO); +// //为 "" 是已经请求成功的 +// if (jsonString == null) { +// getUserAvatarInfo(lifecycle, callback); +// } else { +// Gson gson = new Gson(); +// Type type = new TypeToken() { +// }.getType(); +// UserAvatarInfo userAvatarInfo = gson.fromJson(jsonString, type); +// if (callback != null) { +// callback.setUserAvatarInfo(userAvatarInfo); +// } +// } +// } +// } + + public void getUserAvatarInfo(BehaviorSubject lifecycle, UserAvatarInfoCallback callback) { + getUserAvatarInfoControl() + .compose(RxLifecycle.bindUntilEvent(lifecycle, FragmentEvent.DESTROY)) + .subscribe(getUserAvatarInfoObserver(callback)); + } + + public void getUserAvatarInfo(UserAvatarInfoCallback callback) { + getUserAvatarInfoControl() + .subscribe(getUserAvatarInfoObserver(callback)); + } + + public void getUserAvatarInfo() { + getUserAvatarInfoControl() + .subscribe(getUserAvatarInfoObserver(null)); + } + + public Observer> getUserAvatarInfoObserver(UserAvatarInfoCallback callback) { + return new Observer>() { + @Override + public void onSubscribe(@NonNull Disposable d) { + Log.e("getUserAvatarInfoControl", "onSubscribe: "); + } + + @Override + public void onNext(@NonNull BaseResponse userAvatarInfoBaseResponse) { + Log.e("getUserAvatarInfoControl", "onNext: " + userAvatarInfoBaseResponse); + if (callback != null) { + callback.setUserAvatarInfo(userAvatarInfoBaseResponse.data); + } + } + + @Override + public void onError(@NonNull Throwable e) { + Log.e("getUserAvatarInfoControl", "onError: " + e.getMessage()); + if (callback != null) { + callback.setUserAvatarInfo(null); + } + onComplete(); + } + + @Override + public void onComplete() { + Log.e("getUserAvatarInfoControl", "onComplete: "); + } + }; + } } diff --git a/app/src/main/java/com/uiuios/aios/network/interceptor/RepeatRequestInterceptor.java b/app/src/main/java/com/uiuios/aios/network/interceptor/RepeatRequestInterceptor.java index 49f12cc..2cfa002 100644 --- a/app/src/main/java/com/uiuios/aios/network/interceptor/RepeatRequestInterceptor.java +++ b/app/src/main/java/com/uiuios/aios/network/interceptor/RepeatRequestInterceptor.java @@ -39,7 +39,11 @@ public class RepeatRequestInterceptor implements Interceptor { // Response copy = response.newBuilder().body(responseBody).build(); ResponseBody copy = ResponseBody.create(responseBody.contentType(), content); if (BuildConfig.DEBUG) { -// Log.e(TAG, "请求体返回:| Response: " + request.url().encodedPath() + "\t body: " + content); + if (content.length() < 1024) { + Log.e(TAG, "请求体返回:| Response: " + request.url() + "\t body: " + content); + }else { + Log.e(TAG, "请求体返回:| Response: " + request.url() + "\t body: too long" ); + } } //相同的请求 String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString() + requestBodyToString(request.body())); @@ -83,7 +87,7 @@ public class RepeatRequestInterceptor implements Interceptor { final Request copy = request.newBuilder().build(); final Buffer buffer = new Buffer(); copy.body().writeTo(buffer); - if (buffer.size() > 4096) { + if (buffer.size() > 1024) { return "-too long"; } return buffer.readUtf8(); @@ -96,7 +100,7 @@ public class RepeatRequestInterceptor implements Interceptor { try { final Buffer buffer = new Buffer(); body.writeTo(buffer); - if (buffer.size() > 4096) { + if (buffer.size() > 1024) { return "-too long"; } return buffer.readUtf8(); diff --git a/app/src/main/java/com/uiuios/aios/push/tpush/Constants.java b/app/src/main/java/com/uiuios/aios/push/tpush/Constants.java deleted file mode 100644 index fd57742..0000000 --- a/app/src/main/java/com/uiuios/aios/push/tpush/Constants.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.uiuios.aios.push.tpush; - -/** - * Created by chacewang on 2019/7/5. - */ - -public class Constants { - public static final int TEST_LOCAL_NOTIFICATION = 1; - public static final int TEST_NOTIFICATION = 2; - public static final int TEST_SET_TAG = 3; - public static final int TEST_DEL_TAG = 4; - public static final int TEST_SET_ACCOUNT = 5; - public static final int TEST_DEL_ACCOUNT = 6; - - public static final String LOCAL_NOTIFICATION_TITLE = "localtest"; - public static final String TEST_TAG_NAME = "DiagnosisTag"; -} diff --git a/app/src/main/java/com/uiuios/aios/push/tpush/MessageReceiver.java b/app/src/main/java/com/uiuios/aios/push/tpush/MessageReceiver.java deleted file mode 100644 index a2d9dd7..0000000 --- a/app/src/main/java/com/uiuios/aios/push/tpush/MessageReceiver.java +++ /dev/null @@ -1,305 +0,0 @@ -package com.uiuios.aios.push.tpush; - -import android.content.ContentResolver; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.text.TextUtils; -import android.util.Log; -import android.widget.Toast; - -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.tencent.android.tpush.NotificationAction; -import com.tencent.android.tpush.XGPushBaseReceiver; -import com.tencent.android.tpush.XGPushClickedResult; -import com.tencent.android.tpush.XGPushRegisterResult; -import com.tencent.android.tpush.XGPushShowedResult; -import com.tencent.android.tpush.XGPushTextMessage; -import com.uiuios.aios.push.PushManager; -import com.uiuios.aios.push.tpush.common.NotificationService; -import com.uiuios.aios.push.tpush.po.XGNotification; -import com.uiuios.aios.utils.ToastUtil; - -import java.text.SimpleDateFormat; -import java.util.Calendar; - -public class MessageReceiver extends XGPushBaseReceiver { - private static final String TAG = MessageReceiver.class.getSimpleName(); - - public static final String UPDATE_LISTVIEW_ACTION = "com.qq.xgdemo.activity.UPDATE_LISTVIEW"; - public static final String TEST_ACTION = "com.qq.xgdemo.activity.TEST_ACTION"; - public static final String LogTag = "xg.test"; - - private Context mContext; - private ContentResolver mResolver; - private PackageManager mPackageManager; - - /** - * 消息透传处理 - * - * @param context - * @param message 解析自定义的 JSON - */ - @Override - public void onTextMessage(Context context, XGPushTextMessage message) { - this.mContext = context; - this.mResolver = context.getContentResolver(); - this.mPackageManager = context.getPackageManager(); - String text = "收到消息:" + message.toString(); - // 获取自定义key-value - String customContent = message.getCustomContent(); - if (customContent != null && customContent.length() != 0) { - JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject(); - // key1为前台配置的key - if (!TextUtils.isEmpty(obj.get("key").getAsString())) { - String value = obj.get("key").getAsString(); - Log.d(LogTag, "get custom value:" + value); - } - // ... - } - // APP自主处理消息的过程... - Log.e(LogTag, text); - show(context, text); - processCustomMessage(context, message); - } - - /** - * 通知展示 - * - * @param context - * @param notifiShowedRlt 包含通知的内容 - */ - @Override - public void onNotificationShowedResult(Context context, XGPushShowedResult notifiShowedRlt) { - if (context == null || notifiShowedRlt == null) { - return; - } - XGNotification notific = new XGNotification(); - notific.setMsg_id(notifiShowedRlt.getMsgId()); - notific.setTitle(notifiShowedRlt.getTitle()); - notific.setContent(notifiShowedRlt.getContent()); - // notificationActionType==1为Activity,2为url,3为intent - notific.setNotificationActionType(notifiShowedRlt - .getNotificationActionType()); - // Activity,url,intent都可以通过getActivity()获得 - notific.setActivity(notifiShowedRlt.getActivity()); - notific.setUpdate_time(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") - .format(Calendar.getInstance().getTime())); - NotificationService.getInstance(context).save(notific); - - Intent testIntent = new Intent(TEST_ACTION); - if (notifiShowedRlt.getTitle().equals(Constants.LOCAL_NOTIFICATION_TITLE)) { - testIntent.putExtra("step", Constants.TEST_LOCAL_NOTIFICATION); - } else { - testIntent.putExtra("step", Constants.TEST_NOTIFICATION); - } - context.sendBroadcast(testIntent); - - Intent viewIntent = new Intent(UPDATE_LISTVIEW_ACTION); - context.sendBroadcast(viewIntent); - show(context, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString()); - Log.d(LogTag, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString() + ", PushChannel:" + notifiShowedRlt.getPushChannel()); - } - - /** - * 注册回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - */ - @Override - public void onRegisterResult(Context context, int errorCode, XGPushRegisterResult message) { - if (context == null || message == null) { - return; - } - String text = ""; - if (errorCode == XGPushBaseReceiver.SUCCESS) { - // 在这里拿token - String token = message.getToken(); - text = "注册成功1. token:" + token; - } else { - text = message + "注册失败,错误码:" + errorCode; - } - Log.d(LogTag, text); - show(context, text); - } - - /** - * 反注册回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - */ - @Override - public void onUnregisterResult(Context context, int errorCode) { - if (context == null) { - return; - } - String text = ""; - if (errorCode == XGPushBaseReceiver.SUCCESS) { - text = "反注册成功"; - } else { - text = "反注册失败" + errorCode; - } - Log.d(LogTag, text); - show(context, text); - - } - - /** - * 设置标签回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - * @param tagName 设置的 TAG - */ - @Override - public void onSetTagResult(Context context, int errorCode, String tagName) { - if (context == null) { - return; - } - String text = ""; - if (errorCode == XGPushBaseReceiver.SUCCESS) { - text = "\"" + tagName + "\"设置成功"; - } else { - text = "\"" + tagName + "\"设置失败,错误码:" + errorCode; - } - Log.d(LogTag, text); - show(context, text); - - Intent testIntent = new Intent(TEST_ACTION); - testIntent.putExtra("step", Constants.TEST_SET_TAG); - context.sendBroadcast(testIntent); - } - - /** - * 删除标签的回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - * @param tagName 设置的 TAG - */ - @Override - public void onDeleteTagResult(Context context, int errorCode, String tagName) { - if (context == null) { - return; - } - String text = ""; - if (errorCode == XGPushBaseReceiver.SUCCESS) { - text = "\"" + tagName + "\"删除成功"; - } else { - text = "\"" + tagName + "\"删除失败,错误码:" + errorCode; - } - Log.d(LogTag, text); - show(context, text); - - Intent testIntent = new Intent(TEST_ACTION); - testIntent.putExtra("step", Constants.TEST_DEL_TAG); - context.sendBroadcast(testIntent); - } - - /** - * 设置账号回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - * @param account 设置的账号 - */ - @Override - public void onSetAccountResult(Context context, int errorCode, String account) { - Intent testIntent = new Intent(TEST_ACTION); - testIntent.putExtra("step", Constants.TEST_SET_ACCOUNT); - context.sendBroadcast(testIntent); - } - - - /** - * 删除账号回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - * @param account 设置的账号 - */ - @Override - public void onDeleteAccountResult(Context context, int errorCode, String account) { - Intent testIntent = new Intent(TEST_ACTION); - testIntent.putExtra("step", Constants.TEST_DEL_ACCOUNT); - context.sendBroadcast(testIntent); - } - - @Override - public void onSetAttributeResult(Context context, int i, String s) { - - } - - @Override - public void onDeleteAttributeResult(Context context, int i, String s) { - - } - - @Override - public void onQueryTagsResult(Context context, int errorCode, String data, String operateName) { - Log.i(LogTag, "action - onQueryTagsResult, errorCode:" + errorCode + ", operateName:" + operateName + ", data: " + data); - } - - /** - * 通知点击回调 actionType=1为该消息被清除,actionType=0为该消息被点击 - * - * @param context - * @param message 包含被点击通知的内容 - */ - @Override - public void onNotificationClickedResult(Context context, XGPushClickedResult message) { - if (context == null || message == null) { - return; - } - String text = ""; - if (message.getActionType() == NotificationAction.clicked.getType()) { - // 通知在通知栏被点击啦。。。。。 - // APP自己处理点击的相关动作 - // 这个动作可以在activity的onResume也能监听,请看第3点相关内容 - text = "通知被打开 :" + message; - } else if (message.getActionType() == NotificationAction.delete.getType()) { - // 通知被清除啦。。。。 - // APP自己处理通知被清除后的相关动作 - text = "通知被清除 :" + message; - } - Toast.makeText(context, "广播接收到通知被点击:" + message.toString(), - Toast.LENGTH_SHORT).show(); - // 获取自定义key-value - String customContent = message.getCustomContent(); - if (customContent != null && customContent.length() != 0) { - JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject(); - // key1为前台配置的key - if (!TextUtils.isEmpty(obj.get("key").getAsString())) { - String value = obj.get("key").getAsString(); - Log.d(LogTag, "get custom value:" + value); - } - // ... - } - // APP自主处理的过程。。。 - Log.d(LogTag, text); - show(context, text); - } - - private void show(Context context, String text) { -// Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); - } - - private void processCustomMessage(Context context, XGPushTextMessage message) { - if (context == null || message == null) { - return; - } - - String title = message.getTitle(); - String content = message.getContent(); - JsonObject extrasJson = JsonParser.parseString(content).getAsJsonObject(); - - String extras = ""; - if (extrasJson.get("extras") != null) { - extras = extrasJson.get("extras").toString(); - } - PushManager.getInstance().setPushContent(title, extras); - } -} diff --git a/app/src/main/java/com/uiuios/aios/push/tpush/common/DBOpenHelper.java b/app/src/main/java/com/uiuios/aios/push/tpush/common/DBOpenHelper.java deleted file mode 100644 index c068ab3..0000000 --- a/app/src/main/java/com/uiuios/aios/push/tpush/common/DBOpenHelper.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.uiuios.aios.push.tpush.common; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; - -public class DBOpenHelper extends SQLiteOpenHelper { - - public DBOpenHelper(Context context) { - super(context, "XGExample.db", null, 1); - } - - @Override - public void onCreate(SQLiteDatabase db) { - db.execSQL("CREATE TABLE notification (id integer primary key autoincrement,msg_id varchar(64),title varchar(128),activity varchar(256),notificationActionType varchar(512),content text,update_time varchar(16))"); - } - - @Override - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - - } - -} diff --git a/app/src/main/java/com/uiuios/aios/push/tpush/common/NotificationService.java b/app/src/main/java/com/uiuios/aios/push/tpush/common/NotificationService.java deleted file mode 100644 index 952620a..0000000 --- a/app/src/main/java/com/uiuios/aios/push/tpush/common/NotificationService.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.uiuios.aios.push.tpush.common; - -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; - - -import com.uiuios.aios.push.tpush.po.XGNotification; - -import java.util.ArrayList; -import java.util.List; - -public class NotificationService { - private DBOpenHelper dbOpenHelper; - private static NotificationService instance = null; - - public NotificationService(Context context) { - this.dbOpenHelper = new DBOpenHelper(context); - } - - public synchronized static NotificationService getInstance(Context ctx) { - if (null == instance) { - instance = new NotificationService(ctx); - } - return instance; - } - - public void save(XGNotification notification) { - SQLiteDatabase db = dbOpenHelper.getWritableDatabase(); - ContentValues values = new ContentValues(); - values.put("msg_id", notification.getMsg_id()); - values.put("title", notification.getTitle()); - values.put("content", notification.getContent()); - values.put("activity", notification.getActivity()); - values.put("notificationActionType", notification.getNotificationActionType()); - values.put("update_time", notification.getUpdate_time()); - db.insert("notification", null, values); - } - - public void delete(Integer id) { - SQLiteDatabase db = dbOpenHelper.getWritableDatabase(); - db.delete("notification", "id=?", new String[] { id.toString() }); - } - - public void deleteAll() { - SQLiteDatabase db = dbOpenHelper.getWritableDatabase(); - db.delete("notification", "", null); - } - - public void update(XGNotification notification) { - SQLiteDatabase db = dbOpenHelper.getWritableDatabase(); - ContentValues values = new ContentValues(); - values.put("msg_id", notification.getMsg_id()); - values.put("title", notification.getTitle()); - values.put("content", notification.getContent()); - values.put("activity", notification.getActivity()); - values.put("notificationActionType", notification.getNotificationActionType()); - values.put("update_time", notification.getUpdate_time()); - db.update("notification", values, "id=?", new String[] { notification - .getId().toString() }); - } - - public XGNotification find(Integer id) { - SQLiteDatabase db = dbOpenHelper.getReadableDatabase(); - Cursor cursor = db - .query("notification", - new String[] { "id,msg_id,title,content,activity,notificationActionType,update_time" }, - "id=?", new String[] { id.toString() }, null, null, - null, "1"); - try { - if (cursor.moveToFirst()) { - return new XGNotification(cursor.getInt(cursor - .getColumnIndex("id")), cursor.getLong(cursor - .getColumnIndex("msg_id")), cursor.getString(cursor - .getColumnIndex("title")), cursor.getString(cursor - .getColumnIndex("content")), cursor.getString(cursor - .getColumnIndex("activity")), cursor.getInt(cursor - .getColumnIndex("notificationActionType")), cursor.getString(cursor - .getColumnIndex("update_time"))); - } - return null; - } finally { - cursor.close(); - } - } - - public List getScrollData(int currentPage, int lineSize, - String msg_id) { - String firstResult = String.valueOf((currentPage - 1) * lineSize); - SQLiteDatabase db = dbOpenHelper.getReadableDatabase(); - Cursor cursor = null; - try { - if (msg_id == null || "".equals(msg_id)) { - cursor = db - .query("notification", - new String[] { "id,msg_id,title,content,activity,notificationActionType,update_time" }, - null, null, null, null, "update_time DESC", - firstResult + "," + lineSize); - } else { - cursor = db - .query("notification", - new String[] { "id,msg_id,title,content,activity,notificationActionType,update_time" }, - "msg_id like ?", new String[] { msg_id + "%" }, - null, null, "update_time DESC", firstResult - + "," + lineSize); - } - List notifications = new ArrayList(); - while (cursor.moveToNext()) { - notifications.add(new XGNotification(cursor.getInt(cursor - .getColumnIndex("id")), cursor.getLong(cursor - .getColumnIndex("msg_id")), cursor.getString(cursor - .getColumnIndex("title")), cursor.getString(cursor - .getColumnIndex("content")), cursor.getString(cursor - .getColumnIndex("activity")), cursor.getInt(cursor - .getColumnIndex("notificationActionType")), cursor.getString(cursor - .getColumnIndex("update_time")))); - } - return notifications; - } finally { - cursor.close(); - } - } - - public int getCount() { - SQLiteDatabase db = dbOpenHelper.getReadableDatabase(); - Cursor cursor = db.rawQuery("select count(*) from notification", null); - try { - cursor.moveToFirst(); - return cursor.getInt(0); - } finally { - cursor.close(); - } - } -} diff --git a/app/src/main/java/com/uiuios/aios/push/tpush/po/XGNotification.java b/app/src/main/java/com/uiuios/aios/push/tpush/po/XGNotification.java deleted file mode 100644 index fcccd1a..0000000 --- a/app/src/main/java/com/uiuios/aios/push/tpush/po/XGNotification.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.uiuios.aios.push.tpush.po; - -public class XGNotification { - private Integer id; - private Long msg_id; - private String title; - private String content; - private String activity; - private int notificationActionType; - private String update_time; - - public XGNotification() { - - } - - public XGNotification(Integer id, Long msg_id, String title, - String content, String activity, int notificationActionType, String update_time) { - super(); - this.id = id; - this.msg_id = msg_id; - this.title = title; - this.content = content; - this.activity = activity; - this.notificationActionType = notificationActionType; - this.update_time = update_time; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Long getMsg_id() { - return msg_id; - } - - public void setMsg_id(Long msg_id) { - this.msg_id = msg_id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getUpdate_time() { - return update_time; - } - - public void setUpdate_time(String update_time) { - this.update_time = update_time; - } - - public String getActivity() { - return activity; - } - - public void setActivity(String activity) { - this.activity = activity; - } - - public int getNotificationActionType() { - return notificationActionType; - } - - public void setNotificationActionType(int notificationActionType) { - this.notificationActionType = notificationActionType; - } -} diff --git a/app/src/main/java/com/uiuios/aios/service/main/MainSPresenter.java b/app/src/main/java/com/uiuios/aios/service/main/MainSPresenter.java index 1d5ce35..03bd6ab 100644 --- a/app/src/main/java/com/uiuios/aios/service/main/MainSPresenter.java +++ b/app/src/main/java/com/uiuios/aios/service/main/MainSPresenter.java @@ -11,6 +11,7 @@ import com.uiuios.aios.alarm.AlarmUtils; import com.uiuios.aios.bean.AlarmClockId; import com.uiuios.aios.bean.BaseResponse; import com.uiuios.aios.config.CommonConfig; +import com.uiuios.aios.manager.RemoteManager; import com.uiuios.aios.network.NetInterfaceManager; import com.uiuios.aios.utils.Utils; @@ -80,7 +81,7 @@ public class MainSPresenter implements MainSContact.Presenter { addFinishStatu = 0; for (AlarmClockData alarmClockData : localAddAlarm) { Map params = new HashMap<>(); - params.put("sn", Utils.getSerial()); + params.put("sn", RemoteManager.getInstance().getSerial()); params.put("time", alarmClockData.getTime()); params.put("type", String.valueOf(alarmClockData.getType())); params.put("title", alarmClockData.getTitle()); @@ -168,7 +169,7 @@ public class MainSPresenter implements MainSContact.Presenter { private Observable> getAddObservable(AlarmClockData alarmClockData) { Map params = new HashMap<>(); - params.put("sn", Utils.getSerial()); + params.put("sn", RemoteManager.getInstance().getSerial()); params.put("time", alarmClockData.getTime()); params.put("type", String.valueOf(alarmClockData.getType())); params.put("title", alarmClockData.getTitle()); diff --git a/app/src/main/java/com/uiuios/aios/service/main/MainService.java b/app/src/main/java/com/uiuios/aios/service/main/MainService.java index 303667a..bb5ce9e 100644 --- a/app/src/main/java/com/uiuios/aios/service/main/MainService.java +++ b/app/src/main/java/com/uiuios/aios/service/main/MainService.java @@ -21,6 +21,7 @@ import com.uiuios.aios.alarm.AlarmUtils; import com.uiuios.aios.base.BaseService; import com.uiuios.aios.alarm.AlarmClockData; import com.uiuios.aios.bean.BaseResponse; +import com.uiuios.aios.manager.RemoteManager; import com.uiuios.aios.network.NetInterfaceManager; import com.uiuios.aios.utils.ApkUtils; import com.uiuios.aios.utils.AppUsedTimeUtils; @@ -226,7 +227,6 @@ public class MainService extends BaseService implements MainSContact.MainSView, Log.e(TAG, "TimeChangedReceiver:" + "timezone changed"); } else if (Intent.ACTION_TIME_TICK.equals(intent.getAction())) { Log.e(TAG, "TimeChangedReceiver:" + "time tick"); -// isScreenshot(); } } } @@ -282,7 +282,7 @@ public class MainService extends BaseService implements MainSContact.MainSView, private static Observable getSendFile(String path, MultipartBody.Part body) { return NetInterfaceManager.getInstance() .getScreenshotApi() - .sendScreenshot(Utils.getSerial(), body) + .sendScreenshot(RemoteManager.getInstance().getSerial(), body) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } @@ -397,7 +397,7 @@ public class MainService extends BaseService implements MainSContact.MainSView, // AppUsedTimeUtils.getInstance().setEndTime(System.currentTimeMillis()); if (!TextUtils.isEmpty(packagename)) { NetInterfaceManager.getInstance().getAppUsageRecordControl() - .sendappUsageRecord(Utils.getSerial(), + .sendappUsageRecord(RemoteManager.getInstance().getSerial(), ApkUtils.getAppNameByPackage(context, packagename), packagename, AppUsedTimeUtils.getInstance().getStartTime() / 1000, diff --git a/app/src/main/java/com/uiuios/aios/utils/ApkUtils.java b/app/src/main/java/com/uiuios/aios/utils/ApkUtils.java index f77374e..1ab6a74 100644 --- a/app/src/main/java/com/uiuios/aios/utils/ApkUtils.java +++ b/app/src/main/java/com/uiuios/aios/utils/ApkUtils.java @@ -250,6 +250,12 @@ public class ApkUtils { familyIcon.setPackageName("aios.appstore"); desktopIcons.add(1, familyIcon); + DesktopIcon exitIcon = new DesktopIcon(); + exitIcon.setIcon(context.getDrawable(R.drawable.exit_icon)); + exitIcon.setLable("切换系统"); + exitIcon.setPackageName("aios.exit"); + desktopIcons.add(exitIcon); + return desktopIcons; } diff --git a/app/src/main/java/com/uiuios/aios/utils/AppUsedTimeUtils.java b/app/src/main/java/com/uiuios/aios/utils/AppUsedTimeUtils.java index a5a10a7..d69f43a 100644 --- a/app/src/main/java/com/uiuios/aios/utils/AppUsedTimeUtils.java +++ b/app/src/main/java/com/uiuios/aios/utils/AppUsedTimeUtils.java @@ -11,6 +11,8 @@ import androidx.annotation.NonNull; import com.google.gson.Gson; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; +import com.tencent.mmkv.MMKV; +import com.uiuios.aios.config.CommonConfig; import java.io.Serializable; import java.lang.reflect.Type; @@ -24,6 +26,7 @@ public class AppUsedTimeUtils { @SuppressLint("StaticFieldLeak") private static AppUsedTimeUtils sInstance; private Context mContext; + private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE); private SimpleDateFormat ruleSDF = new SimpleDateFormat("HH:mm:ss"); private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -123,7 +126,7 @@ public class AppUsedTimeUtils { } synchronized private AppTimeinfo getAppTimeinfo() { - String jsonString = Settings.System.getString(mContext.getContentResolver(), "runningAppInfo"); + String jsonString = mMMKV.decodeString("runningAppInfo"); if (TextUtils.isEmpty(jsonString)) { return new AppTimeinfo(); } @@ -137,7 +140,7 @@ public class AppUsedTimeUtils { synchronized private void setAppTimeinfo() { String jsonString = JsonParser.parseString(appTimeinfo.toString()).getAsJsonObject().toString(); - Settings.System.putString(mContext.getContentResolver(), "runningAppInfo", jsonString); + mMMKV.encode("runningAppInfo", jsonString); } private static final long DAY_TIME = 1000 * 60 * 60 * 24; diff --git a/app/src/main/java/com/uiuios/aios/utils/BrightnessUtils.java b/app/src/main/java/com/uiuios/aios/utils/BrightnessUtils.java index 27f4928..7c721f7 100644 --- a/app/src/main/java/com/uiuios/aios/utils/BrightnessUtils.java +++ b/app/src/main/java/com/uiuios/aios/utils/BrightnessUtils.java @@ -16,8 +16,6 @@ */ package com.uiuios.aios.utils; -import android.util.MathUtils; - public class BrightnessUtils { public static final int GAMMA_SPACE_MIN = 0; diff --git a/app/src/main/java/com/uiuios/aios/utils/MathUtils.java b/app/src/main/java/com/uiuios/aios/utils/MathUtils.java new file mode 100644 index 0000000..21d7ff8 --- /dev/null +++ b/app/src/main/java/com/uiuios/aios/utils/MathUtils.java @@ -0,0 +1,186 @@ +package com.uiuios.aios.utils; + +import android.graphics.Rect; + +public final class MathUtils { + private static final float DEG_TO_RAD = 0.017453292F; + private static final float RAD_TO_DEG = 57.295784F; + + private MathUtils() { + } + + public static float abs(float v) { + return v > 0.0F ? v : -v; + } + + public static int constrain(int amount, int low, int high) { + return amount < low ? low : (amount > high ? high : amount); + } + + public static long constrain(long amount, long low, long high) { + return amount < low ? low : (amount > high ? high : amount); + } + + public static float constrain(float amount, float low, float high) { + return amount < low ? low : (amount > high ? high : amount); + } + + public static float log(float a) { + return (float)Math.log((double)a); + } + + public static float exp(float a) { + return (float)Math.exp((double)a); + } + + public static float pow(float a, float b) { + return (float)Math.pow((double)a, (double)b); + } + + public static float sqrt(float a) { + return (float)Math.sqrt((double)a); + } + + public static float max(float a, float b) { + return a > b ? a : b; + } + + public static float max(int a, int b) { + return a > b ? (float)a : (float)b; + } + + public static float max(float a, float b, float c) { + return a > b ? (a > c ? a : c) : (b > c ? b : c); + } + + public static float max(int a, int b, int c) { + return a > b ? (float)(a > c ? a : c) : (float)(b > c ? b : c); + } + + public static float min(float a, float b) { + return a < b ? a : b; + } + + public static float min(int a, int b) { + return a < b ? (float)a : (float)b; + } + + public static float min(float a, float b, float c) { + return a < b ? (a < c ? a : c) : (b < c ? b : c); + } + + public static float min(int a, int b, int c) { + return a < b ? (float)(a < c ? a : c) : (float)(b < c ? b : c); + } + + public static float dist(float x1, float y1, float x2, float y2) { + float x = x2 - x1; + float y = y2 - y1; + return (float)Math.hypot((double)x, (double)y); + } + + public static float dist(float x1, float y1, float z1, float x2, float y2, float z2) { + float x = x2 - x1; + float y = y2 - y1; + float z = z2 - z1; + return (float)Math.sqrt((double)(x * x + y * y + z * z)); + } + + public static float mag(float a, float b) { + return (float)Math.hypot((double)a, (double)b); + } + + public static float mag(float a, float b, float c) { + return (float)Math.sqrt((double)(a * a + b * b + c * c)); + } + + public static float sq(float v) { + return v * v; + } + + public static float dot(float v1x, float v1y, float v2x, float v2y) { + return v1x * v2x + v1y * v2y; + } + + public static float cross(float v1x, float v1y, float v2x, float v2y) { + return v1x * v2y - v1y * v2x; + } + + public static float radians(float degrees) { + return degrees * 0.017453292F; + } + + public static float degrees(float radians) { + return radians * 57.295784F; + } + + public static float acos(float value) { + return (float)Math.acos((double)value); + } + + public static float asin(float value) { + return (float)Math.asin((double)value); + } + + public static float atan(float value) { + return (float)Math.atan((double)value); + } + + public static float atan2(float a, float b) { + return (float)Math.atan2((double)a, (double)b); + } + + public static float tan(float angle) { + return (float)Math.tan((double)angle); + } + + public static float lerp(float start, float stop, float amount) { + return start + (stop - start) * amount; + } + + public static float lerpInv(float a, float b, float value) { + return a != b ? (value - a) / (b - a) : 0.0F; + } + + public static float saturate(float value) { + return constrain(value, 0.0F, 1.0F); + } + + public static float lerpInvSat(float a, float b, float value) { + return saturate(lerpInv(a, b, value)); + } + + public static float lerpDeg(float start, float end, float amount) { + float minAngle = (end - start + 180.0F) % 360.0F - 180.0F; + return minAngle * amount + start; + } + + public static float norm(float start, float stop, float value) { + return (value - start) / (stop - start); + } + + public static float map(float minStart, float minStop, float maxStart, float maxStop, float value) { + return maxStart + (maxStop - maxStart) * ((value - minStart) / (minStop - minStart)); + } + + public static float constrainedMap(float rangeMin, float rangeMax, float valueMin, float valueMax, float value) { + return lerp(rangeMin, rangeMax, lerpInvSat(valueMin, valueMax, value)); + } + + public static float smoothStep(float start, float end, float x) { + return constrain((x - start) / (end - start), 0.0F, 1.0F); + } + + public static int addOrThrow(int a, int b) throws IllegalArgumentException { + if (b == 0) { + return a; + } else if (b > 0 && a <= 2147483647 - b) { + return a + b; + } else if (b < 0 && a >= -2147483648 - b) { + return a + b; + } else { + throw new IllegalArgumentException("Addition overflow: " + a + " + " + b); + } + } + +} diff --git a/app/src/main/java/com/uiuios/aios/utils/Utils.java b/app/src/main/java/com/uiuios/aios/utils/Utils.java index 36a1cb4..2d9a39f 100644 --- a/app/src/main/java/com/uiuios/aios/utils/Utils.java +++ b/app/src/main/java/com/uiuios/aios/utils/Utils.java @@ -18,7 +18,6 @@ import android.graphics.PorterDuffXfermode; import android.os.BatteryManager; import android.os.Build; import android.os.Environment; -import android.os.SystemProperties; import android.os.UserHandle; import android.text.TextUtils; import android.util.Log; @@ -141,15 +140,15 @@ public class Utils { intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.AoleReceiver")); // TODO: 2022/7/6 有问题 setDefaultLauncher(context, "com.android.transfer", "com.android.transfer.MainActivity"); - SystemProperties.set("persist.sys.launcher.pkgname", pkg); - SystemProperties.set("persist.sys.launcher.classname", className); +// SystemProperties.set("persist.sys.launcher.pkgname", pkg); +// SystemProperties.set("persist.sys.launcher.classname", className); // } intent.setPackage("com.android.settings"); context.sendBroadcast(intent); // ApkUtils.openPackage(mContext, pkg); Log.e(TAG, "setDefaultDesktop: " + pkg + ":" + className); - Log.e(TAG, "setDefaultDesktop: " + "persist.sys.launcher.pkgname = " + SystemProperties.get("persist.sys.launcher.pkgname")); - Log.e(TAG, "setDefaultDesktop: " + "persist.sys.launcher.classname = " + SystemProperties.get("persist.sys.launcher.classname")); +// Log.e(TAG, "setDefaultDesktop: " + "persist.sys.launcher.pkgname = " + SystemProperties.get("persist.sys.launcher.pkgname")); +// Log.e(TAG, "setDefaultDesktop: " + "persist.sys.launcher.classname = " + SystemProperties.get("persist.sys.launcher.classname")); } public static void setDefaultLauncher(Context context, String defPackageName, String defClassName) { @@ -204,7 +203,7 @@ public class Utils { + packageName); } }; - roleManager.addRoleHolderAsUser(roleName, packageName, flags, user, executor, callback); +// roleManager.addRoleHolderAsUser(roleName, packageName, flags, user, executor, callback); Log.i("settingssssssstemf", "addRoleHolderAsUser done"); // } } diff --git a/app/src/main/res/drawable-hdpi/app_exit.jpg b/app/src/main/res/drawable-hdpi/app_exit.jpg deleted file mode 100644 index 774942f..0000000 Binary files a/app/src/main/res/drawable-hdpi/app_exit.jpg and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/app_exit.png b/app/src/main/res/drawable-hdpi/app_exit.png new file mode 100644 index 0000000..761ab44 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/app_exit.png differ diff --git a/app/src/main/res/drawable-hdpi/battery1.png b/app/src/main/res/drawable-hdpi/battery1.png index 8959a34..c971feb 100644 Binary files a/app/src/main/res/drawable-hdpi/battery1.png and b/app/src/main/res/drawable-hdpi/battery1.png differ diff --git a/app/src/main/res/drawable-hdpi/bluetooth1.png b/app/src/main/res/drawable-hdpi/bluetooth1.png index 8212fdd..8062ad9 100644 Binary files a/app/src/main/res/drawable-hdpi/bluetooth1.png and b/app/src/main/res/drawable-hdpi/bluetooth1.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_appstore.png b/app/src/main/res/drawable-hdpi/com_android_appstore.png index 9b06c7c..dda8263 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_appstore.png and b/app/src/main/res/drawable-hdpi/com_android_appstore.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_browser.png b/app/src/main/res/drawable-hdpi/com_android_browser.png index b22f226..a0bb4a3 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_browser.png and b/app/src/main/res/drawable-hdpi/com_android_browser.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_calendar.png b/app/src/main/res/drawable-hdpi/com_android_calendar.png index 0065e28..ef5e141 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_calendar.png and b/app/src/main/res/drawable-hdpi/com_android_calendar.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_camera.png b/app/src/main/res/drawable-hdpi/com_android_camera.png index bbeb62c..6e3f4af 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_camera.png and b/app/src/main/res/drawable-hdpi/com_android_camera.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_clean.png b/app/src/main/res/drawable-hdpi/com_android_clean.png index be7eae1..5d8431c 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_clean.png and b/app/src/main/res/drawable-hdpi/com_android_clean.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_contacts.png b/app/src/main/res/drawable-hdpi/com_android_contacts.png index b204ea0..62b572e 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_contacts.png and b/app/src/main/res/drawable-hdpi/com_android_contacts.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_deskclock.png b/app/src/main/res/drawable-hdpi/com_android_deskclock.png index 81bf96f..e240294 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_deskclock.png and b/app/src/main/res/drawable-hdpi/com_android_deskclock.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_dialer.png b/app/src/main/res/drawable-hdpi/com_android_dialer.png index 5bf5306..80a0eb9 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_dialer.png and b/app/src/main/res/drawable-hdpi/com_android_dialer.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_gallery3d_app.png b/app/src/main/res/drawable-hdpi/com_android_gallery3d_app.png index a5177c3..938d2cd 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_gallery3d_app.png and b/app/src/main/res/drawable-hdpi/com_android_gallery3d_app.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_mms_ui.png b/app/src/main/res/drawable-hdpi/com_android_mms_ui.png index 1ac19f2..7550ec4 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_mms_ui.png and b/app/src/main/res/drawable-hdpi/com_android_mms_ui.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_music.png b/app/src/main/res/drawable-hdpi/com_android_music.png index d0b55a9..af5a0aa 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_music.png and b/app/src/main/res/drawable-hdpi/com_android_music.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_settings.png b/app/src/main/res/drawable-hdpi/com_android_settings.png index ad4e3a7..1a01dc3 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_settings.png and b/app/src/main/res/drawable-hdpi/com_android_settings.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_soundrecorder.png b/app/src/main/res/drawable-hdpi/com_android_soundrecorder.png index 538075f..6c54e53 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_soundrecorder.png and b/app/src/main/res/drawable-hdpi/com_android_soundrecorder.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_stk_stkmain.png b/app/src/main/res/drawable-hdpi/com_android_stk_stkmain.png index 1af7e9e..eb953e6 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_stk_stkmain.png and b/app/src/main/res/drawable-hdpi/com_android_stk_stkmain.png differ diff --git a/app/src/main/res/drawable-hdpi/com_android_vdieo.png b/app/src/main/res/drawable-hdpi/com_android_vdieo.png index a031a22..9b3b17b 100644 Binary files a/app/src/main/res/drawable-hdpi/com_android_vdieo.png and b/app/src/main/res/drawable-hdpi/com_android_vdieo.png differ diff --git a/app/src/main/res/drawable-hdpi/com_mediatek_filemanager.png b/app/src/main/res/drawable-hdpi/com_mediatek_filemanager.png index 2c5128a..da3b15f 100644 Binary files a/app/src/main/res/drawable-hdpi/com_mediatek_filemanager.png and b/app/src/main/res/drawable-hdpi/com_mediatek_filemanager.png differ diff --git a/app/src/main/res/drawable-hdpi/com_mediatek_fmradio.png b/app/src/main/res/drawable-hdpi/com_mediatek_fmradio.png index f62afdf..2a2cea8 100644 Binary files a/app/src/main/res/drawable-hdpi/com_mediatek_fmradio.png and b/app/src/main/res/drawable-hdpi/com_mediatek_fmradio.png differ diff --git a/app/src/main/res/drawable-hdpi/com_uiui_sn.png b/app/src/main/res/drawable-hdpi/com_uiui_sn.png index d52f4db..2e27daa 100644 Binary files a/app/src/main/res/drawable-hdpi/com_uiui_sn.png and b/app/src/main/res/drawable-hdpi/com_uiui_sn.png differ diff --git a/app/src/main/res/drawable-hdpi/default_head.png b/app/src/main/res/drawable-hdpi/default_head.png index ff991dd..d94aae5 100644 Binary files a/app/src/main/res/drawable-hdpi/default_head.png and b/app/src/main/res/drawable-hdpi/default_head.png differ diff --git a/app/src/main/res/drawable-hdpi/exit_icon.png b/app/src/main/res/drawable-hdpi/exit_icon.png new file mode 100644 index 0000000..5a609fc Binary files /dev/null and b/app/src/main/res/drawable-hdpi/exit_icon.png differ diff --git a/app/src/main/res/drawable-hdpi/home_clinical_face.png b/app/src/main/res/drawable-hdpi/home_clinical_face.png index b11093c..05b2849 100644 Binary files a/app/src/main/res/drawable-hdpi/home_clinical_face.png and b/app/src/main/res/drawable-hdpi/home_clinical_face.png differ diff --git a/app/src/main/res/drawable-hdpi/home_clinical_hand.png b/app/src/main/res/drawable-hdpi/home_clinical_hand.png index 892581b..d21d9c9 100644 Binary files a/app/src/main/res/drawable-hdpi/home_clinical_hand.png and b/app/src/main/res/drawable-hdpi/home_clinical_hand.png differ diff --git a/app/src/main/res/drawable-hdpi/home_clinical_tongue.png b/app/src/main/res/drawable-hdpi/home_clinical_tongue.png index aa0c298..ac00f06 100644 Binary files a/app/src/main/res/drawable-hdpi/home_clinical_tongue.png and b/app/src/main/res/drawable-hdpi/home_clinical_tongue.png differ diff --git a/app/src/main/res/drawable-hdpi/home_quick_app.png b/app/src/main/res/drawable-hdpi/home_quick_app.png index 3a86c82..43122a4 100644 Binary files a/app/src/main/res/drawable-hdpi/home_quick_app.png and b/app/src/main/res/drawable-hdpi/home_quick_app.png differ diff --git a/app/src/main/res/drawable-hdpi/home_sos_icon.png b/app/src/main/res/drawable-hdpi/home_sos_icon.png index 1186ffb..f62e680 100644 Binary files a/app/src/main/res/drawable-hdpi/home_sos_icon.png and b/app/src/main/res/drawable-hdpi/home_sos_icon.png differ diff --git a/app/src/main/res/drawable-hdpi/icon_add.png b/app/src/main/res/drawable-hdpi/icon_add.png index 0ee1422..b00c6c3 100644 Binary files a/app/src/main/res/drawable-hdpi/icon_add.png and b/app/src/main/res/drawable-hdpi/icon_add.png differ diff --git a/app/src/main/res/drawable-hdpi/icon_alarm.png b/app/src/main/res/drawable-hdpi/icon_alarm.png new file mode 100644 index 0000000..11176de Binary files /dev/null and b/app/src/main/res/drawable-hdpi/icon_alarm.png differ diff --git a/app/src/main/res/drawable-hdpi/icon_daily_app.png b/app/src/main/res/drawable-hdpi/icon_daily_app.png index 19013f4..497d4e8 100644 Binary files a/app/src/main/res/drawable-hdpi/icon_daily_app.png and b/app/src/main/res/drawable-hdpi/icon_daily_app.png differ diff --git a/app/src/main/res/drawable-hdpi/icon_family_space.png b/app/src/main/res/drawable-hdpi/icon_family_space.png index 1d475b4..2c4c715 100644 Binary files a/app/src/main/res/drawable-hdpi/icon_family_space.png and b/app/src/main/res/drawable-hdpi/icon_family_space.png differ diff --git a/app/src/main/res/drawable-hdpi/icon_lock.png b/app/src/main/res/drawable-hdpi/icon_lock.png new file mode 100644 index 0000000..72f6fcb Binary files /dev/null and b/app/src/main/res/drawable-hdpi/icon_lock.png differ diff --git a/app/src/main/res/drawable-hdpi/settings1.png b/app/src/main/res/drawable-hdpi/settings1.png index 1e9fdfe..0bc1f34 100644 Binary files a/app/src/main/res/drawable-hdpi/settings1.png and b/app/src/main/res/drawable-hdpi/settings1.png differ diff --git a/app/src/main/res/drawable-hdpi/wifi1.png b/app/src/main/res/drawable-hdpi/wifi1.png index 8fefacb..48755ea 100644 Binary files a/app/src/main/res/drawable-hdpi/wifi1.png and b/app/src/main/res/drawable-hdpi/wifi1.png differ diff --git a/app/src/main/res/drawable/background_weather_rain.xml b/app/src/main/res/drawable/background_weather_rain.xml index e8f3c68..d01bfbd 100644 --- a/app/src/main/res/drawable/background_weather_rain.xml +++ b/app/src/main/res/drawable/background_weather_rain.xml @@ -4,14 +4,20 @@ + android:topLeftRadius="10dp" + android:topRightRadius="10dp" + android:bottomLeftRadius="10dp" + android:bottomRightRadius="10dp" /> + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_weather_sun.xml b/app/src/main/res/drawable/background_weather_sun.xml index e6c1cc4..558a0d9 100644 --- a/app/src/main/res/drawable/background_weather_sun.xml +++ b/app/src/main/res/drawable/background_weather_sun.xml @@ -4,14 +4,20 @@ + android:bottomLeftRadius="10dp" + android:bottomRightRadius="10dp" + android:topLeftRadius="10dp" + android:topRightRadius="10dp" /> + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_weather_sunny.xml b/app/src/main/res/drawable/background_weather_sun_night.xml similarity index 71% rename from app/src/main/res/drawable/background_weather_sunny.xml rename to app/src/main/res/drawable/background_weather_sun_night.xml index 167dd64..c5bb87e 100644 --- a/app/src/main/res/drawable/background_weather_sunny.xml +++ b/app/src/main/res/drawable/background_weather_sun_night.xml @@ -1,7 +1,7 @@ - + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/custom_bg_alarm.xml b/app/src/main/res/drawable/custom_bg_alarm.xml index 8de7d26..fbb4e61 100644 --- a/app/src/main/res/drawable/custom_bg_alarm.xml +++ b/app/src/main/res/drawable/custom_bg_alarm.xml @@ -10,4 +10,10 @@ android:topRightRadius="10dp" android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp" /> + + \ No newline at end of file diff --git a/app/src/main/res/drawable/custom_bg_sos.xml b/app/src/main/res/drawable/custom_bg_sos.xml index d9a8d07..1ace796 100644 --- a/app/src/main/res/drawable/custom_bg_sos.xml +++ b/app/src/main/res/drawable/custom_bg_sos.xml @@ -10,4 +10,10 @@ android:topRightRadius="10dp" android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp" /> + + \ No newline at end of file diff --git a/app/src/main/res/drawable/seekbar_progress_default.xml b/app/src/main/res/drawable/seekbar_progress_default.xml index c98a318..98d4a36 100644 --- a/app/src/main/res/drawable/seekbar_progress_default.xml +++ b/app/src/main/res/drawable/seekbar_progress_default.xml @@ -12,7 +12,7 @@ - + diff --git a/app/src/main/res/drawable/shape_progress_drawable.xml b/app/src/main/res/drawable/shape_progress_drawable.xml index 12f6c7e..d18d6a8 100644 --- a/app/src/main/res/drawable/shape_progress_drawable.xml +++ b/app/src/main/res/drawable/shape_progress_drawable.xml @@ -2,7 +2,7 @@ - + @@ -12,9 +12,9 @@ + android:centerColor="#8cc0f6" + android:endColor="#8cc0f6" + android:startColor="#8cc0f6" /> diff --git a/app/src/main/res/drawable/shape_thumb_icon.xml b/app/src/main/res/drawable/shape_thumb_icon.xml index d54ad8c..83bc602 100644 --- a/app/src/main/res/drawable/shape_thumb_icon.xml +++ b/app/src/main/res/drawable/shape_thumb_icon.xml @@ -7,6 +7,6 @@ android:height="@dimen/dp_14" /> - + android:color="#8cc0f6" /> + \ No newline at end of file diff --git a/app/src/main/res/drawable/tv_bg_alarm.xml b/app/src/main/res/drawable/tv_bg_alarm.xml new file mode 100644 index 0000000..710305b --- /dev/null +++ b/app/src/main/res/drawable/tv_bg_alarm.xml @@ -0,0 +1,18 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-land/activity_control.xml b/app/src/main/res/layout-land/activity_control.xml index 80e4a0d..7d7c001 100644 --- a/app/src/main/res/layout-land/activity_control.xml +++ b/app/src/main/res/layout-land/activity_control.xml @@ -42,12 +42,12 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="控制中心" + android:textColor="@color/white" android:textSize="@dimen/sp_16" - app:layout_constraintTop_toTopOf="parent" - app:layout_constraintStart_toStartOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" - android:textColor="@color/white" /> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.18" /> + + + + + + + app:layout_constraintVertical_bias="0.18" /> + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/iv_bt" /> + + - - - - - - - - + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.18" /> + + + + + + + app:layout_constraintVertical_bias="0.18" /> + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/iv_flashlight" /> + + + android:background="@drawable/background_weather_sun"> - - - - + app:layout_constraintTop_toTopOf="parent" /> - + android:layout_height="0dp" + android:layout_marginStart="@dimen/dp_8" + android:orientation="vertical" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + + + + + + + + + + + - @@ -336,7 +350,7 @@ android:layout_marginStart="@dimen/dp_4" android:layout_marginTop="@dimen/dp_4" android:text="紧急呼叫" - android:textColor="@color/default_text_color" + android:textColor="@color/white" android:textSize="@dimen/sp_13" android:textStyle="bold" app:layout_constraintStart_toStartOf="parent" diff --git a/app/src/main/res/layout-land/item_notification.xml b/app/src/main/res/layout-land/item_notification.xml deleted file mode 100644 index 786aee1..0000000 --- a/app/src/main/res/layout-land/item_notification.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout-port/activity_control.xml b/app/src/main/res/layout-port/activity_control.xml index dbf13cb..8843671 100644 --- a/app/src/main/res/layout-port/activity_control.xml +++ b/app/src/main/res/layout-port/activity_control.xml @@ -42,12 +42,12 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="控制中心" + android:textColor="@color/white" android:textSize="@dimen/sp_16" - app:layout_constraintTop_toTopOf="parent" - app:layout_constraintStart_toStartOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" - android:textColor="@color/white" /> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.18" /> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/iv_wifi" /> - - - - + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.18" /> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/iv_bt" /> - + + + + + + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.18" /> + + + + + + app:layout_constraintVertical_bias="0.18" /> + android:textSize="@dimen/sp_13" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/iv_flashlight" /> + diff --git a/app/src/main/res/layout-port/fragment_custom.xml b/app/src/main/res/layout-port/fragment_custom.xml index 4e4d98b..b4ea60d 100644 --- a/app/src/main/res/layout-port/fragment_custom.xml +++ b/app/src/main/res/layout-port/fragment_custom.xml @@ -3,12 +3,12 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_margin="@dimen/sp_16"> + android:layout_height="match_parent"> + android:layout_height="match_parent" + android:layout_margin="@dimen/dp_16"> @@ -196,74 +193,83 @@ android:layout_marginEnd="@dimen/dp_4" android:layout_marginBottom="@dimen/dp_2" android:layout_weight="3" - android:background="@drawable/custom_bg_weather"> + android:background="@drawable/background_weather_sun"> - - - + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> - + - + + + + + + + + + @@ -289,10 +295,10 @@ android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="@dimen/dp_16" - android:layout_marginTop="@dimen/dp_16" + android:layout_marginStart="@dimen/dp_4" + android:layout_marginTop="@dimen/dp_4" android:text="爱心闹钟" - android:textColor="@color/title_gray" + android:textColor="@color/white" android:textSize="@dimen/sp_14" android:textStyle="bold" app:layout_constraintStart_toStartOf="parent" @@ -317,7 +323,7 @@ android:adjustViewBounds="true" android:scaleType="centerInside" android:src="@drawable/home_reminder_icon" - android:visibility="visible" + android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -326,12 +332,13 @@ - + app:layout_constraintVertical_bias="0.12" /> + app:layout_constraintVertical_bias="0.12" /> - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_screen_lock.xml b/app/src/main/res/layout/activity_screen_lock.xml new file mode 100644 index 0000000..f0a0220 --- /dev/null +++ b/app/src/main/res/layout/activity_screen_lock.xml @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/item_notification.xml b/app/src/main/res/layout/item_notification.xml new file mode 100644 index 0000000..09d8950 --- /dev/null +++ b/app/src/main/res/layout/item_notification.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png index 7d51e2a..752f189 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png index 7d51e2a..752f189 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png index 7d51e2a..752f189 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index 7d51e2a..752f189 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 7d51e2a..752f189 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/raw/click.mp3 b/app/src/main/res/raw/click.mp3 new file mode 100644 index 0000000..97e0a1c Binary files /dev/null and b/app/src/main/res/raw/click.mp3 differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 2966fbd..62f9686 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -26,11 +26,11 @@ #ecfafd #ffeeee #e1e1ff - #d8fdfd + #ffffff #e08c61 - #47e08e - #fcf3e7 - #fdf6dc + #47E08E + #E3E8FE + #FDF6DC #eae8e8 #bbbaba diff --git a/app/tpns-configs.json b/app/tpns-configs.json deleted file mode 100644 index a5c3e9c..0000000 --- a/app/tpns-configs.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "tpns": { - "access_id": "1500033697", - "access_key": "A0PFUHEPEKKM" - }, - "com.uiuios.aios": { - "channel": { - "enable": true - } - }, - "debug": false, - "version": "1.3.3.3-release", - "upgrade": true -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 8ac000d..51a8371 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,6 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:3.6.4' - classpath "com.tencent.android.tpns:tpnsplugin:1.8.0" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/settings.gradle b/settings.gradle index 70b7022..6979b42 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ -include ':app', ':niceimageview' +include ':app', ':niceimageview', ':verification-view' rootProject.name='AIOS系统' \ No newline at end of file diff --git a/verification-view/.gitignore b/verification-view/.gitignore new file mode 100644 index 0000000..9e20f6c --- /dev/null +++ b/verification-view/.gitignore @@ -0,0 +1,2 @@ +/build +.iml diff --git a/verification-view/build.gradle b/verification-view/build.gradle new file mode 100644 index 0000000..6e2dcf0 --- /dev/null +++ b/verification-view/build.gradle @@ -0,0 +1,72 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 25 + buildToolsVersion '25.0.2' + + + defaultConfig { + minSdkVersion 15 + targetSdkVersion 25 + versionCode 1 + versionName "1.0" + } + + buildTypes { + iPlay50Debug{} + iPlay50Release{} + zhanRuiUserdebug{} + iPlay50SEDebug{} + iPlay50SERelease{} + iPlay50ProDebug{} + iPlay50ProRelease{} + iPlay50miniDebug{} + iPlay50miniRelease{} + iPlay5013Debug{} + iPlay5013Release{} + iPlay50miniProDebug{} + iPlay50miniProRelease{} + MTKAndroid12Debug {} + MTKAndroid12Release {} + teclast8183Debug {} + teclast8183Release {} + XPadDebug{} + XPadRelease{} + debug {} + release {} + } + + + lintOptions { + abortOnError false + } + +} + + + + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation 'androidx.appcompat:appcompat:1.3.1' +} + +//// 上传 jcenter 的配置 +//apply plugin: 'com.novoda.bintray-release'//添加 +// +////添加 +//publish { +// userOrg = 'jacktuotuo'//用户名 +// repoName = 'maven' //仓库的名字 +// groupId = 'com.jacktuotuo.customview'//jcenter上的路径 +// artifactId = 'verificationcodeview'//项目名称 +// publishVersion = '1.0.5'//版本号 +// desc = 'a custom View of the square verification code input box'//描述 +// website = 'http://blog.csdn.net/qq_33553515'//个人网站 +//} + + +// gradle clean build bintrayUpload -PbintrayUser=jacktuotuo -PbintrayKey=key -PdryRun=false +// 最终引用路径 compile 'com.jacktuotuo.customview:verificationcodeview:1.0.0 + + diff --git a/verification-view/proguard-rules.pro b/verification-view/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/verification-view/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/verification-view/src/main/AndroidManifest.xml b/verification-view/src/main/AndroidManifest.xml new file mode 100644 index 0000000..9a187a7 --- /dev/null +++ b/verification-view/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + diff --git a/verification-view/src/main/java/com/tuo/customview/PwdEditText.java b/verification-view/src/main/java/com/tuo/customview/PwdEditText.java new file mode 100644 index 0000000..7e217d9 --- /dev/null +++ b/verification-view/src/main/java/com/tuo/customview/PwdEditText.java @@ -0,0 +1,52 @@ +package com.tuo.customview; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputConnection; + +import androidx.appcompat.widget.AppCompatEditText; + +/** + * author slimvan + * email: slimvan@163.com + * date 2018/7/24. + * desc: 重写InputConnection 监听返回键 + */ + +public class PwdEditText extends AppCompatEditText { + private TInputConnection inputConnection; + + public PwdEditText(Context context) { + super(context); + init(); + } + + public PwdEditText(Context context, AttributeSet attrs) { + super(context, attrs); + init(); + } + + public PwdEditText(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(); + } + + private void init(){ + inputConnection = new TInputConnection(null,true); + } + + /** + * 当输入法和EditText建立连接的时候会通过这个方法返回一个InputConnection。 + * 我们需要代理这个方法的父类方法生成的InputConnection并返回我们自己的代理类。 + * */ + @Override + public InputConnection onCreateInputConnection(EditorInfo outAttrs) { + inputConnection.setTarget(super.onCreateInputConnection(outAttrs)); + return inputConnection; + } + + public void setBackSpaceListener(TInputConnection.BackspaceListener backSpaceLisetener){ + inputConnection.setBackspaceListener(backSpaceLisetener); + } +} diff --git a/verification-view/src/main/java/com/tuo/customview/PwdTextView.java b/verification-view/src/main/java/com/tuo/customview/PwdTextView.java new file mode 100644 index 0000000..c364b8e --- /dev/null +++ b/verification-view/src/main/java/com/tuo/customview/PwdTextView.java @@ -0,0 +1,81 @@ +package com.tuo.customview; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.util.AttributeSet; + +import androidx.appcompat.widget.AppCompatTextView; + +/** + * + * 作者:Tuo on 2018/4/13 16:35 + * 邮箱:839539179@qq.com + */ + +public class PwdTextView extends AppCompatTextView { + + + private float radius; + + private boolean hasPwd; + + public PwdTextView(Context context) { + this(context, null); + } + + public PwdTextView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public PwdTextView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + + if (hasPwd) { + // 画一个黑色的圆 + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); + paint.setColor(Color.WHITE); + paint.setStyle(Paint.Style.FILL); + canvas.drawCircle(getWidth() / 2, getHeight() / 2, radius, paint); + }else { + // 占位白色的圆 + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); + paint.setColor(getResources().getColor(R.color.circle_bg)); + paint.setStyle(Paint.Style.FILL); + canvas.drawCircle(getWidth() / 2, getHeight() / 2, radius, paint); + } + } + + + public void clearPwd() { + this.hasPwd = false; + invalidate(); + } + + + public void drawPwd(float radius) { + this.hasPwd = true; + if (radius == 0) { + this.radius = getWidth() / 4; + } else { + this.radius = radius; + } + invalidate(); + } + + public void drawPwdBg(float radius) { + if (radius == 0) { + this.radius = getWidth() / 4; + } else { + this.radius = radius; + } + invalidate(); + } +} diff --git a/verification-view/src/main/java/com/tuo/customview/TInputConnection.java b/verification-view/src/main/java/com/tuo/customview/TInputConnection.java new file mode 100644 index 0000000..171bc18 --- /dev/null +++ b/verification-view/src/main/java/com/tuo/customview/TInputConnection.java @@ -0,0 +1,74 @@ +package com.tuo.customview; + +import android.view.KeyEvent; +import android.view.inputmethod.InputConnection; +import android.view.inputmethod.InputConnectionWrapper; + +/** + * author slimvan + * email: slimvan@163.com + * date 2018/7/24. + * desc: 参考https://blog.csdn.net/frained/article/details/78880579 + */ + +public class TInputConnection extends InputConnectionWrapper { + + private BackspaceListener mBackspaceListener; + + /** + * Initializes a wrapper. + *

+ *

Caveat: Although the system can accept {@code (InputConnection) null} in some + * places, you cannot emulate such a behavior by non-null {@link InputConnectionWrapper} that + * has {@code null} in {@code target}.

+ * + * @param target the {@link InputConnection} to be proxied. + * @param mutable set {@code true} to protect this object from being reconfigured to target + * another {@link InputConnection}. Note that this is ignored while the target is {@code null}. + */ + public TInputConnection(InputConnection target, boolean mutable) { + super(target, mutable); + } + + public interface BackspaceListener { + /** + * @return true 代表消费了这个事件 + * */ + boolean onBackspace(); + } + + /** + * 当软键盘删除文本之前,会调用这个方法通知输入框,我们可以重写这个方法并判断是否要拦截这个删除事件。 + * 在谷歌输入法上,点击退格键的时候不会调用{@link #sendKeyEvent(KeyEvent event)}, + * 而是直接回调这个方法,所以也要在这个方法上做拦截; + * */ + @Override + public boolean deleteSurroundingText(int beforeLength, int afterLength) { + if(mBackspaceListener != null){ + if(mBackspaceListener.onBackspace()){ + return true; + } + } + + return super.deleteSurroundingText(beforeLength, afterLength); + } + + public void setBackspaceListener(BackspaceListener backspaceListener) { + this.mBackspaceListener = backspaceListener; + } + + /** + * 当在软件盘上点击某些按钮(比如退格键,数字键,回车键等),该方法可能会被触发(取决于输入法的开发者), + * 所以也可以重写该方法并拦截这些事件,这些事件就不会被分发到输入框了 + * */ + @Override + public boolean sendKeyEvent(KeyEvent event) { + if( event.getKeyCode() == KeyEvent.KEYCODE_DEL && event.getAction() == KeyEvent.ACTION_DOWN){ + if(mBackspaceListener != null && mBackspaceListener.onBackspace()){ + return true; + } + } + return super.sendKeyEvent(event); + } + +} \ No newline at end of file diff --git a/verification-view/src/main/java/com/tuo/customview/VerificationCodeView.java b/verification-view/src/main/java/com/tuo/customview/VerificationCodeView.java new file mode 100644 index 0000000..fe49318 --- /dev/null +++ b/verification-view/src/main/java/com/tuo/customview/VerificationCodeView.java @@ -0,0 +1,368 @@ +package com.tuo.customview; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.text.Editable; +import android.text.InputFilter; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.util.AttributeSet; +import android.util.TypedValue; +import android.view.Gravity; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; + + +/** + * description: 自定义view 验证码 输入框 + * Created by Jack on 2017/6/2. + * 邮箱:839539179@qq.com + */ + +public class VerificationCodeView extends RelativeLayout { + + private LinearLayout containerEt; + + private PwdEditText et; + // 输入框数量 + private int mEtNumber; + // 输入框的宽度 + private int mEtWidth; + //输入框分割线 + private Drawable mEtDividerDrawable; + //输入框文字颜色 + private int mEtTextColor; + //输入框文字大小 + private float mEtTextSize; + //输入框获取焦点时背景 + private Drawable mEtBackgroundDrawableFocus; + //输入框没有焦点时背景 + private Drawable mEtBackgroundDrawableNormal; + //是否是密码模式 + private boolean mEtPwd; + //密码模式时圆的半径 + private float mEtPwdRadius; + + //存储TextView的数据 数量由自定义控件的属性传入 + private PwdTextView[] mPwdTextViews; + + private MyTextWatcher myTextWatcher = new MyTextWatcher(); + + + public VerificationCodeView(Context context) { + this(context, null); + } + + public VerificationCodeView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public VerificationCodeView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(context, attrs, defStyleAttr); + } + + //初始化 布局和属性 + private void init(Context context, AttributeSet attrs, int defStyleAttr) { + LayoutInflater.from(context).inflate(R.layout.layout_identifying_code, this); + containerEt = (LinearLayout) this.findViewById(R.id.container_et); + et = (PwdEditText) this.findViewById(R.id.et); + + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.VerificationCodeView, defStyleAttr, 0); + mEtNumber = typedArray.getInteger(R.styleable.VerificationCodeView_icv_et_number, 1); + mEtWidth = typedArray.getDimensionPixelSize(R.styleable.VerificationCodeView_icv_et_width, 42); + mEtDividerDrawable = typedArray.getDrawable(R.styleable.VerificationCodeView_icv_et_divider_drawable); + mEtTextSize = typedArray.getDimensionPixelSize(R.styleable.VerificationCodeView_icv_et_text_size, (int) sp2px(16, context)); + mEtTextColor = typedArray.getColor(R.styleable.VerificationCodeView_icv_et_text_color, Color.BLACK); + mEtBackgroundDrawableFocus = typedArray.getDrawable(R.styleable.VerificationCodeView_icv_et_bg_focus); + mEtBackgroundDrawableNormal = typedArray.getDrawable(R.styleable.VerificationCodeView_icv_et_bg_normal); + mEtPwd = typedArray.getBoolean(R.styleable.VerificationCodeView_icv_et_pwd, false); + mEtPwdRadius = typedArray.getDimensionPixelSize(R.styleable.VerificationCodeView_icv_et_pwd_radius, 0); + //释放资源 + typedArray.recycle(); + + + // 当xml中未配置时 这里进行初始配置默认图片 + if (mEtDividerDrawable == null) { + mEtDividerDrawable = context.getResources().getDrawable(R.drawable.shape_divider_identifying); + } + + if (mEtBackgroundDrawableFocus == null) { + mEtBackgroundDrawableFocus = context.getResources().getDrawable(R.drawable.shape_icv_et_bg_focus); + } + + if (mEtBackgroundDrawableNormal == null) { + mEtBackgroundDrawableNormal = context.getResources().getDrawable(R.drawable.shape_icv_et_bg_normal); + } + + initUI(); + } + + // 初始UI + private void initUI() { + initTextViews(getContext(), mEtNumber, mEtWidth, mEtDividerDrawable, mEtTextSize, mEtTextColor); + initEtContainer(mPwdTextViews); + setListener(); + } + + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + // 设置当 高为 warpContent 模式时的默认值 为 50dp + int mHeightMeasureSpec = heightMeasureSpec; + + int heightMode = MeasureSpec.getMode(mHeightMeasureSpec); + if (heightMode == MeasureSpec.AT_MOST) { + mHeightMeasureSpec = MeasureSpec.makeMeasureSpec((int) dp2px(50, getContext()), MeasureSpec.EXACTLY); + } + + super.onMeasure(widthMeasureSpec, mHeightMeasureSpec); + } + + + //初始化TextView + private void initTextViews(Context context, int etNumber, int etWidth, Drawable etDividerDrawable, float etTextSize, int etTextColor) { + // 设置 editText 的输入长度 + et.setCursorVisible(false);//将光标隐藏 + et.setFilters(new InputFilter[]{new InputFilter.LengthFilter(etNumber)}); //最大输入长度 + // 设置分割线的宽度 + if (etDividerDrawable != null) { + etDividerDrawable.setBounds(0, 0, etDividerDrawable.getMinimumWidth(), etDividerDrawable.getMinimumHeight()); + containerEt.setDividerDrawable(etDividerDrawable); + } + mPwdTextViews = new PwdTextView[etNumber]; + + for (int i = 0; i < mPwdTextViews.length; i++) { + PwdTextView textView = new PwdTextView(context); + textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, etTextSize); + textView.setTextColor(etTextColor); + textView.setWidth(etWidth); + textView.setHeight(etWidth); + if (mEtPwd) { + textView.drawPwdBg(mEtPwdRadius); + } + if (i == 0) { + textView.setBackgroundDrawable(mEtBackgroundDrawableFocus); + } else { + textView.setBackgroundDrawable(mEtBackgroundDrawableNormal); + } + textView.setGravity(Gravity.CENTER); + + textView.setFocusable(false); + + mPwdTextViews[i] = textView; + } + } + + //初始化存储TextView 的容器 + private void initEtContainer(TextView[] mTextViews) { + for (TextView mTextView : mTextViews) { + containerEt.addView(mTextView); + } + } + + + private void setListener() { + // 监听输入内容 + et.addTextChangedListener(myTextWatcher); + + // 监听删除按键 + et.setOnKeyListener(new OnKeyListener() { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_DEL && event.getAction() == KeyEvent.ACTION_DOWN) { + onKeyDelete(); + return true; + } + return false; + } + }); + } + + + // 给TextView 设置文字 + private void setText(String inputContent) { + + for (int i = 0; i < mPwdTextViews.length; i++) { + PwdTextView tv = mPwdTextViews[i]; + if (tv.getText().toString().trim().equals("")) { + if (mEtPwd) { + tv.drawPwd(mEtPwdRadius); + } + tv.setText(inputContent); + // 添加输入完成的监听 + if (inputCompleteListener != null) { + inputCompleteListener.inputComplete(); + } + tv.setBackgroundDrawable(mEtBackgroundDrawableNormal); + if (i < mEtNumber - 1) { + mPwdTextViews[i + 1].setBackgroundDrawable(mEtBackgroundDrawableFocus); + } + break; + } + } + } + + // 监听删除 + private void onKeyDelete() { + for (int i = mPwdTextViews.length - 1; i >= 0; i--) { + PwdTextView tv = mPwdTextViews[i]; + if (!tv.getText().toString().trim().equals("")) { + if (mEtPwd) { + tv.clearPwd(); + } + tv.setText(""); + // 添加删除完成监听 + tv.setBackgroundDrawable(mEtBackgroundDrawableNormal); + if (i < mEtNumber - 1) { + mPwdTextViews[i + 1].setBackgroundDrawable(mEtBackgroundDrawableFocus); + } + // 添加输入完成的监听 + if (inputCompleteListener != null) { + inputCompleteListener.inputComplete(); + } + break; + } + } + } + + + /** + * 获取输入文本 + * + * @return string + */ + public String getInputContent() { + StringBuffer buffer = new StringBuffer(); + for (TextView tv : mPwdTextViews) { + buffer.append(tv.getText().toString().trim()); + } + return buffer.toString(); + } + + /** + * 删除输入内容 + */ + public void clearInputContent() { + for (int i = 0; i < mPwdTextViews.length; i++) { + if (i == 0) { + mPwdTextViews[i].setBackgroundDrawable(mEtBackgroundDrawableFocus); + } else { + mPwdTextViews[i].setBackgroundDrawable(mEtBackgroundDrawableNormal); + } + if (mEtPwd) { + mPwdTextViews[i].clearPwd(); + } + mPwdTextViews[i].setText(""); + } + } + + /** + * 设置输入框个数 + * + * @param etNumber + */ + public void setEtNumber(int etNumber) { + this.mEtNumber = etNumber; + et.removeTextChangedListener(myTextWatcher); + containerEt.removeAllViews(); + initUI(); + } + + + /** + * 获取输入的位数 + * + * @return int + */ + public int getEtNumber() { + return mEtNumber; + } + + + /** + * 设置是否是密码模式 默认不是 + * + * @param isPwdMode + */ + public void setPwdMode(boolean isPwdMode) { + this.mEtPwd = isPwdMode; + } + + + /** + * 获取输入的EditText 用于外界设置键盘弹出 + * + * @return EditText + */ + public EditText getEditText() { + return et; + } + + // 输入完成 和 删除成功 的监听 + private InputCompleteListener inputCompleteListener; + + public void setInputCompleteListener(InputCompleteListener inputCompleteListener) { + this.inputCompleteListener = inputCompleteListener; + } + + + public interface InputCompleteListener { + void inputComplete(); + + void deleteContent(); + } + + + public float dp2px(float dpValue, Context context) { + return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, + dpValue, context.getResources().getDisplayMetrics()); + } + + public float sp2px(float spValue, Context context) { + return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, + spValue, context.getResources().getDisplayMetrics()); + } + + + private class MyTextWatcher implements TextWatcher { + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + + } + + @Override + public void afterTextChanged(Editable editable) { + String inputStr = editable.toString(); + if (!TextUtils.isEmpty(inputStr)) { + + String[] strArray = inputStr.split(""); + + for (int i = 0; i < strArray.length; i++) { + + // 不能大于输入框个数 + if (i > mEtNumber) { + break; + } + setText(strArray[i]); + et.setText(""); + } + } + } + } + + +} diff --git a/verification-view/src/main/res/drawable/shape_divider_identifying.xml b/verification-view/src/main/res/drawable/shape_divider_identifying.xml new file mode 100644 index 0000000..16bd805 --- /dev/null +++ b/verification-view/src/main/res/drawable/shape_divider_identifying.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/verification-view/src/main/res/drawable/shape_icv_et_bg_focus.xml b/verification-view/src/main/res/drawable/shape_icv_et_bg_focus.xml new file mode 100644 index 0000000..9f3bb2b --- /dev/null +++ b/verification-view/src/main/res/drawable/shape_icv_et_bg_focus.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/verification-view/src/main/res/drawable/shape_icv_et_bg_normal.xml b/verification-view/src/main/res/drawable/shape_icv_et_bg_normal.xml new file mode 100644 index 0000000..ab645cb --- /dev/null +++ b/verification-view/src/main/res/drawable/shape_icv_et_bg_normal.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/verification-view/src/main/res/layout/layout_identifying_code.xml b/verification-view/src/main/res/layout/layout_identifying_code.xml new file mode 100644 index 0000000..5176518 --- /dev/null +++ b/verification-view/src/main/res/layout/layout_identifying_code.xml @@ -0,0 +1,24 @@ + + + + + + + + + + \ No newline at end of file diff --git a/verification-view/src/main/res/values/attrs.xml b/verification-view/src/main/res/values/attrs.xml new file mode 100644 index 0000000..fc05788 --- /dev/null +++ b/verification-view/src/main/res/values/attrs.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/verification-view/src/main/res/values/colors.xml b/verification-view/src/main/res/values/colors.xml new file mode 100644 index 0000000..13365a7 --- /dev/null +++ b/verification-view/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + + #2a2c36 + + \ No newline at end of file diff --git a/verification-view/src/main/res/values/strings.xml b/verification-view/src/main/res/values/strings.xml new file mode 100644 index 0000000..5501c05 --- /dev/null +++ b/verification-view/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + VerificationView +