diff --git a/AndroidManifest.xml b/AndroidManifest.xml index d00a8e9..0a9115c 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -37,6 +37,9 @@ - + + \ No newline at end of file diff --git a/res/layout/apps.xml b/res/layout/apps.xml new file mode 100644 index 0000000..9a118ae --- /dev/null +++ b/res/layout/apps.xml @@ -0,0 +1,24 @@ + + + + + + + + \ No newline at end of file diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 9c06429..c01eceb 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -5,6 +5,7 @@ Wählscheibe Verpasste Anrufe SMS + Anwendungen Uhrzeit Daheim Mobil @@ -18,6 +19,6 @@ noch nicht implementiert Bewegen Sie den Finger über den Bildschrim hinauf oder hinunter um einen Eintrag zu wählen. Doppeltes Tippen wählt den aktuellen Eintrag aus. Bewegen Sie den Finger über den Bildschrim hinauf oder hinunter um einen Eintrag zu wählen. Doppeltes Tippen wählt den aktuellen Eintrag aus. - \'Es ist \'HH\' Uhr \'mm\' am \'dd\' \'MMMM + \'Es ist \'HH\' Uhr \'mm\' am \'dd\' \'MMMM \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 21aff93..9be4d3a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5,6 +5,7 @@ Dialer missed calls messages + Applications current time home cell diff --git a/src/net/zaczek/launcherforblind/AppsActivity.java b/src/net/zaczek/launcherforblind/AppsActivity.java new file mode 100644 index 0000000..84df4c9 --- /dev/null +++ b/src/net/zaczek/launcherforblind/AppsActivity.java @@ -0,0 +1,61 @@ +package net.zaczek.launcherforblind; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import net.zaczek.launcherforblind.activitysupport.AbstractArrayActivity; +import net.zaczek.launcherforblind.listentries.AppListEntry; +import net.zaczek.launcherforblind.listentries.ListEntry; +import android.content.Intent; +import android.content.pm.ActivityInfo; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.os.Bundle; +import android.text.TextUtils; +import android.util.Log; +import android.widget.TextView; + +public class AppsActivity extends AbstractArrayActivity { + private static final String TAG = "launcherforblind"; + + private TextView txtMain; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Log.i(TAG, "onCreate"); + setContentView(R.layout.apps); + + txtMain = (TextView) findViewById(R.id.txtMain); + } + + @Override + protected ListEntry[] getList() { + Intent homeIntent = new Intent(Intent.ACTION_MAIN, null); + homeIntent.addCategory(Intent.CATEGORY_LAUNCHER); + + PackageManager pm = this.getPackageManager(); + List result = new ArrayList(); + + for (ResolveInfo info : pm.queryIntentActivities(homeIntent, 0)) { + final ActivityInfo appInfo = info.activityInfo; + if (!appInfo.packageName.equals("net.zaczek.launcherforblind")) { + String lb = info.loadLabel(pm).toString(); + if (TextUtils.isEmpty(lb)) { + lb = info.activityInfo.name.toString(); + } + result.add(new AppListEntry(lb, this, info)); + } + } + + Collections.sort(result); + + return result.toArray(new ListEntry[0]); + } + + @Override + protected void giveFeedback(String label) { + txtMain.setText(label); + } +} diff --git a/src/net/zaczek/launcherforblind/MainActivity.java b/src/net/zaczek/launcherforblind/MainActivity.java index a83cfcf..bb24a13 100644 --- a/src/net/zaczek/launcherforblind/MainActivity.java +++ b/src/net/zaczek/launcherforblind/MainActivity.java @@ -33,6 +33,8 @@ protected ListEntry[] getList() { DialerActivity.class), new NavigatorListEntry(getString(R.string.missedcalls), this, MissedCallsActivity.class), + new NavigatorListEntry(getString(R.string.apps), this, + AppsActivity.class), // new NavigatorListEntry(getString(R.string.sms), this, null), new TimeListEntry(getString(R.string.currenttime), getString(R.string.time_format)), }; diff --git a/src/net/zaczek/launcherforblind/listentries/AppListEntry.java b/src/net/zaczek/launcherforblind/listentries/AppListEntry.java new file mode 100644 index 0000000..b4566a6 --- /dev/null +++ b/src/net/zaczek/launcherforblind/listentries/AppListEntry.java @@ -0,0 +1,33 @@ +package net.zaczek.launcherforblind.listentries; + +import android.content.Context; +import android.content.Intent; +import android.content.pm.ResolveInfo; + +public class AppListEntry extends AbstractListEntry implements Comparable { + private ResolveInfo mInfo; + private Context mCtx; + + public AppListEntry(String label, Context ctx, ResolveInfo info) { + super(label); + mCtx = ctx; + mInfo = info; + } + + @Override + public String getTextToSay() { + return null; + } + + @Override + public void onSelected() { + final Intent i = mCtx.getPackageManager().getLaunchIntentForPackage( + mInfo.activityInfo.packageName); + mCtx.startActivity(i); + } + + @Override + public int compareTo(AppListEntry another) { + return getLabel().compareTo(another.getLabel()); + } +}