// Path: src/com/crossbowffs/quotelock/consts/PrefKeys.java
// public final class PrefKeys {
//     public static final String PREF_COMMON = "common";
//     public static final String PREF_COMMON_REFRESH_RATE = "pref_common_refresh_rate";
//     public static final String PREF_COMMON_REFRESH_RATE_DEFAULT = "900";
//     public static final String PREF_COMMON_UNMETERED_ONLY = "pref_common_unmetered_only";
//     public static final boolean PREF_COMMON_UNMETERED_ONLY_DEFAULT = false;
//     public static final String PREF_COMMON_QUOTE_MODULE = "pref_common_quote_module";
//     public static final String PREF_COMMON_QUOTE_MODULE_DEFAULT = VnaasQuoteModule.class.getName();
//     public static final String PREF_COMMON_MODULE_PREFERENCES = "pref_module_preferences";
//     public static final String PREF_COMMON_REQUIRES_INTERNET = "pref_common_requires_internet";
//     public static final String PREF_COMMON_REFRESH_RATE_OVERRIDE = "pref_common_refresh_rate_override";
//     public static final String PREF_COMMON_FONT_SIZE_TEXT = "pref_common_font_size_text";
//     public static final String PREF_COMMON_FONT_SIZE_TEXT_DEFAULT = "20";
//     public static final String PREF_COMMON_FONT_SIZE_SOURCE = "pref_common_font_size_source";
//     public static final String PREF_COMMON_FONT_SIZE_SOURCE_DEFAULT = "18";
// 
//     public static final String PREF_QUOTES = "quotes";
//     public static final String PREF_QUOTES_TEXT = "pref_quotes_text";
//     public static final String PREF_QUOTES_SOURCE = "pref_quotes_source";
//     public static final String PREF_QUOTES_LAST_UPDATED = "pref_quotes_last_updated";
// 
//     public static final String PREF_ABOUT_CREDITS = "pref_about_credits";
//     public static final String PREF_ABOUT_GITHUB = "pref_about_github";
//     public static final String PREF_ABOUT_VERSION = "pref_about_version";
// 
//     private PrefKeys() { }
// }
// 
// Path: src/com/crossbowffs/quotelock/provider/PreferenceProvider.java
// public class PreferenceProvider extends RemotePreferenceProvider {
//     public static final String AUTHORITY = BuildConfig.APPLICATION_ID + ".preferences";
// 
//     public PreferenceProvider() {
//         super(AUTHORITY, new String[] {PrefKeys.PREF_COMMON, PrefKeys.PREF_QUOTES});
//     }
// 
//     @Override
//     protected boolean checkAccess(String prefName, String prefKey, boolean write) {
//         return !write;
//     }
// }
// 
// Path: src/com/crossbowffs/quotelock/utils/Xlog.java
// public final class Xlog {
//     private static final String LOG_TAG = BuildConfig.LOG_TAG;
//     private static final int LOG_LEVEL = BuildConfig.LOG_LEVEL;
//     private static final boolean LOG_TO_XPOSED = BuildConfig.LOG_TO_XPOSED;
// 
//     private Xlog() { }
// 
//     private static void log(int priority, String tag, String message, Object... args) {
//         if (priority < LOG_LEVEL) {
//             return;
//         }
// 
//         message = String.format(message, args);
//         if (args.length > 0 && args[args.length - 1] instanceof Throwable) {
//             Throwable throwable = (Throwable)args[args.length - 1];
//             String stacktraceStr = Log.getStackTraceString(throwable);
//             message = message + '\n' + stacktraceStr;
//         }
// 
//         Log.println(priority, LOG_TAG, tag + ": " + message);
//         if (LOG_TO_XPOSED) {
//             Log.println(priority, "Xposed", LOG_TAG + ": " + tag + ": " + message);
//         }
//     }
// 
//     public static void v(String tag, String message, Object... args) {
//         log(Log.VERBOSE, tag, message, args);
//     }
// 
//     public static void d(String tag, String message, Object... args) {
//         log(Log.DEBUG, tag, message, args);
//     }
// 
//     public static void i(String tag, String message, Object... args) {
//         log(Log.INFO, tag, message, args);
//     }
// 
//     public static void w(String tag, String message, Object... args) {
//         log(Log.WARN, tag, message, args);
//     }
// 
//     public static void e(String tag, String message, Object... args) {
//         log(Log.ERROR, tag, message, args);
//     }
// }


