Commit bb12ef2ea60060c491405c0c6099f4a88694db0d
1 parent
989ff317
MARC: He fet lo de les preferencies, pero de moment no fa res, només apareix en pantalla.
Showing
8 changed files
with
85 additions
and
52 deletions
AndroidManifest.xml
... | ... | @@ -10,6 +10,7 @@ |
10 | 10 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
11 | 11 | |
12 | 12 | <application |
13 | + android:name=".UpcApp" | |
13 | 14 | android:icon="@drawable/ic_launcher" |
14 | 15 | android:label="@string/app_name" |
15 | 16 | android:theme="@style/AppTheme" > |
... | ... | @@ -23,6 +24,7 @@ |
23 | 24 | </intent-filter> |
24 | 25 | </activity> |
25 | 26 | <activity android:name=".Descarrega"></activity> |
27 | + <activity android:name=".Prefs" ></activity> | |
26 | 28 | </application> |
27 | 29 | |
28 | 30 | </manifest> |
29 | 31 | \ No newline at end of file | ... | ... |
bin/classes.dex
No preview for this file type
bin/classes/com/upc/pbe/upcnews/Parser.class
No preview for this file type
bin/resources.ap_
No preview for this file type
gen/com/upc/pbe/upcnews/R.java
1 | -/* AUTO-GENERATED FILE. DO NOT MODIFY. | |
2 | - * | |
3 | - * This class was automatically generated by the | |
4 | - * aapt tool from the resource data it found. It | |
5 | - * should not be modified by hand. | |
6 | - */ | |
7 | - | |
8 | -package com.upc.pbe.upcnews; | |
9 | - | |
10 | -public final class R { | |
11 | - public static final class attr { | |
12 | - } | |
13 | - public static final class drawable { | |
14 | - public static final int ic_action_search=0x7f020000; | |
15 | - public static final int ic_launcher=0x7f020001; | |
16 | - } | |
17 | - public static final class id { | |
18 | - public static final int AbsoluteLayout1=0x7f070000; | |
19 | - public static final int button=0x7f070003; | |
20 | - public static final int menu_settings=0x7f070004; | |
21 | - public static final int textViewRoute=0x7f070002; | |
22 | - public static final int textViewXml=0x7f070001; | |
23 | - } | |
24 | - public static final class layout { | |
25 | - public static final int main_activity=0x7f030000; | |
26 | - } | |
27 | - public static final class menu { | |
28 | - public static final int activity_main=0x7f060000; | |
29 | - } | |
30 | - public static final class string { | |
31 | - public static final int app_name=0x7f040000; | |
32 | - public static final int descarregar=0x7f040004; | |
33 | - public static final int hello_world=0x7f040001; | |
34 | - public static final int hint=0x7f040005; | |
35 | - public static final int menu_settings=0x7f040002; | |
36 | - public static final int title_activity_main=0x7f040003; | |
37 | - } | |
38 | - public static final class style { | |
39 | - public static final int AppTheme=0x7f050000; | |
40 | - } | |
41 | -} | |
1 | +/* AUTO-GENERATED FILE. DO NOT MODIFY. | |
2 | + * | |
3 | + * This class was automatically generated by the | |
4 | + * aapt tool from the resource data it found. It | |
5 | + * should not be modified by hand. | |
6 | + */ | |
7 | + | |
8 | +package com.upc.pbe.upcnews; | |
9 | + | |
10 | +public final class R { | |
11 | + public static final class attr { | |
12 | + } | |
13 | + public static final class drawable { | |
14 | + public static final int ic_action_search=0x7f020000; | |
15 | + public static final int ic_launcher=0x7f020001; | |
16 | + } | |
17 | + public static final class id { | |
18 | + public static final int AbsoluteLayout1=0x7f080000; | |
19 | + public static final int button=0x7f080003; | |
20 | + public static final int itemprefs=0x7f080004; | |
21 | + public static final int textViewRoute=0x7f080002; | |
22 | + public static final int textViewXml=0x7f080001; | |
23 | + } | |
24 | + public static final class layout { | |
25 | + public static final int main_activity=0x7f030000; | |
26 | + } | |
27 | + public static final class menu { | |
28 | + public static final int menu=0x7f070000; | |
29 | + } | |
30 | + public static final class string { | |
31 | + public static final int app_name=0x7f050000; | |
32 | + public static final int descarregar=0x7f050004; | |
33 | + public static final int hello_world=0x7f050001; | |
34 | + public static final int hint=0x7f050005; | |
35 | + public static final int menu_settings=0x7f050002; | |
36 | + public static final int prefs=0x7f050008; | |
37 | + public static final int title_activity_main=0x7f050003; | |
38 | + public static final int url=0x7f050006; | |
39 | + public static final int urlhint=0x7f050007; | |
40 | + } | |
41 | + public static final class style { | |
42 | + public static final int AppTheme=0x7f060000; | |
43 | + } | |
44 | + public static final class xml { | |
45 | + public static final int prefs=0x7f040000; | |
46 | + } | |
47 | +} | ... | ... |
res/values/strings.xml
... | ... | @@ -6,5 +6,8 @@ |
6 | 6 | <string name="title_activity_main">MainActivity</string> |
7 | 7 | <string name="descarregar">Start</string> |
8 | 8 | <string name="hint">Click to Start Button...</string> |
9 | + <string name="url">URL server</string> | |
10 | + <string name="urlhint">Set the route from the server</string> | |
11 | + <string name="prefs">Preferences</string> | |
9 | 12 | |
10 | 13 | </resources> |
11 | 14 | \ No newline at end of file | ... | ... |
src/com/upc/pbe/upcnews/Descarrega.java
... | ... | @@ -14,6 +14,7 @@ import java.net.URLConnection; |
14 | 14 | import android.os.AsyncTask; |
15 | 15 | import android.util.Log; |
16 | 16 | |
17 | + | |
17 | 18 | public class Descarrega extends AsyncTask<Object, Object, Object>{ |
18 | 19 | final static String TAG = "Descarrega"; |
19 | 20 | private String url; |
... | ... | @@ -47,7 +48,7 @@ public class Descarrega extends AsyncTask<Object, Object, Object>{ |
47 | 48 | URLConnection conn = new URL(url).openConnection(); |
48 | 49 | conn.connect(); |
49 | 50 | Log.d(TAG, "\nDescarregant: \n"); |
50 | - Log.d(TAG, ">> URL: " + url + " >> Nom: " + nomarxiu | |
51 | + Log.d(TAG, " >> URL: " + url + " >> Nom: " + nomarxiu | |
51 | 52 | + " >> Tamany: " + conn.getContentLength() + " bytes"); |
52 | 53 | |
53 | 54 | // Llegeix cada byte i l'escriu en un arxiu fins que arriba a -1 |
... | ... | @@ -100,6 +101,8 @@ public class Descarrega extends AsyncTask<Object, Object, Object>{ |
100 | 101 | |
101 | 102 | |
102 | 103 | } |
104 | + | |
105 | + | |
103 | 106 | |
104 | 107 | @Override |
105 | 108 | protected Object doInBackground(Object... arg0) { | ... | ... |
src/com/upc/pbe/upcnews/MainActivity.java
... | ... | @@ -2,8 +2,11 @@ package com.upc.pbe.upcnews; |
2 | 2 | |
3 | 3 | |
4 | 4 | import android.app.Activity; |
5 | +import android.content.Intent; | |
5 | 6 | import android.os.Bundle; |
6 | 7 | import android.util.Log; |
8 | +import android.view.Menu; | |
9 | +import android.view.MenuItem; | |
7 | 10 | import android.view.View; |
8 | 11 | import android.view.View.OnClickListener; |
9 | 12 | import android.widget.Button; |
... | ... | @@ -12,12 +15,13 @@ import android.widget.Toast; |
12 | 15 | |
13 | 16 | public class MainActivity extends Activity implements OnClickListener { |
14 | 17 | final static String TAG = "Main"; |
18 | + | |
15 | 19 | Button buttonDescarrega; |
16 | - String url = "http://soft0.upc.edu/~francesc/ast/"; //es un server del profe de AST xd | |
20 | + String url = "http://www.google.es"; | |
17 | 21 | String file = "ejemplo.xml"; |
18 | - String folder = "Environment.getExternalStorageDirectory.getPath()"; //si això es una carpeta local de android, hauria de ser /sdcard/downloads | |
22 | + String folder = "Environment.getExternalStorageDirectory.getPath()"; // hauria de ser /sdcard/downloads | |
19 | 23 | TextView showText, showRoute; |
20 | - | |
24 | + | |
21 | 25 | @Override |
22 | 26 | public void onCreate(Bundle savedInstanceState) { |
23 | 27 | super.onCreate(savedInstanceState); |
... | ... | @@ -29,20 +33,35 @@ public class MainActivity extends Activity implements OnClickListener { |
29 | 33 | showRoute = (TextView) findViewById(R.id.textViewRoute); |
30 | 34 | showRoute.setText("Server: " + url); |
31 | 35 | } |
36 | + | |
37 | + public boolean onCreateOptionsMenu(Menu menu) { | |
38 | + getMenuInflater().inflate(R.menu.menu, menu); | |
39 | + return true; | |
40 | + } | |
32 | 41 | |
33 | 42 | public void onClick(View v) { |
34 | - | |
43 | + | |
35 | 44 | Log.d(TAG, "onClicked"); |
36 | 45 | Descarrega d = new Descarrega(url, file, folder); |
37 | 46 | Toast.makeText(this, "Download succesfull", Toast.LENGTH_LONG).show(); |
38 | 47 | CharSequence html = (CharSequence) d.doInBackground(); |
39 | - Log.d(TAG, (String) html); | |
40 | 48 | showText.setText(html); |
41 | - | |
42 | - //HTMLParser pars = new HTMLParser((String) html); | |
43 | - //ArrayList<String> directoris = pars.parse(); | |
44 | - //showText.setText((CharSequence) directoris); | |
45 | - | |
49 | + | |
50 | + // HTMLParser pars = new HTMLParser((String) html); | |
51 | + // ArrayList<String> directoris = pars.parse(); | |
52 | + // showText.setText((CharSequence) directoris); | |
53 | + | |
54 | + } | |
55 | + | |
56 | + public boolean onOptionsItemSelected(MenuItem item) { | |
57 | + switch (item.getItemId()) { | |
58 | + case R.id.itemprefs: | |
59 | + startActivity(new Intent(this, Prefs.class)); | |
60 | + Log.d(TAG, "Preferences"); | |
61 | + return true; | |
62 | + default: | |
63 | + return false; | |
64 | + } | |
46 | 65 | } |
47 | 66 | |
48 | 67 | } |
49 | 68 | \ No newline at end of file | ... | ... |