From 687719f90c896939d2cef3741d529cbdbfb65e74 Mon Sep 17 00:00:00 2001 From: Nikolay Demyankov Date: Mon, 29 Feb 2016 11:24:27 +0100 Subject: [PATCH] Similar changes for android. --- .../nordnetab/chcp/main/config/ApplicationConfig.java | 9 +++++---- .../chcp/main/config/PluginInternalPreferences.java | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/android/src/com/nordnetab/chcp/main/config/ApplicationConfig.java b/src/android/src/com/nordnetab/chcp/main/config/ApplicationConfig.java index de9ffcbd..17bc26f0 100644 --- a/src/android/src/com/nordnetab/chcp/main/config/ApplicationConfig.java +++ b/src/android/src/com/nordnetab/chcp/main/config/ApplicationConfig.java @@ -9,6 +9,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.nordnetab.chcp.main.model.PluginFilesStructure; +import com.nordnetab.chcp.main.utils.Paths; import java.io.BufferedReader; import java.io.InputStreamReader; @@ -22,8 +24,6 @@ public class ApplicationConfig { private static final String MARKET_URL_FORMAT = "market://details?id=%s"; - private static final String APPLICATION_CONFIG_IN_ASSETS = "www/chcp.json"; - private static class JsonKeys { public static final String STORE_PACKAGE_IDENTIFIER = "android_identifier"; } @@ -71,12 +71,13 @@ public static ApplicationConfig fromJson(String jsonString) { * @param context application context * @return application config from assets */ - public static ApplicationConfig configFromAssets(final Context context) { + public static ApplicationConfig configFromAssets(final Context context, final String configFileName) { final AssetManager assetManager = context.getResources().getAssets(); final StringBuilder returnString = new StringBuilder(); + final String configFilePath = "www/" + configFileName; BufferedReader reader = null; try { - InputStreamReader isr = new InputStreamReader(assetManager.open(APPLICATION_CONFIG_IN_ASSETS)); + InputStreamReader isr = new InputStreamReader(assetManager.open(configFilePath)); reader = new BufferedReader(isr); String line; while ((line = reader.readLine()) != null) { diff --git a/src/android/src/com/nordnetab/chcp/main/config/PluginInternalPreferences.java b/src/android/src/com/nordnetab/chcp/main/config/PluginInternalPreferences.java index d2d2f229..c64ee418 100644 --- a/src/android/src/com/nordnetab/chcp/main/config/PluginInternalPreferences.java +++ b/src/android/src/com/nordnetab/chcp/main/config/PluginInternalPreferences.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.nordnetab.chcp.main.model.PluginFilesStructure; import com.nordnetab.chcp.main.utils.VersionHelper; import java.io.IOException; @@ -94,7 +95,7 @@ public static PluginInternalPreferences createDefault(final Context context) { pluginPrefs.setCurrentReleaseVersionName(""); // read app config from assets to get current release version - final ApplicationConfig appConfig = ApplicationConfig.configFromAssets(context); + final ApplicationConfig appConfig = ApplicationConfig.configFromAssets(context, PluginFilesStructure.CONFIG_FILE_NAME); if (appConfig != null) { pluginPrefs.setCurrentReleaseVersionName(appConfig.getContentConfig().getReleaseVersion()); }