"filters": [],
"versionCode": 1,
"versionName": "1.0",
- "outputFile": "ICLoopPageLauncher_V29_202108031427_release.apk"
+ "outputFile": "ICLoopPageLauncher_V31_202108091801_release.apk"
}
]
}
\ No newline at end of file
package com.ic.launcher.presenter;
+import android.content.ContentResolver;
+import android.content.ContentValues;
import android.content.Context;
+import android.net.Uri;
import androidx.lifecycle.MutableLiveData;
+import com.ic.iclooger.ICLogger;
import com.ic.launcher.data.AppItem;
import com.ic.launcher.data.HardCodeAppListRepository;
import com.ic.launcher.data.IAppListRepository;
+import com.ic.launcher.utils.SystemUtils;
import java.util.List;
import java.util.concurrent.ExecutorService;
*/
public class LauncherPresenter extends BasePresenter {
+ private final Context mContext;
//关心的数据:
//应用列表
public MutableLiveData<List<AppItem>> appListValues = new MutableLiveData<>();
private final IAppListRepository appListRepository;
private LauncherPresenter(Context context) {
+ this.mContext = context;
executorService = Executors.newSingleThreadExecutor();
appListRepository = HardCodeAppListRepository.getInstance(context);
//去获取应用列表内容
executorService.execute(() -> {
//获取应用列表
List<AppItem> appList = appListRepository.getAppList();
+ updateDbForAi(appList);
appListValues.postValue(appList);
});
}
+
+ //添加规则
+ public static final String AUTHORITY = "com.ic.ai.info";
+ public static final String PATH = "apps";
+ public static final String APPS = "content://" + AUTHORITY + "/" + PATH;
+
+
+ private void updateDbForAi(List<AppItem> appList) {
+ ICLogger.d("updateLanguageSystemApp...");
+ Executors.newSingleThreadExecutor().submit(() -> {
+ ContentResolver contentResolver = mContext.getContentResolver();
+ //干掉全部内容
+ ICLogger.d("app info.. save into db");
+ contentResolver.delete(Uri.parse(APPS), null, null);
+ //清空数据库
+ for (AppItem appInfoEntity : appList) {
+ //添加内容进去
+ ContentValues contentValues = new ContentValues();
+ contentValues.put("package_name", mContext.getString(appInfoEntity.getPackageNameResId()));
+ contentValues.put("app_name", mContext.getString(appInfoEntity.getTitleResId()));
+ contentValues.put("brand_name", SystemUtils.getLauncherName());
+ contentValues.put("create_time", System.currentTimeMillis());
+ contentValues.put("update_time", System.currentTimeMillis());
+ //保存一份到数据库中
+ contentResolver.insert(Uri.parse(APPS), contentValues);
+ }
+ });
+ }
+
private static LauncherPresenter sInstance = null;
public static LauncherPresenter getInstance(Context context) {
import androidx.lifecycle.MutableLiveData;
import com.ic.iclooger.ICLogger;
+import com.ic.launcher.utils.SoundPlayUtils;
import com.ic.launcher.utils.SystemUtils;
+import com.ic.launcher.utils.VibrateUtil;
import java.util.List;
public class StatusBarBasePresenter extends BasePresenter {
protected final Context mContext;
+ private final SoundPlayUtils playUtils;
//电量状态
public MutableLiveData<Boolean> isChargingValue = new MutableLiveData<>();
//电量
public StatusBarBasePresenter(Context context) {
this.mContext = context;
+ playUtils = new SoundPlayUtils();
+ playUtils.init();
//获取电量和充电状态
getBatteryLevAndChargeState();
getSignalLev();
private void getBatteryLevAndChargeState() {
//充电状态
IntentFilter batteryFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
+ batteryFilter.addAction(Intent.ACTION_POWER_CONNECTED);
+ batteryFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);
mContext.registerReceiver(batteryLevReceiver, batteryFilter);
}
private final BroadcastReceiver batteryLevReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent batteryStatus) {
- int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
- int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
- float batteryPct = level * 100 / (float) scale;
- //ICLogger.d("batteryPct == > " + batteryPct);
- batteryLev.postValue((int) batteryPct);
- // Are we charging / charged?
- int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
- boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
- status == BatteryManager.BATTERY_STATUS_FULL;
- // ICLogger.d("isCharging == > " + isCharging);
- isChargingValue.postValue(isCharging);
+ String action = batteryStatus.getAction();
+ if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
+
+ int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
+ int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
+ float batteryPct = level * 100 / (float) scale;
+ //ICLogger.d("batteryPct == > " + batteryPct);
+ batteryLev.postValue((int) batteryPct);
+ // Are we charging / charged?
+ int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
+ boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
+ status == BatteryManager.BATTERY_STATUS_FULL;
+ // ICLogger.d("isCharging == > " + isCharging);
+ isChargingValue.postValue(isCharging);
+ } else if (Intent.ACTION_POWER_CONNECTED.equals(action)) {
+ showShockAndAudio(0);
+ } else if (Intent.ACTION_POWER_DISCONNECTED.equals(action)) {
+ showShockAndAudio(1);
+ }
}
};
+ private void showShockAndAudio(int index) {
+ VibrateUtil.getInstance(mContext).vibrateOn(true);
+ playUtils.playKeyboardSound(mContext, index);
+ }
+
private void queryPhoneNetworkTypeResId(TelephonyManager tm) {
int networkType = tm.getNetworkType();
--- /dev/null
+package com.ic.launcher.utils;
+
+import android.content.Context;
+import android.media.AudioManager;
+import android.media.SoundPool;
+import android.util.SparseArray;
+
+import com.ic.iclooger.ICLogger;
+import com.ic.launcher.R;
+
+
+public class SoundPlayUtils {
+
+ private int nowSoundNum;
+ private SoundPool mSoundPlayer;
+ private SoundPool.OnLoadCompleteListener SoundLoadListener;
+ private SparseArray soundID;
+
+ private static final int[] NUM_RAW = new int[]{
+ R.raw.chrg_connect,
+ R.raw.chrg_remove,
+ R.raw.chrg_complete,
+ R.raw.do_not_enter,
+ R.raw.goto_see_doctor,
+ R.raw.please_go_back_home};
+
+
+ public void init() {
+ if (mSoundPlayer == null) {
+ mSoundPlayer = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0);
+ }
+ soundID = new SparseArray();
+ }
+
+ public void releaseSoundPlayer() {
+ if (mSoundPlayer != null) {
+ mSoundPlayer.release();
+ }
+ mSoundPlayer = null;
+ }
+
+ public void playKeyboardSound(Context context, int key) {
+ nowSoundNum = key;
+ if (soundID.get(key) == null) {
+ if (SoundLoadListener == null) {
+ SoundLoadListener = (soundPool, sampleId, status) -> SaveSoundIDandPlay(sampleId);
+ mSoundPlayer.setOnLoadCompleteListener(SoundLoadListener);
+ }
+ mSoundPlayer.load(context, NUM_RAW[key], 1);
+ } else {
+ ICLogger.d("play..." + key);
+ mSoundPlayer.play((Integer) soundID.get(key), 1, 1, 0, 0, 1);
+ }
+ }
+
+ private synchronized void SaveSoundIDandPlay(int sampleId) {
+ mSoundPlayer.play(sampleId, 1, 1, 1, 0, 1);
+ ICLogger.d("play--->" + sampleId);
+ soundID.put(nowSoundNum, sampleId);
+ }
+}
--- /dev/null
+package com.ic.launcher.utils;
+
+import android.content.Context;
+import android.os.Vibrator;
+
+import static android.content.Context.VIBRATOR_SERVICE;
+
+public class VibrateUtil {
+
+ private static Context mContext=null;
+ public static VibrateUtil getInstance(Context context){
+ if (mContext==null)
+ mContext=context;
+ if (vibrator==null)
+ vibrator=(Vibrator)mContext.getSystemService(VIBRATOR_SERVICE);
+ vibrateUtil=new VibrateUtil();
+ return vibrateUtil;
+ }
+ private static Vibrator vibrator = null;
+ private static VibrateUtil vibrateUtil=null;
+
+ private final long[] patter = {1000, 1000, 1000, 1000}; //1秒开,1秒关,2秒开,50ms关
+
+ public void vibrateOn(boolean on){
+ if(vibrator!=null) {
+ if (on)
+ vibrator.vibrate(100);//不循环
+ else
+ vibrator.cancel();
+ }
+ }
+
+}
<string name="no_sim_service">no service</string>
<string name="no_application_tips_text">no such app</string>
<string name="checking_sim_text_tips">检测sim卡</string>
+ <string name="ai_voice_text">AI语助</string>
</resources>
\ No newline at end of file
<string name="no_sim_service">サービスなし</string>
<string name="no_application_tips_text">应用未装着</string>
<string name="checking_sim_text_tips">检测sim卡</string>
+ <string name="ai_voice_text">AI语助</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="checking_sim_text_tips">检测sim卡</string>
+ <string name="ai_voice_text">AI语助</string>
</resources>
\ No newline at end of file
<string name="no_sim_car">没有sim卡</string>
<string name="no_sim_service">没有服务</string>
<string name="checking_sim_text_tips">检测sim卡</string>
+ <string name="ai_voice_text">AI语助</string>
</resources>
\ No newline at end of file
<string name="app_title_settings">设置</string>
<!--Package name-->
<string name="app_package_name_temperature" translatable="false">com.ic.temperature</string>
+ <string name="app_package_name_ai" translatable="false">com.ic.ai</string>
<string name="app_package_name_health" translatable="false">com.ic.blood</string>
<string name="app_package_name_sport" translatable="false">com.ic.sport</string>
<string name="app_package_name_weather" translatable="false">com.ic.weather</string>
<string name="no_sim_car">没有sim卡</string>
<string name="no_sim_service">没有服务</string>
<string name="checking_sim_text_tips">检测sim卡</string>
+ <string name="ai_voice_text">AI语助</string>
</resources>
\ No newline at end of file
-#Tue Aug 03 14:27:38 CST 2021
-VERSION_CODE=29
+#Mon Aug 09 18:01:37 CST 2021
+VERSION_CODE=31