From 41d01cddbe2718a75e43539ce21146852ef506dd Mon Sep 17 00:00:00 2001
From: Raphael Michel <michel@rami.io>
Date: Wed, 3 Jul 2024 15:08:26 +0200
Subject: [PATCH] Add deprecation note

---
 .../opacclient/frontend/MainActivity.java     | 37 ++++++++++---------
 .../opacclient/reminder/SyncAccountJob.java   |  5 ++-
 .../src/main/res/values-de/strings.xml        |  5 +--
 .../opacapp/src/main/res/values/strings.xml   |  4 +-
 4 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/opacclient/opacapp/src/main/java/de/geeksfactory/opacclient/frontend/MainActivity.java b/opacclient/opacapp/src/main/java/de/geeksfactory/opacclient/frontend/MainActivity.java
index d1304cf72..43015b91a 100644
--- a/opacclient/opacapp/src/main/java/de/geeksfactory/opacclient/frontend/MainActivity.java
+++ b/opacclient/opacapp/src/main/java/de/geeksfactory/opacclient/frontend/MainActivity.java
@@ -25,6 +25,7 @@
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.widget.TextView;
 import android.widget.Toast;
 
 import org.joda.time.DateTime;
@@ -499,34 +500,34 @@ public void onClick(DialogInterface dialog, int which) {
 
 
     private void supportPolicyHint() {
-        Account account = app.getAccount();
-        if (!app.getLibrary().isSupportContract() && !account.isSupportPolicyHintSeen()) {
+        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
+        String pkey_time = "notice_support";
+        if (System.currentTimeMillis() - sp.getLong(pkey_time, 0) > 24 * 60 * 60 * 1000) {
             findViewById(R.id.support_policy_hint).setVisibility(View.VISIBLE);
+
+            if (app.getLibrary().isSupportContract()) {
+                ((TextView) findViewById(R.id.tvSupportHint)).setText(R.string.support_policy_hint_support);
+            } else {
+                ((TextView) findViewById(R.id.tvSupportHint)).setText(R.string.support_policy_hint);
+            }
+
             findViewById(R.id.btMoreInfo).setOnClickListener(v -> {
                 Intent websiteIntent = new Intent(Intent.ACTION_VIEW);
-                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
-                    // Chrome custom tabs
-                    Bundle extras = new Bundle();
-                    extras.putBinder("android.support.customtabs.extra.SESSION", null);
-                    extras.putInt("android.support.customtabs.extra.TOOLBAR_COLOR",
-                            ContextCompat.getColor(this, R.color.primary_red));
-                    websiteIntent.putExtras(extras);
-                }
 
-                String url = "https://opac.app/en/support-policy/";
-                String languageCode = Locale.getDefault().getLanguage().toLowerCase();
-                if (Arrays.asList("de", "en", "fr").contains(languageCode)) {
-                    url = String.format("https://opac.app/%s/support-policy/", languageCode);
+                String url;
+                if (app.getLibrary().isSupportContract()) {
+                    url = "https://play.google.com/store/apps/details?id=de.subkom.mobilopac";
+                } else {
+                    url = "https://opac.app/";
                 }
-
                 websiteIntent.setData(Uri.parse(url));
                 startActivity(websiteIntent);
-
             });
             findViewById(R.id.btGotIt).setOnClickListener(v -> {
+                sp.edit()
+                  .putLong(pkey_time, System.currentTimeMillis())
+                  .apply();
                 findViewById(R.id.support_policy_hint).setVisibility(View.GONE);
-                account.setSupportPolicyHintSeen(true);
-                new AccountDataSource(this).update(account);
             });
         } else {
             findViewById(R.id.support_policy_hint).setVisibility(View.GONE);
diff --git a/opacclient/opacapp/src/main/java/de/geeksfactory/opacclient/reminder/SyncAccountJob.java b/opacclient/opacapp/src/main/java/de/geeksfactory/opacclient/reminder/SyncAccountJob.java
index b799bb93b..88307f0a9 100644
--- a/opacclient/opacapp/src/main/java/de/geeksfactory/opacclient/reminder/SyncAccountJob.java
+++ b/opacclient/opacapp/src/main/java/de/geeksfactory/opacclient/reminder/SyncAccountJob.java
@@ -25,6 +25,7 @@
 import android.util.Log;
 
 import org.joda.time.DateTime;
+import org.joda.time.Days;
 import org.joda.time.Hours;
 import org.json.JSONException;
 
@@ -171,8 +172,8 @@ private void updateLibraryConfig() {
         PreferenceDataSource prefs = new PreferenceDataSource(getApplicationContext());
         if (prefs.getLastLibraryConfigUpdate() != null
                 && prefs.getLastLibraryConfigUpdate()
-                        .isAfter(DateTime.now().minus(Hours.ONE))) {
-            Log.d(TAG, "Do not run updateLibraryConfig as last run was less than an hour ago.");
+                        .isAfter(DateTime.now().minus(Days.days(3)))) {
+            Log.d(TAG, "Do not run updateLibraryConfig as last run was less than three days ago.");
             return;
         }
 
diff --git a/opacclient/opacapp/src/main/res/values-de/strings.xml b/opacclient/opacapp/src/main/res/values-de/strings.xml
index 605bbcb10..4001781a6 100644
--- a/opacclient/opacapp/src/main/res/values-de/strings.xml
+++ b/opacclient/opacapp/src/main/res/values-de/strings.xml
@@ -343,9 +343,8 @@
     <string name="load_covers_mobile_data_on">Buchcover werden geladen und angezeigt, wenn verfügbar</string>
     <string name="load_covers_mobile_data_off">Buchcover werden nur über WLAN geladen</string>
     <string name="account_ptr_hint">Sie können auch die Liste nach unten ziehen, um die Daten neu zu laden.</string>
-    <string name="support_policy_hint">Für die Nutzung dieser Bibliothek in der App gibt es
-        keinen kostenfreien Support, eventuelle zukünftige Fehler werden wahrscheinlich nicht
-        behoben.</string>
+    <string name="support_policy_hint">Diese App wird nicht mehr gepflegt und wird keine Updates mehr erhalten. Vielen Dank allen Nutzern für 12 ereignisreiche Jahre. </string>
+    <string name="support_policy_hint_support">This wird nicht mehr gepflegt und wird keine Updates mehr erhalten. Wir empfehlen alternativ die App mobilOPAC, die für viele Bibliotheken ähnliche Funktionen anbietet.</string>
     <string name="support_policy_more_info">mehr Infos</string>
     <string name="prolong_due">Fällige Medien verlängern</string>
     <string name="prolong_due_confirm">Wirklich alle fälligen Medien verlängern? In manchen Bibliotheken können für manche Medien Gebühren anfallen.</string>
diff --git a/opacclient/opacapp/src/main/res/values/strings.xml b/opacclient/opacapp/src/main/res/values/strings.xml
index 20b40bb72..873c4dd29 100644
--- a/opacclient/opacapp/src/main/res/values/strings.xml
+++ b/opacclient/opacapp/src/main/res/values/strings.xml
@@ -342,8 +342,8 @@
     <string name="load_covers_mobile_data_on">Cover images will be loaded and displayed if available</string>
     <string name="load_covers_mobile_data_off">Cover images will only be loaded on WiFi</string>
     <string name="account_ptr_hint">You can also pull down the list to refresh the data.</string>
-    <string name="support_policy_hint">We provide no free support for use of this library in the
-        app, problems that may occur in the future will probably not be fixed.</string>
+    <string name="support_policy_hint">This app is no longer under development and will no longer receive updates. It\'s been a great 12 years, thank you all.</string>
+    <string name="support_policy_hint_support">This app is no longer under development and will no longer receive updates. We recommend the app mobilOPAC instead, which offers similar functionality for many libraries.</string>
     <string name="support_policy_more_info">more info</string>
     <string name="prolong_due">Renew due items</string>
     <string name="prolong_due_confirm">Really renew all due items? In some libraries this might cause fees.</string>