Loading Android.mk +17 −69 Original line number Diff line number Diff line 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/) # 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 .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) # SDK Version for this build. LOCAL_SDK_VERSION := current include $(CLEAR_VARS) 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 # 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) LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) include $(BUILD_PREBUILT) include $(CLEAR_VARS) No newline at end of file # 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)) app/src/main/AndroidManifest.xml +0 −1 Original line number Diff line number Diff line Loading @@ -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 Loading app/src/main/ic_test-web.png 0 → 100644 +25.5 KiB Loading image diff... app/src/main/java/org/indin/blisslaunchero/framework/AdaptiveIconProvider.java 0 → 100644 +186 −0 Original line number Diff line number Diff line 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; } } } app/src/main/java/org/indin/blisslaunchero/framework/DeviceProfile.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading
Android.mk +17 −69 Original line number Diff line number Diff line 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/) # 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 .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) # SDK Version for this build. LOCAL_SDK_VERSION := current include $(CLEAR_VARS) 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 # 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) LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) include $(BUILD_PREBUILT) include $(CLEAR_VARS) No newline at end of file # 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))
app/src/main/AndroidManifest.xml +0 −1 Original line number Diff line number Diff line Loading @@ -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 Loading
app/src/main/java/org/indin/blisslaunchero/framework/AdaptiveIconProvider.java 0 → 100644 +186 −0 Original line number Diff line number Diff line 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; } } }
app/src/main/java/org/indin/blisslaunchero/framework/DeviceProfile.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; Loading