refromat code

This commit is contained in:
Andreas Shimokawa 2016-03-03 11:54:07 +01:00
parent 63d938559e
commit 860ded1022
1 changed files with 9 additions and 10 deletions

View File

@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils; import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
@ -70,14 +69,14 @@ public class ExternalPebbleJSActivity extends Activity {
JSInterface gbJSInterface = new JSInterface(); JSInterface gbJSInterface = new JSInterface();
myWebView.addJavascriptInterface(gbJSInterface, "GBjs"); myWebView.addJavascriptInterface(gbJSInterface, "GBjs");
myWebView.loadUrl("file:///android_asset/app_config/configure.html?"+queryString); myWebView.loadUrl("file:///android_asset/app_config/configure.html?" + queryString);
} }
private JSONObject getAppConfigurationKeys() { private JSONObject getAppConfigurationKeys() {
try { try {
File destDir = new File(FileUtils.getExternalFilesDir() + "/pbw-cache"); File destDir = new File(FileUtils.getExternalFilesDir() + "/pbw-cache");
File configurationFile = new File(destDir, appUuid.toString() + ".json"); File configurationFile = new File(destDir, appUuid.toString() + ".json");
if(configurationFile.exists()) { if (configurationFile.exists()) {
String jsonstring = FileUtils.getStringFromFile(configurationFile); String jsonstring = FileUtils.getStringFromFile(configurationFile);
JSONObject json = new JSONObject(jsonstring); JSONObject json = new JSONObject(jsonstring);
return json.getJSONObject("appKeys"); return json.getJSONObject("appKeys");
@ -92,7 +91,7 @@ public class ExternalPebbleJSActivity extends Activity {
private class JSInterface { private class JSInterface {
public JSInterface () { public JSInterface() {
} }
@JavascriptInterface @JavascriptInterface
@ -106,17 +105,17 @@ public class ExternalPebbleJSActivity extends Activity {
JSONObject knownKeys = getAppConfigurationKeys(); JSONObject knownKeys = getAppConfigurationKeys();
ArrayList<Pair<Integer, Object>> pairs = new ArrayList<>(); ArrayList<Pair<Integer, Object>> pairs = new ArrayList<>();
try{ try {
JSONObject in = new JSONObject(msg); JSONObject in = new JSONObject(msg);
String cur_key; String cur_key;
for (Iterator<String> key = in.keys(); key.hasNext();) { for (Iterator<String> key = in.keys(); key.hasNext(); ) {
cur_key = key.next(); cur_key = key.next();
int pebbleAppIndex = knownKeys.optInt(cur_key); int pebbleAppIndex = knownKeys.optInt(cur_key);
if (pebbleAppIndex != 0) { if (pebbleAppIndex != 0) {
//TODO: cast to integer (int32) / String? Is it needed? //TODO: cast to integer (int32) / String? Is it needed?
pairs.add(new Pair<>(pebbleAppIndex, (Object) in.get(cur_key))); pairs.add(new Pair<>(pebbleAppIndex, (Object) in.get(cur_key)));
} else { } else {
GB.toast("Discarded key "+cur_key+", not found in the local configuration.", Toast.LENGTH_SHORT, GB.WARN); GB.toast("Discarded key " + cur_key + ", not found in the local configuration.", Toast.LENGTH_SHORT, GB.WARN);
} }
} }
} catch (JSONException e) { } catch (JSONException e) {
@ -130,7 +129,7 @@ public class ExternalPebbleJSActivity extends Activity {
JSONObject wi = new JSONObject(); JSONObject wi = new JSONObject();
try { try {
wi.put("platform", PebbleUtils.getPlatformName(mGBDevice.getHardwareVersion())); wi.put("platform", PebbleUtils.getPlatformName(mGBDevice.getHardwareVersion()));
}catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
//Json not supported apparently, we need to cast back and forth //Json not supported apparently, we need to cast back and forth
@ -142,8 +141,8 @@ public class ExternalPebbleJSActivity extends Activity {
try { try {
File destDir = new File(FileUtils.getExternalFilesDir() + "/pbw-cache"); File destDir = new File(FileUtils.getExternalFilesDir() + "/pbw-cache");
File configurationFile = new File(destDir, appUuid.toString() + "_config.js"); File configurationFile = new File(destDir, appUuid.toString() + "_config.js");
if(configurationFile.exists()) { if (configurationFile.exists()) {
return "file:///" + configurationFile.getAbsolutePath(); return "file:///" + configurationFile.getAbsolutePath();
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();