diff --git a/app/src/main/java/com/mariogrip/octodroid/Activity.java b/app/src/main/java/com/mariogrip/octodroid/Activity.java index eb82f2c..46cd668 100644 --- a/app/src/main/java/com/mariogrip/octodroid/Activity.java +++ b/app/src/main/java/com/mariogrip/octodroid/Activity.java @@ -27,6 +27,7 @@ public class Activity extends ActionBarActivity { protected SharedPreferences prefs; private get get_class; protected String ip; + protected String key; private Timer timer = new Timer(); private TimerTask timerTask; public static boolean server_status = false; @@ -44,6 +45,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.status_tab); prefs = PreferenceManager.getDefaultSharedPreferences(Activity.this); ip = prefs.getString("ip", "localhost"); + key = prefs.getString("api", "0"); get_class = new get(); Log.d("OctoPrint","test"); runner(); @@ -73,8 +75,8 @@ public void run() { Activity.this.runOnUiThread(new Runnable() { public void run() { - get.refreshJson(ip, "job"); - get.refreshJson(ip, "printer"); + get.refreshJson(ip, "job", key); + get.refreshJson(ip, "printer", key); if (server_status) { ProgressBar progress = (ProgressBar) findViewById(R.id.progressBar); @@ -150,6 +152,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { case RESULT_SETTINGS: prefs = PreferenceManager.getDefaultSharedPreferences(Activity.this); ip = prefs.getString("ip", "localhost"); + key = prefs.getString("api", "0"); break; } diff --git a/app/src/main/java/com/mariogrip/octodroid/get.java b/app/src/main/java/com/mariogrip/octodroid/get.java index 34988c1..20677d0 100644 --- a/app/src/main/java/com/mariogrip/octodroid/get.java +++ b/app/src/main/java/com/mariogrip/octodroid/get.java @@ -206,7 +206,7 @@ public static int getProgress(){ return returnData; } - public static void refreshJson(String ip, String api){ + public static void refreshJson(String ip, String api, String key){ if (ip == null || ip.equals("")){ }else { @@ -214,9 +214,9 @@ public static void refreshJson(String ip, String api){ HttpClient client = new DefaultHttpClient(); HttpGet httpGet; if (ip.startsWith("http://")){ - httpGet = new HttpGet(ip + "/api/"+api); + httpGet = new HttpGet(ip + "/api/"+api + "?apikey=" + key); }else{ - httpGet = new HttpGet("http://"+ ip + "/api/"+api); + httpGet = new HttpGet("http://"+ ip + "/api/"+api + "?apikey=" + key); } try { HttpResponse response = client.execute(httpGet); diff --git a/app/src/main/res/layout/status_tab.xml b/app/src/main/res/layout/status_tab.xml index 5048249..c3d1aab 100644 --- a/app/src/main/res/layout/status_tab.xml +++ b/app/src/main/res/layout/status_tab.xml @@ -185,7 +185,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" - android:text="dsfds" + android:text="" android:id="@+id/textView10_maci" android:layout_below="@id/textView39" android:layout_toEndOf="@id/textView"