From 098fb150dfc64bac893c213dcaabf0b0d83fa24b Mon Sep 17 00:00:00 2001 From: David Luhmer Date: Sat, 7 Oct 2023 08:41:44 +0200 Subject: [PATCH 1/4] show changelog after update of app Signed-off-by: David Luhmer --- .../NewsReaderListActivity.java | 14 ++++++++++- .../PodcastFragmentActivity.java | 1 - .../owncloudnewsreader/SettingsFragment.java | 25 ++++++------------- .../VersionInfoDialogFragment.java | 6 ++--- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java index 7b88f5b99..59764465d 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java @@ -226,7 +226,6 @@ protected void onCreate(Bundle savedInstanceState) { startLoginActivity(); } - Bundle args = new Bundle(); String userName = mPrefs.getString(SettingsActivity.EDT_USERNAME_STRING, null); String url = mPrefs.getString(SettingsActivity.EDT_OWNCLOUDROOTPATH_STRING, null); @@ -273,6 +272,8 @@ public void onDrawerOpened(View drawerView) { if (savedInstanceState == null) { //When the app starts (no orientation change) updateDetailFragment(SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_UNREAD_ITEMS.getValue(), true, null, true); } + + showChangelogIfNecessary(); } @Override @@ -336,6 +337,17 @@ public void onConfigurationChanged(@NonNull Configuration newConfig) { } } + void showChangelogIfNecessary() { + // on first app start with new version - always show the changelog + int currentVersionCode = BuildConfig.VERSION_CODE; + int previousVersionCode = mPrefs.getInt("PREVIOUS_VERSION_CODE", 0); + if (currentVersionCode > previousVersionCode) { + DialogFragment dialog = new VersionInfoDialogFragment(); + dialog.show(getSupportFragmentManager(), "VersionChangelogDialogFragment"); + mPrefs.edit().putInt("PREVIOUS_VERSION_CODE", currentVersionCode).apply(); + } + } + /** * This method increases the "pull to open drawer" area by three. * This method should be called only once! diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragmentActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragmentActivity.java index 1b46e98ec..76053600c 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragmentActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragmentActivity.java @@ -8,7 +8,6 @@ import android.content.res.Resources; import android.net.Uri; import android.os.Bundle; -import android.os.Handler; import android.support.v4.media.session.MediaControllerCompat; import android.support.v4.media.session.PlaybackStateCompat; import android.util.Log; diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java index 8ed0a2f3d..fecc72c2f 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java @@ -29,7 +29,6 @@ import android.accounts.Account; import android.accounts.AccountManager; -import android.app.DialogFragment; import android.app.ProgressDialog; import android.content.ContentResolver; import android.content.Context; @@ -45,6 +44,7 @@ import android.widget.Toast; import androidx.appcompat.app.AlertDialog; +import androidx.fragment.app.DialogFragment; import androidx.preference.CheckBoxPreference; import androidx.preference.DialogPreference; import androidx.preference.ListPreference; @@ -54,6 +54,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -126,10 +127,9 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { private static final Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = (preference, value) -> { String stringValue = value.toString(); - if (preference instanceof ListPreference) { + if (preference instanceof ListPreference listPreference) { // For list preferences, look up the correct display value in // the preference's 'entries' list. - ListPreference listPreference = (ListPreference) preference; int index = listPreference.findIndexOfValue(stringValue); // Set the summary to reflect the new value. @@ -158,8 +158,7 @@ else if(PREF_SYNC_SETTINGS.equals(preference.getKey())) { }; private static final Preference.OnPreferenceChangeListener sBindPreferenceBooleanToValueListener = (preference, newValue) -> { - if(preference instanceof CheckBoxPreference) { //For legacy Android support - CheckBoxPreference cbPreference = ((CheckBoxPreference) preference); + if(preference instanceof CheckBoxPreference cbPreference) { //For legacy Android support cbPreference.setChecked((Boolean) newValue); } else { TwoStatePreference twoStatePreference = ((TwoStatePreference) preference); @@ -297,7 +296,7 @@ private void bindAboutPreferences(final PreferenceFragmentCompat prefFrag) { Preference changelogPreference = prefFrag.findPreference(CB_VERSION); changelogPreference.setOnPreferenceClickListener(preference -> { DialogFragment dialog = new VersionInfoDialogFragment(); - dialog.show(prefFrag.requireActivity().getFragmentManager(), "VersionChangelogDialogFragment"); + dialog.show(prefFrag.requireActivity().getSupportFragmentManager(), "VersionChangelogDialogFragment"); return true; }); @@ -317,10 +316,7 @@ private void bindPodcastPreferences(PreferenceFragmentCompat prefFrag) public void checkForUnsycedChangesInDatabaseAndResetDatabase(final Context context) { DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(context); - boolean resetDatabase = true; - if(dbConn.areThereAnyUnsavedChangesInDatabase()) { - resetDatabase = false; - } + boolean resetDatabase = !dbConn.areThereAnyUnsavedChangesInDatabase(); if(resetDatabase) { new ResetDatabaseAsyncTask(context).execute(); @@ -379,11 +375,7 @@ private void openBugReport() { } } - try { - body = URLEncoder.encode(debugInfo,"UTF-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } + body = URLEncoder.encode(debugInfo, StandardCharsets.UTF_8); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/nextcloud/news-android/issues/new?title=" + title + "&body=" + body)); startActivity(browserIntent); } @@ -453,8 +445,7 @@ protected void onPostExecute(Void result) { pd.dismiss(); Toast.makeText(context, context.getString(R.string.cache_is_cleared), Toast.LENGTH_SHORT).show(); - if(context instanceof SettingsActivity) { - SettingsActivity sa = (SettingsActivity) context; + if(context instanceof SettingsActivity sa) { sa.resultIntent.putExtra(SettingsActivity.RI_CACHE_CLEARED, true); } } diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/VersionInfoDialogFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/VersionInfoDialogFragment.java index 499b5fd8f..0c1adb2ea 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/VersionInfoDialogFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/VersionInfoDialogFragment.java @@ -23,8 +23,6 @@ import android.app.Activity; import android.app.Dialog; -import android.app.DialogFragment; -import android.content.DialogInterface; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Bundle; @@ -34,10 +32,12 @@ import android.widget.ProgressBar; import android.widget.TextView; +import androidx.appcompat.app.AlertDialog; +import androidx.fragment.app.DialogFragment; + import java.io.IOException; import java.util.Formatter; -import androidx.appcompat.app.AlertDialog; import de.luhmer.owncloudnewsreader.async_tasks.DownloadChangelogTask; import de.luhmer.owncloudnewsreader.view.ChangeLogFileListView; From ba5896d92b18db4aea5dedb62662753a7e143f46 Mon Sep 17 00:00:00 2001 From: David Luhmer Date: Sat, 7 Oct 2023 08:46:46 +0200 Subject: [PATCH 2/4] use constant Signed-off-by: David Luhmer --- .../src/main/java/de/luhmer/owncloudnewsreader/Constants.java | 4 +++- .../de/luhmer/owncloudnewsreader/NewsReaderListActivity.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/Constants.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/Constants.java index 7c1ead319..4c7c9a060 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/Constants.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/Constants.java @@ -18,9 +18,11 @@ public class Constants { public static final String USER_INFO_STRING = "USER_INFO"; + public static final String PREVIOUS_VERSION_CODE = "PREVIOUS_VERSION_CODE"; + protected static boolean isNextCloud(SharedPreferences prefs) { int[] version = extractVersionNumberFromString(prefs.getString(Constants.NEWS_WEB_VERSION_NUMBER_STRING, "")); - if(version[0] == 0) { + if (version[0] == 0) { // not initialized yet.. return true; // let's assume that it is nextcloud.. } diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java index 59764465d..8d3b49dd3 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java @@ -340,11 +340,11 @@ public void onConfigurationChanged(@NonNull Configuration newConfig) { void showChangelogIfNecessary() { // on first app start with new version - always show the changelog int currentVersionCode = BuildConfig.VERSION_CODE; - int previousVersionCode = mPrefs.getInt("PREVIOUS_VERSION_CODE", 0); + int previousVersionCode = mPrefs.getInt(Constants.PREVIOUS_VERSION_CODE, 0); if (currentVersionCode > previousVersionCode) { DialogFragment dialog = new VersionInfoDialogFragment(); dialog.show(getSupportFragmentManager(), "VersionChangelogDialogFragment"); - mPrefs.edit().putInt("PREVIOUS_VERSION_CODE", currentVersionCode).apply(); + mPrefs.edit().putInt(Constants.PREVIOUS_VERSION_CODE, currentVersionCode).apply(); } } From 7f4498b35ae89255523ae246bc2f2c1fffeb7edc Mon Sep 17 00:00:00 2001 From: David Luhmer Date: Sat, 7 Oct 2023 08:57:21 +0200 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f031e0a3..5006b709f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,20 @@ 0.9.9.82 --------------------- +- Note: Due to changes to the database schema the data will be cleared when upgrading +- Note: What a release! Thank you for the endless contributions from the community! - Added - !1262 - Add shortcut to "Show only unread articles" in the toolbar (thanks to @mkanilsson) -- Changed - !1186 - Material 3 Theme (thanks to @stefan-niedermann) +- Added - !1264 - Add share to swipe option (thanks to @mkanilsson) +- Added - !1266 - per-feed open-in settings ([#1221](https://github.com/nextcloud/news-android/issues/1221) / [#1058](https://github.com/nextcloud/news-android/issues/1058) / [#957](https://github.com/nextcloud/news-android/issues/957)) (thanks to @mkanilsson) +- Added - !1265 - Allow searching both title and body at the same time (thanks to @mkanilsson) +- Added - !1271 - Enable support for predictive back gestures (thanks to @KingOfDog) +- Added - !1286 - Show changelog after update of app - Changed - !1256 - Fix starred items not obeying sort order (thanks to @mkanilsson) +- Changed - !1186 - Material 3 Theme (thanks to @stefan-niedermann) - Changed - Dependency updates -- Fixed - !1257 - Seeking in podcast player doesn't work (thanks to @annasoin) - Fixed - !1255 - add line-height for h1 tags (thanks to @mkanilsson) +- Fixed - !1257 - Seeking in podcast player doesn't work (thanks to @annasoin) +- Fixed - !1272 - Fix weird formatting in articles (thanks to @mkanilsson) +- Fixed - #1276 - active toggles lack color 0.9.9.81 --------------------- From 41bbcfb8f64943ce32def8a4403c5d57bedef49f Mon Sep 17 00:00:00 2001 From: David Luhmer Date: Sat, 7 Oct 2023 09:08:28 +0200 Subject: [PATCH 4/4] fix lint Signed-off-by: David Luhmer --- .../owncloudnewsreader/PiPVideoPlaybackActivity.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PiPVideoPlaybackActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PiPVideoPlaybackActivity.java index 341a438a7..813a87518 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PiPVideoPlaybackActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PiPVideoPlaybackActivity.java @@ -1,5 +1,7 @@ package de.luhmer.owncloudnewsreader; +import static de.luhmer.owncloudnewsreader.services.PodcastPlaybackService.CURRENT_PODCAST_MEDIA_TYPE; + import android.app.PictureInPictureParams; import android.content.ComponentName; import android.content.pm.PackageManager; @@ -7,7 +9,6 @@ import android.graphics.Point; import android.os.Build; import android.os.Bundle; -import android.os.RemoteException; import android.support.v4.media.MediaBrowserCompat; import android.support.v4.media.MediaMetadataCompat; import android.support.v4.media.session.MediaControllerCompat; @@ -29,8 +30,6 @@ import de.luhmer.owncloudnewsreader.services.PodcastPlaybackService; import de.luhmer.owncloudnewsreader.services.podcast.PlaybackService; -import static de.luhmer.owncloudnewsreader.services.PodcastPlaybackService.CURRENT_PODCAST_MEDIA_TYPE; - public class PiPVideoPlaybackActivity extends AppCompatActivity { private static final String TAG = PiPVideoPlaybackActivity.class.getCanonicalName(); @@ -172,6 +171,8 @@ public void onEvent(CollapsePodcastView event) { @Override public void onBackPressed() { + super.onBackPressed(); + Log.d(TAG, "onBackPressed() called"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { enterPictureInPictureMode();