<commit_before>/*
 * Copyright (C) 2013 <NAME> for GravityBox Project (C3C076@xda)
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.ceco.kitkat.gravitybox;

import java.io.File;
import java.io.FileInputStream;
import java.lang.reflect.Constructor;
import java.util.Hashtable;

import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.TypedValue;

import com.ceco.kitkat.gravitybox.preference.AppPickerPreference;
import com.ceco.kitkat.gravitybox.shortcuts.ShortcutActivity;

import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;

public class GlowPadHelper {
    private static final String TAG = "GB:GlowPadHelper";
    private static final boolean DEBUG = false;

    private static final String CLASS_TARGET_DRAWABLE = 
            "com.android.internal.widget.multiwaveview.TargetDrawable";

    private static Hashtable<String, AppInfo> mAppInfoCache = new Hashtable<String, AppInfo>();
    private static Constructor<?> mTargetDrawableConstructor;

    private static void log(String message) {
        XposedBridge.log(TAG + ": " + message);
    }

    public static class AppInfo {
        public String key;
        public Intent intent;
        public Drawable icon;
        public String name;
    }

    public enum BgStyle {
        NONE("NONE"),
        LIGHT("LIGHT"),
        DARK("DARK"),
        BLACK("BLACK");

        private String mValue;
        BgStyle(String value) {
            mValue = value;
        }
    }

    public static AppInfo getAppInfo(Context context, String app) {
        return getAppInfo(context, app, 40, BgStyle.NONE);
    }

    public static AppInfo getAppInfo(Context context, String app, int iconSizeDp, BgStyle bgStyle) {
        if (context == null || app == null) return null;

        try {
            final String key = app + "_" + bgStyle.toString();
            if (mAppInfoCache.containsKey(key)) {
                if (DEBUG) log("AppInfo: returning from cache for " + key);
                return mAppInfoCache.get(key);
            }

            AppInfo appInfo = new AppInfo();
            appInfo.key = key;
            appInfo.intent = Intent.parseUri(app, 0);
            if (!appInfo.intent.hasExtra("mode")) {<commit_msg>GlowPadHelper: use slightly larger icons by default Change affects size of unlock ring targets since they use implicit GlowPadHelper icon size<commit_after>/*
 * Copyright (C) 2013 <NAME> for GravityBox Project (<EMAIL>)
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.ceco.kitkat.gravitybox;

import java.io.File;
import java.io.FileInputStream;
import java.lang.reflect.Constructor;
import java.util.Hashtable;

import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.TypedValue;

import com.ceco.kitkat.gravitybox.preference.AppPickerPreference;
import com.ceco.kitkat.gravitybox.shortcuts.ShortcutActivity;

import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;

public class GlowPadHelper {
    private static final String TAG = "GB:GlowPadHelper";
    private static final boolean DEBUG = false;

    private static final String CLASS_TARGET_DRAWABLE = 
            "com.android.internal.widget.multiwaveview.TargetDrawable";

    private static Hashtable<String, AppInfo> mAppInfoCache = new Hashtable<String, AppInfo>();
    private static Constructor<?> mTargetDrawableConstructor;

    private static void log(String message) {
        XposedBridge.log(TAG + ": " + message);
    }

    public static class AppInfo {
        public String key;
        public Intent intent;
        public Drawable icon;
        public String name;
    }

    public enum BgStyle {
        NONE("NONE"),
        LIGHT("LIGHT"),
        DARK("DARK"),
        BLACK("BLACK");

        private String mValue;
        BgStyle(String value) {
            mValue = value;
        }
    }

    public static AppInfo getAppInfo(Context context, String app) {
        return getAppInfo(context, app, 50, BgStyle.NONE);
    }

    public static AppInfo getAppInfo(Context context, String app, int iconSizeDp, BgStyle bgStyle) {
        if (context == null || app == null) return null;

        try {
            final String key = app + "_" + bgStyle.toString();
            if (mAppInfoCache.containsKey(key)) {
                if (DEBUG) log("AppInfo: returning from cache for " + key);
                return mAppInfoCache.get(key);
            }

            AppInfo appInfo = new AppInfo();
            appInfo.key = key;
            appInfo.intent = Intent.parseUri(app, 0);
            if (!appInfo.intent.hasExtra("mode")) {
{'fraction_non_alphanumeric': 0.09155145929339478, 'fraction_numerical': 0.0039938556067588326, 'mean_word_length': 3.2527759634225997, 'pattern_counts': {'":': 2, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4548714', 'n_tokens_mistral': 1821, 'n_tokens_neox': 1762, 'n_words': 544}