Merge commit 'refs/merge-requests/51' of gitorious.org:f-droid/fdroidclient
This commit is contained in:
commit
9ba01d16bf
BIN
res/drawable/ic_cab_done_holo_dark.png
Normal file
BIN
res/drawable/ic_cab_done_holo_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 970 B |
@ -14,6 +14,26 @@
|
||||
android:layout_height="50dp"
|
||||
android:padding="4dp"/>
|
||||
|
||||
<LinearLayout android:id="@+id/status_icons"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:padding="4dp">
|
||||
|
||||
<ImageView android:id="@+id/icon_status_has_updates"
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="18dp"
|
||||
android:gravity="end" />
|
||||
|
||||
<ImageView android:id="@+id/icon_status_installed"
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="18dp"
|
||||
android:gravity="end" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView android:id="@+id/name"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
@ -22,6 +42,7 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/icon"
|
||||
android:layout_toLeftOf="@id/status_icons"
|
||||
android:paddingBottom="2dp"
|
||||
android:paddingLeft="1dp"/>
|
||||
|
||||
|
@ -177,6 +177,6 @@
|
||||
<string name="showPermissions_long">Display a list of permissions an app needs</string>
|
||||
<string name="no_handler_app">You don\'t have any app installed that can handle %s</string>
|
||||
<string name="compactlayout">Compact Layout</string>
|
||||
<string name="compactlayout_long">Hide app summaries when listing apps</string>
|
||||
<string name="compactlayout_long">Only show app names and summaries in list</string>
|
||||
|
||||
</resources>
|
||||
|
@ -1,112 +0,0 @@
|
||||
package org.fdroid.fdroid;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.content.SharedPreferences;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class AppListAdapter extends BaseAdapter {
|
||||
|
||||
private List<DB.App> items = new ArrayList<DB.App>();
|
||||
private Context mContext;
|
||||
|
||||
private boolean pref_compact;
|
||||
|
||||
public AppListAdapter(Context context) {
|
||||
mContext = context;
|
||||
SharedPreferences prefs = PreferenceManager
|
||||
.getDefaultSharedPreferences(mContext);
|
||||
pref_compact = prefs.getBoolean("compactlayout", false);
|
||||
}
|
||||
|
||||
public void addItem(DB.App app) {
|
||||
items.add(app);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
items.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return items.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View v = convertView;
|
||||
if (v == null) {
|
||||
LayoutInflater vi = (LayoutInflater) mContext
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
v = vi.inflate(R.layout.applistitem, null);
|
||||
}
|
||||
DB.App app = items.get(position);
|
||||
|
||||
TextView name = (TextView) v.findViewById(R.id.name);
|
||||
name.setText(app.name);
|
||||
|
||||
String vs;
|
||||
if (app.hasUpdates)
|
||||
vs = app.installedVersion + " -> " + app.updateVersion;
|
||||
else if (app.installedVersion != null)
|
||||
vs = app.installedVersion;
|
||||
else {
|
||||
int numav = app.apks.size();
|
||||
if (numav == 1)
|
||||
vs = mContext.getString(R.string.n_version_available);
|
||||
else
|
||||
vs = mContext.getString(R.string.n_versions_available);
|
||||
vs = String.format(vs, numav);
|
||||
}
|
||||
|
||||
TextView status = (TextView) v.findViewById(R.id.status);
|
||||
status.setText(vs);
|
||||
|
||||
TextView license = (TextView) v.findViewById(R.id.license);
|
||||
license.setText(app.license);
|
||||
|
||||
TextView summary = (TextView) v.findViewById(R.id.summary);
|
||||
if (pref_compact)
|
||||
summary.setVisibility(View.GONE);
|
||||
else
|
||||
summary.setText(app.summary);
|
||||
|
||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||
File icn = new File(DB.getIconsPath(), app.icon);
|
||||
if (icn.exists() && icn.length() > 0) {
|
||||
new Uri.Builder().build();
|
||||
icon.setImageURI(Uri.parse(icn.getPath()));
|
||||
} else {
|
||||
icon.setImageResource(android.R.drawable.sym_def_app_icon);
|
||||
}
|
||||
|
||||
// Disable it all if it isn't compatible...
|
||||
View[] views = { v, status, summary, license, name };
|
||||
for (View view : views) {
|
||||
view.setEnabled(app.compatible);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,10 @@ import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.widget.ArrayAdapter;
|
||||
import org.fdroid.fdroid.views.AppListAdapter;
|
||||
import org.fdroid.fdroid.views.AvailableAppListAdapter;
|
||||
import org.fdroid.fdroid.views.CanUpdateAppListAdapter;
|
||||
import org.fdroid.fdroid.views.InstalledAppListAdapter;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -48,9 +52,9 @@ public class AppListManager {
|
||||
public AppListManager(FDroid activity) {
|
||||
this.fdroidActivity = activity;
|
||||
|
||||
availableApps = new AppListAdapter(fdroidActivity);
|
||||
installedApps = new AppListAdapter(fdroidActivity);
|
||||
canUpgradeApps = new AppListAdapter(fdroidActivity);
|
||||
availableApps = new AvailableAppListAdapter(fdroidActivity);
|
||||
installedApps = new InstalledAppListAdapter(fdroidActivity);
|
||||
canUpgradeApps = new CanUpdateAppListAdapter(fdroidActivity);
|
||||
|
||||
// Needs to be created before createViews(), because that will use the
|
||||
// getCategoriesAdapter() accessor which expects this object...
|
||||
|
@ -31,6 +31,8 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import org.fdroid.fdroid.views.AppListAdapter;
|
||||
import org.fdroid.fdroid.views.AvailableAppListAdapter;
|
||||
|
||||
public class SearchResults extends ListActivity {
|
||||
|
||||
@ -45,7 +47,7 @@ public class SearchResults extends ListActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
applist = new AppListAdapter(this);
|
||||
applist = new AvailableAppListAdapter(this);
|
||||
setContentView(R.layout.searchresults);
|
||||
|
||||
Intent intent = getIntent();
|
||||
|
155
src/org/fdroid/fdroid/views/AppListAdapter.java
Normal file
155
src/org/fdroid/fdroid/views/AppListAdapter.java
Normal file
@ -0,0 +1,155 @@
|
||||
package org.fdroid.fdroid.views;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.content.SharedPreferences;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.*;
|
||||
import org.fdroid.fdroid.DB;
|
||||
import org.fdroid.fdroid.R;
|
||||
|
||||
abstract public class AppListAdapter extends BaseAdapter {
|
||||
|
||||
private List<DB.App> items = new ArrayList<DB.App>();
|
||||
private Context mContext;
|
||||
|
||||
private boolean pref_compact;
|
||||
|
||||
public AppListAdapter(Context context) {
|
||||
mContext = context;
|
||||
SharedPreferences prefs = PreferenceManager
|
||||
.getDefaultSharedPreferences(mContext);
|
||||
pref_compact = prefs.getBoolean("compactlayout", false);
|
||||
}
|
||||
|
||||
abstract protected boolean showStatusUpdate();
|
||||
|
||||
abstract protected boolean showStatusInstalled();
|
||||
|
||||
public void addItem(DB.App app) {
|
||||
items.add(app);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
items.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return items.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View v = convertView;
|
||||
if (v == null) {
|
||||
LayoutInflater vi = (LayoutInflater) mContext
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
v = vi.inflate(R.layout.applistitem, null);
|
||||
}
|
||||
DB.App app = items.get(position);
|
||||
|
||||
TextView name = (TextView) v.findViewById(R.id.name);
|
||||
name.setText(app.name);
|
||||
|
||||
TextView summary = (TextView) v.findViewById(R.id.summary);
|
||||
summary.setText(app.summary);
|
||||
|
||||
TextView status = (TextView) v.findViewById(R.id.status);
|
||||
TextView license = (TextView) v.findViewById(R.id.license);
|
||||
|
||||
ImageView iconUpdates = (ImageView)v.findViewById(R.id.icon_status_has_updates);
|
||||
ImageView iconInstalled = (ImageView)v.findViewById(R.id.icon_status_installed);
|
||||
|
||||
if (pref_compact) {
|
||||
|
||||
status.setVisibility(View.GONE);
|
||||
license.setVisibility(View.GONE);
|
||||
|
||||
RelativeLayout.LayoutParams summaryLayout =
|
||||
new RelativeLayout.LayoutParams(
|
||||
RelativeLayout.LayoutParams.WRAP_CONTENT,
|
||||
RelativeLayout.LayoutParams.WRAP_CONTENT);
|
||||
summaryLayout.addRule(RelativeLayout.BELOW, R.id.name);
|
||||
summaryLayout.addRule(RelativeLayout.RIGHT_OF, R.id.icon);
|
||||
summary.setLayoutParams(summaryLayout);
|
||||
|
||||
if (app.hasUpdates && showStatusUpdate()) {
|
||||
iconUpdates.setImageResource(R.drawable.ic_menu_refresh);
|
||||
iconUpdates.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
iconUpdates.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (app.installedVerCode > 0 && showStatusInstalled()) {
|
||||
iconInstalled.setImageResource(R.drawable.ic_cab_done_holo_dark);
|
||||
iconInstalled.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
iconInstalled.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
status.setText(getVersionInfo(app));
|
||||
license.setText(app.license);
|
||||
|
||||
iconUpdates.setVisibility(View.GONE);
|
||||
iconInstalled.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||
File icn = new File(DB.getIconsPath(), app.icon);
|
||||
if (icn.exists() && icn.length() > 0) {
|
||||
new Uri.Builder().build();
|
||||
icon.setImageURI(Uri.parse(icn.getPath()));
|
||||
} else {
|
||||
icon.setImageResource(android.R.drawable.sym_def_app_icon);
|
||||
}
|
||||
|
||||
// Disable it all if it isn't compatible...
|
||||
View[] views = { v, status, summary, license, name };
|
||||
for (View view : views) {
|
||||
view.setEnabled(app.compatible);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
private String getVersionInfo(DB.App app) {
|
||||
StringBuilder version = new StringBuilder();
|
||||
if (app.installedVersion != null) {
|
||||
version.append(app.installedVersion);
|
||||
if (app.hasUpdates) {
|
||||
version.append(" -> ");
|
||||
version.append(app.updateVersion);
|
||||
}
|
||||
} else {
|
||||
int numav = app.apks.size();
|
||||
String numVersions;
|
||||
if (numav == 1)
|
||||
numVersions = mContext.getString(R.string.n_version_available);
|
||||
else
|
||||
numVersions = mContext.getString(R.string.n_versions_available);
|
||||
version.append(String.format(numVersions, numav));
|
||||
}
|
||||
return version.toString();
|
||||
}
|
||||
|
||||
}
|
19
src/org/fdroid/fdroid/views/AvailableAppListAdapter.java
Normal file
19
src/org/fdroid/fdroid/views/AvailableAppListAdapter.java
Normal file
@ -0,0 +1,19 @@
|
||||
package org.fdroid.fdroid.views;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class AvailableAppListAdapter extends AppListAdapter {
|
||||
public AvailableAppListAdapter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showStatusUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showStatusInstalled() {
|
||||
return true;
|
||||
}
|
||||
}
|
19
src/org/fdroid/fdroid/views/CanUpdateAppListAdapter.java
Normal file
19
src/org/fdroid/fdroid/views/CanUpdateAppListAdapter.java
Normal file
@ -0,0 +1,19 @@
|
||||
package org.fdroid.fdroid.views;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class CanUpdateAppListAdapter extends AppListAdapter {
|
||||
public CanUpdateAppListAdapter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showStatusUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showStatusInstalled() {
|
||||
return false;
|
||||
}
|
||||
}
|
19
src/org/fdroid/fdroid/views/InstalledAppListAdapter.java
Normal file
19
src/org/fdroid/fdroid/views/InstalledAppListAdapter.java
Normal file
@ -0,0 +1,19 @@
|
||||
package org.fdroid.fdroid.views;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class InstalledAppListAdapter extends AppListAdapter {
|
||||
public InstalledAppListAdapter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showStatusUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showStatusInstalled() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import org.fdroid.fdroid.*;
|
||||
import org.fdroid.fdroid.views.AppListAdapter;
|
||||
import org.fdroid.fdroid.views.AppListView;
|
||||
|
||||
abstract class AppListFragment extends Fragment implements AdapterView.OnItemClickListener {
|
||||
|
@ -6,7 +6,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.*;
|
||||
|
||||
import org.fdroid.fdroid.AppListAdapter;
|
||||
import org.fdroid.fdroid.views.AppListAdapter;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.views.AppListView;
|
||||
|
||||
|
@ -4,8 +4,7 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import org.fdroid.fdroid.AppListAdapter;
|
||||
import org.fdroid.fdroid.views.AppListAdapter;
|
||||
|
||||
public class CanUpdateAppsFragment extends AppListFragment {
|
||||
|
||||
|
@ -4,7 +4,7 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import org.fdroid.fdroid.AppListAdapter;
|
||||
import org.fdroid.fdroid.views.AppListAdapter;
|
||||
|
||||
public class InstalledAppsFragment extends AppListFragment {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user