Browse Source

Merge branch 'develop' of lyq/AppManager into master

天问 3 years ago
parent
commit
3b566a6987

+ 10 - 4
app/build.gradle

@@ -1,12 +1,18 @@
 apply plugin: 'com.android.application'
 
+def keystoreProperties = new Properties()
+def keystoreProperitiesFile = rootProject.file('keystore.properties')
+if (keystoreProperitiesFile.exists()) {
+    keystoreProperties.load(new FileInputStream(keystoreProperitiesFile))
+}
+
 android {
     signingConfigs {
         release {
-            storeFile file('C:\\Users\\liuyuqi\\OneDrive\\cert\\android\\coding-android-sign-dev.jks')
-            keyAlias 'key0'
-            keyPassword 'coding321'
-            storePassword 'coding321'
+            storeFile file(keystoreProperties['storeFile'])
+            keyAlias keystoreProperties['keyAlias']
+            keyPassword keystoreProperties['keyPassword']
+            storePassword keystoreProperties['storePassword']
         }
     }
     compileSdkVersion 29

+ 8 - 7
app/src/main/AndroidManifest.xml

@@ -3,23 +3,24 @@
     xmlns:tools="http://schemas.android.com/tools"
     package="me.yoqi.android.appmanager">
 
-    <uses-permission android:name="android.permission.INTERNET"/>
-    <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission
+        android:name="android.permission.PACKAGE_USAGE_STATS"
         tools:ignore="ProtectedPermissions" />
-    <uses-permission android:name="android.permission.GET_PACKAGE_SIZE"/>
-
+    <uses-permission android:name="android.permission.GET_PACKAGE_SIZE" />
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
 
     <application
-        android:allowBackup="true"
+        android:allowBackup="false"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name"
         android:roundIcon="@mipmap/ic_launcher"
         android:supportsRtl="true"
         android:theme="@style/AppTheme">
-        <activity android:name=".MainActivity"
+        <activity
+            android:name=".MainActivity"
             android:theme="@style/Theme.AppCompat.Light.NoActionBar">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -27,7 +28,7 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
-        <activity android:name=".views.SplashActivity"/>
+        <activity android:name=".views.SplashActivity" />
     </application>
 
 </manifest>

+ 2 - 2
app/src/main/java/me/yoqi/android/appmanager/model/AppModel.java

@@ -29,7 +29,7 @@ public class AppModel{
         // 查询所有已经安装的应用程序
         List<ApplicationInfo> listAppcations = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);
         Collections.sort(listAppcations, new ApplicationInfo.DisplayNameComparator(pm));// 排序
-        List<AppInfo> appInfos = new ArrayList<AppInfo>(); // 保存过滤查到的AppInfo
+        List<AppInfo> appInfos = new ArrayList<>(); // 保存过滤查到的AppInfo
         // 根据条件来过滤
         switch (filter) {
             case FILTER_ALL_APP: // 所有应用程序
@@ -89,7 +89,7 @@ public class AppModel{
         resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);//android.intent.category.LAUNCHER
         resolveIntent.setPackage(packageName);
         List<ResolveInfo> resolveinfoList = context.getPackageManager().queryIntentActivities(resolveIntent, 0);
-        if (resolveinfoList != null && resolveinfoList.size() > 0) {
+        if (resolveinfoList.size() > 0) {
             ResolveInfo resolveinfo = resolveinfoList.iterator().next();
             if (resolveinfo != null) {
                 className = resolveinfo.activityInfo.name;

+ 0 - 11
app/src/main/java/me/yoqi/android/appmanager/utils/Hanzi2Pinyin.java

@@ -1,11 +0,0 @@
-package me.yoqi.android.appmanager.utils;
-
-/**
- * 文字转拼音
- *
- * @author liuyuqi.gov@msn.cn
- * @createTime 2020-10-01
- */
-public class Hanzi2Pinyin {
-
-}

+ 11 - 7
app/src/main/java/me/yoqi/android/appmanager/views/AppInfoAdapter.java

@@ -55,6 +55,7 @@ public class AppInfoAdapter extends BaseAdapter {
         View view = null;
         ViewHolder holder = null;
         if (convertview == null || convertview.getTag() == null) {
+            // TODO: 2020-10-13
             view = infater.inflate(R.layout.lv_item, null); //设置布局
             holder = new ViewHolder(view);
             view.setTag(holder);
@@ -65,14 +66,17 @@ public class AppInfoAdapter extends BaseAdapter {
         final AppInfo Appinfo = (AppInfo) getItem(position);
         holder.icon.setImageDrawable(Appinfo.getAppIcon());
         holder.appNmae.setText(Appinfo.getAppName());
-        holder.packageName.setText("包名:" + Appinfo.getPackageName());
+        holder.packageName.setText(String.format("%s%s", mContext.getString(R.string.pack_name), Appinfo.getPackageName()));
         if (!TextUtils.isEmpty(Appinfo.getLuancherActivity())) {
-            holder.launcherName.setText("启动类名:" + Appinfo.getLuancherActivity());
+            holder.launcherName.setText(String.format("%s%s", mContext.getString(R.string.start_class), Appinfo.getLuancherActivity()));
+            holder.launcherName.setVisibility(View.VISIBLE);
+        } else {
+            holder.launcherName.setVisibility(View.GONE);
         }
         view.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                SimplexToast.show(mContext, "包名已复制到剪切板");
+                SimplexToast.show(mContext, mContext.getString(R.string.pack_coped));
                 //获取剪贴板管理器:
                 ClipboardManager cm = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
                 // 创建普通字符型ClipData
@@ -91,10 +95,10 @@ public class AppInfoAdapter extends BaseAdapter {
         TextView launcherName;
 
         public ViewHolder(View view) {
-            this.icon = (ImageView) view.findViewById(R.id.icon);
-            this.appNmae = (TextView) view.findViewById(R.id.appNmae);
-            this.packageName = (TextView) view.findViewById(R.id.packageName);
-            this.launcherName = (TextView) view.findViewById(R.id.launcherName);
+            this.icon = view.findViewById(R.id.icon);
+            this.appNmae = view.findViewById(R.id.appNmae);
+            this.packageName = view.findViewById(R.id.packageName);
+            this.launcherName = view.findViewById(R.id.launcherName);
         }
     }
 }

+ 5 - 7
app/src/main/java/me/yoqi/android/utils/SPUtils.java

@@ -9,18 +9,16 @@ import java.util.Set;
 
 public class SPUtils {
     private static final String SP_NAME = "common";
-    private static SPUtils mSpUtils;
-    private Context context;
+    private SPUtils mSpUtils;
     private SharedPreferences sp;
     private Editor editor;
 
-    public SPUtils(Context context) {
-        this.context = context;
-        sp = this.context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
+    public SPUtils(Context mContext) {
+        sp = mContext.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
         editor = sp.edit();
     }
 
-    public static SPUtils getInstance(Context context) {
+    public SPUtils getInstance(Context context) {
 
         if (mSpUtils == null) {
             synchronized (SPUtils.class) {
@@ -74,7 +72,7 @@ public class SPUtils {
     }
 
     public void remove(String key) {
-        sp.edit().remove(key).commit();
+        sp.edit().remove(key).apply();
     }
 
 }

+ 6 - 0
app/src/main/res/drawable/item_selector.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@android:color/transparent" android:state_pressed="false" />
+    <item android:drawable="@android:color/darker_gray" android:state_pressed="true" />
+    <item android:drawable="@android:color/holo_purple" android:state_selected="true" />
+</selector>

+ 6 - 4
app/src/main/res/layout/activity_main.xml

@@ -22,8 +22,10 @@
                 android:layout_marginLeft="20dp"
                 android:layout_marginTop="10dp"
                 android:layout_marginRight="20dp"
+                android:autofillHints="@string/hite_search_app"
                 android:enabled="false"
                 android:hint="@string/hite_search_app"
+                android:inputType="text"
                 android:singleLine="true"
                 android:textAlignment="center" />
 
@@ -32,8 +34,8 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_gravity="center"
-                android:layout_marginTop="10dp"
-                android:layout_marginBottom="10dp"
+                android:layout_marginTop="5dp"
+                android:layout_marginBottom="5dp"
                 android:orientation="horizontal">
 
                 <RadioButton
@@ -58,8 +60,8 @@
                 android:layout_height="0dp"
                 android:layout_weight="1"
                 android:choiceMode="singleChoice"
-                android:listSelector="@android:color/transparent"
-                android:visibility="gone"></ListView>
+                android:listSelector="@drawable/item_selector"
+                android:visibility="gone" />
         </LinearLayout>
 
         <TextView

+ 21 - 8
app/src/main/res/layout/lv_item.xml

@@ -1,39 +1,52 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     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:background="@android:color/transparent"
     android:orientation="horizontal"
-    android:padding="16dp"
-    android:layout_height="match_parent">
+    android:padding="8dp">
 
     <ImageView
         android:id="@+id/icon"
         android:layout_width="48dp"
         android:layout_height="48dp"
+        android:layout_marginEnd="10dp"
         android:layout_marginRight="10dp"
+        android:contentDescription="麦克风"
         app:srcCompat="@android:drawable/presence_audio_away" />
 
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="vertical">
+
         <TextView
             android:id="@+id/appNmae"
-            android:text="115"
             android:layout_width="wrap_content"
-            android:layout_height="wrap_content" />
+            android:layout_height="wrap_content"
+            android:text=""
+            android:visibility="visible"
+            tools:text="115"
+            tools:visibility="visible" />
 
         <TextView
             android:id="@+id/packageName"
-            android:text="com.xx.123"
             android:layout_width="wrap_content"
-            android:layout_height="wrap_content" />
+            android:layout_height="wrap_content"
+            android:text=""
+            android:visibility="visible"
+            tools:text="me.yoqi.xx"
+            tools:visibility="visible" />
 
         <TextView
             android:id="@+id/launcherName"
-            android:text="com.xx"
             android:layout_width="wrap_content"
-            android:layout_height="wrap_content" />
+            android:layout_height="wrap_content"
+            android:text=""
+            tools:text="xx"
+            tools:visibility="visible" />
     </LinearLayout>
 
 </LinearLayout>

+ 4 - 1
app/src/main/res/values-zh/strings.xml

@@ -3,6 +3,9 @@
     <string name="app_name">包名查看器</string>
     <string name="system_app">系统App</string>
     <string name="dsf_app">第三方App</string>
-    <string name="loading">正在加载中...</string>
+    <string name="loading">正在加载中</string>
     <string name="hite_search_app">搜索app</string>
+    <string name="start_class">启动类名:</string>
+    <string name="pack_name">包名:</string>
+    <string name="pack_coped">包名已复制到剪切板</string>
 </resources>

+ 5 - 2
app/src/main/res/values/strings.xml

@@ -1,7 +1,10 @@
 <resources>
-    <string name="app_name">appManager</string>
+    <string name="app_name">AppManager</string>
     <string name="system_app">System App</string>
     <string name="dsf_app">User App</string>
-    <string name="loading">loading...</string>
+    <string name="loading">loading</string>
     <string name="hite_search_app">Search App</string>
+    <string name="start_class">StartClass: </string>
+    <string name="pack_name">Package    : </string>
+    <string name="pack_coped">"Copied to clipboard"</string>
 </resources>

+ 4 - 0
keystore.properties

@@ -0,0 +1,4 @@
+storeFile=C:\\Users\\liuyuqi\\OneDrive\\cert\\android\\coding-android-sign-dev.jks
+keyAlias=key0
+keyPassword=coding321
+storePassword=coding321

+ 1 - 1
settings.gradle

@@ -1,2 +1,2 @@
 include ':app'
-rootProject.name = "appManager"
+rootProject.name = "AppManager"