From 7a91079e6c78bc317bc44176a089e657c5128925 Mon Sep 17 00:00:00 2001 From: Equip de Desenvolupadors de PBE Date: Wed, 12 Dec 2012 03:59:07 +0000 Subject: [PATCH] Mejor deteccion de Vitamio --- src/com/upc/pbe/upcnews/MainActivity.java | 15 ++++++++++----- src/com/upc/pbe/upcnews/Prefs.java | 27 --------------------------- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/src/com/upc/pbe/upcnews/MainActivity.java b/src/com/upc/pbe/upcnews/MainActivity.java index 7727b26..48c7012 100644 --- a/src/com/upc/pbe/upcnews/MainActivity.java +++ b/src/com/upc/pbe/upcnews/MainActivity.java @@ -3,11 +3,12 @@ package com.upc.pbe.upcnews; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; +import java.util.List; import android.app.Activity; import android.content.Intent; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.util.Log; import android.view.Menu; @@ -27,6 +28,7 @@ public class MainActivity extends Activity implements OnClickListener { private ImageView alerta; private ImageButton buttonDescarrega; private TextView URLText, alertaText; + private boolean libsFound = false; @Override public void onCreate(Bundle savedInstanceState) @@ -46,11 +48,15 @@ public class MainActivity extends Activity implements OnClickListener { buttonDescarrega.setOnClickListener(this); updateURL(); PackageManager pm = getPackageManager(); - try + List apps = pm.getInstalledPackages(0); + for(int i = 0; i < apps.size(); i++) { - pm.getApplicationInfo("io.vov.vitamio", 0); + if(apps.get(i).applicationInfo.loadLabel(getPackageManager()).toString().equals("Vitamio")) + { + libsFound = true; + } } - catch (NameNotFoundException e) + if(!libsFound) { alerta = (ImageView) findViewById(R.id.imageViewAlerta); alerta.setVisibility(View.VISIBLE); @@ -132,7 +138,6 @@ public class MainActivity extends Activity implements OnClickListener { /* * COSAS POR HACER * (RELEASE-CRITICAL) Lentitud descarga -- Todos (este miercoles) - * (NORMAL) Evitar k salga el panel de preferencias dentro de preferencias (no es crucial) * (NORMAL) Poner la defaultURL al server de PBE * (WISHLIST) Descarga en segundo plano (Mejora dificil) * (WISHLIST) A�adir gif Imanol bailando (Easter eggs? vais en serio? XDDDDDDDDDDDD) diff --git a/src/com/upc/pbe/upcnews/Prefs.java b/src/com/upc/pbe/upcnews/Prefs.java index 4dcf98a..147427a 100644 --- a/src/com/upc/pbe/upcnews/Prefs.java +++ b/src/com/upc/pbe/upcnews/Prefs.java @@ -1,11 +1,8 @@ package com.upc.pbe.upcnews; -import android.content.Intent; import android.os.Bundle; import android.preference.PreferenceActivity; import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; //Menu de preferencies public class Prefs extends PreferenceActivity { @@ -18,28 +15,4 @@ public class Prefs extends PreferenceActivity { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.prefs); } - - /*@Override - public boolean onCreateOptionsMenu(Menu menu) { - //Determina el funcionament al apretar la tecla d'opcions - getMenuInflater().inflate(R.menu.menu, menu); - Log.d(TAG, "Menu"); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - //Determina el funcionament al clickar en el menu d'opcions - switch (item.getItemId()) { - case R.id.itemprefs: - return true; - case R.id.itemhelp: - startActivity(new Intent(this, Help.class)); - Log.d(TAG, "Help"); - return true; - default: - return false; - } - }*/ - } \ No newline at end of file -- libgit2 0.22.2