From 1b4c4d5bfac594829721a75ce2ffe131b868a44f Mon Sep 17 00:00:00 2001 From: mariogrip Date: Tue, 4 Nov 2014 23:11:55 +0100 Subject: [PATCH] Release on google play, https://plus.google.com/u/0/communities/114304177638370435116 --- app/build.gradle | 1 + app/src/main/AndroidManifest.xml | 15 +++-- .../com/mariogrip/octodroid/Activity.java | 37 +++++++----- .../java/com/mariogrip/octodroid/sendbug.java | 59 +++++++++++++++++++ .../java/com/mariogrip/octodroid/service.java | 11 ++-- .../java/com/mariogrip/octodroid/util.java | 2 +- app/src/main/res/layout/bug.xml | 33 +++++++++++ app/src/main/res/menu/my.xml | 10 +++- app/src/main/res/menu/sendbug.xml | 8 +++ app/src/main/res/values/naw.xml | 3 +- app/src/main/res/values/strings.xml | 7 +++ 11 files changed, 157 insertions(+), 29 deletions(-) create mode 100644 app/src/main/java/com/mariogrip/octodroid/sendbug.java create mode 100644 app/src/main/res/layout/bug.xml create mode 100644 app/src/main/res/menu/sendbug.xml diff --git a/app/build.gradle b/app/build.gradle index 69961d3..995966d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,4 +22,5 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:20.0.0' + } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 65766e6..20d65af 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,9 +2,11 @@ + + + + + + android:name="com.mariogrip.octodroid.service" + android:exported="false" /> - + diff --git a/app/src/main/java/com/mariogrip/octodroid/Activity.java b/app/src/main/java/com/mariogrip/octodroid/Activity.java index 7a20fb6..feb7f8a 100644 --- a/app/src/main/java/com/mariogrip/octodroid/Activity.java +++ b/app/src/main/java/com/mariogrip/octodroid/Activity.java @@ -8,6 +8,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.net.Uri; import android.os.Bundle; import android.os.StrictMode; import android.preference.PreferenceManager; @@ -26,8 +27,6 @@ import android.widget.ProgressBar; import android.widget.TextView; -import com.mariogrip.octodroid.iu.controls; - import java.util.Timer; import java.util.TimerTask; @@ -112,7 +111,7 @@ public void onDrawerOpened(View drawerView) { running = false; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Warning!"); - builder.setMessage("I understand that this application is experimental and might crash. There are some functions that do not work like push notifications. Please report bugs!"); + builder.setMessage("Thank you for downloading this app!\nplease note that this app is under heavy development, so there will be a lot more to be added (example: controls,start,stop and pause) and there might be some bugs, so please report bugs!"); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { SharedPreferences sharedPref = Activity.this.getPreferences(Context.MODE_PRIVATE); @@ -263,12 +262,14 @@ public void run() { textmaci.setText("Cannot connect to\n" + ip); } break; - case 1: + case 2: ProgressBar progress = (ProgressBar) findViewById(R.id.progressBar_controls); TextView texttime = (TextView) findViewById(R.id.printTimeControls); texttime.setText(" " + util.toHumanRead(Double.parseDouble(util.getData("job", "printTimeLeft")))); progress.setProgress(util.getProgress()); break; + default: + break; } } @@ -277,9 +278,6 @@ public void run() { }; timer.schedule(timerTask, 0, 3000); - - - } @Override @@ -307,6 +305,16 @@ public boolean onOptionsItemSelected(MenuItem item) { startActivityForResult(i, RESULT_SETTINGS); return true; } + if (id == R.id.action_bug) { + Intent i1 = new Intent(this, sendbug.class); + startActivity(i1); + return true; + } + if (id == R.id.action_git){ + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/mariogrip/octodroid")); + startActivity(browserIntent); + } + return super.onOptionsItemSelected(item); } @@ -359,12 +367,8 @@ public void onStop(){ } public void onStart(){ super.onStart(); -// runner(); - not needed } - // NAW - - private class DrawerItemClickListener implements ListView.OnItemClickListener { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { @@ -372,7 +376,7 @@ public void onItemClick(AdapterView parent, View view, int position, long id) } } - private void selectItem(final int position) { + private void selectItem(int position) { pos = position; Fragment fragment = new PlanetFragment(); switch (position) { @@ -380,7 +384,12 @@ private void selectItem(final int position) { fragment = new PlanetFragment(); break; case 1: - fragment = new controls(); + fragment = new PlanetFragment(); + pos = 0; + position = 0; + Intent i = new Intent(this, settings.class); + startActivityForResult(i, RESULT_SETTINGS); + //fragment = new controls(); break; default: break; @@ -419,10 +428,8 @@ public void onConfigurationChanged(Configuration newConfig) { public static class PlanetFragment extends Fragment { public static final String ARG_PLANET_NUMBER = "planet_number"; - public PlanetFragment(){} - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView; diff --git a/app/src/main/java/com/mariogrip/octodroid/sendbug.java b/app/src/main/java/com/mariogrip/octodroid/sendbug.java new file mode 100644 index 0000000..bbe9538 --- /dev/null +++ b/app/src/main/java/com/mariogrip/octodroid/sendbug.java @@ -0,0 +1,59 @@ +package com.mariogrip.octodroid; + +import android.app.Activity; +import android.os.Bundle; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +public class sendbug extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.bug); + + Button up = (Button) findViewById(R.id.button_send_bug); + up.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + EditText errorRaport = (EditText) findViewById(R.id.editText_bug); + Log.d("OctoDroid", "SendErrRap Pressed"); + if (errorRaport.getText().toString().equals("") || errorRaport.getText().toString() == "" || errorRaport.getText() == null || errorRaport.getText().toString().isEmpty()){ + Toast.makeText(sendbug.this, "You cannot send a empty bug rapport", Toast.LENGTH_SHORT).show(); + }else { + util.sendError("BUG_RAPORT:" + errorRaport.getText().toString().replaceAll("[^A-Za-z0-9()\\[\\]]", "_")); + Toast.makeText(sendbug.this, "Thanks for the Bug rapport, we will try to fix the bug", Toast.LENGTH_LONG).show(); + sendbug.this.finish(); + } + } + }); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.sendbug, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} diff --git a/app/src/main/java/com/mariogrip/octodroid/service.java b/app/src/main/java/com/mariogrip/octodroid/service.java index 9074d20..745a234 100644 --- a/app/src/main/java/com/mariogrip/octodroid/service.java +++ b/app/src/main/java/com/mariogrip/octodroid/service.java @@ -27,12 +27,11 @@ public class service extends IntentService { private int intcom; public service() { - super("MyIntentService"); + super("OctoDroidService"); } @Override protected void onHandleIntent(Intent workIntent) { - runner(); } @@ -44,20 +43,19 @@ public void run() { util.refreshJson(Activity.ip, "job", Activity.key); util.decodeJsonService(); Log.d("OctoDroid Service", "runner" + Activity.printing); - if (Activity.printing) { Activity.printing = true; timerTask.cancel(); startPrintService(); return; } - if (util.getData("job", "state").equals("Printing") && Activity.printing == false) { + if (util.getData("job", "state").equals("Printing") && !Activity.printing) { Activity.printing = true; timerTask.cancel(); startPrintService(); return; } - if (!util.getData("job", "state").equals("Printing") && Activity.printing == true) { + if (!util.getData("job", "state").equals("Printing") && Activity.printing) { Activity.printing = false; } } @@ -75,7 +73,6 @@ protected void startPrintService() { mBuilder.setContentTitle("OctoDroid") .setContentText("Print in progress") .setSmallIcon(R.drawable.octoprint); - timerTask2 = new TimerTask() { @Override public void run() { @@ -85,7 +82,7 @@ public void run() { complete = Double.parseDouble(util.getData("job", "completion")); - if (!util.getData("job", "state").equals("Printing") && Activity.printing == true) { + if (!util.getData("job", "state").equals("Printing") && Activity.printing) { Activity.printing = false; Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); mBuilder.setContentText("Print complete") diff --git a/app/src/main/java/com/mariogrip/octodroid/util.java b/app/src/main/java/com/mariogrip/octodroid/util.java index 006c594..aaa9fa7 100644 --- a/app/src/main/java/com/mariogrip/octodroid/util.java +++ b/app/src/main/java/com/mariogrip/octodroid/util.java @@ -360,7 +360,7 @@ public static void sendcmd(String ip ,String api, String cmd, String value, Stri } } - private void sendError(String er){ + protected static void sendError(String er){ StringBuilder builder = new StringBuilder(); HttpClient client = new DefaultHttpClient(); HttpGet httpGet; diff --git a/app/src/main/res/layout/bug.xml b/app/src/main/res/layout/bug.xml new file mode 100644 index 0000000..e54f231 --- /dev/null +++ b/app/src/main/res/layout/bug.xml @@ -0,0 +1,33 @@ + + + + + + +