Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 6413d48d6aef05c6835be8239097e82dc9a3f825 0 parents
onyxbits authored
8 .classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
20 .gitignore
@@ -0,0 +1,20 @@
+*.class
+*~
+DEADJOE
+.#*
+*.jar
+*.zip
+*.apk
+bin/
+gen/
+bin/*
+gen/*
+libs/
+libs/*
+compiled/
+compiled/*
+local.properties
+build.xml
+assets/build.properties
+.settings/
+.settings/*
33 .project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ListMyApps</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
27 AndroidManifest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="de.onyxbits.listmyapps"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="9"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="de.onyxbits.listmyapps.MainActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
21 custom_rules.xml
@@ -0,0 +1,21 @@
+<!--
+Customize the build process: create an assets/build.properties file that can
+be checked at runtime for build options and give the APK a more verbose
+name.
+-->
+<project name="Bundle Helper for enabling app store specific features">
+
+
+ <target name="-pre-build">
+ <!-- Extract version information from AndroidManifest.xml -->
+ <xpath input="${manifest.abs.file}" expression="/manifest/@android:versionName" output="dist.version.name" default="unknown"/>
+ <xpath input="${manifest.abs.file}" expression="/manifest/@android:versionCode" output="dist.version.code" default="-1"/>
+ </target>
+
+ <target name="-post-build">
+ <copy
+ overwrite="true"
+ file="${out.final.file}"
+ tofile="${out.absolute.dir}/${ant.project.name}-${build.target}-${dist.version.name}.apk" />
+ </target>
+</project>
BIN  ic_launcher-web.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
14 project.properties
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-17
BIN  res/drawable-hdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-mdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-xhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-xxhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 res/layout/activity_main.xml
@@ -0,0 +1,49 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ tools:context=".MainActivity" >
+
+ <TextView
+ android:id="@+id/format_as"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentTop="true"
+ android:layout_centerVertical="true"
+ android:text="@string/format_as"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <Spinner
+ android:id="@+id/format_select"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentTop="true"
+ android:layout_toRightOf="@+id/format_as" />
+
+ <CheckBox
+ android:id="@+id/always_link"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/format_as"
+ android:layout_centerHorizontal="true"
+ android:padding="30dp"
+ android:text="@string/always_link" />
+
+ <ListView
+ android:id="@+id/listView1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentRight="true"
+ android:layout_below="@+id/always_link"
+ android:paddingTop="10dp" >
+ </ListView>
+
+</RelativeLayout>
38 res/layout/app_item.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/RelativeLayout1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal"
+ android:paddingBottom="5dp"
+ android:paddingLeft="5dp"
+ android:paddingTop="5dp" >
+
+ <CheckBox
+ android:id="@+id/selected"
+ android:focusable="false"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentTop="true"
+ android:layout_centerVertical="true"
+ android:paddingLeft="10dp" />
+
+ <TextView
+ android:id="@+id/appname"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_toRightOf="@+id/selected"
+ android:text=""
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ <TextView
+ android:id="@+id/apppackage"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/appname"
+ android:layout_toRightOf="@+id/selected"
+ android:text=""
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+</RelativeLayout>
7 res/menu/main.xml
@@ -0,0 +1,7 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+ <item android:id="@+id/copy" android:title="@android:string/copy" android:showAsAction="ifRoom"></item>
+ <item android:id="@+id/share" android:title="@string/share" android:showAsAction="ifRoom"></item><item android:id="@+id/select_all" android:title="@android:string/selectAll"></item>
+ <item android:id="@+id/deselect_all" android:title="@string/deselect_all"></item>
+
+
+</menu>
8 res/values-sw600dp/dimens.xml
@@ -0,0 +1,8 @@
+<resources>
+
+ <!--
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw600dp devices (e.g. 7" tablets) here.
+ -->
+
+</resources>
9 res/values-sw720dp-land/dimens.xml
@@ -0,0 +1,9 @@
+<resources>
+
+ <!--
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+ -->
+ <dimen name="activity_horizontal_margin">128dp</dimen>
+
+</resources>
11 res/values-v11/styles.xml
@@ -0,0 +1,11 @@
+<resources>
+
+ <!--
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+ <!-- API 11 theme customizations can go here. -->
+ </style>
+
+</resources>
12 res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+<resources>
+
+ <!--
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- API 14 theme customizations can go here. -->
+ </style>
+
+</resources>
7 res/values/dimens.xml
@@ -0,0 +1,7 @@
+<resources>
+
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+
+</resources>
18 res/values/strings.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">List My Apps</string>
+ <string name="deselect_all">Deselect All</string>
+ <string name="share">Share</string>
+ <string-array name="formatnames">
+ <item>Plain Text</item><item>HTML List</item><item>BBCode List</item><item >Markdown List</item>
+
+
+
+ </string-array>
+ <string name="format_as">Copy/Share as:</string>
+ <string name="list_copied_to_clipboard">List copied to clipboard</string>
+ <string name="always_link">Always link to Google Play, even if the app does not come from there</string>
+ <string name="warn_nothing_selected">Select the apps you want to list!</string>
+
+</resources>
20 res/values/styles.xml
@@ -0,0 +1,20 @@
+<resources>
+
+ <!--
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Light">
+ <!--
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+ -->
+ </style>
+
+ <!-- Application theme. -->
+ <style name="AppTheme" parent="AppBaseTheme">
+ <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+ </style>
+
+</resources>
36 src/de/onyxbits/listmyapps/AppAdapter.java
@@ -0,0 +1,36 @@
+package de.onyxbits.listmyapps;
+
+import java.util.List;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.CheckBox;
+import android.widget.TextView;
+
+public class AppAdapter extends ArrayAdapter<SortablePackageInfo> {
+
+ public AppAdapter(Context context, int textViewResourceId,
+ List<SortablePackageInfo> spi) {
+ super(context, textViewResourceId, spi);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View ret;
+ SortablePackageInfo spi = getItem(position);
+
+ LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ ret = inflater.inflate(R.layout.app_item,null);
+ ((TextView)ret.findViewById(R.id.appname)).setText(spi.displayName);
+ ((TextView)ret.findViewById(R.id.apppackage)).setText(spi.packageName);
+ CheckBox sel = ((CheckBox)ret.findViewById(R.id.selected));
+ sel.setOnClickListener(spi);
+ sel.setChecked(spi.selected);
+ return ret;
+
+ }
+
+}
65 src/de/onyxbits/listmyapps/ListTask.java
@@ -0,0 +1,65 @@
+package de.onyxbits.listmyapps;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+
+import android.content.SharedPreferences;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.AsyncTask;
+import android.util.Log;
+import android.widget.ListView;
+
+public class ListTask extends
+ AsyncTask<Object, Object, ArrayList<SortablePackageInfo>> {
+
+ private ListView listView;
+ private MainActivity mainActivity;
+
+ public ListTask(MainActivity mainActivity, ListView listView) {
+ this.listView = listView;
+ this.mainActivity = mainActivity;
+ }
+
+ @Override
+ protected ArrayList<SortablePackageInfo> doInBackground(Object... params) {
+ SharedPreferences prefs = mainActivity.getSharedPreferences(MainActivity.PREFSFILE, 0);
+ ArrayList<SortablePackageInfo> ret = new ArrayList<SortablePackageInfo>();
+ PackageManager pm = mainActivity.getPackageManager();
+ List<PackageInfo> list = pm.getInstalledPackages(0);
+ SortablePackageInfo spitmp[] = new SortablePackageInfo[list.size()];
+ Iterator<PackageInfo> it = list.iterator();
+ int idx = 0;
+ while (it.hasNext()) {
+ PackageInfo info = it.next();
+ CharSequence tmp = pm.getApplicationLabel(info.applicationInfo);
+ if (pm.getLaunchIntentForPackage(info.packageName) != null) {
+ String inst = pm.getInstallerPackageName(info.packageName);
+ spitmp[idx] = new SortablePackageInfo(info.packageName, tmp,true,inst);
+ idx++;
+ }
+ }
+ SortablePackageInfo spi[] = new SortablePackageInfo[idx];
+ System.arraycopy(spitmp, 0, spi, 0, idx);
+ Arrays.sort(spi);
+ for (int i = 0; i < spi.length; i++) {
+ spi[i].selected=prefs.getBoolean(MainActivity.SELECTED+"."+spi[i].packageName,false);
+ ret.add(spi[i]);
+ }
+ return ret;
+ }
+
+ @Override
+ protected void onPostExecute(ArrayList<SortablePackageInfo> result) {
+ super.onPostExecute(result);
+ listView
+ .setAdapter(new AppAdapter(mainActivity, R.layout.app_item, result));
+ mainActivity.apps=result;
+ mainActivity.setProgressBarIndeterminate(false);
+ mainActivity.setProgressBarVisibility(false);
+ }
+
+}
246 src/de/onyxbits/listmyapps/MainActivity.java
@@ -0,0 +1,246 @@
+package de.onyxbits.listmyapps;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.text.ClipboardManager;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.Window;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
+import android.widget.ArrayAdapter;
+import android.widget.CheckBox;
+import android.widget.ListView;
+import android.widget.Spinner;
+import android.widget.Toast;
+
+public class MainActivity extends Activity implements OnItemSelectedListener {
+
+ protected ArrayList<SortablePackageInfo> apps;
+ private int formatIndex;
+ private String[] formatTypes;
+
+ public static final String PREFSFILE = "settings";
+ private static final String ALWAYS_GOOGLE_PLAY = "always_link_to_google_play";
+ private static final String FORMATTYPE = "formattype";
+ public static final String SELECTED = "selected";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ requestWindowFeature(Window.FEATURE_PROGRESS);
+ setContentView(R.layout.activity_main);
+ setProgressBarIndeterminate(true);
+ setProgressBarVisibility(true);
+ CheckBox checkbox = (CheckBox) findViewById(R.id.always_link);
+ Spinner spinner = (Spinner) findViewById(R.id.format_select);
+ ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
+ R.array.formatnames, android.R.layout.simple_spinner_item);
+ adapter
+ .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ spinner.setAdapter(adapter);
+ spinner.setOnItemSelectedListener(this);
+ formatTypes = getResources().getStringArray(R.array.formatnames);
+ SharedPreferences prefs = getSharedPreferences(PREFSFILE, 0);
+ checkbox.setChecked(prefs.getBoolean((ALWAYS_GOOGLE_PLAY), false));
+ formatIndex = prefs.getInt(FORMATTYPE, 0);
+ spinner.setSelection(formatIndex);
+ new ListTask(this, (ListView) findViewById(R.id.listView1)).execute("");
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ SharedPreferences.Editor editor = getSharedPreferences(PREFSFILE, 0).edit();
+ editor.putBoolean(ALWAYS_GOOGLE_PLAY,
+ ((CheckBox) findViewById(R.id.always_link)).isChecked());
+ editor.putInt(FORMATTYPE, formatIndex);
+ if (apps != null) {
+ Iterator<SortablePackageInfo> it = apps.iterator();
+ while (it.hasNext()) {
+ SortablePackageInfo spi = it.next();
+ editor.putBoolean(SELECTED + "." + spi.packageName, spi.selected);
+ }
+ }
+ editor.commit();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (apps == null) {
+ return true;
+ }
+
+ switch (item.getItemId()) {
+ case R.id.share: {
+ if (isNothingSelected()) {
+ return true;
+ }
+ Intent sendIntent = new Intent();
+ sendIntent.setAction(Intent.ACTION_SEND);
+ sendIntent.putExtra(Intent.EXTRA_TEXT, buildList().toString());
+ sendIntent.setType("text/plain");
+ startActivity(sendIntent);
+ break;
+ }
+ case R.id.copy: {
+ if (isNothingSelected()) {
+ return true;
+ }
+ ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
+ clipboard.setText(buildList().toString());
+ Toast.makeText(this, R.string.list_copied_to_clipboard,
+ Toast.LENGTH_SHORT).show();
+ break;
+ }
+ case (R.id.deselect_all): {
+ Iterator<SortablePackageInfo> it = apps.iterator();
+ while (it.hasNext()) {
+ SortablePackageInfo spi = it.next();
+ spi.selected = false;
+ ((AppAdapter) ((ListView) findViewById(R.id.listView1)).getAdapter())
+ .notifyDataSetChanged();
+ }
+ break;
+ }
+ case (R.id.select_all): {
+ Iterator<SortablePackageInfo> it = apps.iterator();
+ while (it.hasNext()) {
+ SortablePackageInfo spi = it.next();
+ spi.selected = true;
+ ((AppAdapter) ((ListView) findViewById(R.id.listView1)).getAdapter())
+ .notifyDataSetChanged();
+ }
+ break;
+ }
+ }
+ return true;
+ }
+
+ private CharSequence buildList() {
+ StringBuilder ret = new StringBuilder();
+ Iterator<SortablePackageInfo> it = apps.iterator();
+ boolean toMarket = ((CheckBox) findViewById(R.id.always_link)).isChecked();
+ while (it.hasNext()) {
+ SortablePackageInfo spi = it.next();
+ if (spi.selected) {
+ String tmp = spi.packageName;
+ if (toMarket) {
+ tmp = "com.google.vending";
+ }
+ String marketLink = getMarketLink(tmp, spi.packageName);
+
+ switch (formatIndex) {
+ case 0: { // Plain Text
+ ret.append(spi.displayName);
+ ret.append("\n\t");
+ ret.append(spi.packageName);
+ ret.append("\n");
+ break;
+ }
+ case 1: { // HTML list
+ ret.append("<li>");
+ if (marketLink == null) {
+ ret.append(spi.displayName);
+ }
+ else {
+ ret.append("<a href=\"");
+ ret.append(marketLink);
+ ret.append("\">");
+ ret.append(spi.displayName);
+ ret.append("</a>");
+ }
+ ret.append("</li>\n");
+ break;
+ }
+ case 2: { // BBCode
+ ret.append("[*] ");
+ if (marketLink == null) {
+ ret.append(spi.displayName);
+ ret.append("\n");
+ }
+ else {
+ ret.append("[url=");
+ ret.append(marketLink);
+ ret.append("]");
+ ret.append(spi.displayName);
+ ret.append("[/url]\n");
+ }
+ break;
+ }
+ case 3: { // Markdown
+ ret.append("* ");
+ if (marketLink == null) {
+ ret.append(spi.displayName);
+ ret.append("\n");
+ }
+ else {
+ ret.append("[");
+ ret.append(spi.displayName);
+ ret.append("](");
+ ret.append(marketLink);
+ ret.append(")\n");
+ }
+ break;
+ }
+ }
+ }
+ }
+ return ret;
+ }
+
+ public boolean isNothingSelected() {
+ if (apps != null) {
+ Iterator<SortablePackageInfo> it = apps.iterator();
+ while (it.hasNext()) {
+ if (it.next().selected) {
+ return false;
+ }
+ }
+ }
+ Toast
+ .makeText(this, R.string.warn_nothing_selected, Toast.LENGTH_LONG)
+ .show();
+ return true;
+ }
+
+ public String getMarketLink(String installer, String packname) {
+ if (installer == null) {
+ return null;
+ }
+ if (installer.startsWith("com.google")) {
+ return "https://play.google.com/store/apps/details?id=" + packname;
+ }
+
+ return null;
+ }
+
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view, int position,
+ long id) {
+ String tmp = parent.getItemAtPosition(position).toString();
+ for (int i = 0; i < formatTypes.length; i++) {
+ if (tmp.equals(formatTypes[i])) {
+ formatIndex = i;
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> parent) {
+
+ }
+}
37 src/de/onyxbits/listmyapps/SortablePackageInfo.java
@@ -0,0 +1,37 @@
+package de.onyxbits.listmyapps;
+
+import android.view.View;
+import android.widget.CheckBox;
+
+/**
+ * Wrapper class for sorting packages alphabetically by label.
+ *
+ * @author patrick
+ *
+ */
+class SortablePackageInfo implements Comparable<SortablePackageInfo>, View.OnClickListener{
+
+ public String packageName;
+ public String displayName;
+ public String installer;
+ public boolean selected;
+
+ public SortablePackageInfo(CharSequence pn, CharSequence dn, boolean sel, String inst) {
+ packageName = pn.toString();
+ displayName = dn.toString();
+ selected=sel;
+ installer=inst;
+ }
+
+ @Override
+ public int compareTo(SortablePackageInfo another) {
+ return displayName.compareTo(another.displayName);
+ }
+
+ @Override
+ public void onClick(View v) {
+
+ selected = ((CheckBox)v).isChecked();
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.