diff options
author | aleksandar-stefanovic <theonewithideas@gmail.com> | 2017-01-31 17:18:57 +0100 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2017-02-07 11:48:15 +0000 |
commit | 62cad676e9beb9d94e8adee6033d7c11c35baf0c (patch) | |
tree | f03d87ca2e172c2e013ce51ac069d6ef0af7c20b /android/source/res | |
parent | ae1b9d55ee62e904ecc52359f536b9b5966174bd (diff) |
Add recents files to the document browser
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>
Diffstat (limited to 'android/source/res')
-rw-r--r-- | android/source/res/layout/activity_document_browser.xml | 76 | ||||
-rw-r--r-- | android/source/res/layout/item_recent_files.xml | 34 | ||||
-rw-r--r-- | android/source/res/values/strings.xml | 2 |
3 files changed, 96 insertions, 16 deletions
diff --git a/android/source/res/layout/activity_document_browser.xml b/android/source/res/layout/activity_document_browser.xml index 2c1874459b19..a444d6f66b49 100644 --- a/android/source/res/layout/activity_document_browser.xml +++ b/android/source/res/layout/activity_document_browser.xml @@ -22,23 +22,67 @@ android:layout_height="match_parent"> <!-- The content --> - - <android.support.v7.widget.RecyclerView - android:id="@+id/file_recycler_view" + <ScrollView android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@color/background_normal" - android:orientation="vertical" /> - - <!-- The navigation drawer --> - <android.support.design.widget.NavigationView - android:id="@+id/navigation_drawer" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_gravity="start" - android:background="@color/background_normal" - app:menu="@menu/navigation_menu" - android:theme="@style/LibreOfficeTheme.NavigationView" /> + android:layout_height="match_parent"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:divider="@color/doorhanger_divider_light" + android:showDividers="middle"> + + <TextView + android:layout_width="match_parent" + android:layout_height="48dp" + android:id="@+id/header_recents" + android:text="@string/title_recents" + android:gravity="center_vertical" + android:textSize="14sp" + android:padding="16dp" + android:textStyle="bold"/> + + <!--Recent files--> + <android.support.v7.widget.RecyclerView + android:id="@+id/list_recent" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp"/> + + <TextView + android:layout_width="match_parent" + android:layout_height="48dp" + android:id="@+id/header_browser" + android:text="@string/title_browser" + android:gravity="center_vertical" + android:textSize="14sp" + android:padding="16dp" + android:textStyle="bold" /> + + + <!--Document browser--> + <android.support.v7.widget.RecyclerView + android:id="@+id/file_recycler_view" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/background_normal" + android:orientation="vertical" /> + + </LinearLayout> + + </ScrollView> + + <!-- The navigation drawer --> + <android.support.design.widget.NavigationView + android:id="@+id/navigation_drawer" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_gravity="start" + android:background="@color/background_normal" + app:menu="@menu/navigation_menu" + android:theme="@style/LibreOfficeTheme.NavigationView" /> </android.support.v4.widget.DrawerLayout> </LinearLayout> diff --git a/android/source/res/layout/item_recent_files.xml b/android/source/res/layout/item_recent_files.xml new file mode 100644 index 000000000000..fa966d8b554c --- /dev/null +++ b/android/source/res/layout/item_recent_files.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + This file is part of the LibreOffice project. + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + --> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="48dp" + android:orientation="horizontal" + android:background="?android:attr/selectableItemBackground" + tools:ignore="UseCompoundDrawables"> + <!--using compound drawables is ignored because more control over the drawable size is needed--> + + <ImageView + android:layout_width="32dp" + android:layout_height="wrap_content" + android:layout_margin="8dp" + android:layout_gravity="center_vertical" + android:adjustViewBounds="true" + android:id="@+id/imageView" + android:contentDescription="@string/file_icon_desc"/> + + + <TextView + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:id="@+id/textView" + style="@style/ListItemText"/> + +</LinearLayout>
\ No newline at end of file diff --git a/android/source/res/values/strings.xml b/android/source/res/values/strings.xml index 5cf731100dd0..f02b4097723a 100644 --- a/android/source/res/values/strings.xml +++ b/android/source/res/values/strings.xml @@ -31,6 +31,8 @@ <string name="menu_sort_modified">Sort by Date</string> <string name="menu_preferences">Preferences</string> <string name="file_icon_desc">fileicon</string> + <string name="title_recents">Recent files</string> + <string name="title_browser">All files</string> <!-- Pref keys as resources ; Not currently used --> <string name="EXPLORER_VIEW_TYPE_KEY">EXPLORER_VIEW_TYPE</string> <string name="CURRENT_DIRECTORY_KEY">CURRENT_DIRECTORY</string> |