diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 6314b09..712b6a6 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -10,6 +10,7 @@ @@ -23,6 +24,7 @@ + \ No newline at end of file diff --git a/bin/classes.dex b/bin/classes.dex index 8ccf24f..1e0b1c4 100644 --- a/bin/classes.dex +++ b/bin/classes.dex diff --git a/bin/classes/com/upc/pbe/upcnews/Parser.class b/bin/classes/com/upc/pbe/upcnews/Parser.class index 4619d47..1b81138 100644 --- a/bin/classes/com/upc/pbe/upcnews/Parser.class +++ b/bin/classes/com/upc/pbe/upcnews/Parser.class diff --git a/bin/resources.ap_ b/bin/resources.ap_ index 841f991..39735a8 100644 --- a/bin/resources.ap_ +++ b/bin/resources.ap_ diff --git a/gen/com/upc/pbe/upcnews/R.java b/gen/com/upc/pbe/upcnews/R.java index b1eb370..21f38c8 100644 --- a/gen/com/upc/pbe/upcnews/R.java +++ b/gen/com/upc/pbe/upcnews/R.java @@ -1,41 +1,47 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package com.upc.pbe.upcnews; - -public final class R { - public static final class attr { - } - public static final class drawable { - public static final int ic_action_search=0x7f020000; - public static final int ic_launcher=0x7f020001; - } - public static final class id { - public static final int AbsoluteLayout1=0x7f070000; - public static final int button=0x7f070003; - public static final int menu_settings=0x7f070004; - public static final int textViewRoute=0x7f070002; - public static final int textViewXml=0x7f070001; - } - public static final class layout { - public static final int main_activity=0x7f030000; - } - public static final class menu { - public static final int activity_main=0x7f060000; - } - public static final class string { - public static final int app_name=0x7f040000; - public static final int descarregar=0x7f040004; - public static final int hello_world=0x7f040001; - public static final int hint=0x7f040005; - public static final int menu_settings=0x7f040002; - public static final int title_activity_main=0x7f040003; - } - public static final class style { - public static final int AppTheme=0x7f050000; - } -} +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package com.upc.pbe.upcnews; + +public final class R { + public static final class attr { + } + public static final class drawable { + public static final int ic_action_search=0x7f020000; + public static final int ic_launcher=0x7f020001; + } + public static final class id { + public static final int AbsoluteLayout1=0x7f080000; + public static final int button=0x7f080003; + public static final int itemprefs=0x7f080004; + public static final int textViewRoute=0x7f080002; + public static final int textViewXml=0x7f080001; + } + public static final class layout { + public static final int main_activity=0x7f030000; + } + public static final class menu { + public static final int menu=0x7f070000; + } + public static final class string { + public static final int app_name=0x7f050000; + public static final int descarregar=0x7f050004; + public static final int hello_world=0x7f050001; + public static final int hint=0x7f050005; + public static final int menu_settings=0x7f050002; + public static final int prefs=0x7f050008; + public static final int title_activity_main=0x7f050003; + public static final int url=0x7f050006; + public static final int urlhint=0x7f050007; + } + public static final class style { + public static final int AppTheme=0x7f060000; + } + public static final class xml { + public static final int prefs=0x7f040000; + } +} diff --git a/res/values/strings.xml b/res/values/strings.xml index 15bef7a..6d3c78e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -6,5 +6,8 @@ MainActivity Start Click to Start Button... + URL server + Set the route from the server + Preferences \ No newline at end of file diff --git a/src/com/upc/pbe/upcnews/Descarrega.java b/src/com/upc/pbe/upcnews/Descarrega.java index b317237..cad14f5 100644 --- a/src/com/upc/pbe/upcnews/Descarrega.java +++ b/src/com/upc/pbe/upcnews/Descarrega.java @@ -14,6 +14,7 @@ import java.net.URLConnection; import android.os.AsyncTask; import android.util.Log; + public class Descarrega extends AsyncTask{ final static String TAG = "Descarrega"; private String url; @@ -47,7 +48,7 @@ public class Descarrega extends AsyncTask{ URLConnection conn = new URL(url).openConnection(); conn.connect(); Log.d(TAG, "\nDescarregant: \n"); - Log.d(TAG, ">> URL: " + url + " >> Nom: " + nomarxiu + Log.d(TAG, " >> URL: " + url + " >> Nom: " + nomarxiu + " >> Tamany: " + conn.getContentLength() + " bytes"); // Llegeix cada byte i l'escriu en un arxiu fins que arriba a -1 @@ -100,6 +101,8 @@ public class Descarrega extends AsyncTask{ } + + @Override protected Object doInBackground(Object... arg0) { diff --git a/src/com/upc/pbe/upcnews/MainActivity.java b/src/com/upc/pbe/upcnews/MainActivity.java index 894a228..8ae86b1 100644 --- a/src/com/upc/pbe/upcnews/MainActivity.java +++ b/src/com/upc/pbe/upcnews/MainActivity.java @@ -2,8 +2,11 @@ package com.upc.pbe.upcnews; import android.app.Activity; +import android.content.Intent; import android.os.Bundle; import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; @@ -12,12 +15,13 @@ import android.widget.Toast; public class MainActivity extends Activity implements OnClickListener { final static String TAG = "Main"; + Button buttonDescarrega; - String url = "http://soft0.upc.edu/~francesc/ast/"; //es un server del profe de AST xd + String url = "http://www.google.es"; String file = "ejemplo.xml"; - String folder = "Environment.getExternalStorageDirectory.getPath()"; //si això es una carpeta local de android, hauria de ser /sdcard/downloads + String folder = "Environment.getExternalStorageDirectory.getPath()"; // hauria de ser /sdcard/downloads TextView showText, showRoute; - + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -29,20 +33,35 @@ public class MainActivity extends Activity implements OnClickListener { showRoute = (TextView) findViewById(R.id.textViewRoute); showRoute.setText("Server: " + url); } + + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu, menu); + return true; + } public void onClick(View v) { - + Log.d(TAG, "onClicked"); Descarrega d = new Descarrega(url, file, folder); Toast.makeText(this, "Download succesfull", Toast.LENGTH_LONG).show(); CharSequence html = (CharSequence) d.doInBackground(); - Log.d(TAG, (String) html); showText.setText(html); - - //HTMLParser pars = new HTMLParser((String) html); - //ArrayList directoris = pars.parse(); - //showText.setText((CharSequence) directoris); - + + // HTMLParser pars = new HTMLParser((String) html); + // ArrayList directoris = pars.parse(); + // showText.setText((CharSequence) directoris); + + } + + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.itemprefs: + startActivity(new Intent(this, Prefs.class)); + Log.d(TAG, "Preferences"); + return true; + default: + return false; + } } } \ No newline at end of file