summaryrefslogtreecommitdiffstats
path: root/android/source/src/java/org/libreoffice/ui/RecentFilesAdapter.java
Commit message (Collapse)AuthorAgeFilesLines
* android: Port from Android Support Lib to AndroidXMichael Weghorn2022-04-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace the no longer maintained Android Support Library with the Android Jetpack libraries. Quoting [1]: > Version 28.0.0 is the last release of the Support Library. There will be > no more android.support library releases. All new feature development > will be in the androidx namespace. Most porting was done automatically by using Android Studio's "Refactor" -> "Migrate to AndroidX..." function. In `android/source/res/layout/toolbar_bottom.xml` and `android/source/res/layout/toolbar_color_picker.xml`, the uses of `app:layout_behavior="android.support.design.widget.BottomSheetBehavior"` had to be replaced manually as described at [2], because the app would crash when using the old "android.support" values. Also drop the Android Support Library related bits from configure.ac In a quick test, this worked fine and no obvious difference was visible when running this in various AVDs. When trying to test this in an x86 AVD still using SDK 16 (Android 4.1), which is currently specified as Android Viewer's `minSdkVersion`, only various unrelated issues showed up, some of which will be handled in follow-up commits. After the migration, many weird errors showed up in Android Studio, which disappeared after invalidating the caches (via "File" -> "Invalidate Caches..."). [1] https://developer.android.com/jetpack/androidx [2] https://stackoverflow.com/questions/45100963/runtimeexception-could-not-inflate-behavior-subclass Change-Id: I2a57f0ebd56e7ecc09b7d65aae17fd15088a633b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133002 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
* android: Some trivial style improvementsMichael Weghorn2021-04-231-2/+2
| | | | | | | | | | | | | | | Those were mostly suggested by Android Studio, like: * mark members static or final * drop unused variables and members * avoid unnecessary cast * simplify condition: '(!cond)' instead of 'cond == false' * drop unused imports Change-Id: I252fe836e4a3184e13af59a30202c6daccac1794 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114546 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
* android: Show files opened using system picker for recently usedMichael Weghorn2021-04-011-7/+5
| | | | | | | | | | | | | | | | | | | | | | | Switch the list of recently used documents in LibreOffice Android Viewer to show the documents opened using the system file picker instead of those shown using the custom UI elements for file selection. This way, files provided by DocumentsProviders, like Nextcloud, can also be handled. As described at [1], this requires persisting permissions in order to be able to access the files after a device reboot. The corresponding method to do this, 'ContentResolver#takePersistableUriPermission', is only available from SDK level 19 on, so drop entries for older SDK levels (current minSdkVersion is 16). [1] https://developer.android.com/training/data-storage/shared/documents-files#persist-permissions Change-Id: Ifbf7148cda687a8a2e3f0c14fe66651509b2f19a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113459 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
* android: Avoid a crash when recently used file has unknown typeMichael Weghorn2020-03-061-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I cannot tell how to reproduce (how to open a file of "invalid type"?), but had a crash with this stacktrace in adb log at some point when testing various scenarios with the Android Viewer app. It shows that no proper value was assigned for the resource ID, leaving the default 0. Just don't set an icon in this case. E AndroidRuntime: FATAL EXCEPTION: main E AndroidRuntime: Process: org.libreoffice, PID: 8749 E AndroidRuntime: android.content.res.Resources$NotFoundException: Resource ID #0x0 E AndroidRuntime: at android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:246) E AndroidRuntime: at android.content.res.Resources.getDrawableForDensity(Resources.java:905) E AndroidRuntime: at android.content.res.Resources.getDrawable(Resources.java:845) E AndroidRuntime: at android.content.Context.getDrawable(Context.java:687) E AndroidRuntime: at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:358) E AndroidRuntime: at org.libreoffice.ui.RecentFilesAdapter.onBindViewHolder(RecentFilesAdapter.java:73) E AndroidRuntime: at org.libreoffice.ui.RecentFilesAdapter.onBindViewHolder(RecentFilesAdapter.java:25) E AndroidRuntime: at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6673) E AndroidRuntime: at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6714) E AndroidRuntime: at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5647) E AndroidRuntime: at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5913) E AndroidRuntime: at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5752) E AndroidRuntime: at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5748) E AndroidRuntime: at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2232) E AndroidRuntime: at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:556) E AndroidRuntime: at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1519) E AndroidRuntime: at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:614) E AndroidRuntime: at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170) E AndroidRuntime: at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3812) E AndroidRuntime: at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3225) [...] Change-Id: I05594c3da26125a18be9226f290430aa9c7fa14c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90090 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
* lint: remove redundant type casts (findViewById to object of type)Christian Lohmaier2017-09-241-2/+2
| | | | Change-Id: I0ec35ea5817d110ca20942ce9d95e0120848580a
* Add recents files to the document browseraleksandar-stefanovic2017-02-071-0/+92
The recents mechanism works like this: Every time the file is opened, it saves that file to the shared preferences set, by putting it in the first place, and removing the oldest file from the list, if there are more than 4 recent files. It also adds dynamic App Shortcuts if the device is 7.0 and above. Screenshot: http://imgur.com/a/7kWOl Edited the layout to add a new RecyclerView for recent items, as well as the headers for both the recycler view's. Recent files appear only if in home directory, below app bar and above the file browser. This could be subjected to change in the future. Screenshot of the recents section: http://imgur.com/a/qrqZq Change-Id: I5c99aa26351d9ad2313e18b5b696d04a782e6155 Reviewed-on: https://gerrit.libreoffice.org/33759 Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>