Remove app list adapters from old 3 tab layout.
This commit is contained in:
parent
65afc83b16
commit
d7fbd868b9
@ -312,7 +312,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is cached as it is called several times inside the AppListAdapter.
|
* This is cached as it is called several times inside app list adapters.
|
||||||
* Providing it here means the shared preferences file only needs to be
|
* Providing it here means the shared preferences file only needs to be
|
||||||
* read once, and we will keep our copy up to date by listening to changes
|
* read once, and we will keep our copy up to date by listening to changes
|
||||||
* in PREF_ROOTED.
|
* in PREF_ROOTED.
|
||||||
@ -326,7 +326,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is cached as it is called several times inside the AppListAdapter.
|
* This is cached as it is called several times inside app list adapters.
|
||||||
* Providing it here means the shared preferences file only needs to be
|
* Providing it here means the shared preferences file only needs to be
|
||||||
* read once, and we will keep our copy up to date by listening to changes
|
* read once, and we will keep our copy up to date by listening to changes
|
||||||
* in PREF_HIDE_ANTI_FEATURE_APPS.
|
* in PREF_HIDE_ANTI_FEATURE_APPS.
|
||||||
|
@ -1,137 +0,0 @@
|
|||||||
package org.fdroid.fdroid.views;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.support.v4.widget.CursorAdapter;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
|
||||||
|
|
||||||
import org.fdroid.fdroid.R;
|
|
||||||
import org.fdroid.fdroid.Utils;
|
|
||||||
import org.fdroid.fdroid.data.App;
|
|
||||||
|
|
||||||
public abstract class AppListAdapter extends CursorAdapter {
|
|
||||||
|
|
||||||
private LayoutInflater inflater;
|
|
||||||
private DisplayImageOptions displayImageOptions;
|
|
||||||
private String upgradeFromTo;
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public AppListAdapter(Context context, Cursor c) {
|
|
||||||
super(context, c);
|
|
||||||
init(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return mDataValid && super.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public AppListAdapter(Context context, Cursor c, boolean autoRequery) {
|
|
||||||
super(context, c, autoRequery);
|
|
||||||
init(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AppListAdapter(Context context, Cursor c, int flags) {
|
|
||||||
super(context, c, flags);
|
|
||||||
init(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(Context context) {
|
|
||||||
inflater = (LayoutInflater) context.getSystemService(
|
|
||||||
Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
displayImageOptions = Utils.getImageLoadingOptions().build();
|
|
||||||
upgradeFromTo = context.getResources().getString(R.string.upgrade_from_to);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract boolean showStatusUpdate();
|
|
||||||
|
|
||||||
protected abstract boolean showStatusInstalled();
|
|
||||||
|
|
||||||
private static class ViewHolder {
|
|
||||||
TextView name;
|
|
||||||
TextView summary;
|
|
||||||
TextView status;
|
|
||||||
TextView license;
|
|
||||||
ImageView icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
|
||||||
View view = inflater.inflate(R.layout.applistitem, parent, false);
|
|
||||||
|
|
||||||
ViewHolder holder = new ViewHolder();
|
|
||||||
holder.name = (TextView) view.findViewById(R.id.name);
|
|
||||||
holder.summary = (TextView) view.findViewById(R.id.summary);
|
|
||||||
holder.status = (TextView) view.findViewById(R.id.status);
|
|
||||||
holder.license = (TextView) view.findViewById(R.id.license);
|
|
||||||
holder.icon = (ImageView) view.findViewById(R.id.icon);
|
|
||||||
view.setTag(holder);
|
|
||||||
|
|
||||||
setupView(view, cursor, holder);
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void bindView(View view, Context context, Cursor cursor) {
|
|
||||||
ViewHolder holder = (ViewHolder) view.getTag();
|
|
||||||
setupView(view, cursor, holder);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupView(View view, Cursor cursor, ViewHolder holder) {
|
|
||||||
final App app = new App(cursor);
|
|
||||||
|
|
||||||
holder.name.setText(app.name);
|
|
||||||
holder.summary.setText(app.summary);
|
|
||||||
|
|
||||||
ImageLoader.getInstance().displayImage(app.iconUrl, holder.icon,
|
|
||||||
displayImageOptions);
|
|
||||||
|
|
||||||
holder.status.setText(getVersionInfo(app));
|
|
||||||
holder.license.setText(app.license);
|
|
||||||
|
|
||||||
// Disable it all if it isn't compatible...
|
|
||||||
final View[] views = {
|
|
||||||
view,
|
|
||||||
holder.status,
|
|
||||||
holder.summary,
|
|
||||||
holder.license,
|
|
||||||
holder.name,
|
|
||||||
};
|
|
||||||
|
|
||||||
for (View v : views) {
|
|
||||||
v.setEnabled(app.compatible && !app.isFiltered());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getVersionInfo(App app) {
|
|
||||||
|
|
||||||
if (app.suggestedVersionCode <= 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!app.isInstalled()) {
|
|
||||||
return app.getSuggestedVersionName();
|
|
||||||
}
|
|
||||||
|
|
||||||
final String installedVersionString = app.installedVersionName;
|
|
||||||
|
|
||||||
if (app.canAndWantToUpdate(mContext) && showStatusUpdate()) {
|
|
||||||
return String.format(upgradeFromTo,
|
|
||||||
installedVersionString, app.getSuggestedVersionName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (app.installedVersionCode > 0 && showStatusInstalled()) {
|
|
||||||
return installedVersionString + " ✔";
|
|
||||||
}
|
|
||||||
|
|
||||||
return installedVersionString;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package org.fdroid.fdroid.views;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.os.Build;
|
|
||||||
|
|
||||||
public class AvailableAppListAdapter extends AppListAdapter {
|
|
||||||
|
|
||||||
public static AvailableAppListAdapter create(Context context, Cursor cursor, int flags) {
|
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
|
||||||
return new AvailableAppListAdapter(context, cursor, flags);
|
|
||||||
}
|
|
||||||
return new AvailableAppListAdapter(context, cursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
private AvailableAppListAdapter(Context context, Cursor c) {
|
|
||||||
super(context, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AvailableAppListAdapter(Context context, Cursor c, boolean autoRequery) {
|
|
||||||
super(context, c, autoRequery);
|
|
||||||
}
|
|
||||||
|
|
||||||
private AvailableAppListAdapter(Context context, Cursor c, int flags) {
|
|
||||||
super(context, c, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean showStatusUpdate() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean showStatusInstalled() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package org.fdroid.fdroid.views;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.os.Build;
|
|
||||||
|
|
||||||
public class CanUpdateAppListAdapter extends AppListAdapter {
|
|
||||||
|
|
||||||
public static CanUpdateAppListAdapter create(Context context, Cursor cursor, int flags) {
|
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
|
||||||
return new CanUpdateAppListAdapter(context, cursor, flags);
|
|
||||||
}
|
|
||||||
return new CanUpdateAppListAdapter(context, cursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CanUpdateAppListAdapter(Context context, Cursor c) {
|
|
||||||
super(context, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CanUpdateAppListAdapter(Context context, Cursor c, boolean autoRequery) {
|
|
||||||
super(context, c, autoRequery);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CanUpdateAppListAdapter(Context context, Cursor c, int flags) {
|
|
||||||
super(context, c, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean showStatusUpdate() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean showStatusInstalled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package org.fdroid.fdroid.views;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.os.Build;
|
|
||||||
|
|
||||||
public class InstalledAppListAdapter extends AppListAdapter {
|
|
||||||
|
|
||||||
public static InstalledAppListAdapter create(Context context, Cursor cursor, int flags) {
|
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
|
||||||
return new InstalledAppListAdapter(context, cursor, flags);
|
|
||||||
}
|
|
||||||
return new InstalledAppListAdapter(context, cursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
private InstalledAppListAdapter(Context context, Cursor c) {
|
|
||||||
super(context, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InstalledAppListAdapter(Context context, Cursor c, boolean autoRequery) {
|
|
||||||
super(context, c, autoRequery);
|
|
||||||
}
|
|
||||||
|
|
||||||
private InstalledAppListAdapter(Context context, Cursor c, int flags) {
|
|
||||||
super(context, c, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean showStatusUpdate() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean showStatusInstalled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user