Commit 0726e13e authored by Amit Kumar's avatar Amit Kumar
Browse files

Move to develop branch

parent e4338e4b
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
# Module_Tags controls what build flavors the package gets included in.
LOCAL_MODULE_TAGS := optional
# Package name of the app.
LOCAL_PACKAGE_NAME := BlissLauncher
# Certificate to use to sign the apk. In this case, sign using platform certificate.
LOCAL_CERTIFICATE := platform
LOCAL_DEX_PREOPT := false
# Enable or disable proguard.
LOCAL_PROGUARD_ENABLED := disabled
# Manifest file for this app.
LOCAL_MANIFEST_FILE := app/src/main/AndroidManifest.xml
# Resource directory for this app.
LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/app/src/main/res/
ifeq ($(TARGET_BUILD_APPS),)
LOCAL_RESOURCE_DIR += frameworks/support/v7/appcompat/res
LOCAL_RESOURCE_DIR += frameworks/support/v7/gridlayout/res
else
LOCAL_RESOURCE_DIR += prebuilts/sdk/current/support/v7/appcompat/res
LOCAL_RESOURCE_DIR += prebuilts/sdk/current/support/v7/gridlayout/res
endif
# Java source directory for this app.
LOCAL_SRC_FILES := $(call all-java-files-under, app/src/main/)
LOCAL_PATH := $(call my-dir)
# Unbundled java libraries.
LOCAL_STATIC_JAVA_LIBRARIES := \
android-common \
android-support-v4 \
android-support-v7-appcompat \
android-support-v7-gridlayout \
rxrelay \
rxjava
LOCAL_GRADLE_PROJECT_NAME := BlissLauncherO
submodule_path := $(LOCAL_PATH)/$(LOCAL_GRADLE_PROJECT_NAME)
apk_relative_path := app/build/outputs/apk/debug/app-debug.apk
PRIVATE_SRC_FILES := $(LOCAL_GRADLE_PROJECT_NAME)/$(apk_relative_path)
# Unbundled aar libraries.
LOCAL_STATIC_JAVA_AAR_LIBRARIES := rxandroid \
calligraphy \
circleindicator
# SDK Version for this build.
LOCAL_SDK_VERSION := current
LOCAL_PRIVILEGED_MODULE := true
# Flags for AAPT.
LOCAL_AAPT_FLAGS := --auto-add-overlay \
--extra-packages android.support.v4 \
--extra-packages android.support.v7.appcompat \
--extra-packages android.support.v7.gridlayout \
--extra-packages uk.co.chrisjenx.calligraphy \
--extra-packages me.relex.circleindicator
include $(BUILD_PACKAGE)
.PHONY: $(submodule_path)/$(apk_relative_path)
$(submodule_path)/$(apk_relative_path) :
PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" PRODUCT_AAPT_PREF_CONFIG="$(PRODUCT_AAPT_PREF_CONFIG)" PRODUCT_LOCALES="$(PRODUCT_LOCALES)" $(submodule_path)/gradlew assembleDebug -p $(submodule_path)
include $(CLEAR_VARS)
# Prebuilt java and aar libraries.
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := rxrelay:libs/rxrelay-2.0.0.jar \
rxjava:libs/rxjava-2.1.10.jar \
rxandroid:libs/rxandroid-2.0.2.aar \
circleindicator:libs/circleindicator-1.2.2.aar \
calligraphy:libs/calligraphy-2.3.0.aar
include $(BUILD_MULTI_PREBUILT)
# Use the following include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := $(notdir $(LOCAL_PATH))
LOCAL_MODULE_CLASS := APPS
LOCAL_SRC_FILES := $(PRIVATE_SRC_FILES)
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_PRIVILEGED_MODULE := true
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
\ No newline at end of file
......@@ -15,7 +15,6 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
......
package org.indin.blisslaunchero.framework;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.graphics.drawable.Drawable;
import android.support.v4.content.res.ResourcesCompat;
import android.util.Log;
import org.indin.blisslaunchero.framework.customviews.AdaptiveIconDrawableCompat;
import org.indin.blisslaunchero.framework.util.ResourceUtils;
import org.xmlpull.v1.XmlPullParser;
/**
* Created by falcon on 19/4/18.
*/
public class AdaptiveIconProvider {
private static final String TAG = "AdaptiveIconProvider";
private static final String ANDROID_SCHEMA = "http://schemas.android.com/apk/res/android";
private static final String[] IC_DIRS = new String[]{"mipmap", "drawable"};
private static final String[] IC_CONFIGS = new String[]{"-anydpi-v26", "-v26", ""};
public Drawable load(Context context, String packageName) {
if (context == null) {
throw new IllegalStateException(
"Loader.with(Context) must be called before loading an icon.");
}
PackageManager packageManager = context.getPackageManager();
Drawable background = null, foreground = null;
try {
Resources resources = packageManager.getResourcesForApplication(packageName);
Resources.Theme theme = resources.newTheme();
ResourceUtils.setFakeConfig(resources, 26); //Build.VERSION_CODES.O = 26
AssetManager assetManager = resources.getAssets();
XmlResourceParser manifestParser = null;
String iconName = null;
int iconId = 0;
try {
manifestParser = assetManager.openXmlResourceParser("AndroidManifest.xml");
int eventType;
String matcher = "application";
while ((eventType = manifestParser.nextToken()) != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG && manifestParser.getName().equals(
matcher)) {
iconId = manifestParser.getAttributeResourceValue(
ANDROID_SCHEMA, "icon",
0);
if (iconId != 0) {
iconName = resources.getResourceName(iconId);
if (iconName.contains("/")) {
iconName = iconName.split("/")[1];
}
break;
}
if (iconId == 0) {
matcher = "activity";
}
}
}
manifestParser.close();
} catch (Exception e) {
}
XmlResourceParser parser = null;
for (int dir = 0; dir < IC_DIRS.length && parser == null; dir++) {
for (int config = 0; config < IC_CONFIGS.length && parser == null; config++) {
for (String name : iconName != null && !iconName.equals("ic_launcher")
? new String[]{iconName, "ic_launcher"} : new String[]{"ic_launcher"}) {
try {
parser = assetManager.openXmlResourceParser(
"res/" + IC_DIRS[dir] + IC_CONFIGS[config] + "/" + name
+ ".xml");
} catch (Exception e) {
continue;
}
if (parser != null) {
break;
}
}
}
}
int backgroundRes = -1, foregroundRes = -1;
if (parser != null) {
int event;
while ((event = parser.getEventType()) != XmlPullParser.END_DOCUMENT) {
Log.i(TAG, packageName + ":parserName: " + parser.getName()+" "+parser.getAttributeCount());
if (event == XmlPullParser.START_TAG) {
switch (parser.getName()) {
case "background":
try {
backgroundRes = parser.getAttributeResourceValue(
"http://schemas.android.com/apk/res/android",
"drawable", 0);
} catch (Exception e) {
try {
backgroundRes = parser.getAttributeResourceValue(
"http://schemas.android.com/apk/res/android",
"mipmap", 0);
} catch (Exception e1) {
}
}
break;
case "foreground":
try {
foregroundRes = parser.getAttributeResourceValue(
"http://schemas.android.com/apk/res/android",
"drawable", 0);
} catch (Exception e) {
try {
foregroundRes = parser.getAttributeResourceValue(
"http://schemas.android.com/apk/res/android",
"mipmap", 0);
} catch (Exception e1) {
}
}
break;
}
}
parser.next();
}
parser.close();
}
if (background == null && backgroundRes != 0) {
try {
background = ResourcesCompat.getDrawable(resources, backgroundRes, theme);
} catch (Resources.NotFoundException e) {
try {
background = ResourcesCompat.getDrawable(resources,
resources.getIdentifier("ic_launcher_background", "mipmap",
packageName), theme);
} catch (Resources.NotFoundException e1) {
try {
background = ResourcesCompat.getDrawable(resources,
resources.getIdentifier("ic_launcher_background", "drawable",
packageName), theme);
} catch (Resources.NotFoundException e2) {
}
}
}
}
if (foreground == null) {
try {
foreground = ResourcesCompat.getDrawable(resources, foregroundRes, theme);
} catch (Resources.NotFoundException e) {
try {
foreground = ResourcesCompat.getDrawable(resources,
resources.getIdentifier("ic_launcher_foreground", "mipmap",
packageName), theme);
} catch (Resources.NotFoundException e1) {
try {
foreground = ResourcesCompat.getDrawable(resources,
resources.getIdentifier("ic_launcher_foreground", "drawable",
packageName), theme);
} catch (Resources.NotFoundException e2) {
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (foreground != null && background != null) {
return new AdaptiveIconDrawableCompat(background, foreground);
} else {
Log.i(TAG, packageName + "load: " + (foreground == null) + " " + (background == null));
return null;
}
}
}
......@@ -14,7 +14,7 @@ import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
import org.indin.blisslaunchero.framework.customviews.AdaptiveIconUtils;
import org.indin.blisslaunchero.framework.util.AdaptiveIconUtils;
import org.indin.blisslaunchero.framework.customviews.PathParser;
import java.util.ArrayList;
......
......@@ -18,20 +18,23 @@ public class Utilities {
public static final String AUTHORITY = (BuildConfig.APPLICATION_ID + ".settings").intern();
/**
* Use hard coded values to compile with android source.
*/
public static final boolean ATLEAST_OREO =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
Build.VERSION.SDK_INT >= 26;
public static final boolean ATLEAST_NOUGAT_MR1 =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1;
Build.VERSION.SDK_INT >= 25;
public static final boolean ATLEAST_NOUGAT =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
Build.VERSION.SDK_INT >= 24;
public static final boolean ATLEAST_MARSHMALLOW =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
Build.VERSION.SDK_INT >= 23;
public static final boolean ATLEAST_LOLLIPOP_MR1 =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1;
Build.VERSION.SDK_INT >=22;
/**
* Compresses the bitmap to a byte array for serialization.
......
package org.indin.blisslaunchero.framework.customviews;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
......@@ -24,17 +20,14 @@ import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Shader;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.res.ResourcesCompat;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import org.indin.blisslaunchero.framework.util.ResourceUtils;
import org.indin.blisslaunchero.framework.util.AdaptiveIconUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
......@@ -107,10 +100,6 @@ public class AdaptiveIconDrawableCompat extends Drawable implements Drawable.Cal
private static final int BACKGROUND_ID = 0;
private static final int FOREGROUND_ID = 1;
private static final String ANDROID_SCHEMA = "http://schemas.android.com/apk/res/android";
private static final String[] IC_DIRS = new String[]{"mipmap", "drawable"};
private static final String[] IC_CONFIGS = new String[]{"-anydpi-v26", "-v26", ""};
/**
* State variable that maintains the {@link ChildDrawable} array.
*/
......@@ -134,10 +123,12 @@ public class AdaptiveIconDrawableCompat extends Drawable implements Drawable.Cal
private boolean mUseMyUglyWorkaround = true;
private static final String TAG = "AdaptiveIconDrawable";
/**
* Constructor used for xml inflation.
*/
public AdaptiveIconDrawableCompat() throws Exception {
public AdaptiveIconDrawableCompat() {
this((LayerState) null, null);
}
......@@ -563,7 +554,7 @@ public class AdaptiveIconDrawableCompat extends Drawable implements Drawable.Cal
final TypedValue value = new TypedValue();
a.getValue(index, value);
if (value.resourceId != 0) {
return a.getResources().getDrawableForDensity(value.resourceId, 480, null);
return a.getResources().getDrawableForDensity(value.resourceId, DisplayMetrics.DENSITY_DEFAULT, null);
}
return null;
}
......@@ -1102,161 +1093,4 @@ public class AdaptiveIconDrawableCompat extends Drawable implements Drawable.Cal
mCheckedStateful = false;
}
}
public static AdaptiveIconDrawableCompat load(Context context, String packageName) {
if (context == null) {
throw new IllegalStateException(
"Loader.with(Context) must be called before loading an icon.");
}
PackageManager packageManager = context.getPackageManager();
Drawable background = null, foreground = null;
try {
Resources resources = packageManager.getResourcesForApplication(packageName);
Resources.Theme theme = resources.newTheme();
ResourceUtils.setFakeConfig(resources, Build.VERSION_CODES.O);
AssetManager assetManager = resources.getAssets();
XmlResourceParser manifestParser = null;
String iconName = null;
try {
manifestParser = assetManager.openXmlResourceParser("AndroidManifest.xml");
} catch (Exception e) {
}
if (manifestParser != null) {
int event;
while ((event = manifestParser.getEventType()) != XmlPullParser.END_DOCUMENT) {
if (event == XmlPullParser.START_TAG && manifestParser.getName().equals(
"application")) {
iconName = resources.getResourceName(
manifestParser.getAttributeResourceValue(ANDROID_SCHEMA, "icon",
0));
if (iconName.contains("/")) {
iconName = iconName.split("/")[1];
}
break;
}
manifestParser.next();
}
manifestParser.close();
}
XmlResourceParser parser = null;
for (int dir = 0; dir < IC_DIRS.length && parser == null; dir++) {
for (int config = 0; config < IC_CONFIGS.length && parser == null; config++) {
for (String name : iconName != null && !iconName.equals("ic_launcher")
? new String[]{iconName, "ic_launcher"} : new String[]{"ic_launcher"}) {
try {
parser = assetManager.openXmlResourceParser(
"res/" + IC_DIRS[dir] + IC_CONFIGS[config] + "/" + name
+ ".xml");
} catch (Exception e) {
continue;
}
if (parser != null) {
break;
}
}
}
}
int backgroundRes = -1, foregroundRes = -1;
if (parser != null) {
int event;
while ((event = parser.getEventType()) != XmlPullParser.END_DOCUMENT) {
if (event == XmlPullParser.START_TAG) {
switch (parser.getName()) {
case "background":
for (int dir = 0; dir < IC_DIRS.length; dir++) {
}
try {
backgroundRes = parser.getAttributeResourceValue(
"http://schemas.android.com/apk/res/android",
"drawable", 0);
} catch (Exception e) {
try {
backgroundRes = parser.getAttributeResourceValue(
"http://schemas.android.com/apk/res/android",
"mipmap", 0);
} catch (Exception e1) {
}
}
break;
case "foreground":
try {
foregroundRes = parser.getAttributeResourceValue(
"http://schemas.android.com/apk/res/android",
"drawable", 0);
} catch (Exception e) {
try {
foregroundRes = parser.getAttributeResourceValue(
"http://schemas.android.com/apk/res/android",
"mipmap", 0);
} catch (Exception e1) {
}
}
break;
}
}
parser.next();
}
parser.close();
}
if (background == null && backgroundRes != 0) {
try {
background = ResourcesCompat.getDrawable(resources, backgroundRes, theme);
} catch (Resources.NotFoundException e) {
try {
background = ResourcesCompat.getDrawable(resources,
resources.getIdentifier("ic_launcher_background", "mipmap",
packageName), theme);
} catch (Resources.NotFoundException e1) {
try {
background = ResourcesCompat.getDrawable(resources,
resources.getIdentifier("ic_launcher_background", "drawable",
packageName), theme);
} catch (Resources.NotFoundException e2) {
background = new ColorDrawable(Color.WHITE);
}
}
}
}
if (foreground == null) {
try {
foreground = ResourcesCompat.getDrawable(resources, foregroundRes, theme);
} catch (Resources.NotFoundException e) {
try {
foreground = ResourcesCompat.getDrawable(resources,
resources.getIdentifier("ic_launcher_foreground", "mipmap",
packageName), theme);
} catch (Resources.NotFoundException e1) {
try {
foreground = ResourcesCompat.getDrawable(resources,
resources.getIdentifier("ic_launcher_foreground", "drawable",
packageName), theme);
} catch (Resources.NotFoundException e2) {
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (foreground != null && background != null) {
return new AdaptiveIconDrawableCompat(background, foreground);
} else {
return null;
}
}
}
package org.indin.blisslaunchero.framework.customviews;
package org.indin.blisslaunchero.framework.util;
public class AdaptiveIconUtils {
......
......@@ -18,6 +18,7 @@ import android.util.Log;
import org.indin.blisslaunchero.R;
import org.indin.blisslaunchero.data.model.AppItem;
import org.indin.blisslaunchero.features.launcher.AllAppsList;
import org.indin.blisslaunchero.framework.AdaptiveIconProvider;
import org.indin.blisslaunchero.framework.Utilities;
import org.indin.blisslaunchero.framework.customviews.AdaptiveIconDrawableCompat;
......@@ -63,7 +64,7 @@ public class AppUtil {
}
if (appIcon == null) {