version:5.0
fix: update:增加app快捷方式
This commit is contained in:
@@ -15,8 +15,8 @@ android {
|
|||||||
applicationId "com.uiuios.aios"
|
applicationId "com.uiuios.aios"
|
||||||
minSdkVersion 24
|
minSdkVersion 24
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 40
|
versionCode 41
|
||||||
versionName "4.9"
|
versionName "5.0"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
@@ -201,6 +201,7 @@ dependencies {
|
|||||||
// Java language implementation
|
// Java language implementation
|
||||||
implementation "androidx.fragment:fragment:1.4.1"
|
implementation "androidx.fragment:fragment:1.4.1"
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||||
|
|||||||
@@ -2,6 +2,20 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.uiuios.aios">
|
package="com.uiuios.aios">
|
||||||
|
|
||||||
|
<permission
|
||||||
|
android:name="com.android.launcher.permission.INSTALL_SHORTCUT"
|
||||||
|
android:description="@string/permdesc_install_shortcut"
|
||||||
|
android:label="@string/permlab_install_shortcut"
|
||||||
|
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
|
||||||
|
android:protectionLevel="dangerous" />
|
||||||
|
|
||||||
|
<!-- 添加快捷方式 -->
|
||||||
|
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||||
|
<!-- 移除快捷方式 -->
|
||||||
|
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
|
||||||
|
<!-- 查询快捷方式 -->
|
||||||
|
<uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
|
||||||
|
|
||||||
<!-- 清单文件中, 申明监听通话精确状态权限,该权限需要android:sharedUserId="android.uid.system" -->
|
<!-- 清单文件中, 申明监听通话精确状态权限,该权限需要android:sharedUserId="android.uid.system" -->
|
||||||
<uses-permission android:name="android.permission.READ_PRECISE_PHONE_STATE" />
|
<uses-permission android:name="android.permission.READ_PRECISE_PHONE_STATE" />
|
||||||
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
|
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
|
||||||
@@ -75,6 +89,30 @@
|
|||||||
android:resumeWhilePausing="true"
|
android:resumeWhilePausing="true"
|
||||||
android:stateNotNeeded="true"
|
android:stateNotNeeded="true"
|
||||||
android:windowSoftInputMode="adjustPan">
|
android:windowSoftInputMode="adjustPan">
|
||||||
|
<!-- <intent-filter>-->
|
||||||
|
<!-- <action android:name="android.intent.action.MAIN" />-->
|
||||||
|
|
||||||
|
<!-- <category android:name="android.intent.category.HOME" />-->
|
||||||
|
<!-- <category android:name="android.intent.category.DEFAULT" />-->
|
||||||
|
<!-- <category android:name="android.intent.category.MONKEY" />-->
|
||||||
|
<!-- <category android:name="android.intent.category.LAUNCHER_APP" />-->
|
||||||
|
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
|
||||||
|
<!-- </intent-filter>-->
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".activity.main.MainActivity"
|
||||||
|
android:clearTaskOnLaunch="true"
|
||||||
|
android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
|
||||||
|
android:enabled="true"
|
||||||
|
android:excludeFromRecents="true"
|
||||||
|
android:exported="true"
|
||||||
|
android:resizeableActivity="true"
|
||||||
|
android:resumeWhilePausing="true"
|
||||||
|
android:screenOrientation="userLandscape"
|
||||||
|
android:stateNotNeeded="true"
|
||||||
|
android:taskAffinity=""
|
||||||
|
android:windowSoftInputMode="adjustPan">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
@@ -84,12 +122,8 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER_APP" />
|
<category android:name="android.intent.category.LAUNCHER_APP" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
|
||||||
android:name=".activity.main.MainActivity"
|
|
||||||
android:exported="true"
|
|
||||||
android:launchMode="singleTask"
|
|
||||||
android:screenOrientation="userLandscape" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.main.PhoneMainActivity"
|
android:name=".activity.main.PhoneMainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
@@ -221,6 +255,18 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".activity.AddItemActivity"
|
||||||
|
android:autoRemoveFromRecents="true"
|
||||||
|
android:excludeFromRecents="true"
|
||||||
|
android:label="@string/action_add_to_workspace"
|
||||||
|
android:theme="@style/activity_styles">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.content.pm.action.CONFIRM_PIN_SHORTCUT" />
|
||||||
|
<action android:name="android.content.pm.action.CONFIRM_PIN_APPWIDGET" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".receiver.BootReceiver"
|
android:name=".receiver.BootReceiver"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
|
|||||||
169
app/src/main/java/com/uiuios/aios/activity/AddItemActivity.java
Normal file
169
app/src/main/java/com/uiuios/aios/activity/AddItemActivity.java
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
package com.uiuios.aios.activity;
|
||||||
|
|
||||||
|
import android.appwidget.AppWidgetManager;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.LauncherApps;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ShortcutInfo;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.RemoteViews;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.uiuios.aios.R;
|
||||||
|
import com.uiuios.aios.base.BaseActivity;
|
||||||
|
import com.uiuios.aios.shortcut.ShortcutPkgInfo;
|
||||||
|
import com.uiuios.aios.shortcut.ShortcutUtils;
|
||||||
|
import com.uiuios.aios.utils.ToastUtil;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
|
public class AddItemActivity extends BaseActivity {
|
||||||
|
private static final String TAG = AddItemActivity.class.getSimpleName();
|
||||||
|
|
||||||
|
@BindView(R.id.tv_app_name)
|
||||||
|
TextView tv_app_name;
|
||||||
|
@BindView(R.id.iv_icon)
|
||||||
|
ImageView iv_icon;
|
||||||
|
@BindView(R.id.tv_add)
|
||||||
|
TextView tv_add;
|
||||||
|
@BindView(R.id.tv_cancel)
|
||||||
|
TextView tv_cancel;
|
||||||
|
|
||||||
|
|
||||||
|
int mIconDpi = 1000;
|
||||||
|
|
||||||
|
private LauncherApps.PinItemRequest mRequest;
|
||||||
|
private ShortcutInfo mInfo;
|
||||||
|
private String mId;
|
||||||
|
private String mPackageName;
|
||||||
|
private String mTitle;
|
||||||
|
private ComponentName mComponentName;
|
||||||
|
|
||||||
|
private Bundle mWidgetOptions;
|
||||||
|
private AppWidgetManager mAppWidgetManager;
|
||||||
|
private int mPendingBindWidgetId;
|
||||||
|
|
||||||
|
private ShortcutPkgInfo mShortcutPkgInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置布局
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getLayoutId() {
|
||||||
|
return R.layout.add_item_confirmation_activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化视图
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void initView() {
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
tv_cancel.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tv_add.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (mShortcutPkgInfo == null) {
|
||||||
|
ToastUtil.show("快捷方式信息为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ShortcutUtils.getInstance().addShortcut(mShortcutPkgInfo)) {
|
||||||
|
mRequest.accept(mWidgetOptions);
|
||||||
|
mWidgetOptions.putInt(AppWidgetManager.EXTRA_APPWIDGET_ID, mPendingBindWidgetId);
|
||||||
|
boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(mPendingBindWidgetId, mComponentName, mWidgetOptions);
|
||||||
|
Log.e(TAG, "onClick: success + " + success);
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
ToastUtil.show("添加失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void initData() {
|
||||||
|
mAppWidgetManager = AppWidgetManager.getInstance(AddItemActivity.this);
|
||||||
|
mPendingBindWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
|
||||||
|
mWidgetOptions = new Bundle();
|
||||||
|
mRequest = getPinItemRequest(getIntent());
|
||||||
|
if (mRequest == null) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mInfo = mRequest.getShortcutInfo();
|
||||||
|
if (mInfo == null) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mRequest.getRequestType() == LauncherApps.PinItemRequest.REQUEST_TYPE_SHORTCUT) {
|
||||||
|
// mAppWidgetProviderInfo = mRequest.getAppWidgetProviderInfo(AddItemActivity.this);
|
||||||
|
mId = mInfo.getId();
|
||||||
|
mPackageName = mInfo.getPackage();
|
||||||
|
mTitle = mInfo.getShortLabel().toString();
|
||||||
|
tv_app_name.setText(mTitle);
|
||||||
|
Drawable d = getSystemService(LauncherApps.class).getShortcutIconDrawable(mInfo, mIconDpi);
|
||||||
|
iv_icon.setImageDrawable(d);
|
||||||
|
mComponentName = mInfo.getActivity();
|
||||||
|
// Drawable icon = getFullResIcon(mAppWidgetProviderInfo.provider.getPackageName(), mAppWidgetProviderInfo.icon);
|
||||||
|
// RemoteViews remoteViews = getPreview(mRequest);
|
||||||
|
mShortcutPkgInfo = new ShortcutPkgInfo(mId, mTitle, mPackageName, mComponentName, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LauncherApps.PinItemRequest getPinItemRequest(Intent intent) {
|
||||||
|
Parcelable extra = intent.getParcelableExtra(LauncherApps.EXTRA_PIN_ITEM_REQUEST);
|
||||||
|
return extra instanceof LauncherApps.PinItemRequest ? (LauncherApps.PinItemRequest) extra : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RemoteViews getPreview(LauncherApps.PinItemRequest request) {
|
||||||
|
Bundle extras = request.getExtras();
|
||||||
|
if (extras != null &&
|
||||||
|
extras.get(AppWidgetManager.EXTRA_APPWIDGET_PREVIEW) instanceof RemoteViews) {
|
||||||
|
return (RemoteViews) extras.get(AppWidgetManager.EXTRA_APPWIDGET_PREVIEW);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable getFullResIcon(String packageName, int iconId) {
|
||||||
|
try {
|
||||||
|
return getFullResIcon(getPackageManager().getResourcesForApplication(packageName), iconId);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
}
|
||||||
|
return getFullResDefaultActivityIcon(mIconDpi);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drawable getFullResIcon(Resources resources, int iconId) {
|
||||||
|
if (resources != null && iconId != 0) {
|
||||||
|
try {
|
||||||
|
return resources.getDrawableForDensity(iconId, mIconDpi);
|
||||||
|
} catch (Resources.NotFoundException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getFullResDefaultActivityIcon(mIconDpi);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Drawable getFullResDefaultActivityIcon(int iconDpi) {
|
||||||
|
return Resources.getSystem().getDrawableForDensity(
|
||||||
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||||
|
? android.R.drawable.sym_def_app_icon : android.R.mipmap.sym_def_app_icon,
|
||||||
|
iconDpi);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
package com.uiuios.aios.activity.main;
|
package com.uiuios.aios.activity.main;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.uiuios.aios.R;
|
import com.uiuios.aios.R;
|
||||||
|
|
||||||
public class MainActivity extends BaseMainActivity {
|
public class MainActivity extends BaseMainActivity {
|
||||||
@@ -9,4 +15,18 @@ public class MainActivity extends BaseMainActivity {
|
|||||||
public int getLayoutId() {
|
public int getLayoutId() {
|
||||||
return R.layout.activity_main;
|
return R.layout.activity_main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
Log.e(TAG, "onCreate: ");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onNewIntent(Intent intent) {
|
||||||
|
super.onNewIntent(intent);
|
||||||
|
Log.e(TAG, "onNewIntent: getAction = " + intent.getAction());
|
||||||
|
Log.e(TAG, "onNewIntent: getCategories = " + intent.getCategories());
|
||||||
|
Log.e(TAG, "onNewIntent: getFlags = " + intent.getFlags());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ public class AddAppAdapter extends RecyclerView.Adapter<AddAppAdapter.AppHolder>
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull AppHolder holder, int position) {
|
public void onBindViewHolder(@NonNull AppHolder holder, int position) {
|
||||||
DesktopIcon desktopIcon = desktopIcons.get(position);
|
DesktopIcon desktopIcon = desktopIcons.get(position);
|
||||||
String lable = desktopIcon.getLable();
|
String lable = desktopIcon.getTitle();
|
||||||
holder.tv_appname.setText(lable);
|
holder.tv_appname.setText(lable);
|
||||||
holder.iv_icon.setImageDrawable(desktopIcon.getIcon());
|
holder.iv_icon.setImageDrawable(desktopIcon.getIcon());
|
||||||
String pkg = desktopIcon.getPackageName();
|
String pkg = desktopIcon.getPackage();
|
||||||
|
|
||||||
if (packageSet != null) {
|
if (packageSet != null) {
|
||||||
if (packageSet.contains(pkg)) {
|
if (packageSet.contains(pkg)) {
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ public class HomeAppAdapter extends RecyclerView.Adapter<HomeAppAdapter.AppHolde
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull AppHolder holder, int position) {
|
public void onBindViewHolder(@NonNull AppHolder holder, int position) {
|
||||||
DesktopIcon desktopIcon = desktopIcons.get(position);
|
DesktopIcon desktopIcon = desktopIcons.get(position);
|
||||||
String lable = desktopIcon.getLable();
|
String lable = desktopIcon.getTitle();
|
||||||
holder.tv_appname.setText(lable);
|
holder.tv_appname.setText(lable);
|
||||||
holder.iv_icon.setImageDrawable(desktopIcon.getIcon());
|
holder.iv_icon.setImageDrawable(desktopIcon.getIcon());
|
||||||
String pkg = desktopIcon.getPackageName();
|
String pkg = desktopIcon.getPackage();
|
||||||
Log.e(TAG, "getView: " + pkg);
|
Log.e(TAG, "getView: " + pkg);
|
||||||
int i = IconUtils.appClassNameList.indexOf(pkg);
|
int i = IconUtils.appClassNameList.indexOf(pkg);
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
@@ -80,11 +80,11 @@ public class HomeAppAdapter extends RecyclerView.Adapter<HomeAppAdapter.AppHolde
|
|||||||
} else {
|
} else {
|
||||||
int setting_other_appInstaller = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.SETTING_OTHER_APPINSTALLER_KEY, 1);
|
int setting_other_appInstaller = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.SETTING_OTHER_APPINSTALLER_KEY, 1);
|
||||||
if (setting_other_appInstaller == 0
|
if (setting_other_appInstaller == 0
|
||||||
&& !ApkUtils.isSystemApp(mContext, desktopIcon.getPackageName()
|
&& !ApkUtils.isSystemApp(mContext, desktopIcon.getPackage()
|
||||||
)) {
|
)) {
|
||||||
ToastUtil.show("已禁止应用打开");
|
ToastUtil.show("已禁止应用打开");
|
||||||
} else {
|
} else {
|
||||||
ApkUtils.openPackage(mContext, desktopIcon.getPackageName(), desktopIcon.getClassName());
|
ApkUtils.openPackage(mContext, desktopIcon.getPackage(), desktopIcon.getClazz());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.uiuios.aios.manager.RemoteManager;
|
|||||||
import com.uiuios.aios.network.NetInterfaceManager;
|
import com.uiuios.aios.network.NetInterfaceManager;
|
||||||
import com.uiuios.aios.push.PushManager;
|
import com.uiuios.aios.push.PushManager;
|
||||||
import com.uiuios.aios.service.main.MainService;
|
import com.uiuios.aios.service.main.MainService;
|
||||||
|
import com.uiuios.aios.shortcut.ShortcutUtils;
|
||||||
import com.uiuios.aios.utils.AppUsedTimeUtils;
|
import com.uiuios.aios.utils.AppUsedTimeUtils;
|
||||||
import com.uiuios.aios.utils.JGYUtils;
|
import com.uiuios.aios.utils.JGYUtils;
|
||||||
import com.uiuios.aios.utils.WiFiUtils;
|
import com.uiuios.aios.utils.WiFiUtils;
|
||||||
@@ -52,9 +53,12 @@ public class BaseApplication extends Application {
|
|||||||
WiFiUtils.init(this);
|
WiFiUtils.init(this);
|
||||||
AppUsedTimeUtils.init(this);
|
AppUsedTimeUtils.init(this);
|
||||||
AlarmUtils.init(this);
|
AlarmUtils.init(this);
|
||||||
|
ShortcutUtils.init(this);
|
||||||
|
|
||||||
HeConfig.init("HE2210211540591362", "fe42a7bb59b14eefb27eea4fb2c40e99");
|
HeConfig.init("HE2210211540591362", "fe42a7bb59b14eefb27eea4fb2c40e99");
|
||||||
//切换至开发版服务
|
//切换至开发版服务
|
||||||
HeConfig.switchToDevService();
|
HeConfig.switchToDevService();
|
||||||
|
|
||||||
RemoteManager.init(this);
|
RemoteManager.init(this);
|
||||||
ConnectManager.init(this);
|
ConnectManager.init(this);
|
||||||
AppStatusManager.init(this);
|
AppStatusManager.init(this);
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ import java.io.Serializable;
|
|||||||
public class DesktopIcon implements Serializable, Parcelable {
|
public class DesktopIcon implements Serializable, Parcelable {
|
||||||
private static final long serialVersionUID = 3358230413497783708L;
|
private static final long serialVersionUID = 3358230413497783708L;
|
||||||
|
|
||||||
String packageName;
|
protected String mTitle;
|
||||||
String className;
|
protected String mClass;
|
||||||
Drawable icon;
|
protected String mPackage;
|
||||||
String lable;
|
protected Drawable icon;
|
||||||
|
|
||||||
int position;
|
int position;
|
||||||
|
|
||||||
public DesktopIcon() {
|
public DesktopIcon() {
|
||||||
@@ -23,15 +24,15 @@ public class DesktopIcon implements Serializable, Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DesktopIcon(Parcel in) {
|
private DesktopIcon(Parcel in) {
|
||||||
packageName = in.readString();
|
mPackage = in.readString();
|
||||||
lable = in.readString();
|
mTitle = in.readString();
|
||||||
position = in.readInt();
|
position = in.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeString(packageName);
|
dest.writeString(mPackage);
|
||||||
dest.writeString(lable);
|
dest.writeString(mTitle);
|
||||||
dest.writeInt(position);
|
dest.writeInt(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,20 +53,20 @@ public class DesktopIcon implements Serializable, Parcelable {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public String getPackageName() {
|
public String getPackage() {
|
||||||
return packageName;
|
return mPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPackageName(String packageName) {
|
public void setPackage(String aPackage) {
|
||||||
this.packageName = packageName;
|
this.mPackage = aPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClassName() {
|
public String getClazz() {
|
||||||
return className;
|
return mClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClassName(String className) {
|
public void setClass(String aClass) {
|
||||||
this.className = className;
|
this.mClass = aClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable getIcon() {
|
public Drawable getIcon() {
|
||||||
@@ -76,12 +77,12 @@ public class DesktopIcon implements Serializable, Parcelable {
|
|||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLable() {
|
public String getTitle() {
|
||||||
return lable;
|
return mTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLable(String lable) {
|
public void setTitle(String title) {
|
||||||
this.lable = lable;
|
this.mTitle = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPosition() {
|
public int getPosition() {
|
||||||
@@ -95,10 +96,10 @@ public class DesktopIcon implements Serializable, Parcelable {
|
|||||||
public static DesktopIcon creatDesktopIcon(Context context, ResolveInfo resolveInfo) {
|
public static DesktopIcon creatDesktopIcon(Context context, ResolveInfo resolveInfo) {
|
||||||
PackageManager pm = context.getPackageManager();
|
PackageManager pm = context.getPackageManager();
|
||||||
DesktopIcon desktopIcon = new DesktopIcon();
|
DesktopIcon desktopIcon = new DesktopIcon();
|
||||||
desktopIcon.setPackageName(resolveInfo.activityInfo.packageName);
|
desktopIcon.setPackage(resolveInfo.activityInfo.packageName);
|
||||||
desktopIcon.setClassName(resolveInfo.activityInfo.name);
|
desktopIcon.setClass(resolveInfo.activityInfo.name);
|
||||||
desktopIcon.setIcon(resolveInfo.loadIcon(pm));
|
desktopIcon.setIcon(resolveInfo.loadIcon(pm));
|
||||||
desktopIcon.setLable(resolveInfo.loadLabel(pm).toString());
|
desktopIcon.setTitle(resolveInfo.loadLabel(pm).toString());
|
||||||
desktopIcon.setPosition(0);
|
desktopIcon.setPosition(0);
|
||||||
return desktopIcon;
|
return desktopIcon;
|
||||||
}
|
}
|
||||||
@@ -106,10 +107,10 @@ public class DesktopIcon implements Serializable, Parcelable {
|
|||||||
public static DesktopIcon creatDesktopIcon(Context context, ResolveInfo resolveInfo, int position) {
|
public static DesktopIcon creatDesktopIcon(Context context, ResolveInfo resolveInfo, int position) {
|
||||||
PackageManager pm = context.getPackageManager();
|
PackageManager pm = context.getPackageManager();
|
||||||
DesktopIcon desktopIcon = new DesktopIcon();
|
DesktopIcon desktopIcon = new DesktopIcon();
|
||||||
desktopIcon.setPackageName(resolveInfo.activityInfo.packageName);
|
desktopIcon.setPackage(resolveInfo.activityInfo.packageName);
|
||||||
desktopIcon.setClassName(resolveInfo.activityInfo.name);
|
desktopIcon.setClass(resolveInfo.activityInfo.name);
|
||||||
desktopIcon.setIcon(resolveInfo.loadIcon(pm));
|
desktopIcon.setIcon(resolveInfo.loadIcon(pm));
|
||||||
desktopIcon.setLable(resolveInfo.loadLabel(pm).toString());
|
desktopIcon.setTitle(resolveInfo.loadLabel(pm).toString());
|
||||||
desktopIcon.setPosition(position);
|
desktopIcon.setPosition(position);
|
||||||
return desktopIcon;
|
return desktopIcon;
|
||||||
}
|
}
|
||||||
|
|||||||
231
app/src/main/java/com/uiuios/aios/dialog/ShortcutDialog.java
Normal file
231
app/src/main/java/com/uiuios/aios/dialog/ShortcutDialog.java
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
package com.uiuios.aios.dialog;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
|
import com.uiuios.aios.R;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* description:自定义dialog
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ShortcutDialog extends AlertDialog {
|
||||||
|
/**
|
||||||
|
* 显示的标题
|
||||||
|
*/
|
||||||
|
private TextView titleTv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示的消息
|
||||||
|
*/
|
||||||
|
private TextView messageTv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认和取消按钮
|
||||||
|
*/
|
||||||
|
private TextView positiveBn;
|
||||||
|
private TextView negtiveBn;
|
||||||
|
|
||||||
|
private ImageView ivIcon;
|
||||||
|
private ImageView ivAppIcon;
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
public ShortcutDialog(Context context) {
|
||||||
|
super(context, R.style.CustomDialog);
|
||||||
|
this.mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 都是内容数据
|
||||||
|
*/
|
||||||
|
private String message;
|
||||||
|
private String title;
|
||||||
|
private String positive, negtive;
|
||||||
|
private Drawable mDrawable;
|
||||||
|
private Drawable mAppDrawable;
|
||||||
|
/**
|
||||||
|
* 底部是否只有一个按钮
|
||||||
|
*/
|
||||||
|
private boolean isSingle = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.dialog_shortcut);
|
||||||
|
//按空白处不能取消动画
|
||||||
|
setCanceledOnTouchOutside(false);
|
||||||
|
//初始化界面控件
|
||||||
|
initView();
|
||||||
|
//初始化界面数据
|
||||||
|
refreshView();
|
||||||
|
//初始化界面控件的事件
|
||||||
|
initEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化界面的确定和取消监听器
|
||||||
|
*/
|
||||||
|
private void initEvent() {
|
||||||
|
//设置确定按钮被点击后,向外界提供监听
|
||||||
|
positiveBn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (onClickBottomListener != null) {
|
||||||
|
onClickBottomListener.onPositiveClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//设置取消按钮被点击后,向外界提供监听
|
||||||
|
negtiveBn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (onClickBottomListener != null) {
|
||||||
|
onClickBottomListener.onNegtiveClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化界面控件的显示数据
|
||||||
|
*/
|
||||||
|
private void refreshView() {
|
||||||
|
//如果用户自定了title和message
|
||||||
|
if (!TextUtils.isEmpty(title)) {
|
||||||
|
titleTv.setText(title);
|
||||||
|
titleTv.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
titleTv.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
if (!TextUtils.isEmpty(message)) {
|
||||||
|
messageTv.setText(message);
|
||||||
|
}
|
||||||
|
//如果设置按钮的文字
|
||||||
|
if (!TextUtils.isEmpty(positive)) {
|
||||||
|
positiveBn.setText(positive);
|
||||||
|
} else {
|
||||||
|
positiveBn.setText("确定");
|
||||||
|
}
|
||||||
|
if (!TextUtils.isEmpty(negtive)) {
|
||||||
|
negtiveBn.setText(negtive);
|
||||||
|
} else {
|
||||||
|
negtiveBn.setText("取消");
|
||||||
|
}
|
||||||
|
ivIcon.setImageDrawable(mDrawable);
|
||||||
|
ivAppIcon.setImageDrawable(mAppDrawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
super.show();
|
||||||
|
refreshView();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化界面控件
|
||||||
|
*/
|
||||||
|
private void initView() {
|
||||||
|
negtiveBn = findViewById(R.id.negtive);
|
||||||
|
positiveBn = findViewById(R.id.positive);
|
||||||
|
titleTv = findViewById(R.id.title);
|
||||||
|
messageTv = findViewById(R.id.message);
|
||||||
|
ivIcon = findViewById(R.id.iv_icon);
|
||||||
|
ivAppIcon = findViewById(R.id.iv_app_icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置确定取消按钮的回调
|
||||||
|
*/
|
||||||
|
private OnClickBottomListener onClickBottomListener;
|
||||||
|
|
||||||
|
public void setOnClickBottomListener(OnClickBottomListener onClickBottomListener) {
|
||||||
|
this.onClickBottomListener = onClickBottomListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnClickBottomListener {
|
||||||
|
/**
|
||||||
|
* 点击确定按钮事件
|
||||||
|
*/
|
||||||
|
void onPositiveClick();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击取消按钮事件
|
||||||
|
*/
|
||||||
|
void onNegtiveClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShortcutDialog setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShortcutDialog setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPositive() {
|
||||||
|
return positive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShortcutDialog setPositive(String positive) {
|
||||||
|
this.positive = positive;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNegtive() {
|
||||||
|
return negtive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShortcutDialog setNegtive(String negtive) {
|
||||||
|
this.negtive = negtive;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShortcutDialog setNegtiveText(String negtive) {
|
||||||
|
negtiveBn.setText(negtive);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSingle() {
|
||||||
|
return isSingle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShortcutDialog setSingle(boolean single) {
|
||||||
|
isSingle = single;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShortcutDialog setIconImage(Drawable drawable) {
|
||||||
|
this.mDrawable = drawable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShortcutDialog setAppIconImage(Drawable drawable) {
|
||||||
|
this.mAppDrawable = drawable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dismiss() {
|
||||||
|
super.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
package com.uiuios.aios.fragment;
|
package com.uiuios.aios.fragment;
|
||||||
|
|
||||||
|
import android.app.ActivityOptions;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.LauncherApps;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Process;
|
||||||
import androidx.annotation.NonNull;
|
import android.os.UserHandle;
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -18,27 +18,33 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.trello.rxlifecycle4.RxLifecycle;
|
import com.trello.rxlifecycle4.RxLifecycle;
|
||||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||||
import com.uiuios.aios.R;
|
import com.uiuios.aios.R;
|
||||||
import com.uiuios.aios.activity.DailyAppActivity;
|
import com.uiuios.aios.activity.DailyAppActivity;
|
||||||
import com.uiuios.aios.activity.ScreenLockActivity;
|
import com.uiuios.aios.activity.ScreenLockActivity;
|
||||||
|
import com.uiuios.aios.activity.main.MainActivity;
|
||||||
import com.uiuios.aios.base.BaseFragment;
|
import com.uiuios.aios.base.BaseFragment;
|
||||||
import com.uiuios.aios.bean.BaseResponse;
|
import com.uiuios.aios.bean.BaseResponse;
|
||||||
import com.uiuios.aios.bean.DesktopIcon;
|
import com.uiuios.aios.bean.DesktopIcon;
|
||||||
import com.uiuios.aios.config.CommonConfig;
|
import com.uiuios.aios.config.CommonConfig;
|
||||||
import com.uiuios.aios.dialog.CustomDialog;
|
|
||||||
import com.uiuios.aios.dialog.DailyAppDialog;
|
import com.uiuios.aios.dialog.DailyAppDialog;
|
||||||
|
import com.uiuios.aios.dialog.ShortcutDialog;
|
||||||
import com.uiuios.aios.manager.AppManager;
|
import com.uiuios.aios.manager.AppManager;
|
||||||
import com.uiuios.aios.manager.AppStatusManager;
|
import com.uiuios.aios.manager.AppStatusManager;
|
||||||
import com.uiuios.aios.manager.RemoteManager;
|
import com.uiuios.aios.manager.RemoteManager;
|
||||||
import com.uiuios.aios.network.NetInterfaceManager;
|
import com.uiuios.aios.network.NetInterfaceManager;
|
||||||
import com.uiuios.aios.service.NotificationService;
|
import com.uiuios.aios.service.NotificationService;
|
||||||
|
import com.uiuios.aios.shortcut.ShortcutPkgInfo;
|
||||||
|
import com.uiuios.aios.shortcut.ShortcutUtils;
|
||||||
import com.uiuios.aios.utils.ApkUtils;
|
import com.uiuios.aios.utils.ApkUtils;
|
||||||
import com.uiuios.aios.utils.BitmapUtils;
|
|
||||||
import com.uiuios.aios.utils.IconUtils;
|
|
||||||
import com.uiuios.aios.utils.AppUsedTimeUtils;
|
import com.uiuios.aios.utils.AppUsedTimeUtils;
|
||||||
|
import com.uiuios.aios.utils.IconUtils;
|
||||||
import com.uiuios.aios.utils.ToastUtil;
|
import com.uiuios.aios.utils.ToastUtil;
|
||||||
import com.uiuios.aios.view.MyGridLayout;
|
import com.uiuios.aios.view.MyGridLayout;
|
||||||
|
|
||||||
@@ -67,6 +73,7 @@ public class AppListFragment extends BaseFragment {
|
|||||||
private ArrayList<DesktopIcon> mDesktopIcons;
|
private ArrayList<DesktopIcon> mDesktopIcons;
|
||||||
private MyGridLayout gridLayout;
|
private MyGridLayout gridLayout;
|
||||||
private String TAG = AppListFragment.class.getSimpleName();
|
private String TAG = AppListFragment.class.getSimpleName();
|
||||||
|
private LauncherApps mLauncherApps;
|
||||||
|
|
||||||
public AppListFragment() {
|
public AppListFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@@ -114,6 +121,7 @@ public class AppListFragment extends BaseFragment {
|
|||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
rootView = inflater.inflate(R.layout.fragment_applist, container, false);
|
rootView = inflater.inflate(R.layout.fragment_applist, container, false);
|
||||||
mContext = rootView.getContext();
|
mContext = rootView.getContext();
|
||||||
|
mLauncherApps = (LauncherApps) mContext.getSystemService(Context.LAUNCHER_APPS_SERVICE);
|
||||||
initView();
|
initView();
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
@@ -136,12 +144,19 @@ public class AppListFragment extends BaseFragment {
|
|||||||
View view = getLayoutInflater().inflate(R.layout.item_actions,
|
View view = getLayoutInflater().inflate(R.layout.item_actions,
|
||||||
null);
|
null);
|
||||||
ImageView iv = view.findViewById(R.id.iv);
|
ImageView iv = view.findViewById(R.id.iv);
|
||||||
|
ImageView iv_app = view.findViewById(R.id.iv_app);
|
||||||
TextView tv = view.findViewById(R.id.tv);
|
TextView tv = view.findViewById(R.id.tv);
|
||||||
TextView bg = view.findViewById(R.id.bg);
|
TextView bg = view.findViewById(R.id.bg);
|
||||||
ConstraintLayout constraintLayout = view.findViewById(R.id.btn_booktag);
|
ConstraintLayout constraintLayout = view.findViewById(R.id.btn_booktag);
|
||||||
DesktopIcon desktopIcon = mDesktopIcons.get(index);
|
DesktopIcon desktopIcon = mDesktopIcons.get(index);
|
||||||
if (desktopIcon != null) {
|
if (desktopIcon != null) {
|
||||||
String pkg = desktopIcon.getPackageName();
|
String pkg = desktopIcon.getPackage();
|
||||||
|
if (desktopIcon instanceof ShortcutPkgInfo) {
|
||||||
|
iv_app.setVisibility(View.VISIBLE);
|
||||||
|
iv_app.setImageDrawable(ApkUtils.getAppDrawable(mContext, pkg));
|
||||||
|
} else {
|
||||||
|
iv_app.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
Log.e(TAG, "getView: " + pkg);
|
Log.e(TAG, "getView: " + pkg);
|
||||||
int i = IconUtils.appClassNameList.indexOf(pkg);
|
int i = IconUtils.appClassNameList.indexOf(pkg);
|
||||||
int size = NotificationService.getNotificationLength(pkg);
|
int size = NotificationService.getNotificationLength(pkg);
|
||||||
@@ -175,9 +190,9 @@ public class AppListFragment extends BaseFragment {
|
|||||||
desktopIcon.setIcon(mContext.getResources().getDrawable(resID));
|
desktopIcon.setIcon(mContext.getResources().getDrawable(resID));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
iv.setImageDrawable( desktopIcon.getIcon());
|
iv.setImageDrawable(desktopIcon.getIcon());
|
||||||
}
|
}
|
||||||
tv.setText(desktopIcon.getLable());
|
tv.setText(desktopIcon.getTitle());
|
||||||
// linearLayout.setEnabled(true);
|
// linearLayout.setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
// linearLayout.setEnabled(false);
|
// linearLayout.setEnabled(false);
|
||||||
@@ -198,8 +213,22 @@ public class AppListFragment extends BaseFragment {
|
|||||||
public void onItemClick(View v, int index) {
|
public void onItemClick(View v, int index) {
|
||||||
DesktopIcon desktopIcon = mDesktopIcons.get(index);
|
DesktopIcon desktopIcon = mDesktopIcons.get(index);
|
||||||
if (desktopIcon != null) {
|
if (desktopIcon != null) {
|
||||||
Log.e(TAG, "onItemClick: " + desktopIcon.getPackageName());
|
Log.e(TAG, "onItemClick: " + desktopIcon.getPackage());
|
||||||
switch (desktopIcon.getPackageName()) {
|
if (desktopIcon instanceof ShortcutPkgInfo) {
|
||||||
|
try {
|
||||||
|
ActivityOptions activityOptions = ActivityOptions.makeClipRevealAnimation(v, v.getScrollX(), v.getScrollY(), v.getMeasuredWidth(), v.getMeasuredHeight());
|
||||||
|
String packegeName = ((ShortcutPkgInfo) desktopIcon).getPackageName();
|
||||||
|
String id = ((ShortcutPkgInfo) desktopIcon).getId();
|
||||||
|
Rect rect = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
|
||||||
|
UserHandle userHandle = Process.myUserHandle();
|
||||||
|
Log.e(TAG, "onItemClick: " + packegeName);
|
||||||
|
mLauncherApps.startShortcut(packegeName, id, rect, activityOptions.toBundle(), userHandle);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Failed to start shortcut: " + e.getMessage());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (desktopIcon.getPackage()) {
|
||||||
case "aios.daily.app":
|
case "aios.daily.app":
|
||||||
startActivity(new Intent(mContext, DailyAppActivity.class));
|
startActivity(new Intent(mContext, DailyAppActivity.class));
|
||||||
break;
|
break;
|
||||||
@@ -224,8 +253,8 @@ public class AppListFragment extends BaseFragment {
|
|||||||
// ToastUtil.show("电话功能被禁用");
|
// ToastUtil.show("电话功能被禁用");
|
||||||
// return;
|
// return;
|
||||||
// } else {
|
// } else {
|
||||||
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackageName(), desktopIcon.getClassName());
|
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackage(), desktopIcon.getClazz());
|
||||||
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackageName());
|
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackage());
|
||||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||||
SendRunningApp(getActivity());
|
SendRunningApp(getActivity());
|
||||||
// }
|
// }
|
||||||
@@ -234,20 +263,20 @@ public class AppListFragment extends BaseFragment {
|
|||||||
case "com.uiuios.sn":
|
case "com.uiuios.sn":
|
||||||
case "com.uiuios.appstore":
|
case "com.uiuios.appstore":
|
||||||
case "com.uiuios.browser":
|
case "com.uiuios.browser":
|
||||||
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackageName(), desktopIcon.getClassName());
|
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackage(), desktopIcon.getClazz());
|
||||||
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackageName());
|
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackage());
|
||||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||||
SendRunningApp(getActivity());
|
SendRunningApp(getActivity());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
int setting_other_appInstaller = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.SETTING_OTHER_APPINSTALLER_KEY, 1);
|
int setting_other_appInstaller = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.SETTING_OTHER_APPINSTALLER_KEY, 1);
|
||||||
if (setting_other_appInstaller == 0
|
if (setting_other_appInstaller == 0
|
||||||
&& !ApkUtils.isSystemApp(mContext, desktopIcon.getPackageName()
|
&& !ApkUtils.isSystemApp(mContext, desktopIcon.getPackage()
|
||||||
)) {
|
)) {
|
||||||
ToastUtil.show("已禁止应用打开");
|
ToastUtil.show("已禁止应用打开");
|
||||||
} else {
|
} else {
|
||||||
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackageName(), desktopIcon.getClassName());
|
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackage(), desktopIcon.getClazz());
|
||||||
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackageName());
|
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackage());
|
||||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||||
SendRunningApp(getActivity());
|
SendRunningApp(getActivity());
|
||||||
}
|
}
|
||||||
@@ -259,8 +288,12 @@ public class AppListFragment extends BaseFragment {
|
|||||||
public void onLongClick(View v, int index) {
|
public void onLongClick(View v, int index) {
|
||||||
DesktopIcon desktopIcon = mDesktopIcons.get(index);
|
DesktopIcon desktopIcon = mDesktopIcons.get(index);
|
||||||
if (desktopIcon == null) return;
|
if (desktopIcon == null) return;
|
||||||
String pkg = desktopIcon.getPackageName();
|
String pkg = desktopIcon.getPackage();
|
||||||
Log.e(TAG, "onLongClick: " + pkg);
|
Log.e(TAG, "onLongClick: " + pkg);
|
||||||
|
if (desktopIcon instanceof ShortcutPkgInfo) {
|
||||||
|
showShortcutDialog((ShortcutPkgInfo) desktopIcon);
|
||||||
|
return;
|
||||||
|
}
|
||||||
switch (pkg) {
|
switch (pkg) {
|
||||||
case "aios.exit":
|
case "aios.exit":
|
||||||
case "com.uiuios.sn":
|
case "com.uiuios.sn":
|
||||||
@@ -313,9 +346,36 @@ public class AppListFragment extends BaseFragment {
|
|||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showShortcutDialog(ShortcutPkgInfo shortcutPkgInfo) {
|
||||||
|
if (shortcutPkgInfo == null) return;
|
||||||
|
String label = shortcutPkgInfo.getTitle();
|
||||||
|
String pkg = shortcutPkgInfo.getPackage();
|
||||||
|
ShortcutDialog shortcutDialog = new ShortcutDialog(mContext);
|
||||||
|
shortcutDialog.setTitle("删除快捷方式");
|
||||||
|
shortcutDialog.setMessage(label);
|
||||||
|
shortcutDialog.setIconImage(shortcutPkgInfo.getIcon());
|
||||||
|
shortcutDialog.setAppIconImage(ApkUtils.getAppDrawable(mContext, pkg));
|
||||||
|
shortcutDialog.setOnClickBottomListener(new ShortcutDialog.OnClickBottomListener() {
|
||||||
|
@Override
|
||||||
|
public void onPositiveClick() {
|
||||||
|
if (!ShortcutUtils.getInstance().deleteShortcut(shortcutPkgInfo.getId(), shortcutPkgInfo.getPackageName())) {
|
||||||
|
ToastUtil.show("删除失败");
|
||||||
|
}
|
||||||
|
mContext.sendBroadcast(new Intent(MainActivity.ACTION_PACKAGE_HIDE));
|
||||||
|
shortcutDialog.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNegtiveClick() {
|
||||||
|
shortcutDialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
shortcutDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
private void showHideDialog(DesktopIcon desktopIcon) {
|
private void showHideDialog(DesktopIcon desktopIcon) {
|
||||||
String label = desktopIcon.getLable();
|
String label = desktopIcon.getTitle();
|
||||||
String pkg = desktopIcon.getPackageName();
|
String pkg = desktopIcon.getPackage();
|
||||||
DailyAppDialog dailyAppDialog = new DailyAppDialog(mContext);
|
DailyAppDialog dailyAppDialog = new DailyAppDialog(mContext);
|
||||||
dailyAppDialog.setTitle("移到日常应用");
|
dailyAppDialog.setTitle("移到日常应用");
|
||||||
dailyAppDialog.setMessage(label);
|
dailyAppDialog.setMessage(label);
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package com.uiuios.aios.fragment.home;
|
package com.uiuios.aios.fragment.home;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||||
import com.uiuios.aios.R;
|
import com.uiuios.aios.R;
|
||||||
import com.uiuios.aios.alarm.AlarmClockData;
|
import com.uiuios.aios.alarm.AlarmClockData;
|
||||||
import com.uiuios.aios.alarm.AlarmUtils;
|
|
||||||
import com.uiuios.aios.bean.DesktopIcon;
|
import com.uiuios.aios.bean.DesktopIcon;
|
||||||
import com.uiuios.aios.manager.AppManager;
|
import com.uiuios.aios.manager.AppManager;
|
||||||
import com.uiuios.aios.network.NetInterfaceManager;
|
import com.uiuios.aios.network.NetInterfaceManager;
|
||||||
@@ -57,8 +55,8 @@ public class HomePresenter implements HomeContact.Presenter {
|
|||||||
// desktopIcons.add(desktopIcons.size(), updateDesktopIcon);
|
// desktopIcons.add(desktopIcons.size(), updateDesktopIcon);
|
||||||
|
|
||||||
DesktopIcon desktopIcon = new DesktopIcon();
|
DesktopIcon desktopIcon = new DesktopIcon();
|
||||||
desktopIcon.setLable("添加应用");
|
desktopIcon.setTitle("添加应用");
|
||||||
desktopIcon.setPackageName(AppManager.ADD_NAME);
|
desktopIcon.setPackage(AppManager.ADD_NAME);
|
||||||
desktopIcon.setIcon(mContext.getDrawable(R.drawable.home_icon_add));
|
desktopIcon.setIcon(mContext.getDrawable(R.drawable.home_icon_add));
|
||||||
desktopIcons.add(desktopIcons.size(), desktopIcon);
|
desktopIcons.add(desktopIcons.size(), desktopIcon);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.uiuios.aios.shortcut;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class ShortcutHelper extends SQLiteOpenHelper {
|
||||||
|
private static final String TAG = ShortcutHelper.class.getSimpleName();
|
||||||
|
|
||||||
|
public static final int DATABASE_VERSION = 1;
|
||||||
|
public static final String DATABASE_NAME = "Shortcut.db";
|
||||||
|
// public static final String DATABASE_FILE_NAME = Environment.getExternalStorageDirectory().getPath() + File.separator + DATABASE_NAME;
|
||||||
|
public static final String DATABASE_FILE_NAME = File.separator + DATABASE_NAME;
|
||||||
|
|
||||||
|
public static final String TABLE_ICON = " Icon";
|
||||||
|
|
||||||
|
public static final String KEY_MID = "mId";
|
||||||
|
public static final String KEY_TITLE = "mTitle";
|
||||||
|
public static final String KEY_PACKAGENAME = "mPackageName";
|
||||||
|
public static final String KEY_CLASS = "mClass";
|
||||||
|
public static final String KEY_PACKAGE = "mPackage";
|
||||||
|
public static final String KEY_ICON = "icon";
|
||||||
|
public static final String KEY_TIMESTAMP = "timestamp";
|
||||||
|
|
||||||
|
String CREATE_SHORTCUT_TABLE = "CREATE TABLE IF NOT EXISTS" + TABLE_ICON +
|
||||||
|
"("
|
||||||
|
+ KEY_MID + " TEXT PRIMARY KEY,"
|
||||||
|
+ KEY_TITLE + " TEXT,"
|
||||||
|
+ KEY_PACKAGENAME + " TEXT,"
|
||||||
|
+ KEY_CLASS + " TEXT,"
|
||||||
|
+ KEY_PACKAGE + " TEXT,"
|
||||||
|
+ KEY_ICON + " BLOB,"
|
||||||
|
+ KEY_TIMESTAMP + " LONG"
|
||||||
|
+ ")";
|
||||||
|
|
||||||
|
public ShortcutHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
|
||||||
|
super(context, name, factory, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
db.execSQL(CREATE_SHORTCUT_TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
switch (newVersion) {
|
||||||
|
default:
|
||||||
|
case 1:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.uiuios.aios.shortcut;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
import com.uiuios.aios.bean.DesktopIcon;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class ShortcutPkgInfo extends DesktopIcon implements Serializable {
|
||||||
|
private static final long serialVersionUID = -8142340420690477465L;
|
||||||
|
|
||||||
|
String mId;
|
||||||
|
String mPackageName;//谁创建的
|
||||||
|
|
||||||
|
public ShortcutPkgInfo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShortcutPkgInfo(String id, String title, String packageName, ComponentName componentName, Drawable icon) {
|
||||||
|
mId = id;
|
||||||
|
mTitle = title;
|
||||||
|
mPackageName = packageName;
|
||||||
|
mClass = componentName.getClassName();
|
||||||
|
mPackage = componentName.getPackageName();
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShortcutPkgInfo(String id, String title, String packageName, String aClass, String aPackage, Drawable icon) {
|
||||||
|
mId = id;
|
||||||
|
mTitle = title;
|
||||||
|
mPackageName = packageName;
|
||||||
|
mClass = aClass;
|
||||||
|
mPackage = aPackage;
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return mId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
mId = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPackageName() {
|
||||||
|
return mPackageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackageName(String packageName) {
|
||||||
|
mPackageName = packageName;
|
||||||
|
}
|
||||||
|
}
|
||||||
154
app/src/main/java/com/uiuios/aios/shortcut/ShortcutUtils.java
Normal file
154
app/src/main/java/com/uiuios/aios/shortcut/ShortcutUtils.java
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
package com.uiuios.aios.shortcut;
|
||||||
|
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.PixelFormat;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ShortcutUtils {
|
||||||
|
private static final String TAG = ShortcutUtils.class.getSimpleName();
|
||||||
|
|
||||||
|
private static ShortcutUtils sInstance;
|
||||||
|
private Context mContext;
|
||||||
|
private ShortcutHelper mShortcutHelper;
|
||||||
|
private SQLiteDatabase mDatabase;
|
||||||
|
|
||||||
|
public ShortcutUtils(Context context) {
|
||||||
|
this.mContext = context;
|
||||||
|
// this.mShortcutHelper = new ShortcutHelper(context, ShortcutHelper.DATABASE_FILE_NAME, null, ShortcutHelper.DATABASE_VERSION);
|
||||||
|
this.mShortcutHelper = new ShortcutHelper(context, mContext.getExternalCacheDir() + ShortcutHelper.DATABASE_FILE_NAME, null, ShortcutHelper.DATABASE_VERSION);
|
||||||
|
this.mDatabase = mShortcutHelper.getWritableDatabase();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(Context context) {
|
||||||
|
if (context == null) {
|
||||||
|
throw new RuntimeException("context is NULL");
|
||||||
|
}
|
||||||
|
if (sInstance == null) {
|
||||||
|
sInstance = new ShortcutUtils(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ShortcutUtils getInstance() {
|
||||||
|
if (sInstance == null) {
|
||||||
|
throw new IllegalStateException("You must be init ShortcutUtils first");
|
||||||
|
}
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean addShortcut(ShortcutPkgInfo shortcutPkgInfo) {
|
||||||
|
ContentValues values = getValuesFromShortcutPkgInfo(shortcutPkgInfo);
|
||||||
|
long id = 0;
|
||||||
|
mDatabase.beginTransaction();
|
||||||
|
try {
|
||||||
|
id = mDatabase.insertWithOnConflict(ShortcutHelper.TABLE_ICON, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||||
|
mDatabase.setTransactionSuccessful();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "addShortcut: " + e.getMessage());
|
||||||
|
} finally {
|
||||||
|
mDatabase.endTransaction();
|
||||||
|
}
|
||||||
|
return id > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deleteShortcut(ShortcutPkgInfo shortcutPkgInfo) {
|
||||||
|
if (shortcutPkgInfo == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return deleteShortcut(shortcutPkgInfo.getId(), shortcutPkgInfo.getPackageName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deleteShortcut(String mId, String pkg) {
|
||||||
|
long id = 0;
|
||||||
|
mDatabase.beginTransaction();
|
||||||
|
try {
|
||||||
|
id = mDatabase.delete(ShortcutHelper.TABLE_ICON, " mId = '" + mId + "' and mPackageName = '" + pkg + "'", null);
|
||||||
|
mDatabase.setTransactionSuccessful();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "deleteShortcut: " + e.getMessage());
|
||||||
|
} finally {
|
||||||
|
mDatabase.endTransaction();
|
||||||
|
}
|
||||||
|
return id > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// public boolean deleteShortcut(String mId) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
public List<ShortcutPkgInfo> getShortcutList() {
|
||||||
|
List<ShortcutPkgInfo> list = new ArrayList<>();
|
||||||
|
String selectQuery = "SELECT * FROM " + ShortcutHelper.TABLE_ICON;
|
||||||
|
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
ShortcutPkgInfo shortcutPkgInfo = new ShortcutPkgInfo();
|
||||||
|
shortcutPkgInfo.setId(cursor.getString(0));
|
||||||
|
shortcutPkgInfo.setTitle(cursor.getString(1));
|
||||||
|
shortcutPkgInfo.setPackageName(cursor.getString(2));
|
||||||
|
shortcutPkgInfo.setClass(cursor.getString(3));
|
||||||
|
shortcutPkgInfo.setPackage(cursor.getString(4));
|
||||||
|
shortcutPkgInfo.setIcon(Bytes2Drawable(cursor.getBlob(5)));
|
||||||
|
list.add(shortcutPkgInfo);
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ContentValues getValuesFromShortcutPkgInfo(ShortcutPkgInfo shortcutPkgInfo) {
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(ShortcutHelper.KEY_MID, shortcutPkgInfo.getId());
|
||||||
|
values.put(ShortcutHelper.KEY_TITLE, shortcutPkgInfo.getTitle());
|
||||||
|
values.put(ShortcutHelper.KEY_PACKAGENAME, shortcutPkgInfo.getPackageName());
|
||||||
|
values.put(ShortcutHelper.KEY_CLASS, shortcutPkgInfo.getClazz());
|
||||||
|
values.put(ShortcutHelper.KEY_PACKAGE, shortcutPkgInfo.getPackage());
|
||||||
|
values.put(ShortcutHelper.KEY_ICON, drawableToBitmap(shortcutPkgInfo.getIcon()));
|
||||||
|
values.put(ShortcutHelper.KEY_TIMESTAMP, System.currentTimeMillis());
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] drawableToBitmap(Drawable drawable) {
|
||||||
|
// 取 drawable 的长宽
|
||||||
|
int w = drawable.getIntrinsicWidth();
|
||||||
|
int h = drawable.getIntrinsicHeight();
|
||||||
|
|
||||||
|
// 取 drawable 的颜色格式
|
||||||
|
Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
|
||||||
|
: Bitmap.Config.RGB_565;
|
||||||
|
// 建立对应 bitmap
|
||||||
|
Bitmap bitmap = Bitmap.createBitmap(w, h, config);
|
||||||
|
// 建立对应 bitmap 的画布
|
||||||
|
Canvas canvas = new Canvas(bitmap);
|
||||||
|
drawable.setBounds(0, 0, w, h);
|
||||||
|
// 把 drawable 内容画到画布中
|
||||||
|
drawable.draw(canvas);
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
|
||||||
|
return baos.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable Bytes2Drawable(byte[] b) {
|
||||||
|
if (b.length != 0) {
|
||||||
|
Bitmap bm = BitmapFactory.decodeByteArray(b, 0, b.length);
|
||||||
|
BitmapDrawable bd = new BitmapDrawable(mContext.getResources(), bm);
|
||||||
|
return bd;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import android.content.pm.PackageInfo;
|
|||||||
import android.content.pm.PackageInstaller;
|
import android.content.pm.PackageInstaller;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -19,11 +20,12 @@ import androidx.annotation.RequiresApi;
|
|||||||
|
|
||||||
import com.uiuios.aios.BuildConfig;
|
import com.uiuios.aios.BuildConfig;
|
||||||
import com.uiuios.aios.R;
|
import com.uiuios.aios.R;
|
||||||
import com.uiuios.aios.activity.QuickAppActivity;
|
|
||||||
import com.uiuios.aios.bean.DesktopIcon;
|
import com.uiuios.aios.bean.DesktopIcon;
|
||||||
import com.uiuios.aios.manager.AppManager;
|
import com.uiuios.aios.manager.AppManager;
|
||||||
import com.uiuios.aios.manager.AppStatusManager;
|
import com.uiuios.aios.manager.AppStatusManager;
|
||||||
import com.uiuios.aios.receiver.InstallResultReceiver;
|
import com.uiuios.aios.receiver.InstallResultReceiver;
|
||||||
|
import com.uiuios.aios.shortcut.ShortcutPkgInfo;
|
||||||
|
import com.uiuios.aios.shortcut.ShortcutUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@@ -36,7 +38,6 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
@@ -159,7 +160,7 @@ public class ApkUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ArrayList<DesktopIcon> queryFilterAppInfo(Context context) {
|
public static ArrayList<DesktopIcon> queryFilterAppInfo(Context context) {
|
||||||
List<String> quickApps= new ArrayList<>(AppManager.getInstance().getAddPackages());
|
List<String> quickApps = new ArrayList<>(AppManager.getInstance().getAddPackages());
|
||||||
|
|
||||||
PackageManager pm = context.getPackageManager();
|
PackageManager pm = context.getPackageManager();
|
||||||
// 查询所有已经安装的应用程序
|
// 查询所有已经安装的应用程序
|
||||||
@@ -245,23 +246,25 @@ public class ApkUtils {
|
|||||||
desktopIcons.add(DesktopIcon.creatDesktopIcon(context, applicationInfo));
|
desktopIcons.add(DesktopIcon.creatDesktopIcon(context, applicationInfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
List<ShortcutPkgInfo> shortcutPkgInfos = ShortcutUtils.getInstance().getShortcutList();
|
||||||
|
desktopIcons.addAll(shortcutPkgInfos);
|
||||||
|
|
||||||
DesktopIcon dailyIcon = new DesktopIcon();
|
DesktopIcon dailyIcon = new DesktopIcon();
|
||||||
dailyIcon.setIcon(context.getDrawable(R.drawable.icon_daily_app));
|
dailyIcon.setIcon(context.getDrawable(R.drawable.icon_daily_app));
|
||||||
dailyIcon.setLable("日常应用");
|
dailyIcon.setTitle("日常应用");
|
||||||
dailyIcon.setPackageName("aios.daily.app");
|
dailyIcon.setPackage("aios.daily.app");
|
||||||
desktopIcons.add(0, dailyIcon);
|
desktopIcons.add(0, dailyIcon);
|
||||||
|
|
||||||
DesktopIcon familyIcon = new DesktopIcon();
|
DesktopIcon familyIcon = new DesktopIcon();
|
||||||
familyIcon.setIcon(context.getDrawable(R.drawable.com_android_appstore));
|
familyIcon.setIcon(context.getDrawable(R.drawable.com_android_appstore));
|
||||||
familyIcon.setLable("应用市场");
|
familyIcon.setTitle("应用市场");
|
||||||
familyIcon.setPackageName("aios.appstore");
|
familyIcon.setPackage("aios.appstore");
|
||||||
desktopIcons.add(1, familyIcon);
|
desktopIcons.add(1, familyIcon);
|
||||||
|
|
||||||
DesktopIcon exitIcon = new DesktopIcon();
|
DesktopIcon exitIcon = new DesktopIcon();
|
||||||
exitIcon.setIcon(context.getDrawable(R.drawable.exit_icon));
|
exitIcon.setIcon(context.getDrawable(R.drawable.exit_icon));
|
||||||
exitIcon.setLable("切换系统");
|
exitIcon.setTitle("切换系统");
|
||||||
exitIcon.setPackageName("aios.exit");
|
exitIcon.setPackage("aios.exit");
|
||||||
desktopIcons.add(exitIcon);
|
desktopIcons.add(exitIcon);
|
||||||
|
|
||||||
return desktopIcons;
|
return desktopIcons;
|
||||||
@@ -341,6 +344,24 @@ public class ApkUtils {
|
|||||||
return applicationInfo;
|
return applicationInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Drawable getAppDrawable(Context context, String pkg) {
|
||||||
|
if (context==null||TextUtils.isEmpty(pkg)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
PackageManager packageManager = context.getPackageManager();
|
||||||
|
ApplicationInfo applicationInfo = null;
|
||||||
|
try {
|
||||||
|
applicationInfo = packageManager.getApplicationInfo(pkg, 0);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (applicationInfo != null) {
|
||||||
|
return applicationInfo.loadIcon(packageManager);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void openApp(Context context, String packageName) {
|
public static void openApp(Context context, String packageName) {
|
||||||
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);
|
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
|
|||||||
85
app/src/main/res/layout/add_item_confirmation_activity.xml
Normal file
85
app/src/main/res/layout/add_item_confirmation_activity.xml
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout 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">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="@dimen/dp_280"
|
||||||
|
android:layout_height="@dimen/dp_200"
|
||||||
|
android:background="@drawable/bg_dialog"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_app_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/dp_16"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textSize="@dimen/sp_11"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:text="appName" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_icon"
|
||||||
|
android:layout_width="@dimen/dp_64"
|
||||||
|
android:layout_height="@dimen/dp_64"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/constraintLayout16"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/tv_app_name" />
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/constraintLayout16"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/dp_32"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_add"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/dp_24"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/default_button_bg"
|
||||||
|
android:gravity="center"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="@dimen/sp_11"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
android:text="添加" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_cancel"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/dp_24"
|
||||||
|
android:layout_marginStart="@dimen/dp_48"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/default_button_cancel_bg"
|
||||||
|
android:gravity="center"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="@dimen/sp_11"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/tv_add"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.0"
|
||||||
|
android:text="取消" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
139
app/src/main/res/layout/dialog_shortcut.xml
Normal file
139
app/src/main/res/layout/dialog_shortcut.xml
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout 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:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="@dimen/dp_300"
|
||||||
|
android:layout_height="@dimen/dp_200"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:background="@drawable/bg_dialog"
|
||||||
|
android:minWidth="@dimen/dp_240"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="@dimen/dp_8"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/linearLayout2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/dp_8"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="@dimen/sp_18"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:visibility="visible"
|
||||||
|
tools:text="消息提示" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/linearLayout3"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/linearLayout2">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_icon"
|
||||||
|
android:layout_width="@dimen/dp_40"
|
||||||
|
android:layout_height="@dimen/dp_40"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:src="@mipmap/ic_launcher" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_app_icon"
|
||||||
|
android:layout_width="@dimen/dp_16"
|
||||||
|
android:layout_height="@dimen/dp_16"
|
||||||
|
android:layout_marginStart="@dimen/dp_26"
|
||||||
|
android:layout_marginTop="@dimen/dp_26"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/iv_icon"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:src="@mipmap/ic_launcher" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/message"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/dp_20"
|
||||||
|
android:layout_marginTop="@dimen/dp_16"
|
||||||
|
android:layout_marginEnd="@dimen/dp_20"
|
||||||
|
android:gravity="center"
|
||||||
|
android:lineSpacingExtra="@dimen/dp_3"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="#999999"
|
||||||
|
android:textSize="@dimen/sp_14"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/iv_icon"
|
||||||
|
tools:text="app" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/linearLayout3"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/dp_56"
|
||||||
|
android:layout_marginEnd="@dimen/dp_56"
|
||||||
|
android:layout_marginBottom="@dimen/dp_20"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/positive"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/dp_28"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/default_button_bg"
|
||||||
|
android:gravity="center"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="@dimen/sp_14"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:text="确定" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/negtive"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/dp_28"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/default_button_cancel_bg"
|
||||||
|
android:gravity="center"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="@dimen/sp_14"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:text="取消" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -17,37 +17,37 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<!-- <ImageView-->
|
<!-- <ImageView-->
|
||||||
<!-- android:layout_width="2px"-->
|
<!-- android:layout_width="2px"-->
|
||||||
<!-- android:layout_height="0dp"-->
|
<!-- android:layout_height="0dp"-->
|
||||||
<!-- android:background="@color/line_color"-->
|
<!-- android:background="@color/line_color"-->
|
||||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
<!-- app:layout_constraintTop_toTopOf="parent" />-->
|
<!-- app:layout_constraintTop_toTopOf="parent" />-->
|
||||||
|
|
||||||
<!-- <ImageView-->
|
<!-- <ImageView-->
|
||||||
<!-- android:layout_width="2px"-->
|
<!-- android:layout_width="2px"-->
|
||||||
<!-- android:layout_height="0dp"-->
|
<!-- android:layout_height="0dp"-->
|
||||||
<!-- android:background="@color/line_color"-->
|
<!-- android:background="@color/line_color"-->
|
||||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
<!-- app:layout_constraintTop_toTopOf="parent" />-->
|
<!-- app:layout_constraintTop_toTopOf="parent" />-->
|
||||||
|
|
||||||
<!-- <ImageView-->
|
<!-- <ImageView-->
|
||||||
<!-- android:layout_width="0dp"-->
|
<!-- android:layout_width="0dp"-->
|
||||||
<!-- android:layout_height="2px"-->
|
<!-- android:layout_height="2px"-->
|
||||||
<!-- android:background="@color/line_color"-->
|
<!-- android:background="@color/line_color"-->
|
||||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
<!-- app:layout_constraintTop_toTopOf="parent" />-->
|
<!-- app:layout_constraintTop_toTopOf="parent" />-->
|
||||||
|
|
||||||
<!-- <ImageView-->
|
<!-- <ImageView-->
|
||||||
<!-- android:layout_width="0dp"-->
|
<!-- android:layout_width="0dp"-->
|
||||||
<!-- android:layout_height="2px"-->
|
<!-- android:layout_height="2px"-->
|
||||||
<!-- android:background="@color/line_color"-->
|
<!-- android:background="@color/line_color"-->
|
||||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/iv"
|
android:id="@+id/iv"
|
||||||
@@ -60,6 +60,18 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_app"
|
||||||
|
android:layout_width="@dimen/dp_24"
|
||||||
|
android:layout_height="@dimen/dp_24"
|
||||||
|
android:layout_marginStart="@dimen/dp_28"
|
||||||
|
android:layout_marginTop="@dimen/dp_28"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/iv"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/iv" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/bg"
|
android:id="@+id/bg"
|
||||||
android:layout_width="@dimen/dp_20"
|
android:layout_width="@dimen/dp_20"
|
||||||
@@ -68,10 +80,10 @@
|
|||||||
android:layout_marginBottom="@dimen/dp_36"
|
android:layout_marginBottom="@dimen/dp_36"
|
||||||
android:background="@drawable/badge_bg"
|
android:background="@drawable/badge_bg"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:maxLines="1"
|
||||||
android:minWidth="@dimen/dp_20"
|
android:minWidth="@dimen/dp_20"
|
||||||
android:minHeight="@dimen/dp_20"
|
android:minHeight="@dimen/dp_20"
|
||||||
android:text="1"
|
android:text="1"
|
||||||
android:maxLines="1"
|
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="@dimen/sp_10"
|
android:textSize="@dimen/sp_10"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
|||||||
@@ -7,4 +7,8 @@
|
|||||||
<!-- TODO: Remove or change this placeholder text -->
|
<!-- TODO: Remove or change this placeholder text -->
|
||||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
|
|
||||||
|
<string name="permdesc_install_shortcut" msgid="923466509822011139">"允许应用自行添加快捷方式。"</string>
|
||||||
|
<string name="permlab_install_shortcut" msgid="5632423390354674437">"安装快捷方式"</string>
|
||||||
|
<string name="action_add_to_workspace" msgid="8902165848117513641">"添加到主屏幕"</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
<!--是否浮现在activity之上-->
|
<!--是否浮现在activity之上-->
|
||||||
<item name="android:windowIsFloating">false</item>
|
<item name="android:windowIsFloating">false</item>
|
||||||
<!--是否半透明-->
|
<!--是否半透明-->
|
||||||
<!-- <item name="android:windowIsTranslucent">true</item>-->
|
<item name="android:windowIsTranslucent">true</item>
|
||||||
<!--设置窗口内容不覆盖-->
|
<!--设置窗口内容不覆盖-->
|
||||||
<item name="android:windowContentOverlay">@null</item>
|
<item name="android:windowContentOverlay">@null</item>
|
||||||
<!--设置动画,在这里使用让它继承系统的Animation.Dialog-->
|
<!--设置动画,在这里使用让它继承系统的Animation.Dialog-->
|
||||||
|
|||||||
Reference in New Issue
Block a user