Skip to content

Commit fc9b1ac

Browse files
committed
maintenance release
maintenance release including updated support libraries
1 parent 39ae3ce commit fc9b1ac

30 files changed

+454
-261
lines changed

app/build.gradle

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 30
4+
compileSdkVersion 32
55

66
defaultConfig {
77
applicationId "livio.rssreader"
88
minSdkVersion 23
9-
targetSdkVersion 30
10-
versionCode 100
11-
versionName "1.00"
9+
targetSdkVersion 31
10+
versionCode 101
11+
versionName "1.0.1"
1212
}
1313

1414
compileOptions {
@@ -26,15 +26,17 @@ android {
2626
}
2727

2828
dependencies {
29-
implementation 'androidx.appcompat:appcompat:1.3.1'
30-
implementation 'androidx.appcompat:appcompat-resources:1.3.1'
29+
implementation 'androidx.appcompat:appcompat:1.5.1'
30+
implementation 'androidx.appcompat:appcompat-resources:1.5.1'
3131

3232
implementation 'androidx.cardview:cardview:1.0.0'
3333
implementation 'androidx.recyclerview:recyclerview:1.2.1'
3434
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
35-
implementation 'androidx.preference:preference:1.1.1'
36-
implementation 'androidx.work:work-runtime:2.5.0'
35+
implementation 'androidx.preference:preference:1.2.0'
36+
implementation 'androidx.work:work-runtime:2.7.1'
3737

38-
implementation 'com.google.android.material:material:1.4.0'
38+
implementation 'com.google.android.material:material:1.7.0'
39+
40+
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' //added as workaround for issue https://issuetracker.google.com/issues/238425626
3941

4042
}

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="livio.rssreader">
3-
<uses-permission android:name="android.permission.INTERNET" />
3+
4+
<uses-permission android:name="android.permission.INTERNET" />
45
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
56
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />
67
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /><!--required to access data written before user uninstalls and reinstalls app-->
@@ -41,18 +42,18 @@
4142
android:label="@string/show_help_label"/>
4243
<activity
4344
android:name=".SelectColors" android:exported="false" android:resizeableActivity="false" android:configChanges="orientation|screenSize"
44-
android:theme="@style/Theme.MaterialComponents.Dialog.Bridge"
45+
android:theme="@style/MyDialogTheme"
4546
android:label="@string/prefs_theme_sub">
4647
</activity>
4748
<!-- Widget -->
48-
<receiver android:name="livio.rssreader.RSSWidget" android:label="@string/widget_name">
49+
<receiver android:name="livio.rssreader.RSSWidget" android:exported="true" android:label="@string/widget_name">
4950
<intent-filter>
5051
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
5152
</intent-filter>
5253
<meta-data android:name="android.appwidget.provider" android:resource="@xml/rss_widget" />
5354
</receiver>
5455
<!-- Widget dark -->
55-
<receiver android:name="livio.rssreader.RSSWidgetDark" android:label="@string/widget_name">
56+
<receiver android:name="livio.rssreader.RSSWidgetDark" android:exported="true" android:label="@string/widget_name">
5657
<intent-filter>
5758
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
5859
</intent-filter>

app/src/main/java/livio/rssreader/ListFeeds.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
*/
1515
import java.util.ArrayList;
1616

17+
import androidx.annotation.NonNull;
18+
import androidx.annotation.Nullable;
1719
import livio.rssreader.backend.UserDB;
1820
import livio.rssreader.backend.Item;
1921
import livio.rssreader.backend.ItemArrayAdapter;
@@ -37,6 +39,7 @@
3739

3840
import android.view.MenuItem;
3941

42+
import android.view.View;
4043
import android.widget.ListView;
4144

4245
import static livio.rssreader.backend.UserDB.DEFAULT_FEED_ID;
@@ -60,15 +63,7 @@ protected void onCreate(Bundle savedInstanceState) {
6063
if (t != null) {
6164
t.setDisplayHomeAsUpEnabled(true);
6265
}
63-
64-
Intent startingIntent = getIntent();
65-
if (startingIntent != null) {
66-
Bundle b = startingIntent.getBundleExtra(SelectCategory.ID_CATEGORY);
67-
if (b != null) {
68-
cat = b.getString("category");
69-
}
70-
}
71-
66+
7267
}
7368

7469
/////////////////////////////////////////
@@ -78,14 +73,22 @@ public static class FeedsFragment extends ListFragment implements NewFeedDialog.
7873
SharedPreferences prefs;
7974

8075
@Override
81-
public void onActivityCreated(Bundle savedInstanceState) {
82-
super.onActivityCreated(savedInstanceState);
76+
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {//03-12-2022: sostituisce onActivityCreated deprecated
77+
super.onViewCreated(view, savedInstanceState);
8378

8479
final Activity act = getActivity();
8580
prefs = PreferenceManager.getDefaultSharedPreferences(act);
8681

8782
udb = UserDB.getInstance(act, prefs);
8883

84+
Intent startingIntent = act.getIntent();
85+
if (startingIntent != null) {
86+
Bundle b = startingIntent.getBundleExtra(SelectCategory.ID_CATEGORY);
87+
if (b != null) {
88+
cat = b.getString("category");
89+
} else Log.e(tag, "missing category!");
90+
}
91+
8992
currentUserFeeds = udb.getUserFeeds(cat);
9093
nativeFeeds = UserDB.getNativeFeeds();
9194
catIdx = udb.cat2int(cat);
@@ -103,15 +106,15 @@ public void onActivityCreated(Bundle savedInstanceState) {
103106
ListView lv = getListView();
104107
lv.setTextFilterEnabled(true);
105108

106-
lv.setOnItemClickListener((parent, view, position, id) -> { //select a feed
109+
lv.setOnItemClickListener((parent, v, position, id) -> { //select a feed
107110
SharedPreferences.Editor editor = prefs.edit();
108111
editor.putString(RSSReader.PREF_FEED_ID, getFeed(position)[2]);
109112
editor.apply();
110113
act.setResult(RESULT_OK);
111114
act.finish();
112115
});
113116
//long click --> edit (work in progress)
114-
lv.setOnItemLongClickListener((parent, view, position, id) -> { //edit a feed
117+
lv.setOnItemLongClickListener((parent, v, position, id) -> { //edit a feed
115118
if (isUserFeed(position)) {//only feeds in user category can be edited
116119
String[] feed = getFeed(position);
117120
NewFeedDialog editNameDialog = NewFeedDialog.newInstance(feed);
@@ -141,7 +144,8 @@ public void onFinishEditDialog(String[] feed) {//add or replace feed
141144
addFeed(cat, feed);
142145
iaa.add(new Item(feed[0], false));
143146
final Activity act = getActivity();
144-
act.invalidateOptionsMenu();
147+
if (act != null)
148+
act.invalidateOptionsMenu();
145149
}
146150
iaa.notifyDataSetChanged();
147151
}

app/src/main/java/livio/rssreader/PreferencesFragXML.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
import android.content.SharedPreferences;
1717
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
1818
import android.content.res.Configuration;
19+
import android.content.res.Resources;
1920
import android.os.Build;
2021
import android.os.Bundle;
2122

23+
import androidx.annotation.NonNull;
2224
import androidx.fragment.app.DialogFragment;
2325
import androidx.preference.Preference;
2426
import androidx.preference.PreferenceFragmentCompat;
@@ -29,6 +31,7 @@
2931
import tools.SeekBarPreference;
3032

3133
import android.view.MenuItem;
34+
import android.view.WindowManager;
3235

3336
import static livio.rssreader.RSSReader.PREF_FONTSIZE;
3437

@@ -59,7 +62,18 @@ public boolean onOptionsItemSelected(MenuItem item) {
5962
}
6063
return super.onOptionsItemSelected(item);
6164
}
62-
65+
66+
@Override
67+
public void onStart() {//14-11-2022: narrow panel in case of table in landscape mode
68+
super.onStart();
69+
Resources resources = getResources();
70+
if (resources.getBoolean(R.bool.is_tablet_landscape)) {//isTablet && isLandscape
71+
// int dialogHeight = (int) (getResources().getDisplayMetrics().heightPixels * 0.6);
72+
int dialogWidth = (int) (resources.getDisplayMetrics().widthPixels * 0.6);
73+
getWindow().setLayout(dialogWidth, WindowManager.LayoutParams.MATCH_PARENT);
74+
}
75+
}
76+
6377
public static class PrefsFragment extends PreferenceFragmentCompat implements OnSharedPreferenceChangeListener{
6478
SharedPreferences prefs;
6579

@@ -91,7 +105,7 @@ private void setFontSizeSummary() {
91105
private static final String DIALOG_FRAGMENT_TAG = "SeekBarDialogPreference";
92106

93107
@Override
94-
public void onDisplayPreferenceDialog(Preference preference) {
108+
public void onDisplayPreferenceDialog(@NonNull Preference preference) {
95109
// check if dialog is already showing
96110
if (getParentFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) {
97111
return;

app/src/main/java/livio/rssreader/RSSReader.java

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
import androidx.annotation.NonNull;
7575
import androidx.appcompat.app.AlertDialog;
7676
import androidx.appcompat.app.AppCompatDialogFragment;
77+
import androidx.appcompat.view.ContextThemeWrapper;
78+
import androidx.appcompat.widget.PopupMenu;
7779
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
7880
import androidx.appcompat.app.ActionBar;
7981
import androidx.appcompat.app.AppCompatActivity;
@@ -84,6 +86,7 @@
8486
import android.text.format.DateUtils;
8587
import android.text.method.LinkMovementMethod;
8688
import android.util.Log;
89+
import android.view.Gravity;
8790
import android.view.KeyEvent;
8891
import android.view.LayoutInflater;
8992
import android.view.Menu;
@@ -181,6 +184,8 @@ public final class RSSReader extends AppCompatActivity implements FileHandler, A
181184
public static final String PREF_CLIENT_VERSION = "client_version";
182185
public static final String PREF_FEED_ID = "news_feed";
183186

187+
public static final String PREF_BRICIOLA = "briciola";//used in place of Settings.Secure.ANDROID_ID, DO NOT insert this in backable_prefs
188+
184189
private final static String tag = "RSSReader";
185190

186191
public final static String uniqueWorkerName = "RSSReaderService";
@@ -221,23 +226,30 @@ else if (lang_code.startsWith("de"))
221226

222227
private final FileManager mBackupRestore = new FileManager(this, this, true, APP_FOLDER);
223228

224-
/** Called when the activity is first created. */
225-
@SuppressLint("NewApi")
226229
@Override
227-
public void onCreate(Bundle savedInstanceState) {
228-
prefs = PreferenceManager.getDefaultSharedPreferences(this);
230+
public Resources.Theme getTheme() {
231+
Resources.Theme theme = super.getTheme();
232+
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
229233
int theme_idx = get_theme_idx(prefs, getResources());
230234
int background = preset_colors[theme_idx][0];
231235
if (!isDarkColor(background)) { // light background
232-
setTheme(R.style.ThemeLightNoActionBar);
236+
theme.applyStyle(R.style.ThemeLightNoActionBar, true);
233237
} else { // dark background
234-
setTheme(R.style.ThemeNoActionBar);
238+
theme.applyStyle(R.style.ThemeNoActionBar, true);
235239
}
240+
return theme;
241+
}
242+
243+
/** Called when the activity is first created. */
244+
@SuppressLint("NewApi")
245+
@Override
246+
public void onCreate(Bundle savedInstanceState) {
236247
super.onCreate(savedInstanceState);
237248
if (BuildConfig.DEBUG)
238249
Log.d(tag, "onCreate");
239250

240251
setContentView(R.layout.main);
252+
prefs = PreferenceManager.getDefaultSharedPreferences(this);
241253

242254
System.setProperty("http.keepAlive", "false"); // workaround to avoid responseCode = -1 problem
243255

@@ -336,7 +348,7 @@ public void run() {
336348
Uri intent_data = intent.getData();
337349
if (intent_data != null) {
338350
if (BuildConfig.DEBUG)
339-
Log.d(tag, "intent uri: " + intent_data.toString());
351+
Log.d(tag, "intent uri: " + intent_data);
340352
//TODO: process feed via intent
341353
//command: adb shell am start -W -a android.intent.action.VIEW -d "<replace with url to feed>" -t "application/rss+xml"
342354
}
@@ -434,11 +446,6 @@ public boolean onCreateOptionsMenu(Menu menu) {
434446
inflater.inflate(R.menu.menu, menu);
435447
ttsplay = menu.findItem(R.id.menu_play);
436448
ttsplay.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
437-
438-
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {//scopedstorage
439-
MenuItem restore = menu.findItem(R.id.menu_restore);//scopedstorage
440-
restore.getSubMenu().clear();//scopedstorage - disable (local restore / external restore)
441-
}
442449
return true;
443450
}
444451

@@ -455,7 +462,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
455462

456463
@Override
457464
public boolean onOptionsItemSelected(MenuItem item) {
458-
// Handle item selection
465+
// Handle item selection
459466
int itemId = item.getItemId();
460467
if (itemId == R.id.menu_preferences) {
461468
showPreferences();
@@ -515,16 +522,27 @@ public boolean onOptionsItemSelected(MenuItem item) {
515522
} else if (itemId == R.id.menu_backup) {
516523
doBackup(prefs, mBackupRestore, getResources());
517524
return true;
518-
} else if (itemId == R.id.menu_local_storage) {//restore from local storage (direct) - not valid for Android 11 or later
519-
mBackupRestore.readLocalFile(EXTENDED_BACKUP_FILENAME, BACKUP_FILENAME);//scopedstorage
520-
return true;
521525
} else if (itemId == R.id.menu_restore) {//scopedstorage (purtroppo in Android 11 non si riesce ad usare in modo sicuro filename2uri_downloads_Q(), quindi usiamo per il restore comunque il SAF, come nel caso di storage esterno
522526
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
523527
mBackupRestore.openFileSAF(EXTENDED_BACKUP_MIMETYPE_ONEDRIVE, false);//scopedstorage, use SAF on Android 11 or later
524-
} // else ignore
525-
return true;
526-
} else if (itemId == R.id.menu_ext_storage) {//restore from external storage - not valid for Android 11 or later
527-
mBackupRestore.readExternalFile();
528+
} else {
529+
//18-09-2022: nuova gestione con PopupMenu per evitare problemi in ChromeOS basato su Android 11 (o superiore)
530+
//PopupMenu risolve problema del passaggio del mouse sopra la voce del menu 'restore' che apre il filemanager su ChromeOS in modo indesiderato
531+
PopupMenu popup = showRestorePopup(findViewById(R.id.my_toolbar), Gravity.END);
532+
533+
popup.setOnMenuItemClickListener(item1 -> {
534+
// mDrawerLayout.closeDrawer(mDrawerList);
535+
int itemId1 = item1.getItemId();
536+
if (itemId1 == R.id.menu_ext_storage) {//restore from external storage
537+
mBackupRestore.readExternalFile();
538+
return true;
539+
} else if (itemId1 == R.id.menu_local_storage) {//restore from local storage (direct)
540+
mBackupRestore.readLocalFile(EXTENDED_BACKUP_FILENAME, BACKUP_FILENAME);//scopedstorage
541+
return true;
542+
}
543+
return false;//never happen
544+
});
545+
}
528546
return true;
529547
} else if (itemId == R.id.menu_exit) {
530548
finishAffinity();//nn
@@ -538,6 +556,17 @@ public boolean onOptionsItemSelected(MenuItem item) {
538556
return super.onOptionsItemSelected(item);
539557
}
540558

559+
private PopupMenu showRestorePopup(View view, int gravity) {
560+
Context wrapper = new ContextThemeWrapper(RSSReader.this, R.style.MyPopupMenu);//18-09-2022: aggiunto wrapper per risolvere un problema sul colore del testo del popup quando il tema è scuro
561+
PopupMenu popup = new PopupMenu(wrapper, view, gravity);
562+
Menu popmenu = popup.getMenu();
563+
popmenu.add(Menu.NONE, R.id.menu_local_storage, Menu.NONE, R.string.local_storage);//menu_local_storage is hidden in buildNavDrawerItems()
564+
popmenu.add(Menu.NONE, R.id.menu_ext_storage, Menu.NONE, R.string.ext_storage);//menu_ext_storage is hidden in buildNavDrawerItems()
565+
566+
popup.show();
567+
return popup;
568+
}
569+
541570
private static void doBackup(SharedPreferences prefs, FileManager mBackupRestore, Resources resources) {
542571
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {//scopedstorage
543572
mBackupRestore.createFileSAF(EXTENDED_BACKUP_FILENAME);//scopedstorage
@@ -676,7 +705,7 @@ private void showPreferences() {
676705

677706
@Override
678707
public void onRequestPermissionsResult(int requestCode,
679-
String[] permissions, int[] grantResults) {
708+
@NonNull String[] permissions, int[] grantResults) {
680709
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
681710
mBackupRestore.processRequestPermissionsResult(requestCode);
682711
} else {// permission denied

app/src/main/java/livio/rssreader/SelectColors.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import android.os.Bundle;
2222
import android.preference.PreferenceManager;
2323

24+
import androidx.annotation.NonNull;
2425
import androidx.appcompat.app.AppCompatActivity;
2526
import androidx.appcompat.app.AlertDialog;
2627
import android.util.Log;
@@ -257,7 +258,7 @@ public ColorItem() {
257258
//Auto-generated constructor stub
258259
}
259260

260-
ColorItem(String name, int color) {
261+
ColorItem(@NonNull String name, int color) {
261262
this.name = name;
262263
this.resourceId = color;
263264
}
@@ -266,6 +267,7 @@ void setColor(int color) {
266267
this.resourceId = color;
267268
}
268269

270+
@NonNull
269271
@Override
270272
public String toString() {
271273
return this.name;

0 commit comments

Comments
 (0)