Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bin/AndProject.apk
Binary file not shown.
Binary file modified bin/classes.dex
Binary file not shown.
Binary file modified bin/classes/bonsai/app/AndroidProjectActivity.class
Binary file not shown.
Binary file added bin/classes/bonsai/app/BonsaiActivity$1.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/BonsaiActivity.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/EditBonsaiActivity$1.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/EditBonsaiActivity$2.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/EditBonsaiActivity$3.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/EditBonsaiActivity$4.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/EditBonsaiActivity$5.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/EditBonsaiActivity.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/MoreActivity.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/R$drawable.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/R$id.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/R$layout.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/R$string.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/SelectBonsaiActivity.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/StartActivity.class
Binary file not shown.
Binary file modified bin/classes/bonsai/app/TaskActivity.class
Binary file not shown.
Binary file added bin/classes/bonsai/app/weather/Weather.class
Binary file not shown.
Binary file added bin/classes/bonsai/app/weather/XmlHandler.class
Binary file not shown.
Binary file added bin/classes/bonsai/app/weather/XmlParserSax.class
Binary file not shown.
Binary file modified bin/resources.ap_
Binary file not shown.
88 changes: 54 additions & 34 deletions gen/bonsai/app/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,60 @@ public static final class array {
public static final class attr {
}
public static final class drawable {
public static final int escaledlogo=0x7f020000;
public static final int ic_launcher=0x7f020001;
public static final int ic_tab_bonsai=0x7f020002;
public static final int ic_tab_calendar=0x7f020003;
public static final int ic_tab_more=0x7f020004;
public static final int ic_tab_selectbonsai=0x7f020005;
public static final int chance_of_rain=0x7f020000;
public static final int chance_of_snow=0x7f020001;
public static final int chance_of_storm=0x7f020002;
public static final int cloudy=0x7f020003;
public static final int dust=0x7f020004;
public static final int escaledlogo=0x7f020005;
public static final int fog=0x7f020006;
public static final int haze=0x7f020007;
public static final int ic_launcher=0x7f020008;
public static final int ic_tab_bonsai=0x7f020009;
public static final int ic_tab_calendar=0x7f02000a;
public static final int ic_tab_more=0x7f02000b;
public static final int ic_tab_selectbonsai=0x7f02000c;
public static final int icy=0x7f02000d;
public static final int mist=0x7f02000e;
public static final int mostly_sunny=0x7f02000f;
public static final int sleet=0x7f020010;
public static final int smoke=0x7f020011;
public static final int snow=0x7f020012;
public static final int storm=0x7f020013;
public static final int sunny=0x7f020014;
public static final int thunderstorm=0x7f020015;
}
public static final class id {
public static final int ImageView01=0x7f06000d;
public static final int bonsaiImage=0x7f060002;
public static final int bonsairowtext=0x7f060018;
public static final int btnCountry=0x7f060024;
public static final int btnPostCode=0x7f060022;
public static final int button1=0x7f06001e;
public static final int button2=0x7f06001f;
public static final int cancelButton=0x7f06002b;
public static final int donatebutton=0x7f060029;
public static final int editAge=0x7f06001b;
public static final int editCountry=0x7f060023;
public static final int editHeight=0x7f06001c;
public static final int editName=0x7f060019;
public static final int editPostCode=0x7f060021;
public static final int familySpinner=0x7f06001a;
public static final int btnCountry=0x7f060027;
public static final int btnPostCode=0x7f060025;
public static final int button1=0x7f060021;
public static final int button2=0x7f060022;
public static final int cancelButton=0x7f06001b;
public static final int donatebutton=0x7f06002c;
public static final int editAge=0x7f06001e;
public static final int editCountry=0x7f060026;
public static final int editHeight=0x7f06001f;
public static final int editName=0x7f06001c;
public static final int editPostCode=0x7f060024;
public static final int familySpinner=0x7f06001d;
public static final int footer=0x7f060013;
public static final int imageButton1=0x7f060026;
public static final int imageButton1=0x7f060029;
public static final int imageButton2=0x7f060017;
public static final int imageButton3=0x7f060027;
public static final int imageView1=0x7f060008;
public static final int imageButton3=0x7f06002a;
public static final int imageView1=0x7f06002d;
public static final int imageView2=0x7f06000a;
public static final int imageView4=0x7f060010;
public static final int imageWeather=0x7f060008;
public static final int linearLayout1=0x7f060001;
public static final int photoURLtext=0x7f06001d;
public static final int photoURLtext=0x7f060020;
public static final int podeButton=0x7f060015;
public static final int relativeLayout1=0x7f060025;
public static final int saveButton=0x7f06002a;
public static final int relativeLayout1=0x7f060028;
public static final int saveButton=0x7f06001a;
public static final int scrollView1=0x7f060000;
public static final int spinner1=0x7f060020;
public static final int spinner1=0x7f060023;
public static final int tableRow1=0x7f060009;
public static final int tableRow2=0x7f06000c;
public static final int tableRow3=0x7f06000f;
Expand All @@ -60,24 +77,27 @@ public static final class id {
public static final int textPrune=0x7f060011;
public static final int textTemperature=0x7f060012;
public static final int textTransplant=0x7f06000e;
public static final int textView1=0x7f060007;
public static final int textView2=0x7f060028;
public static final int textView1=0x7f060019;
public static final int textView2=0x7f06002b;
public static final int textView3=0x7f060006;
public static final int textWater=0x7f06000b;
public static final int textYears=0x7f060005;
public static final int textweather=0x7f060007;
public static final int transplantButton=0x7f060016;
public static final int waterButton=0x7f060014;
}
public static final class layout {
public static final int bonsai=0x7f030000;
public static final int bonsai_row=0x7f030001;
public static final int editbonsai=0x7f030002;
public static final int main=0x7f030003;
public static final int more=0x7f030004;
public static final int selectbonsai=0x7f030005;
public static final int start=0x7f030006;
public static final int task=0x7f030007;
public static final int task_row=0x7f030008;
public static final int calendar=0x7f030002;
public static final int editbonsai=0x7f030003;
public static final int gallery=0x7f030004;
public static final int main=0x7f030005;
public static final int more=0x7f030006;
public static final int selectbonsai=0x7f030007;
public static final int start=0x7f030008;
public static final int task=0x7f030009;
public static final int task_row=0x7f03000a;
}
public static final class string {
public static final int app_name=0x7f040000;
Expand Down
Binary file added res/drawable/chance_of_rain.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/chance_of_snow.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/chance_of_storm.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/cloudy.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/dust.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/fog.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/haze.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/icy.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/mist.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/mostly_sunny.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/sleet.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/smoke.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/snow.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/storm.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/sunny.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/thunderstorm.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions res/layout/bonsai.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@
</LinearLayout>

<TextView
android:id="@+id/textView1"
android:id="@+id/textweather"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.48"
android:text="18ºC"
android:text="no conexion"
android:textAppearance="?android:attr/textAppearanceMedium" />

</LinearLayout>

<ImageView
android:id="@+id/imageView1"
android:id="@+id/imageWeather"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
Expand Down Expand Up @@ -181,7 +181,7 @@
<TextView
android:id="@+id/textTemperature"
android:layout_gravity="center_vertical"
android:padding="3dip"
android:padding="8dip"
android:text="No weather info" />

</TableRow>
Expand Down
112 changes: 109 additions & 3 deletions src/bonsai/app/BonsaiActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@


import java.util.Date;
import java.util.List;

import bonsai.app.weather.Weather;
import bonsai.app.weather.XmlParserSax;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
Expand All @@ -29,7 +34,16 @@ public class BonsaiActivity extends Activity {
private TextView textTransplant;
private TextView textPrune;
private TextView textTemperature;
private TextView textWeather;
private ImageView weatherIcon;
//variables necesarias para ser asignadas en la hebra de checkWeather
private ProgressDialog dialog;
private Weather w;
private String location;


//
private double temperature;

/** Called when the activity is first created. */
@Override
Expand All @@ -46,11 +60,14 @@ public void onCreate(Bundle savedInstanceState) {
textTransplant = (TextView)findViewById(R.id.textTransplant);
textPrune = (TextView)findViewById(R.id.textPrune);
textTemperature = (TextView)findViewById(R.id.textTemperature);
textWeather =(TextView)findViewById(R.id.textweather);
weatherIcon = (ImageView)findViewById(R.id.imageWeather);

bonsaidb = new BonsaiDbUtil(this); // Construinos el DDBBAdapter
bonsaidb.open();
familydb = new FamilyDbUtil(this); // Construinos el DDBBAdapter
familydb.open();
checkWeather();

/*
try {
Expand Down Expand Up @@ -92,10 +109,14 @@ public void onResume() {
} else photo.setImageResource(R.drawable.ic_launcher);
long date = new Date().getTime() / (1000*60*60);
age.setText("" + ((date - bonsai.getLong(bonsai.getColumnIndexOrThrow(BonsaiDbUtil.KEY_AGE)))/(365*24)));
checkWeather();
checkWater();
checkTransplant();
checkPode();
checkWeather();






} catch (Exception e) {
Expand Down Expand Up @@ -143,7 +164,6 @@ private void checkWater() {
long lastwatered;
long waterfrec;
int height = 30;
int temperature = 20;
long hoursTime = (new Date().getTime())/(1000*60*60);


Expand Down Expand Up @@ -236,7 +256,7 @@ private void checkPode() {

// LOGICA DE TRANSPLANTE
if(lastpode == 0) textPrune.setText("No info about " + name + " prunes.\nMaybe never pruned.");
else if(age < 2) { // Los bonsais con menos de dos a�os se suelen defoliar al 50% cada 2 meses, aprox
else if(age < 2) { // Los bonsais con menos de dos a�os se suelen defoliar al 50% cada 2 meses, aprox
if(hoursTime - lastpode > 60 * 24) textPrune.setText("Defoliate your bonsai 50%");
else textPrune.setText("Your bonsai prune is not necessary");
}
Expand All @@ -250,6 +270,92 @@ private void checkPode() {

}
private void checkWeather() {
Cursor bonsai;
String situation;
dialog = ProgressDialog.show(this, "", "Data obtaining…", true);

Thread thread = new Thread() {
@Override
public void run() {
try{
Cursor bonsai = bonsaidb.fetchBonsai(AndroidProjectActivity.bonsaiactual);
startManagingCursor(bonsai);
location = bonsai.getString(bonsai.getColumnIndexOrThrow(BonsaiDbUtil.KEY_LOCALIZATION));
XmlParserSax saxparser = new XmlParserSax("http://www.google.com/ig/api?weather="+location);
List<Weather> weather = saxparser.parse();
w=weather.get(0);

}catch(Exception e){
Toast tx;
System.out.println(e.toString());
tx = Toast.makeText(getApplicationContext(), "Conexion is not aviable", Toast.LENGTH_LONG);
tx.show();
}
dialog.dismiss();
}


};
thread.start();
try{
bonsai = bonsaidb.fetchBonsai(AndroidProjectActivity.bonsaiactual);
startManagingCursor(bonsai);
situation= bonsai.getString(bonsai.getColumnIndexOrThrow(BonsaiDbUtil.KEY_SITUATION));
System.out.println("la situación es "+situation);
textWeather.setText(Double.toString(w.getTempMedia())+"ºC");
temperature=w.getTempMedia();
String s=w.getIcon();
s=s.replaceAll("/ig/images/weather/", "");
s=s.replaceAll(".gif", "");
System.out.println("El nombre del icono que me queda es "+s);
if(s.equals("chance_of_rain")){
weatherIcon.setImageResource(R.drawable.chance_of_rain);
}
if(s.equals("chance_of_snow"))
weatherIcon.setImageResource(R.drawable.chance_of_snow);
if(s.equals("chance_of_storm"))
weatherIcon.setImageResource(R.drawable.chance_of_storm);
if(s.equals("cloudly"))
weatherIcon.setImageResource(R.drawable.cloudy);
if(s.equals("dust"))
weatherIcon.setImageResource(R.drawable.dust);
if(s.equals("fog"))
weatherIcon.setImageResource(R.drawable.fog);
if(s.equals("haze"))
weatherIcon.setImageResource(R.drawable.haze);
if(s.equals("icy")){
weatherIcon.setImageResource(R.drawable.icy);
if(situation.equals("Exterior"))
textTemperature.setText("Your Bonsai is frozen, please put it indoor");}
if(s.equals("mist"))
weatherIcon.setImageResource(R.drawable.mist);
if(s.equals("mostly_sunny")){
weatherIcon.setImageResource(R.drawable.mostly_sunny);
if(situation.equals("Interior"))
textTemperature.setText("Your Bonsai would like to have some sunbathing today");}
if(s.equals("smoke"))
weatherIcon.setImageResource(R.drawable.smoke);
if(s.equals("snow")){
weatherIcon.setImageResource(R.drawable.snow);
if(situation.equals("Exterior"))
textTemperature.setText("Your Bonsai looks like snowman");}
if(s.equals("storm")){
weatherIcon.setImageResource(R.drawable.storm);
if(situation.equals("Exterior"))
textTemperature.setText("Your Bonsai is scare of thunderstorm");}
if(s.equals("sunny")){
weatherIcon.setImageResource(R.drawable.sunny);
if(situation.equals("Interior"))
textTemperature.setText("Your Bonsai would like to " +
"have some sunbathing today");}
if(s.equals("thunderstorm")){
weatherIcon.setImageResource(R.drawable.thunderstorm);
if(situation.equals("Exterior"))
textTemperature.setText("Your Bonsai is scare of thunderstorm");}
}catch(Exception e){
System.out.println("Salta una excepción de el segundo try del tiempo");

}

}

Expand Down
14 changes: 9 additions & 5 deletions src/bonsai/app/EditBonsaiActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class EditBonsaiActivity extends Activity {
private Spinner editSituation;
private EditText editpostCode;
private EditText editCountry;


private String name;
private String family;
Expand Down Expand Up @@ -87,7 +88,7 @@ public void onCreate(Bundle savedInstanceState) {

editpostCode=(EditText)findViewById(R.id.editPostCode);
editCountry=(EditText)findViewById(R.id.editCountry);


createCancelAlert();
createDeleteAlert();
Expand Down Expand Up @@ -125,6 +126,9 @@ public void onCreate(Bundle savedInstanceState) {
photoURLtext.setText("..." + photo.substring((photo.length() - 18), photo.length()));
}





} catch (Exception e) {
Toast.makeText(this, "None bonsai created: " + e.toString(), Toast.LENGTH_LONG).show();
Expand Down Expand Up @@ -283,7 +287,7 @@ public void goMakeCountry(View v) {
Location loc = comenzarLocalizacion();

if(loc == null) {
Toast.makeText(this, "Incapaz de obtener localizacion", Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Incapaz de obtener localizacion, turn on 3g please", Toast.LENGTH_SHORT).show();
return;
}
Geocoder myloc = new Geocoder(this,Locale.getDefault());
Expand All @@ -295,7 +299,7 @@ public void goMakeCountry(View v) {
editCountry.setText(ad.getCountryCode());
} catch (IOException e) {
// TODO Auto-generated catch block
Toast.makeText(this, "Error trying to get country " + e.toString(), Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Error trying to get country, turn on 3g please " + e.toString(), Toast.LENGTH_SHORT).show();
}

}
Expand All @@ -304,7 +308,7 @@ public void goMakePostCode(View v){
Location loc = comenzarLocalizacion();

if(loc == null) {
Toast.makeText(this, "Cannot get info about localization.", Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Cannot get info about localization, turn on 3g please", Toast.LENGTH_SHORT).show();
return;
}

Expand All @@ -317,7 +321,7 @@ public void goMakePostCode(View v){
editpostCode.setText(ad.getPostalCode());
} catch (Exception e) {
// TODO Auto-generated catch block
Toast.makeText(this, "Error trying to get location " + e.toString(), Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Error trying to get location, turn on 3g please " + e.toString(), Toast.LENGTH_SHORT).show();
}

}
Expand Down
Loading