Commit 9411cd3e9b695fc2696303b016463f7adc718409

Authored by Imanol-Mikel Barba Sabariego
1 parent 235ef046

--no commit message

gen/com/upc/pbe/upcnews/R.java
@@ -16,19 +16,23 @@ public final class R { @@ -16,19 +16,23 @@ public final class R {
16 public static final int ic_menu_name=0x7f020002; 16 public static final int ic_menu_name=0x7f020002;
17 } 17 }
18 public static final class id { 18 public static final class id {
19 - public static final int AbsoluteLayout1=0x7f080005;  
20 - public static final int LinearLayout1=0x7f080002;  
21 - public static final int button=0x7f080008;  
22 - public static final int imageView1=0x7f080006;  
23 - public static final int itemhelp=0x7f08000c;  
24 - public static final int itemprefs=0x7f08000b;  
25 - public static final int menu_settings=0x7f08000a;  
26 - public static final int textView1=0x7f080003;  
27 - public static final int textView2=0x7f080004;  
28 - public static final int textViewRoute=0x7f080007;  
29 - public static final int textViewTitle=0x7f080000;  
30 - public static final int textViewXml=0x7f080009;  
31 - public static final int text_out=0x7f080001; 19 + public static final int AbsoluteLayout1=0x7f080008;
  20 + public static final int ImageView01=0x7f08000d;
  21 + public static final int ImageView1=0x7f08000c;
  22 + public static final int LinearLayout1=0x7f080000;
  23 + public static final int button=0x7f08000a;
  24 + public static final int button1=0x7f080002;
  25 + public static final int button2=0x7f080003;
  26 + public static final int button3=0x7f080004;
  27 + public static final int button4=0x7f080005;
  28 + public static final int itemhelp=0x7f080010;
  29 + public static final int itemprefs=0x7f08000f;
  30 + public static final int menu_settings=0x7f08000e;
  31 + public static final int textView1=0x7f080006;
  32 + public static final int textView2=0x7f080007;
  33 + public static final int textViewRoute=0x7f080009;
  34 + public static final int textViewTitle=0x7f080001;
  35 + public static final int textViewXml=0x7f08000b;
32 } 36 }
33 public static final class layout { 37 public static final class layout {
34 public static final int dirs=0x7f030000; 38 public static final int dirs=0x7f030000;
@@ -41,6 +45,8 @@ public final class R { @@ -41,6 +45,8 @@ public final class R {
41 } 45 }
42 public static final class string { 46 public static final class string {
43 public static final int app_name=0x7f050000; 47 public static final int app_name=0x7f050000;
  48 + public static final int button=0x7f05000c;
  49 + public static final int button1=0x7f05000d;
44 public static final int desc=0x7f050009; 50 public static final int desc=0x7f050009;
45 public static final int descarregar=0x7f050003; 51 public static final int descarregar=0x7f050003;
46 public static final int dir=0x7f05000a; 52 public static final int dir=0x7f05000a;
@@ -49,6 +55,7 @@ public final class R { @@ -49,6 +55,7 @@ public final class R {
49 public static final int hint=0x7f050004; 55 public static final int hint=0x7f050004;
50 public static final int menu_settings=0x7f050001; 56 public static final int menu_settings=0x7f050001;
51 public static final int prefs=0x7f050007; 57 public static final int prefs=0x7f050007;
  58 + public static final int title=0x7f05000e;
52 public static final int title_activity_main=0x7f050002; 59 public static final int title_activity_main=0x7f050002;
53 public static final int url=0x7f050005; 60 public static final int url=0x7f050005;
54 public static final int urlhint=0x7f050006; 61 public static final int urlhint=0x7f050006;
res/layout/dirs.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:id="@+id/LinearLayout1"
3 android:layout_width="match_parent" 4 android:layout_width="match_parent"
4 android:layout_height="match_parent" 5 android:layout_height="match_parent"
  6 + android:gravity="center_horizontal"
5 android:orientation="vertical" > 7 android:orientation="vertical" >
6 8
  9 + <!-- Vista en llista -->
  10 +
7 <TextView 11 <TextView
8 android:id="@+id/textViewTitle" 12 android:id="@+id/textViewTitle"
9 android:layout_width="wrap_content" 13 android:layout_width="wrap_content"
10 android:layout_height="wrap_content" 14 android:layout_height="wrap_content"
11 - android:layout_gravity="left" 15 + android:layout_marginLeft="14dp"
  16 + android:text="@string/title"
12 android:textAppearance="?android:attr/textAppearanceMedium" /> 17 android:textAppearance="?android:attr/textAppearanceMedium" />
13 18
14 - <!-- Vista en llista --> 19 + <Button
  20 + android:id="@+id/button1"
  21 + android:layout_width="match_parent"
  22 + android:layout_height="wrap_content"
  23 + android:layout_marginTop="38dp" />
15 24
16 - <ScrollView 25 + <Button
  26 + android:id="@+id/button2"
17 android:layout_width="match_parent" 27 android:layout_width="match_parent"
18 - android:layout_height="match_parent" > 28 + android:layout_height="wrap_content"
  29 + android:layout_marginTop="38dp" />
19 30
20 - <TextView  
21 - android:id="@+id/text_out"  
22 - android:layout_width="match_parent"  
23 - android:layout_height="wrap_content"  
24 - android:layout_gravity="left"  
25 - android:textAppearance="?android:attr/textAppearanceMedium" />  
26 - </ScrollView> 31 + <Button
  32 + android:id="@+id/button3"
  33 + android:layout_width="match_parent"
  34 + android:layout_height="wrap_content"
  35 + android:layout_marginTop="38dp" />
  36 +
  37 + <Button
  38 + android:id="@+id/button4"
  39 + android:layout_width="match_parent"
  40 + android:layout_height="wrap_content"
  41 + android:layout_marginTop="38dp" />
27 42
28 </LinearLayout> 43 </LinearLayout>
29 \ No newline at end of file 44 \ No newline at end of file
res/layout/main_activity.xml
@@ -15,14 +15,6 @@ @@ -15,14 +15,6 @@
15 android:text="@string/app_name" 15 android:text="@string/app_name"
16 android:textAppearance="?android:attr/textAppearanceLarge" /> 16 android:textAppearance="?android:attr/textAppearanceLarge" />
17 17
18 - <ImageView  
19 - android:id="@+id/imageView1"  
20 - android:layout_width="134dp"  
21 - android:layout_height="134dp"  
22 - android:layout_x="84dp"  
23 - android:layout_y="50dp"  
24 - android:src="@drawable/ic_launcher" />  
25 -  
26 <TextView 18 <TextView
27 android:id="@+id/textViewRoute" 19 android:id="@+id/textViewRoute"
28 android:layout_width="250dp" 20 android:layout_width="250dp"
@@ -50,4 +42,20 @@ @@ -50,4 +42,20 @@
50 android:scrollbarStyle="insideInset" 42 android:scrollbarStyle="insideInset"
51 android:scrollbars="vertical" /> 43 android:scrollbars="vertical" />
52 44
  45 + <ImageView
  46 + android:id="@+id/ImageView1"
  47 + android:layout_width="wrap_content"
  48 + android:layout_height="wrap_content"
  49 + android:layout_x="28dp"
  50 + android:layout_y="12dp"
  51 + android:src="@drawable/ic_launcher" />
  52 +
  53 + <ImageView
  54 + android:id="@+id/ImageView01"
  55 + android:layout_width="wrap_content"
  56 + android:layout_height="wrap_content"
  57 + android:layout_x="223dp"
  58 + android:layout_y="14dp"
  59 + android:src="@drawable/ic_launcher" />
  60 +
53 </AbsoluteLayout> 61 </AbsoluteLayout>
54 \ No newline at end of file 62 \ No newline at end of file
res/values/strings.xml
@@ -12,5 +12,8 @@ @@ -12,5 +12,8 @@
12 <string name="desc">Play</string> 12 <string name="desc">Play</string>
13 <string name="dir">Directory</string> 13 <string name="dir">Directory</string>
14 <string name="directoris">Directoris</string> 14 <string name="directoris">Directoris</string>
  15 + <string name="button">Button</string>
  16 + <string name="button1">Play</string>
  17 + <string name="title">Directories found:</string>
15 18
16 </resources> 19 </resources>
17 \ No newline at end of file 20 \ No newline at end of file
src/com/upc/pbe/upcnews/Directoris.java
@@ -3,39 +3,82 @@ package com.upc.pbe.upcnews; @@ -3,39 +3,82 @@ package com.upc.pbe.upcnews;
3 import java.util.ArrayList; 3 import java.util.ArrayList;
4 4
5 import android.app.Activity; 5 import android.app.Activity;
  6 +import android.content.Intent;
6 import android.os.Bundle; 7 import android.os.Bundle;
7 import android.util.Log; 8 import android.util.Log;
8 -import android.widget.TextView; 9 +import android.view.Menu;
  10 +import android.view.MenuItem;
  11 +import android.view.View;
  12 +import android.widget.Button;
9 13
10 public class Directoris extends Activity { 14 public class Directoris extends Activity {
11 15
12 final static String TAG = "Directoris"; 16 final static String TAG = "Directoris";
13 -  
14 - TextView title;  
15 - TextView textout;  
16 String s; 17 String s;
17 18
  19 + ArrayList<Button> buttons = new ArrayList<Button>();
  20 + Button button1, button2, button3, button4;
  21 +
18 public void onCreate(Bundle savedInstanceState) { 22 public void onCreate(Bundle savedInstanceState) {
  23 +
19 Log.d(TAG, "onCreated"); 24 Log.d(TAG, "onCreated");
20 - 25 +
21 super.onCreate(savedInstanceState); 26 super.onCreate(savedInstanceState);
22 setContentView(R.layout.dirs); 27 setContentView(R.layout.dirs);
23 28
24 - textout = (TextView) findViewById(R.id.text_out);  
25 - title = (TextView) findViewById(R.id.textViewTitle);  
26 -  
27 - title.setText("Server --> " + ((UpcApp) getApplication()).getUrl()); 29 + this.crearButtons();
28 30
29 s = ((UpcApp) getApplication()).getDesc(); 31 s = ((UpcApp) getApplication()).getDesc();
30 HTMLParser pars = new HTMLParser(); 32 HTMLParser pars = new HTMLParser();
31 ArrayList<String> dirs = pars.parse(s); 33 ArrayList<String> dirs = pars.parse(s);
32 34
33 for (int i = 0; i < dirs.size(); i++) { 35 for (int i = 0; i < dirs.size(); i++) {
34 -  
35 Log.d(TAG, "Directori " + i); 36 Log.d(TAG, "Directori " + i);
36 - textout.append(String.format("\nDirectori: %s\n", dirs.get(i)  
37 - .toString())); 37 + buttons.get(i).setVisibility(View.VISIBLE);
  38 + buttons.get(i).setText(dirs.get(i));
  39 +
38 } 40 }
39 41
40 } 42 }
41 -} 43 +
  44 + public boolean onCreateOptionsMenu(Menu menu) {
  45 + getMenuInflater().inflate(R.menu.menu, menu);
  46 + Log.d(TAG, "Menu");
  47 + return true;
  48 + }
  49 +
  50 + public boolean onOptionsItemSelected(MenuItem item) {
  51 + switch (item.getItemId()) {
  52 + case R.id.itemprefs:
  53 + startActivity(new Intent(this, Prefs.class));
  54 + Log.d(TAG, "Preferences");
  55 + return true;
  56 + case R.id.itemhelp:
  57 + startActivity(new Intent(this, Help.class));
  58 + Log.d(TAG, "Help");
  59 + return true;
  60 + default:
  61 + return false;
  62 + }
  63 + }
  64 +
  65 + public void crearButtons(){
  66 +
  67 +
  68 + button1 = (Button)findViewById(R.id.button1);
  69 + button2 = (Button)findViewById(R.id.button2);
  70 + button3 = (Button)findViewById(R.id.button3);
  71 + button4 = (Button)findViewById(R.id.button4);
  72 +
  73 +
  74 + buttons.add(button1);
  75 + buttons.add(button2);
  76 + buttons.add(button3);
  77 + buttons.add(button4);
  78 +
  79 + button1.setVisibility(View.GONE);
  80 + button2.setVisibility(View.GONE);
  81 + button3.setVisibility(View.GONE);
  82 + button4.setVisibility(View.GONE);
  83 + }
  84 +}
42 \ No newline at end of file 85 \ No newline at end of file
src/com/upc/pbe/upcnews/MainActivity.java
@@ -32,7 +32,6 @@ public class MainActivity extends Activity implements OnClickListener { @@ -32,7 +32,6 @@ public class MainActivity extends Activity implements OnClickListener {
32 showText = (TextView) findViewById(R.id.textViewXml); 32 showText = (TextView) findViewById(R.id.textViewXml);
33 showRoute = (TextView) findViewById(R.id.textViewRoute); 33 showRoute = (TextView) findViewById(R.id.textViewRoute);
34 this.getUrl(); 34 this.getUrl();
35 -  
36 } 35 }
37 36
38 public boolean onCreateOptionsMenu(Menu menu) { 37 public boolean onCreateOptionsMenu(Menu menu) {