Move "what's new" from its own section to the header section
Also, add some styling and placeholder text (randomly set or not set)
This commit is contained in:
parent
2d27ba4086
commit
622a1245dc
@ -9,6 +9,7 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.fdroid.fdroid.BuildConfig;
|
||||
import org.fdroid.fdroid.RepoXMLHandler;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
import org.fdroid.fdroid.data.Schema.ApkTable.Cols;
|
||||
@ -74,6 +75,11 @@ public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
|
||||
public String repoAddress;
|
||||
public String[] incompatibleReasons;
|
||||
|
||||
/**
|
||||
* A descriptive text for what has changed in the latest version.
|
||||
*/
|
||||
public String whatsNew;
|
||||
|
||||
public String[] antiFeatures;
|
||||
|
||||
/**
|
||||
@ -211,6 +217,13 @@ public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// For now, just populate "what's new" with placeholder (or leave blank)
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (Math.random() > 0.5) {
|
||||
whatsNew = "This section will contain the 'what's new' information for the apk.\n\n\t• Bug fixes.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkRepoAddress() {
|
||||
|
@ -52,6 +52,7 @@ import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class AppDetailsRecyclerViewAdapter
|
||||
@ -83,12 +84,11 @@ public class AppDetailsRecyclerViewAdapter
|
||||
|
||||
private static final int VIEWTYPE_HEADER = 0;
|
||||
private static final int VIEWTYPE_SCREENSHOTS = 1;
|
||||
private static final int VIEWTYPE_WHATS_NEW = 2;
|
||||
private static final int VIEWTYPE_DONATE = 3;
|
||||
private static final int VIEWTYPE_LINKS = 4;
|
||||
private static final int VIEWTYPE_PERMISSIONS = 5;
|
||||
private static final int VIEWTYPE_VERSIONS = 6;
|
||||
private static final int VIEWTYPE_VERSION = 7;
|
||||
private static final int VIEWTYPE_DONATE = 2;
|
||||
private static final int VIEWTYPE_LINKS = 3;
|
||||
private static final int VIEWTYPE_PERMISSIONS = 4;
|
||||
private static final int VIEWTYPE_VERSIONS = 5;
|
||||
private static final int VIEWTYPE_VERSION = 6;
|
||||
|
||||
private final Context context;
|
||||
@NonNull
|
||||
@ -127,7 +127,6 @@ public class AppDetailsRecyclerViewAdapter
|
||||
}
|
||||
addItem(VIEWTYPE_HEADER);
|
||||
addItem(VIEWTYPE_SCREENSHOTS);
|
||||
addItem(VIEWTYPE_WHATS_NEW);
|
||||
addItem(VIEWTYPE_DONATE);
|
||||
addItem(VIEWTYPE_LINKS);
|
||||
addItem(VIEWTYPE_PERMISSIONS);
|
||||
@ -169,6 +168,12 @@ public class AppDetailsRecyclerViewAdapter
|
||||
|
||||
private boolean shouldShowPermissions() {
|
||||
// Figure out if we should show permissions section
|
||||
Apk curApk = getSuggestedApk();
|
||||
final boolean curApkCompatible = curApk != null && curApk.compatible;
|
||||
return versions.size() > 0 && (curApkCompatible || Preferences.get().showIncompatibleVersions());
|
||||
}
|
||||
|
||||
private Apk getSuggestedApk() {
|
||||
Apk curApk = null;
|
||||
for (int i = 0; i < versions.size(); i++) {
|
||||
final Apk apk = versions.get(i);
|
||||
@ -177,8 +182,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
break;
|
||||
}
|
||||
}
|
||||
final boolean curApkCompatible = curApk != null && curApk.compatible;
|
||||
return versions.size() > 0 && (curApkCompatible || Preferences.get().showIncompatibleVersions());
|
||||
return curApk;
|
||||
}
|
||||
|
||||
private boolean shouldShowDonate() {
|
||||
@ -208,9 +212,6 @@ public class AppDetailsRecyclerViewAdapter
|
||||
case VIEWTYPE_SCREENSHOTS:
|
||||
View screenshots = inflater.inflate(R.layout.app_details2_screenshots, parent, false);
|
||||
return new ScreenShotsViewHolder(screenshots);
|
||||
case VIEWTYPE_WHATS_NEW:
|
||||
View whatsNew = inflater.inflate(R.layout.app_details2_whatsnew, parent, false);
|
||||
return new WhatsNewViewHolder(whatsNew);
|
||||
case VIEWTYPE_DONATE:
|
||||
View donate = inflater.inflate(R.layout.app_details2_donate, parent, false);
|
||||
return new DonateViewHolder(donate);
|
||||
@ -242,9 +243,6 @@ public class AppDetailsRecyclerViewAdapter
|
||||
case VIEWTYPE_SCREENSHOTS:
|
||||
((ScreenShotsViewHolder) holder).bindModel();
|
||||
break;
|
||||
case VIEWTYPE_WHATS_NEW:
|
||||
((WhatsNewViewHolder) holder).bindModel();
|
||||
break;
|
||||
case VIEWTYPE_DONATE:
|
||||
((DonateViewHolder) holder).bindModel();
|
||||
break;
|
||||
@ -292,6 +290,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
final TextView titleView;
|
||||
final TextView authorView;
|
||||
final TextView lastUpdateView;
|
||||
final TextView whatsNewView;
|
||||
final TextView descriptionView;
|
||||
final TextView descriptionMoreView;
|
||||
final TextView antiFeaturesLabelView;
|
||||
@ -314,6 +313,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
titleView = (TextView) view.findViewById(R.id.title);
|
||||
authorView = (TextView) view.findViewById(R.id.author);
|
||||
lastUpdateView = (TextView) view.findViewById(R.id.text_last_update);
|
||||
whatsNewView = (TextView) view.findViewById(R.id.whats_new);
|
||||
descriptionView = (TextView) view.findViewById(R.id.description);
|
||||
descriptionMoreView = (TextView) view.findViewById(R.id.description_more);
|
||||
antiFeaturesLabelView = (TextView) view.findViewById(R.id.label_anti_features);
|
||||
@ -412,6 +412,17 @@ public class AppDetailsRecyclerViewAdapter
|
||||
} else {
|
||||
lastUpdateView.setVisibility(View.GONE);
|
||||
}
|
||||
Apk suggestedApk = getSuggestedApk();
|
||||
if (suggestedApk == null || TextUtils.isEmpty(suggestedApk.whatsNew)) {
|
||||
whatsNewView.setVisibility(View.GONE);
|
||||
} else {
|
||||
StringBuilder sbWhatsNew = new StringBuilder();
|
||||
sbWhatsNew.append(whatsNewView.getContext().getString(R.string.details_new_in_version, suggestedApk.versionName).toUpperCase(Locale.getDefault()));
|
||||
sbWhatsNew.append("\n\n");
|
||||
sbWhatsNew.append(suggestedApk.whatsNew);
|
||||
whatsNewView.setText(sbWhatsNew);
|
||||
whatsNewView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
final Spanned desc = Html.fromHtml(app.description, null, new Utils.HtmlTagHandler());
|
||||
descriptionView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
descriptionView.setText(trimTrailingNewlines(desc));
|
||||
@ -569,19 +580,6 @@ public class AppDetailsRecyclerViewAdapter
|
||||
}
|
||||
}
|
||||
|
||||
private class WhatsNewViewHolder extends RecyclerView.ViewHolder {
|
||||
final TextView textView;
|
||||
|
||||
WhatsNewViewHolder(View view) {
|
||||
super(view);
|
||||
textView = (TextView) view.findViewById(R.id.text);
|
||||
}
|
||||
|
||||
public void bindModel() {
|
||||
textView.setText("WHATS NEW GOES HERE");
|
||||
}
|
||||
}
|
||||
|
||||
private class DonateViewHolder extends RecyclerView.ViewHolder {
|
||||
final TextView donateHeading;
|
||||
final GridLayout donationOptionsLayout;
|
||||
|
@ -13,12 +13,15 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
android:paddingBottom="8dp"
|
||||
>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
@ -156,8 +159,25 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/whats_new"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:background="@color/details_panel_light"
|
||||
tools:text="NEW IN VERSION 1.0.2233\n\nA lot has happened since the last build:\n\n\t• Improved UI\n\t• Bug fixes"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
@ -170,6 +190,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:scrollbars="none"
|
||||
android:textStyle="bold"
|
||||
android:textAllCaps="true"
|
||||
@ -181,6 +203,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:scrollbars="none"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
tools:text="\t• This app tracks and reports your activity." />
|
||||
@ -190,6 +214,8 @@
|
||||
style="@style/DetailsMoreButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:gravity="right|end"
|
||||
android:text="@string/more"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
@ -200,6 +226,8 @@
|
||||
style="@style/DetailsAntiFeaturesWarningStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:drawableStart="@drawable/ic_warning_black_24dp"
|
||||
android:drawableLeft="@drawable/ic_warning_black_24dp"
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/details_activity_padding"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
/>
|
@ -169,6 +169,7 @@
|
||||
|
||||
<string name="details_installed">Version %s installed</string>
|
||||
<string name="details_notinstalled">Not installed</string>
|
||||
<string name="details_new_in_version">New in version %s</string>
|
||||
|
||||
<string name="antifeatureswarning">This app has features you may not like.</string>
|
||||
<string name="antifeatures">Anti-features</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user