Commit 7a91079e6c78bc317bc44176a089e657c5128925

Authored by Imanol-Mikel Barba Sabariego
1 parent 027c9589

Mejor deteccion de Vitamio

src/com/upc/pbe/upcnews/MainActivity.java
@@ -3,11 +3,12 @@ package com.upc.pbe.upcnews; @@ -3,11 +3,12 @@ package com.upc.pbe.upcnews;
3 import java.io.File; 3 import java.io.File;
4 import java.io.IOException; 4 import java.io.IOException;
5 import java.net.MalformedURLException; 5 import java.net.MalformedURLException;
  6 +import java.util.List;
6 7
7 import android.app.Activity; 8 import android.app.Activity;
8 import android.content.Intent; 9 import android.content.Intent;
  10 +import android.content.pm.PackageInfo;
9 import android.content.pm.PackageManager; 11 import android.content.pm.PackageManager;
10 -import android.content.pm.PackageManager.NameNotFoundException;  
11 import android.os.Bundle; 12 import android.os.Bundle;
12 import android.util.Log; 13 import android.util.Log;
13 import android.view.Menu; 14 import android.view.Menu;
@@ -27,6 +28,7 @@ public class MainActivity extends Activity implements OnClickListener { @@ -27,6 +28,7 @@ public class MainActivity extends Activity implements OnClickListener {
27 private ImageView alerta; 28 private ImageView alerta;
28 private ImageButton buttonDescarrega; 29 private ImageButton buttonDescarrega;
29 private TextView URLText, alertaText; 30 private TextView URLText, alertaText;
  31 + private boolean libsFound = false;
30 32
31 @Override 33 @Override
32 public void onCreate(Bundle savedInstanceState) 34 public void onCreate(Bundle savedInstanceState)
@@ -46,11 +48,15 @@ public class MainActivity extends Activity implements OnClickListener { @@ -46,11 +48,15 @@ public class MainActivity extends Activity implements OnClickListener {
46 buttonDescarrega.setOnClickListener(this); 48 buttonDescarrega.setOnClickListener(this);
47 updateURL(); 49 updateURL();
48 PackageManager pm = getPackageManager(); 50 PackageManager pm = getPackageManager();
49 - try 51 + List<PackageInfo> apps = pm.getInstalledPackages(0);
  52 + for(int i = 0; i < apps.size(); i++)
50 { 53 {
51 - pm.getApplicationInfo("io.vov.vitamio", 0); 54 + if(apps.get(i).applicationInfo.loadLabel(getPackageManager()).toString().equals("Vitamio"))
  55 + {
  56 + libsFound = true;
  57 + }
52 } 58 }
53 - catch (NameNotFoundException e) 59 + if(!libsFound)
54 { 60 {
55 alerta = (ImageView) findViewById(R.id.imageViewAlerta); 61 alerta = (ImageView) findViewById(R.id.imageViewAlerta);
56 alerta.setVisibility(View.VISIBLE); 62 alerta.setVisibility(View.VISIBLE);
@@ -132,7 +138,6 @@ public class MainActivity extends Activity implements OnClickListener { @@ -132,7 +138,6 @@ public class MainActivity extends Activity implements OnClickListener {
132 /* 138 /*
133 * COSAS POR HACER 139 * COSAS POR HACER
134 * (RELEASE-CRITICAL) Lentitud descarga -- Todos (este miercoles) 140 * (RELEASE-CRITICAL) Lentitud descarga -- Todos (este miercoles)
135 - * (NORMAL) Evitar k salga el panel de preferencias dentro de preferencias (no es crucial)  
136 * (NORMAL) Poner la defaultURL al server de PBE 141 * (NORMAL) Poner la defaultURL al server de PBE
137 * (WISHLIST) Descarga en segundo plano (Mejora dificil) 142 * (WISHLIST) Descarga en segundo plano (Mejora dificil)
138 * (WISHLIST) A�adir gif Imanol bailando (Easter eggs? vais en serio? XDDDDDDDDDDDD) 143 * (WISHLIST) A�adir gif Imanol bailando (Easter eggs? vais en serio? XDDDDDDDDDDDD)
src/com/upc/pbe/upcnews/Prefs.java
1 package com.upc.pbe.upcnews; 1 package com.upc.pbe.upcnews;
2 2
3 -import android.content.Intent;  
4 import android.os.Bundle; 3 import android.os.Bundle;
5 import android.preference.PreferenceActivity; 4 import android.preference.PreferenceActivity;
6 import android.util.Log; 5 import android.util.Log;
7 -import android.view.Menu;  
8 -import android.view.MenuItem;  
9 6
10 //Menu de preferencies 7 //Menu de preferencies
11 public class Prefs extends PreferenceActivity { 8 public class Prefs extends PreferenceActivity {
@@ -18,28 +15,4 @@ public class Prefs extends PreferenceActivity { @@ -18,28 +15,4 @@ public class Prefs extends PreferenceActivity {
18 super.onCreate(savedInstanceState); 15 super.onCreate(savedInstanceState);
19 addPreferencesFromResource(R.xml.prefs); 16 addPreferencesFromResource(R.xml.prefs);
20 } 17 }
21 -  
22 - /*@Override  
23 - public boolean onCreateOptionsMenu(Menu menu) {  
24 - //Determina el funcionament al apretar la tecla d'opcions  
25 - getMenuInflater().inflate(R.menu.menu, menu);  
26 - Log.d(TAG, "Menu");  
27 - return true;  
28 - }  
29 -  
30 - @Override  
31 - public boolean onOptionsItemSelected(MenuItem item) {  
32 - //Determina el funcionament al clickar en el menu d'opcions  
33 - switch (item.getItemId()) {  
34 - case R.id.itemprefs:  
35 - return true;  
36 - case R.id.itemhelp:  
37 - startActivity(new Intent(this, Help.class));  
38 - Log.d(TAG, "Help");  
39 - return true;  
40 - default:  
41 - return false;  
42 - }  
43 - }*/  
44 -  
45 } 18 }
46 \ No newline at end of file 19 \ No newline at end of file