Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mariogrip committed Nov 4, 2014
1 parent d4600a3 commit 1b4c4d5
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 29 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.0.0'

}
15 changes: 11 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mariogrip.octodroid" >

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@drawable/octoprint"
android:icon="@drawable/octodroid"
android:label="@string/app_name"
android:theme="@style/Theme.Base.AppCompat.Light" >
<activity
Expand All @@ -20,9 +22,14 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.mariogrip.octodroid.sendbug"
android:label="@string/Send_bug" >
</activity>

<service
android:name=".service"
android:exported="false"/>
android:name="com.mariogrip.octodroid.service"
android:exported="false" />
</application>
<uses-permission android:name="android.permission.INTERNET" />

</manifest>
37 changes: 22 additions & 15 deletions app/src/main/java/com/mariogrip/octodroid/Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

}
}
Expand All @@ -277,9 +278,6 @@ public void run() {

};
timer.schedule(timerTask, 0, 3000);



}

@Override
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -359,28 +367,29 @@ 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) {
selectItem(position);
}
}

private void selectItem(final int position) {
private void selectItem(int position) {
pos = position;
Fragment fragment = new PlanetFragment();
switch (position) {
case 0:
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;
Expand Down Expand Up @@ -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;
Expand Down
59 changes: 59 additions & 0 deletions app/src/main/java/com/mariogrip/octodroid/sendbug.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
11 changes: 4 additions & 7 deletions app/src/main/java/com/mariogrip/octodroid/service.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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;
}
}
Expand All @@ -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() {
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/mariogrip/octodroid/util.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
33 changes: 33 additions & 0 deletions app/src/main/res/layout/bug.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_margin="10dp"
android:layout_height="match_parent">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Comments about the problem below:"
android:id="@+id/textView_commen"></TextView>

<EditText
android:layout_below="@id/textView_commen"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:inputType="textMultiLine"
android:id="@+id/editText_bug"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_below="@id/editText_bug"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Send_bug"
android:id="@+id/button_send_bug"
android:layout_gravity="center_vertical"
android:layout_weight="1" />


</RelativeLayout>
10 changes: 9 additions & 1 deletion app/src/main/res/menu/my.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
tools:context=".MyActivity" >
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
android:orderInCategory="1"
/>
<item android:id="@+id/action_bug"
android:title="@string/report_bug"
android:orderInCategory="2"
/>
<item android:id="@+id/action_git"
android:title="Show on Github"
android:orderInCategory="3"
/>
</menu>
8 changes: 8 additions & 0 deletions app/src/main/res/menu/sendbug.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.mariogrip.octodroid.sendbug" >
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
android:showAsAction="never" />
</menu>
3 changes: 2 additions & 1 deletion app/src/main/res/values/naw.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<resources>
<string-array name="nawbars">
<item>Status</item>
<item>Controls-WORK-IN-PROGRESS</item>
<item>Settings</item>
<!-- <item>Controls-WORK-IN-PROGRESS</item>-->
</string-array>
<string name="drawer_open">Open navigation drawer</string>
<string name="drawer_close">Close navigation drawer</string>
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">OctoDroid</string>
<string name="action_settings">Settings</string>
<string name="machine_state">Machine State:</string>
Expand Down Expand Up @@ -29,4 +30,10 @@
<string name="send_error">Send error report</string>
<string name="error_report">Error report</string>
<string name="send_error_info">Send anonymous error data</string>
<string name="report_bug">Report bug</string>
<string name="donate">Donate</string>
<string name="Send_bug">Send bug rapport</string>
<string name="title_activity_sendbug">sendbug</string>
<string name="hello_world">Hello world!</string>

</resources>

0 comments on commit 1b4c4d5

Please sign in to comment.