forked from arthurzaczek/launcherforblind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
399761c
commit 6b1b545
Showing
7 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" > | ||
|
||
<TextView | ||
android:id="@+id/txtMain" | ||
style="@style/Main" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_centerInParent="true" | ||
android:gravity="center" | ||
android:text="@string/apps" /> | ||
|
||
<TextView | ||
android:id="@+id/txtHelp" | ||
style="@style/Help" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@id/txtMain" | ||
android:gravity="center" | ||
android:text="@string/main_help" /> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AppListEntry> result = new ArrayList<AppListEntry>(); | ||
|
||
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/net/zaczek/launcherforblind/listentries/AppListEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AppListEntry> { | ||
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()); | ||
} | ||
} |