From 4bfcdcef2a93352a18b6465df1ab759af9e8bb29 Mon Sep 17 00:00:00 2001 From: SnickerSun Date: Mon, 16 Aug 2021 10:59:09 +0800 Subject: [PATCH] =?utf8?q?=E6=9B=B4=E6=96=B0=20library=20=E6=94=B9?= =?utf8?q?=E4=B8=BA=20com.ic.xxx=20[=E8=99=BD=E7=84=B6=E6=9A=82=E6=97=B6?= =?utf8?q?=E5=B9=B6=E4=B8=8D=E7=94=A8]?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- library/src/main/AndroidManifest.xml | 2 +- .../{eiot => ic}/watch_lib/LauncherCtrl.java | 252 +++++++++--------- 2 files changed, 127 insertions(+), 127 deletions(-) rename library/src/main/java/com/{eiot => ic}/watch_lib/LauncherCtrl.java (96%) diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml index 85a5bf87..71e78e4c 100644 --- a/library/src/main/AndroidManifest.xml +++ b/library/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ diff --git a/library/src/main/java/com/eiot/watch_lib/LauncherCtrl.java b/library/src/main/java/com/ic/watch_lib/LauncherCtrl.java similarity index 96% rename from library/src/main/java/com/eiot/watch_lib/LauncherCtrl.java rename to library/src/main/java/com/ic/watch_lib/LauncherCtrl.java index 19c69185..b9cf4198 100644 --- a/library/src/main/java/com/eiot/watch_lib/LauncherCtrl.java +++ b/library/src/main/java/com/ic/watch_lib/LauncherCtrl.java @@ -1,126 +1,126 @@ -package com.eiot.watch_lib; - -import android.content.ContentResolver; -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.net.Uri; -import android.text.TextUtils; -import android.util.Log; - -public class LauncherCtrl { - private static final String TAG = "LauncherCtrl"; - private static final boolean DEBUG = false;//BuildConfig.DEBUG; - - private static final String AUTHORITY = "com.ic.db.watchProvider"; - private static final String STATUS_BAR_TABLE = "status_bar"; - public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); - public static final Uri STATUS_BAR_URI = Uri.withAppendedPath(AUTHORITY_URI, STATUS_BAR_TABLE); - - /// 来自 FragmentQuickSettings @{ - // 状态栏图标名称, 根据此名称控制状态栏图标是否显示 -// public static final String STATUS_BAR_SIGNAL = "signal"; -// public static final String STATUS_BAR_BATTERY = "battery"; -// public static final String STATUS_BAR_SIM_OPERATOR_NAME = "sim_operator_name"; - public static final String STATUS_BAR_LOCATE_TYPE = "locate_type"; - // public static final String STATUS_BAR_SMS = "sms"; - public static final String STATUS_BAR_SERVER_CONNECTED = "server_connected"; - // public static final String STATUS_BAR_SOUND_MODE = "sound_mode"; -// public static final String STATUS_BAR_LOCKER = "locker"; -// public static final String STATUS_BAR_ALARM_CLOCK = "alarm_clock"; - - // 状态栏,普通图标状态值,只表示隐藏或显示 - public static final int STATUS_BAR_STATE_HIDE = 0; - public static final int STATUS_BAR_STATE_SHOW = 1; - - // 状态栏,"定位类型"图标状态值 - public static final int STATUS_BAR_STATE_LOCATE_TYPE_GPS = 1; - public static final int STATUS_BAR_STATE_LOCATE_TYPE_LBS = 2; - public static final int STATUS_BAR_STATE_LOCATE_TYPE_WIFI = 3; - - // 状态栏,"服务器连接状态"图标状态值 - public static final int STATUS_BAR_STATE_SERVER_CONNECTED_OFF = 1; - public static final int STATUS_BAR_STATE_SERVER_CONNECTED_ON = 2; - /// @} - - - private static LauncherCtrl instance; - private static Context mContext; - - - - - private static void log(String funcName, String msg) { - if (DEBUG) { - Log.i(TAG, "[" + funcName + "]" + msg); - } - } - - private static void log(String funcName) { - if (DEBUG) { - Log.i(TAG, "[" + funcName + "]"); - } - } - - private LauncherCtrl(Context context) { - mContext = context; - } - - public synchronized static LauncherCtrl getInstance(Context context) { - if (instance == null) { - instance = new LauncherCtrl(context); - } - return instance; - } - - public void setStatusBarIcon(String name, int state) { - ContentResolver contentResolver = mContext.getContentResolver(); - Uri uri = Uri.withAppendedPath(STATUS_BAR_URI, "update"); - -// Log.i(TAG, "setStatusBarIcon: " + uri.toString()); - - if (!TextUtils.isEmpty(name)) { - ContentValues values = new ContentValues(); - values.put("name", name); - values.put("state", state); - - String where = "name=?"; - String[] args = new String[]{name}; - contentResolver.update(uri, values, where, args); - } - - Log.i(TAG, name + " icon set state: " + state); - } - - - public int getStatusBarIconState(String whereName) { - int retValue = 0; - ContentResolver contentResolver = mContext.getContentResolver(); - Uri uri = Uri.withAppendedPath(STATUS_BAR_URI, "query"); - - - String where = null; - String[] args = null; - if (whereName != null) { - where = "name=?"; - args = new String[]{whereName}; - } - - Cursor cursor = contentResolver.query(uri, new String[]{"id", "name", "state"}, where, args, null); - - if (cursor != null) { - if (cursor.moveToNext()) { - int id = cursor.getInt(0); - String name = cursor.getString(1); - retValue = cursor.getShort(2); -// Log.i(TAG, "statusBarIconIsVisible, id:" + id + ", name:" + name + ", state:" + state); - } - cursor.close(); - } - - Log.i(TAG, whereName + " icon state: " + retValue); - - return retValue; - } - -} +package com.ic.watch_lib; + +import android.content.ContentResolver; +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.net.Uri; +import android.text.TextUtils; +import android.util.Log; + +public class LauncherCtrl { + private static final String TAG = "LauncherCtrl"; + private static final boolean DEBUG = false;//BuildConfig.DEBUG; + + private static final String AUTHORITY = "com.ic.db.watchProvider"; + private static final String STATUS_BAR_TABLE = "status_bar"; + public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); + public static final Uri STATUS_BAR_URI = Uri.withAppendedPath(AUTHORITY_URI, STATUS_BAR_TABLE); + + /// 来自 FragmentQuickSettings @{ + // 状态栏图标名称, 根据此名称控制状态栏图标是否显示 +// public static final String STATUS_BAR_SIGNAL = "signal"; +// public static final String STATUS_BAR_BATTERY = "battery"; +// public static final String STATUS_BAR_SIM_OPERATOR_NAME = "sim_operator_name"; + public static final String STATUS_BAR_LOCATE_TYPE = "locate_type"; + // public static final String STATUS_BAR_SMS = "sms"; + public static final String STATUS_BAR_SERVER_CONNECTED = "server_connected"; + // public static final String STATUS_BAR_SOUND_MODE = "sound_mode"; +// public static final String STATUS_BAR_LOCKER = "locker"; +// public static final String STATUS_BAR_ALARM_CLOCK = "alarm_clock"; + + // 状态栏,普通图标状态值,只表示隐藏或显示 + public static final int STATUS_BAR_STATE_HIDE = 0; + public static final int STATUS_BAR_STATE_SHOW = 1; + + // 状态栏,"定位类型"图标状态值 + public static final int STATUS_BAR_STATE_LOCATE_TYPE_GPS = 1; + public static final int STATUS_BAR_STATE_LOCATE_TYPE_LBS = 2; + public static final int STATUS_BAR_STATE_LOCATE_TYPE_WIFI = 3; + + // 状态栏,"服务器连接状态"图标状态值 + public static final int STATUS_BAR_STATE_SERVER_CONNECTED_OFF = 1; + public static final int STATUS_BAR_STATE_SERVER_CONNECTED_ON = 2; + /// @} + + + private static LauncherCtrl instance; + private static Context mContext; + + + + + private static void log(String funcName, String msg) { + if (DEBUG) { + Log.i(TAG, "[" + funcName + "]" + msg); + } + } + + private static void log(String funcName) { + if (DEBUG) { + Log.i(TAG, "[" + funcName + "]"); + } + } + + private LauncherCtrl(Context context) { + mContext = context; + } + + public synchronized static LauncherCtrl getInstance(Context context) { + if (instance == null) { + instance = new LauncherCtrl(context); + } + return instance; + } + + public void setStatusBarIcon(String name, int state) { + ContentResolver contentResolver = mContext.getContentResolver(); + Uri uri = Uri.withAppendedPath(STATUS_BAR_URI, "update"); + +// Log.i(TAG, "setStatusBarIcon: " + uri.toString()); + + if (!TextUtils.isEmpty(name)) { + ContentValues values = new ContentValues(); + values.put("name", name); + values.put("state", state); + + String where = "name=?"; + String[] args = new String[]{name}; + contentResolver.update(uri, values, where, args); + } + + Log.i(TAG, name + " icon set state: " + state); + } + + + public int getStatusBarIconState(String whereName) { + int retValue = 0; + ContentResolver contentResolver = mContext.getContentResolver(); + Uri uri = Uri.withAppendedPath(STATUS_BAR_URI, "query"); + + + String where = null; + String[] args = null; + if (whereName != null) { + where = "name=?"; + args = new String[]{whereName}; + } + + Cursor cursor = contentResolver.query(uri, new String[]{"id", "name", "state"}, where, args, null); + + if (cursor != null) { + if (cursor.moveToNext()) { + int id = cursor.getInt(0); + String name = cursor.getString(1); + retValue = cursor.getShort(2); +// Log.i(TAG, "statusBarIconIsVisible, id:" + id + ", name:" + name + ", state:" + state); + } + cursor.close(); + } + + Log.i(TAG, whereName + " icon state: " + retValue); + + return retValue; + } + +} -- 2.17.1