Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2dcff919 authored by Amit Kumar's avatar Amit Kumar
Browse files

Fix #29, #33

parents 331fcf0b 9f9d6103
Loading
Loading
Loading
Loading
Loading
+24 −15
Original line number Diff line number Diff line
package org.indin.blisslaunchero.framework;

import org.indin.blisslaunchero.framework.customviews.AdaptiveIconDrawableCompat;
import org.indin.blisslaunchero.framework.utils.ResourceUtils;
import org.xmlpull.v1.XmlPullParser;

import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
@@ -13,6 +9,10 @@ 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.utils.ResourceUtils;
import org.xmlpull.v1.XmlPullParser;

/**
 * Created by falcon on 19/4/18.
 */
@@ -43,7 +43,7 @@ public class AdaptiveIconProvider {

            XmlResourceParser manifestParser;
            String iconName = null;
            int iconId;
            int iconId = 0;
            try {
                manifestParser = assetManager.openXmlResourceParser("AndroidManifest.xml");
                int eventType;
@@ -52,18 +52,20 @@ public class AdaptiveIconProvider {
                while ((eventType = manifestParser.nextToken()) != XmlPullParser.END_DOCUMENT) {
                    if (eventType == XmlPullParser.START_TAG && manifestParser.getName().equals(
                            matcher)) {
                        iconId = manifestParser.getAttributeResourceValue(
                                ANDROID_SCHEMA, "icon",
                                0);

                        for (int i = 0; i < manifestParser.getAttributeCount(); i++) {
                            if (manifestParser.getAttributeName(i).equalsIgnoreCase("icon")) {
                                iconId = Integer.parseInt(
                                        manifestParser.getAttributeValue(i).substring(1));
                                break;
                            }
                        }
                        if (iconId != 0) {
                            iconName = resources.getResourceName(iconId);
                            if (iconName.contains("/")) {
                                iconName = iconName.split("/")[1];
                            }
                            break;
                        }
                        if (iconId == 0) {
                        } else {
                            matcher = "activity";
                        }
                    }
@@ -73,15 +75,21 @@ public class AdaptiveIconProvider {
            }

            XmlResourceParser parser = null;
            if (iconId != 0) {
                parser = resources.getXml(iconId);
            }

            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");
                            String path = "res/" + IC_DIRS[dir] + IC_CONFIGS[config] + "/" + name
                                    + ".xml";
                            Log.i(TAG, "path: " + path);
                            parser = assetManager.openXmlResourceParser(path);
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }

@@ -96,7 +104,8 @@ public class AdaptiveIconProvider {
            if (parser != null) {
                int event;
                while ((event = parser.getEventType()) != XmlPullParser.END_DOCUMENT) {
                    Log.i(TAG, packageName + ":parserName: " + parser.getName()+" "+parser.getAttributeCount());
                    Log.i(TAG, packageName + ":parserName: " + parser.getName() + " "
                            + parser.getAttributeCount());
                    if (event == XmlPullParser.START_TAG) {
                        switch (parser.getName()) {
                            case "background":
+1 −0
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ public class IconsHandler {

        systemIcon = new AdaptiveIconProvider().load(ctx, componentName.getPackageName());
        if(systemIcon != null){
            Log.i(TAG, "getDrawableIconForPackage: herrrre");
            cacheStoreDrawable(componentName.toString(), systemIcon);
            return systemIcon;
        }
+5 −2
Original line number Diff line number Diff line
@@ -30,6 +30,9 @@ public class PackageAddedRemovedHandler extends BroadcastReceiver {
            if (launchIntent == null) {//for some plugin app
                return;
            }

            BlissLauncher.getApplication(ctx).resetIconsHandler();

            AppAddEvent appAddEvent = new AppAddEvent();
            appAddEvent.packageName = packageName;
            EventBus.getDefault().post(appAddEvent);
@@ -43,6 +46,8 @@ public class PackageAddedRemovedHandler extends BroadcastReceiver {
                        launchIntent.getComponent(), user);
            }

            BlissLauncher.getApplication(ctx).resetIconsHandler();

            AppChangeEvent appChangeEvent = new AppChangeEvent();
            appChangeEvent.packageName = packageName;
            EventBus.getDefault().post(appChangeEvent);
@@ -56,8 +61,6 @@ public class PackageAddedRemovedHandler extends BroadcastReceiver {
            EventBus.getDefault().post(appRemoveEvent);
        }

        BlissLauncher.getApplication(ctx).resetIconsHandler();

        // Reload application list
        final AppProvider provider = BlissLauncher.getApplication(ctx).getAppProvider();
        if (provider != null) {
+0 −2
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ import android.os.Bundle;
import android.os.UserManager;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.util.Log;

public class AppUtils {

@@ -84,7 +83,6 @@ public class AppUtils {

                Drawable appIcon = iconsHandler.getDrawableIconForPackage(
                        activityInfo.getComponentName(), user);
                Log.i(TAG, "loadAll: here");
                boolean isSystemApp = false;

                if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
+88 −88
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:clipChildren="true"
@@ -16,20 +16,20 @@
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="8dp"
            android:layout_toStartOf="@+id/weather_setting_imageview"
            android:padding="8dp"
            android:text="@string/weather"
            android:textAllCaps="true"
            android:textColor="#88FFFFFF"
            android:textSize="16sp"/>
        <ImageView
            android:id="@+id/weather_setting_imageview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:padding="8dp"
            android:contentDescription="@string/weather_setting"
            android:padding="8dp"
            android:src="@drawable/ic_settings_white_24dp"
            android:id="@+id/weather_setting_imageview"
        />
    </RelativeLayout>
    <FrameLayout
@@ -42,14 +42,24 @@
            android:layout_height="120dp"
            android:layout_gravity="center"
            android:gravity="center"
            android:textSize="16sp"
            android:text="@string/weather_tap_to_setup"
            android:textColor="@color/transparent_white"/>
        <RelativeLayout
            android:textColor="@color/transparent_white"
            android:textSize="16sp"
            android:visibility="gone"/>
        <LinearLayout
            android:id="@+id/weather_panel"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="gone">
            android:orientation="vertical"
            android:visibility="visible">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="16dp">

                <ImageView
                    android:id="@+id/weather_image"
@@ -57,66 +67,62 @@
                    android:layout_height="wrap_content"
                    android:layout_alignParentStart="true"
                    android:layout_alignParentTop="true"
                android:layout_marginBottom="8dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="16dp"
                    android:layout_centerVertical="true"
                    android:contentDescription="@string/weather_condition_image"
                    android:src="@drawable/weather_color_32"/>
            <GridLayout
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                android:layout_marginBottom="16dp"
                android:layout_marginEnd="16dp"
                android:layout_marginStart="32dp"
                android:layout_marginTop="16dp"
                android:layout_toEndOf="@id/weather_image"
                android:columnCount="2"
                android:rowCount="3">
                    android:layout_centerVertical="true"
                    android:layout_marginEnd="8dp"
                    android:layout_marginStart="16dp"
                    android:layout_toEndOf="@+id/weather_image"
                    android:layout_toStartOf="@+id/weather_temperature_linearlayout"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/weather_city"
                    android:layout_column="0"
                    android:layout_columnSpan="1"
                    android:layout_columnWeight="3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_vertical"
                    android:layout_row="0"
                    android:layout_rowSpan="1"
                        android:layout_marginEnd="8dp"
                        android:ellipsize="end"
                        android:fontFamily="sans-serif-medium"
                        android:maxLines="2"
                        android:textColor="@color/white"
                    android:textSize="18sp"/>
                        android:textSize="18sp"
                        tools:text="Chhatarpur, New Delhi, India"/>

                    <TextView
                        android:id="@+id/weather_condition"
                    android:layout_column="0"
                    android:layout_columnSpan="1"
                    android:layout_columnWeight="3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_vertical"
                    android:layout_row="1"
                    android:layout_rowSpan="1"
                        android:textColor="@color/transparent_white"
                    android:textSize="16sp"/>
                        android:textSize="16sp"
                        tools:text="Fair"/>

                    <TextView
                        android:id="@+id/weather_chance_rain"
                    android:layout_column="0"
                    android:layout_columnSpan="1"
                    android:layout_columnWeight="3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_vertical"
                    android:layout_row="2"
                    android:layout_rowSpan="1"
                        android:textColor="@color/transparent_white"
                    android:textSize="14sp"/>

                        android:textSize="14sp"
                        tools:text="40%, 11kpH SW"/>
                </LinearLayout>
                <LinearLayout
                    android:id="@+id/weather_temperature_linearlayout"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentEnd="true"
                    android:layout_centerVertical="true"
                    android:orientation="vertical">
                    <TextView
                        android:id="@+id/weather_current_temperature"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                    android:layout_column="1"
                    android:layout_columnSpan="1"
                    android:layout_columnWeight="1"
                        android:layout_gravity="end"
                    android:layout_row="0"
                    android:layout_rowSpan="2"
                        android:fontFamily="sans-serif-light"
                        android:gravity="end"
                        android:text="@string/dummy_weather_temp"
@@ -127,27 +133,21 @@
                        android:id="@+id/weather_low_high"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                    android:layout_column="1"
                    android:layout_columnSpan="1"
                    android:layout_columnWeight="1"
                    android:layout_row="2"
                    android:layout_rowSpan="1"
                        android:gravity="end"
                        android:text="@string/dummy_weather_temp_min_max"
                        android:textColor="@color/white"/>
            </GridLayout>
                </LinearLayout>
            </RelativeLayout>

            <HorizontalScrollView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/weather_image"
                android:layout_centerHorizontal="true"
                android:fadingEdgeLength="12dp"
                android:requiresFadingEdge="horizontal"
                android:layout_marginBottom="8dp"
                android:layout_marginEnd="16dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="8dp"
                android:fadingEdgeLength="12dp"
                android:requiresFadingEdge="horizontal"
                android:scrollbars="none">

                <LinearLayout
@@ -158,6 +158,6 @@
                    android:orientation="horizontal"/>
            </HorizontalScrollView>

        </RelativeLayout>
        </LinearLayout>
    </FrameLayout>
</LinearLayout>
 No newline at end of file
Loading