feat(ui): 添加壁纸设置与重置工具类
This commit is contained in:
36
build.gradle
36
build.gradle
@@ -159,6 +159,15 @@ android {
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
iPlay50miniPro {
|
||||
storeFile file("keystore/iPlay50miniPro.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "iplay50minipro"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
G10P {
|
||||
storeFile file("keystore/G10PMTK11.jks")
|
||||
storePassword "123456"
|
||||
@@ -265,6 +274,15 @@ android {
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
SM8150 {
|
||||
storeFile file("keystore/sm8150.jks")
|
||||
storePassword "logan-123456789"
|
||||
keyAlias "platformkey"
|
||||
keyPassword "logan-123456789"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@@ -315,13 +333,13 @@ android {
|
||||
buildConfigField "String", "platform", '"QualcommA"'
|
||||
versionNameSuffix "_debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.zhanRui
|
||||
signingConfig signingConfigs.SM8150
|
||||
}
|
||||
|
||||
QualcommRelease.initWith(release)
|
||||
QualcommRelease {
|
||||
buildConfigField "String", "platform", '"QualcommA"'
|
||||
signingConfig signingConfigs.zhanRui
|
||||
signingConfig signingConfigs.SM8150
|
||||
}
|
||||
|
||||
G128TDebug.initWith(debug)
|
||||
@@ -492,6 +510,20 @@ android {
|
||||
signingConfig signingConfigs.G10P
|
||||
}
|
||||
|
||||
iPlay50miniProDebug.initWith(debug)
|
||||
iPlay50miniProDebug {
|
||||
buildConfigField "String", "platform", '"miniG99"'
|
||||
versionNameSuffix "_debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.iPlay50miniPro
|
||||
}
|
||||
|
||||
iPlay50miniProRelease.initWith(release)
|
||||
iPlay50miniProRelease {
|
||||
buildConfigField "String", "platform", '"miniG99"'
|
||||
signingConfig signingConfigs.iPlay50miniPro
|
||||
}
|
||||
|
||||
zhanRuiDebug.initWith(debug)
|
||||
zhanRuiDebug {
|
||||
versionNameSuffix "_debug"
|
||||
|
||||
@@ -47,6 +47,8 @@ android {
|
||||
c2Release {}
|
||||
G104Debug {}
|
||||
G104Release {}
|
||||
iPlay50miniProDebug {}
|
||||
iPlay50miniProRelease {}
|
||||
G10PDebug {}
|
||||
G10PRelease {}
|
||||
zhanRuiDebug {}
|
||||
|
||||
BIN
keystore/iPlay50miniPro.jks
Normal file
BIN
keystore/iPlay50miniPro.jks
Normal file
Binary file not shown.
BIN
keystore/sm8150.jks
Normal file
BIN
keystore/sm8150.jks
Normal file
Binary file not shown.
@@ -485,10 +485,12 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
|
||||
try {
|
||||
if ("Aiud_A8_ag_1095".equals(Build.MODEL)
|
||||
||JgyUtils.getInstance().checkAppPlatform() == JgyUtils.seewoPlatform
|
||||
|| JgyUtils.getInstance().checkAppPlatform() == JgyUtils.seewoPlatform
|
||||
) {
|
||||
wallpaperManager.setBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.wallpapers_aiudu));
|
||||
}else {
|
||||
// } else if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.QualcommPlatform) {
|
||||
// wallpaperManager.clear();
|
||||
} else {
|
||||
wallpaperManager.setBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.wallpapers));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -208,6 +208,8 @@ public class NetInterfaceManager {
|
||||
set.add(JgyUtils.AUDG104Tag);
|
||||
} else if (platform == JgyUtils.seewoPlatform) {
|
||||
set.add(JgyUtils.seewoTag);
|
||||
} else if (platform == JgyUtils.QualcommPlatform) {
|
||||
set.add(JgyUtils.Qualcomm_TAG);
|
||||
} else if (platform == JgyUtils.DX11Platform) {
|
||||
set.add(JgyUtils.DX11_TAG);
|
||||
} else if (platform == JgyUtils.G12NLPlatform) {
|
||||
|
||||
@@ -45,6 +45,7 @@ public class JgyUtils {
|
||||
public static final int MT8768Platform = 17;
|
||||
public static final int AUDG104Platform = 18;
|
||||
public static final int seewoPlatform = 25;
|
||||
public static final int QualcommPlatform = 30;
|
||||
public static final int DX11Platform = 31;
|
||||
public static final int G12NLPlatform = 32;
|
||||
|
||||
@@ -65,6 +66,7 @@ public class JgyUtils {
|
||||
public static final String MT8768Tag = "MT8768";
|
||||
public static final String AUDG104Tag = "AUDG104";
|
||||
public static final String seewoTag = "seewo";
|
||||
public static final String Qualcomm_TAG = "QualcommA";
|
||||
public static final String DX11_TAG = "DX11";
|
||||
public static final String G12NL_TAG = "G12NL";
|
||||
|
||||
@@ -125,7 +127,10 @@ public class JgyUtils {
|
||||
} else if (seewoTag.equalsIgnoreCase(platform)) {
|
||||
Log.i(TAG, "checkAppPlatform: " + "seewo");
|
||||
return seewoPlatform;
|
||||
} else if (DX11_TAG.equalsIgnoreCase(platform)) {
|
||||
}else if (Qualcomm_TAG.equalsIgnoreCase(platform)) {
|
||||
Log.i(TAG, "checkAppPlatform: " + "QualcommA");
|
||||
return QualcommPlatform;
|
||||
} else if (DX11_TAG.equalsIgnoreCase(platform)) {
|
||||
Log.i(TAG, "checkAppPlatform: " + "DX11");
|
||||
return DX11Platform;
|
||||
} else if (G12NL_TAG.equalsIgnoreCase(platform)) {
|
||||
@@ -165,6 +170,8 @@ public class JgyUtils {
|
||||
getAppPlatformCallback.AppPlatform(AUDG104Platform);
|
||||
} else if (seewoTag.equalsIgnoreCase(platform)) {
|
||||
getAppPlatformCallback.AppPlatform(seewoPlatform);
|
||||
} else if (Qualcomm_TAG.equalsIgnoreCase(platform)) {
|
||||
getAppPlatformCallback.AppPlatform(QualcommPlatform);
|
||||
} else if (DX11_TAG.equalsIgnoreCase(platform)) {
|
||||
getAppPlatformCallback.AppPlatform(DX11Platform);
|
||||
} else if (G12NL_TAG.equalsIgnoreCase(platform)) {
|
||||
|
||||
120
src/com/aoleyun/os/uiuiutils/WallpaperUtils.java
Normal file
120
src/com/aoleyun/os/uiuiutils/WallpaperUtils.java
Normal file
@@ -0,0 +1,120 @@
|
||||
package com.aoleyun.os.uiuiutils;
|
||||
|
||||
import android.app.WallpaperManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.content.Context;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class WallpaperUtils {
|
||||
|
||||
|
||||
/**
|
||||
* @param lockOnly true=仅锁屏;false=按 flags 控制
|
||||
* @param flags 0 使用传统 setBitmap(主屏);
|
||||
* WallpaperManager.FLAG_SYSTEM 主屏;
|
||||
* WallpaperManager.FLAG_LOCK 锁屏;
|
||||
* 可组合 FLAG_SYSTEM|FLAG_LOCK
|
||||
*/
|
||||
public static void setBitmapAsWallpaper(final Context context,
|
||||
final Bitmap bmp,
|
||||
final boolean lockOnly,
|
||||
final int flags) {
|
||||
new AsyncTask<Void, Void, Boolean>() {
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... v) {
|
||||
try {
|
||||
WallpaperManager wm = WallpaperManager.getInstance(context);
|
||||
if (lockOnly && android.os.Build.VERSION.SDK_INT >= 24) {
|
||||
wm.setBitmap(bmp, null, true, WallpaperManager.FLAG_LOCK);
|
||||
} else if (flags != 0 && android.os.Build.VERSION.SDK_INT >= 24) {
|
||||
wm.setBitmap(bmp, null, true, flags);
|
||||
} else {
|
||||
wm.setBitmap(bmp); // 传统:设置主屏壁纸
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
Log.e("Wallpaper", "set failed", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
// 获取当前主屏壁纸并重新设置(相当于“重设当前壁纸”)
|
||||
public static void reapplyCurrentWallpaper(Context context) {
|
||||
new AsyncTask<Void, Void, Bitmap>() {
|
||||
@Override
|
||||
protected Bitmap doInBackground(Void... voids) {
|
||||
try {
|
||||
WallpaperManager wm = WallpaperManager.getInstance(context);
|
||||
Drawable d = wm.getDrawable(); // 当前系统壁纸,无则返回默认 [11](@ref)
|
||||
if (d instanceof BitmapDrawable) {
|
||||
return ((BitmapDrawable) d).getBitmap();
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Bitmap bmp) {
|
||||
if (bmp == null) return;
|
||||
setBitmapAsWallpaper(context, bmp, false, 0);
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
public static void reapplyLockWallpaper(Context context) {
|
||||
if (android.os.Build.VERSION.SDK_INT < 24) return;
|
||||
new AsyncTask<Void, Void, Bitmap>() {
|
||||
@Override
|
||||
protected Bitmap doInBackground(Void... v) {
|
||||
try {
|
||||
WallpaperManager wm = WallpaperManager.getInstance(context);
|
||||
ParcelFileDescriptor pfd = wm.getWallpaperFile(WallpaperManager.FLAG_LOCK);
|
||||
if (pfd == null) {
|
||||
pfd = wm.getWallpaperFile(WallpaperManager.FLAG_SYSTEM);
|
||||
}
|
||||
if (pfd == null) return null;
|
||||
Bitmap bmp = BitmapFactory.decodeFileDescriptor(pfd.getFileDescriptor());
|
||||
pfd.close();
|
||||
return bmp;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onPostExecute(Bitmap bmp) {
|
||||
if (bmp != null) setBitmapAsWallpaper(context, bmp, true, 0);
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
public static void applyBuiltInDefault(Context context) {
|
||||
new AsyncTask<Void, Void, Bitmap>() {
|
||||
@Override
|
||||
protected Bitmap doInBackground(Void... v) {
|
||||
WallpaperManager wm = WallpaperManager.getInstance(context);
|
||||
Drawable d = wm.getBuiltInDrawable(); // 框架内置默认壁纸
|
||||
if (d instanceof BitmapDrawable) {
|
||||
return ((BitmapDrawable) d).getBitmap();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Bitmap bmp) {
|
||||
if (bmp != null) setBitmapAsWallpaper(context, bmp, false, 0);
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user