Java Code Examples for com.grarak.kerneladiutor.utils.Utils#readAssetFile()

The following examples show how to use com.grarak.kerneladiutor.utils.Utils#readAssetFile() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SupportedDownloads.java    From KernelAdiutor with GNU General Public License v3.0 6 votes vote down vote up
public SupportedDownloads(Context context) {
    try {
        String json = Utils.existFile(context.getFilesDir() + "/downloads.json") ?
                Utils.readFile(context.getFilesDir() + "/downloads.json", false) :
                Utils.readAssetFile(context, "downloads.json");
        JSONArray devices = new JSONArray(json);
        for (int i = 0; i < devices.length(); i++) {
            JSONObject device = devices.getJSONObject(i);
            JSONArray vendors = device.getJSONArray("vendor");
            for (int x = 0; x < vendors.length(); x++) {
                if (vendors.getString(x).equals(Device.getVendor())) {
                    JSONArray names = device.getJSONArray("device");
                    for (int y = 0; y < names.length(); y++) {
                        if (names.getString(y).equals(Device.getDeviceName())) {
                            mLink = device.getString("link");
                        }
                    }
                }
            }
        }
    } catch (JSONException e) {
        Utils.toast("Failed to read downloads.json " + e.getMessage(), context);
    }
}
 
Example 2
Source File: Screen.java    From KA27 with Apache License 2.0 5 votes vote down vote up
public static GammaProfiles.DsiPanelProfiles getDsiPanelProfiles(Context context) {
    if (GAMMA_PROFILES == null) {
        if (Utils.existFile(context.getFilesDir() + "/gamma_profiles.json")) {
            GAMMA_PROFILES = new GammaProfiles(Utils.readFile(context.getFilesDir() + "/gamma_profiles.json"));
        } else {
            GAMMA_PROFILES = new GammaProfiles(Utils.readAssetFile(context, "gamma_profiles.json"));
        }
    }
    return GAMMA_PROFILES.getDsiPanelProfiles();
}
 
Example 3
Source File: Screen.java    From KA27 with Apache License 2.0 5 votes vote down vote up
public static GammaProfiles.GammaControlProfiles getGammaControlProfiles(Context context) {
    if (GAMMA_PROFILES == null) {
        if (Utils.existFile(context.getFilesDir() + "/gamma_profiles.json")) {
            GAMMA_PROFILES = new GammaProfiles(Utils.readFile(context.getFilesDir() + "/gamma_profiles.json"));
        } else {
            GAMMA_PROFILES = new GammaProfiles(Utils.readAssetFile(context, "gamma_profiles.json"));
        }
    }
    return GAMMA_PROFILES.getGammaControl();
}
 
Example 4
Source File: Screen.java    From KA27 with Apache License 2.0 5 votes vote down vote up
public static GammaProfiles.KGammaProfiles getKGammaProfiles(Context context) {
    if (GAMMA_PROFILES == null) {
        if (Utils.existFile(context.getFilesDir() + "/gamma_profiles.json")) {
            GAMMA_PROFILES = new GammaProfiles(Utils.readFile(context.getFilesDir() + "/gamma_profiles.json"));
        } else {
            GAMMA_PROFILES = new GammaProfiles(Utils.readAssetFile(context, "gamma_profiles.json"));
        }
    }
    return GAMMA_PROFILES.getKGamma();
}
 
Example 5
Source File: Screen.java    From KA27 with Apache License 2.0 5 votes vote down vote up
public static GammaProfiles.ScreenColorProfiles getScreenColorProfiles(Context context) {
    if (GAMMA_PROFILES == null) {
        if (Utils.existFile(context.getFilesDir() + "/gamma_profiles.json")) {
            GAMMA_PROFILES = new GammaProfiles(Utils.readFile(context.getFilesDir() + "/gamma_profiles.json"));
        } else {
            GAMMA_PROFILES = new GammaProfiles(Utils.readAssetFile(context, "gamma_profiles.json"));
        }
    }
    return GAMMA_PROFILES.getScreenColorProfiles();
}
 
