From b08dfdcb808f74c552f3a8a01ffa7be86a9ff8c8 Mon Sep 17 00:00:00 2001
From: Hans-Christoph Steiner <hans@eds.org>
Date: Wed, 29 Mar 2017 18:12:07 +0200
Subject: [PATCH] move "What's New" placeholder to where its used

There is still quite a bit to figure out in the data format of the
per-package "What's New" entries, and its breaking the tests, so move
the placeholder code to the one spot where the placeholder whatsNew
entry is used.
---
 app/src/main/java/org/fdroid/fdroid/data/Apk.java   | 13 -------------
 .../fdroid/views/AppDetailsRecyclerViewAdapter.java | 13 +++++++++++--
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/app/src/main/java/org/fdroid/fdroid/data/Apk.java b/app/src/main/java/org/fdroid/fdroid/data/Apk.java
index 66c86d3ce..5b65ad9ac 100644
--- a/app/src/main/java/org/fdroid/fdroid/data/Apk.java
+++ b/app/src/main/java/org/fdroid/fdroid/data/Apk.java
@@ -11,7 +11,6 @@ import android.support.annotation.NonNull;
 import com.fasterxml.jackson.annotation.JacksonInject;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
-import org.fdroid.fdroid.BuildConfig;
 import org.fdroid.fdroid.RepoXMLHandler;
 import org.fdroid.fdroid.Utils;
 import org.fdroid.fdroid.data.Schema.ApkTable.Cols;
@@ -102,11 +101,6 @@ public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
 
     public String[] incompatibleReasons;
 
-    /**
-     * A descriptive text for what has changed in the latest version.
-     */
-    public String whatsNew;
-
     public String[] antiFeatures;
 
     /**
@@ -246,13 +240,6 @@ 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() {
diff --git a/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java
index 48b1b868a..05fb567a1 100644
--- a/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java
+++ b/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java
@@ -35,6 +35,7 @@ import android.widget.Toast;
 import com.nostra13.universalimageloader.core.DisplayImageOptions;
 import com.nostra13.universalimageloader.core.ImageLoader;
 import com.nostra13.universalimageloader.core.assist.ImageScaleType;
+import org.fdroid.fdroid.BuildConfig;
 import org.fdroid.fdroid.Preferences;
 import org.fdroid.fdroid.R;
 import org.fdroid.fdroid.Utils;
@@ -413,7 +414,15 @@ public class AppDetailsRecyclerViewAdapter
                 lastUpdateView.setVisibility(View.GONE);
             }
             Apk suggestedApk = getSuggestedApk();
-            if (suggestedApk == null || TextUtils.isEmpty(suggestedApk.whatsNew)) {
+            // TODO replace this whatsNew test code with what comes from suggestedApk once that exists
+            //if (suggestedApk == null || TextUtils.isEmpty(suggestedApk.whatsNew)) {
+            String whatsNew = null;
+            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.";
+                }
+            }
+            if (suggestedApk == null || TextUtils.isEmpty(whatsNew)) {
                 whatsNewView.setVisibility(View.GONE);
             } else {
                 //noinspection deprecation Ignore deprecation because the suggested way is only available in API 24.
@@ -422,7 +431,7 @@ public class AppDetailsRecyclerViewAdapter
                 StringBuilder sbWhatsNew = new StringBuilder();
                 sbWhatsNew.append(whatsNewView.getContext().getString(R.string.details_new_in_version, suggestedApk.versionName).toUpperCase(locale));
                 sbWhatsNew.append("\n\n");
-                sbWhatsNew.append(suggestedApk.whatsNew);
+                sbWhatsNew.append("This section will contain the 'what's new' information for the apk.\n\n\t• Bug fixes.");
                 whatsNewView.setText(sbWhatsNew);
                 whatsNewView.setVisibility(View.VISIBLE);
             }