import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.GridLayout;
import android.widget.TextView;
import com.crossbowffs.quotelock.consts.PrefKeys;
import com.crossbowffs.quotelock.provider.PreferenceProvider;
import com.crossbowffs.quotelock.utils.Xlog;
import com.crossbowffs.remotepreferences.RemotePreferences;
import de.robv.android.xposed.*;
import de.robv.android.xposed.callbacks.XC_InitPackageResources;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import org.xmlpull.v1.XmlPullParser;
package com.crossbowffs.quotelock.xposed;


public class LockscreenHook implements IXposedHookZygoteInit, IXposedHookInitPackageResources,
                                       IXposedHookLoadPackage, SharedPreferences.OnSharedPreferenceChangeListener {
    private static final String TAG = LockscreenHook.class.getSimpleName();
    private static final String RES_LAYOUT_QUOTE_LAYOUT = "quote_layout";
    private static final String RES_STRING_OPEN_APP_1 = "open_quotelock_app_line1";
    private static final String RES_STRING_OPEN_APP_2 = "open_quotelock_app_line2";
    private static final String RES_ID_QUOTE_TEXTVIEW = "quote_textview";
    private static final String RES_ID_SOURCE_TEXTVIEW = "source_textview";

    private static String sModulePath;
    private static XSafeModuleResources sModuleRes;
    private TextView mQuoteTextView;
    private TextView mSourceTextView;
    private RemotePreferences mCommonPrefs;
    private RemotePreferences mQuotePrefs;

    private void refreshQuote() {
// Path: src/com/crossbowffs/quotelock/consts/PrefKeys.java
// public final class PrefKeys {
//     public static final String PREF_COMMON = "common";
//     public static final String PREF_COMMON_REFRESH_RATE = "pref_common_refresh_rate";
//     public static final String PREF_COMMON_REFRESH_RATE_DEFAULT = "900";
//     public static final String PREF_COMMON_UNMETERED_ONLY = "pref_common_unmetered_only";
//     public static final boolean PREF_COMMON_UNMETERED_ONLY_DEFAULT = false;
//     public static final String PREF_COMMON_QUOTE_MODULE = "pref_common_quote_module";
//     public static final String PREF_COMMON_QUOTE_MODULE_DEFAULT = VnaasQuoteModule.class.getName();
//     public static final String PREF_COMMON_MODULE_PREFERENCES = "pref_module_preferences";
//     public static final String PREF_COMMON_REQUIRES_INTERNET = "pref_common_requires_internet";
//     public static final String PREF_COMMON_REFRESH_RATE_OVERRIDE = "pref_common_refresh_rate_override";
//     public static final String PREF_COMMON_FONT_SIZE_TEXT = "pref_common_font_size_text";
//     public static final String PREF_COMMON_FONT_SIZE_TEXT_DEFAULT = "20";
//     public static final String PREF_COMMON_FONT_SIZE_SOURCE = "pref_common_font_size_source";
//     public static final String PREF_COMMON_FONT_SIZE_SOURCE_DEFAULT = "18";
// 
//     public static final String PREF_QUOTES = "quotes";
//     public static final String PREF_QUOTES_TEXT = "pref_quotes_text";
//     public static final String PREF_QUOTES_SOURCE = "pref_quotes_source";
//     public static final String PREF_QUOTES_LAST_UPDATED = "pref_quotes_last_updated";
// 
//     public static final String PREF_ABOUT_CREDITS = "pref_about_credits";
//     public static final String PREF_ABOUT_GITHUB = "pref_about_github";
//     public static final String PREF_ABOUT_VERSION = "pref_about_version";
// 
//     private PrefKeys() { }
// }
// 
// Path: src/com/crossbowffs/quotelock/provider/PreferenceProvider.java
// public class PreferenceProvider extends RemotePreferenceProvider {
//     public static final String AUTHORITY = BuildConfig.APPLICATION_ID + ".preferences";
// 
//     public PreferenceProvider() {
//         super(AUTHORITY, new String[] {PrefKeys.PREF_COMMON, PrefKeys.PREF_QUOTES});
//     }
// 
//     @Override
//     protected boolean checkAccess(String prefName, String prefKey, boolean write) {
//         return !write;
//     }
// }
// 
// Path: src/com/crossbowffs/quotelock/utils/Xlog.java
// public final class Xlog {
//     private static final String LOG_TAG = BuildConfig.LOG_TAG;
//     private static final int LOG_LEVEL = BuildConfig.LOG_LEVEL;
//     private static final boolean LOG_TO_XPOSED = BuildConfig.LOG_TO_XPOSED;
// 
//     private Xlog() { }
// 
//     private static void log(int priority, String tag, String message, Object... args) {
//         if (priority < LOG_LEVEL) {
//             return;
//         }
// 
//         message = String.format(message, args);
//         if (args.length > 0 && args[args.length - 1] instanceof Throwable) {
//             Throwable throwable = (Throwable)args[args.length - 1];
//             String stacktraceStr = Log.getStackTraceString(throwable);
//             message = message + '\n' + stacktraceStr;
//         }
// 
//         Log.println(priority, LOG_TAG, tag + ": " + message);
//         if (LOG_TO_XPOSED) {
//             Log.println(priority, "Xposed", LOG_TAG + ": " + tag + ": " + message);
//         }
//     }
// 
//     public static void v(String tag, String message, Object... args) {
//         log(Log.VERBOSE, tag, message, args);
//     }
// 
//     public static void d(String tag, String message, Object... args) {
//         log(Log.DEBUG, tag, message, args);
//     }
// 
//     public static void i(String tag, String message, Object... args) {
//         log(Log.INFO, tag, message, args);
//     }
// 
//     public static void w(String tag, String message, Object... args) {
//         log(Log.WARN, tag, message, args);
//     }
// 
//     public static void e(String tag, String message, Object... args) {
//         log(Log.ERROR, tag, message, args);
//     }
// }


// Path: src/com/crossbowffs/quotelock/xposed/LockscreenHook.java
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.GridLayout;
import android.widget.TextView;
import com.crossbowffs.quotelock.consts.PrefKeys;
import com.crossbowffs.quotelock.provider.PreferenceProvider;
import com.crossbowffs.quotelock.utils.Xlog;
import com.crossbowffs.remotepreferences.RemotePreferences;
import de.robv.android.xposed.*;
import de.robv.android.xposed.callbacks.XC_InitPackageResources;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import org.xmlpull.v1.XmlPullParser;

package com.crossbowffs.quotelock.xposed;


public class LockscreenHook implements IXposedHookZygoteInit, IXposedHookInitPackageResources,
                                       IXposedHookLoadPackage, SharedPreferences.OnSharedPreferenceChangeListener {
    private static final String TAG = LockscreenHook.class.getSimpleName();
    private static final String RES_LAYOUT_QUOTE_LAYOUT = "quote_layout";
    private static final String RES_STRING_OPEN_APP_1 = "open_quotelock_app_line1";
    private static final String RES_STRING_OPEN_APP_2 = "open_quotelock_app_line2";
    private static final String RES_ID_QUOTE_TEXTVIEW = "quote_textview";
    private static final String RES_ID_SOURCE_TEXTVIEW = "source_textview";

    private static String sModulePath;
    private static XSafeModuleResources sModuleRes;
    private TextView mQuoteTextView;
    private TextView mSourceTextView;
    private RemotePreferences mCommonPrefs;
    private RemotePreferences mQuotePrefs;

    private void refreshQuote() {
        Xlog.d(TAG, "Quote changed, updating lockscreen layout");