Example 6
Source File: Downloads.java    From kernel_adiutor with Apache License 2.0 5 votes vote down vote up
public Downloads(Context context) {
    try {
        String json;
        if (Utils.existFile("/res/kernel_adiutor_mod/downloads.json")) {
            json = Tools.readFile("/res/kernel_adiutor_mod/downloads.json", false);
        }
        else if (Utils.existFile(context.getFilesDir() + "/downloads.json")) {
            json = Tools.readFile(context.getFilesDir() + "/downloads.json", false);
        }
        else {
            json = Utils.readAssetFile(context, "downloads.json");
        }
        JSONArray devices = new JSONArray(json);
        for (int i = 0; i < devices.length(); i++) {
            JSONObject device = devices.getJSONObject(i);
            JSONArray vendors = device.getJSONArray("vendor");
            for (int x = 0; x < vendors.length(); x++)
                if (vendors.getString(x).equals(Utils.getVendorName())) {
                    JSONArray names = device.getJSONArray("device");
                    for (int y = 0; y < names.length(); y++)
                        if (names.getString(y).equals(Utils.getDeviceName()))
                            link = device.getString("link");
                }
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
 
Example 7
Source File: Screen.java    From kernel_adiutor with Apache License 2.0 5 votes vote down vote up
public static GammaProfiles.DsiPanelProfiles getDsiPanelProfiles(Context context) {
    if (GAMMA_PROFILES == null) {
        if (Utils.existFile(context.getFilesDir() + "/gamma_profiles.json")) {
            GAMMA_PROFILES = new GammaProfiles(Utils.readFile(context.getFilesDir() + "/gamma_profiles.json"));
        } else {
            GAMMA_PROFILES = new GammaProfiles(Utils.readAssetFile(context, "gamma_profiles.json"));
        }
    }
    return GAMMA_PROFILES.getDsiPanelProfiles();
}
 
Example 8
Source File: Screen.java    From kernel_adiutor with Apache License 2.0 5 votes vote down vote up
public static GammaProfiles.GammaControlProfiles getGammaControlProfiles(Context context) {
    if (GAMMA_PROFILES == null) {
        if (Utils.existFile(context.getFilesDir() + "/gamma_profiles.json")) {
            GAMMA_PROFILES = new GammaProfiles(Utils.readFile(context.getFilesDir() + "/gamma_profiles.json"));
        } else {
            GAMMA_PROFILES = new GammaProfiles(Utils.readAssetFile(context, "gamma_profiles.json"));
        }
    }
    return GAMMA_PROFILES.getGammaControl();
}
 
Example 9
Source File: Screen.java    From kernel_adiutor with Apache License 2.0 5 votes vote down vote up
public static GammaProfiles.KGammaProfiles getKGammaProfiles(Context context) {
    if (GAMMA_PROFILES == null) {
        if (Utils.existFile(context.getFilesDir() + "/gamma_profiles.json")) {
            GAMMA_PROFILES = new GammaProfiles(Utils.readFile(context.getFilesDir() + "/gamma_profiles.json"));
        } else {
            GAMMA_PROFILES = new GammaProfiles(Utils.readAssetFile(context, "gamma_profiles.json"));
        }
    }
    return GAMMA_PROFILES.getKGamma();
}
 
Example 10
Source File: Screen.java    From kernel_adiutor with Apache License 2.0 5 votes vote down vote up
public static GammaProfiles.ScreenColorProfiles getScreenColorProfiles (Context context) {
    if (GAMMA_PROFILES == null) {
        if (Utils.existFile(context.getFilesDir() + "/gamma_profiles.json")) {
            GAMMA_PROFILES = new GammaProfiles(Utils.readFile(context.getFilesDir() + "/gamma_profiles.json"));
        } else {
            GAMMA_PROFILES = new GammaProfiles(Utils.readAssetFile(context, "gamma_profiles.json"));
        }
    }
    return GAMMA_PROFILES.getScreenColorProfiles();
}
 
Example 11
Source File: Temperature.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
private TempJson(Context context) {
    try {
        JSONArray tempArray = new JSONArray(Utils.readAssetFile(context, "temp.json"));
        for (int i = 0; i < tempArray.length(); i++) {
            JSONObject device = tempArray.getJSONObject(i);
            if (Device.getBoard().equalsIgnoreCase(device.getString("board"))) {
                mDeviceJson = device;
                break;
            }
        }
    } catch (JSONException ignored) {
        Log.e(TAG, "Can't read temp.json");
    }
}
 
Example 12
Source File: Gamma.java    From KernelAdiutor with GNU General Public License v3.0 4 votes vote down vote up
public static GammaProfiles.DsiPanelProfiles getDsiPanelProfiles(Context context) {
    if (GAMMA_PROFILES == null) {
        GAMMA_PROFILES = new GammaProfiles(Utils.readAssetFile(context, "gamma_profiles.json"));
    }
    return GAMMA_PROFILES.getDsiPanelProfiles();
}
 
Example 13
Source File: Gamma.java    From KernelAdiutor with GNU General Public License v3.0 4 votes vote down vote up
public static GammaProfiles.GammaControlProfiles getGammaControlProfiles(Context context) {
    if (GAMMA_PROFILES == null)
        GAMMA_PROFILES = new GammaProfiles(Utils.readAssetFile(context, "gamma_profiles.json"));
    return GAMMA_PROFILES.getGammaControl();
}
 
Example 14
Source File: Gamma.java    From KernelAdiutor with GNU General Public License v3.0 4 votes vote down vote up
public static GammaProfiles.KGammaProfiles getKGammaProfiles(Context context) {
    if (GAMMA_PROFILES == null) {
        GAMMA_PROFILES = new GammaProfiles(Utils.readAssetFile(context, "gamma_profiles.json"));
    }
    return GAMMA_PROFILES.getKGamma();
}