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 3 import java.io.File;
4 4 import java.io.IOException;
5 5 import java.net.MalformedURLException;
  6 +import java.util.List;
6 7  
7 8 import android.app.Activity;
8 9 import android.content.Intent;
  10 +import android.content.pm.PackageInfo;
9 11 import android.content.pm.PackageManager;
10   -import android.content.pm.PackageManager.NameNotFoundException;
11 12 import android.os.Bundle;
12 13 import android.util.Log;
13 14 import android.view.Menu;
... ... @@ -27,6 +28,7 @@ public class MainActivity extends Activity implements OnClickListener {
27 28 private ImageView alerta;
28 29 private ImageButton buttonDescarrega;
29 30 private TextView URLText, alertaText;
  31 + private boolean libsFound = false;
30 32  
31 33 @Override
32 34 public void onCreate(Bundle savedInstanceState)
... ... @@ -46,11 +48,15 @@ public class MainActivity extends Activity implements OnClickListener {
46 48 buttonDescarrega.setOnClickListener(this);
47 49 updateURL();
48 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 61 alerta = (ImageView) findViewById(R.id.imageViewAlerta);
56 62 alerta.setVisibility(View.VISIBLE);
... ... @@ -132,7 +138,6 @@ public class MainActivity extends Activity implements OnClickListener {
132 138 /*
133 139 * COSAS POR HACER
134 140 * (RELEASE-CRITICAL) Lentitud descarga -- Todos (este miercoles)
135   - * (NORMAL) Evitar k salga el panel de preferencias dentro de preferencias (no es crucial)
136 141 * (NORMAL) Poner la defaultURL al server de PBE
137 142 * (WISHLIST) Descarga en segundo plano (Mejora dificil)
138 143 * (WISHLIST) A�adir gif Imanol bailando (Easter eggs? vais en serio? XDDDDDDDDDDDD)
... ...
src/com/upc/pbe/upcnews/Prefs.java
1 1 package com.upc.pbe.upcnews;
2 2  
3   -import android.content.Intent;
4 3 import android.os.Bundle;
5 4 import android.preference.PreferenceActivity;
6 5 import android.util.Log;
7   -import android.view.Menu;
8   -import android.view.MenuItem;
9 6  
10 7 //Menu de preferencies
11 8 public class Prefs extends PreferenceActivity {
... ... @@ -18,28 +15,4 @@ public class Prefs extends PreferenceActivity {
18 15 super.onCreate(savedInstanceState);
19 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 19 \ No newline at end of file
... ...