[Libreoffice-commits] online.git: android/app
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Apr 8 10:51:37 UTC 2019
android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java | 16 ++-
android/app/src/main/java/org/libreoffice/androidapp/ui/RecentFilesAdapter.java | 5 +
android/app/src/main/res/layout/activity_document_browser.xml | 50 ++++++++--
android/app/src/main/res/values/strings.xml | 2
4 files changed, 61 insertions(+), 12 deletions(-)
New commits:
commit 789a1c1a7b7376612adcdf43c3d18a318faf7a1b
Author: kaishu-sahu <kaishusahu101 at gmail.com>
AuthorDate: Mon Apr 1 00:27:35 2019 +0530
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Mon Apr 8 12:51:17 2019 +0200
android: add no_recent_items/no_items msg.
Change-Id: I398c65702d246772aeb46b68ba54d2800ce8200a
Reviewed-on: https://gerrit.libreoffice.org/70014
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
index 3ad028620..7035fd473 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
@@ -145,6 +145,10 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
private RecyclerView fileRecyclerView;
private RecyclerView recentRecyclerView;
+ //kept package-private to use these in recyclerView's adapter
+ TextView noRecentItemsTextView;
+ TextView noItemsTextView;
+
private boolean canQuit = false;
private Animation fabOpenAnimation;
@@ -222,6 +226,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
drawLayout = findViewById(R.id.drawLayout);
recentRecyclerView = findViewById(R.id.list_recent);
+ noRecentItemsTextView = findViewById(R.id.no_recent_items_msg);
Set<String> recentFileStrings = prefs.getStringSet(RECENT_DOCUMENTS_KEY, new HashSet<String>());
@@ -241,6 +246,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
recentRecyclerView.setAdapter(new RecentFilesAdapter(this, recentFiles));
fileRecyclerView = findViewById(R.id.file_recycler_view);
+ noItemsTextView = findViewById(R.id.no_items_msg);
//This should be tested because it possibly disables view recycling
fileRecyclerView.setNestedScrollingEnabled(false);
openDirectory(currentDirectory);
@@ -498,6 +504,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
findViewById(R.id.text_directory_path).setVisibility(View.GONE);
} else {
recentRecyclerView.setVisibility(View.GONE);
+ noRecentItemsTextView.setVisibility(View.GONE);
findViewById(R.id.header_browser).setVisibility((View.GONE));
findViewById(R.id.header_recents).setVisibility((View.GONE));
actionBar.setTitle(dir.getName());
@@ -1154,12 +1161,12 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
class ExplorerItemAdapter extends RecyclerView.Adapter<ExplorerItemAdapter.ViewHolder> {
- private Activity mActivity;
+ private LibreOfficeUIActivity mActivity;
private List<IFile> filePaths;
private final long KB = 1024;
private final long MB = 1048576;
- ExplorerItemAdapter(Activity activity, List<IFile> filePaths) {
+ ExplorerItemAdapter(LibreOfficeUIActivity activity, List<IFile> filePaths) {
this.mActivity = activity;
this.filePaths = filePaths;
}
@@ -1238,6 +1245,11 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
@Override
public int getItemCount() {
+ if (filePaths.size() == 0) {
+ mActivity.noItemsTextView.setVisibility(View.VISIBLE);
+ } else {
+ mActivity.noItemsTextView.setVisibility(View.GONE);
+ }
return filePaths.size();
}
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/ui/RecentFilesAdapter.java b/android/app/src/main/java/org/libreoffice/androidapp/ui/RecentFilesAdapter.java
index 51468a627..6ad8aba48 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/ui/RecentFilesAdapter.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/ui/RecentFilesAdapter.java
@@ -77,6 +77,11 @@ class RecentFilesAdapter extends RecyclerView.Adapter<RecentFilesAdapter.ViewHol
@Override
public int getItemCount() {
+ if (recentFiles.size() == 0) {
+ mActivity.noRecentItemsTextView.setVisibility(View.VISIBLE);
+ } else {
+ mActivity.noRecentItemsTextView.setVisibility(View.GONE);
+ }
return recentFiles.size();
}
diff --git a/android/app/src/main/res/layout/activity_document_browser.xml b/android/app/src/main/res/layout/activity_document_browser.xml
index 8c8e7fd59..fc43f43d2 100644
--- a/android/app/src/main/res/layout/activity_document_browser.xml
+++ b/android/app/src/main/res/layout/activity_document_browser.xml
@@ -71,12 +71,27 @@
android:textStyle="bold" />
<!--Recent files-->
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/list_recent"
+ <FrameLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="8dp"
- android:layout_marginBottom="8dp" />
+ android:layout_height="wrap_content">
+
+ <androidx.recyclerview.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:id="@+id/no_recent_items_msg"
+ android:layout_width="wrap_content"
+ android:layout_height="48dp"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:textSize="14sp"
+ android:text="@string/no_recent_items" />
+
+ </FrameLayout>
<TextView
android:layout_width="match_parent"
@@ -99,12 +114,27 @@
<!--Document browser-->
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/file_recycler_view"
+ <FrameLayout
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/background_normal"
- android:orientation="vertical" />
+ android:layout_height="match_parent">
+
+ <androidx.recyclerview.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" />
+
+ <TextView
+ android:id="@+id/no_items_msg"
+ android:layout_width="wrap_content"
+ android:layout_height="48dp"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:textSize="14sp"
+ android:text="@string/no_items" />
+
+ </FrameLayout>
</LinearLayout>
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index 9bf1f9764..bfde02318 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -5,6 +5,8 @@
<string name="app_description">LibreOffice Viewer is a document viewer based on LibreOffice.</string>
<string name="app_credits">https://www.libreoffice.org</string>
<string name="app_vendor">This release was supplied by $VENDOR.</string>
+ <string name="no_recent_items">No recent items</string>
+ <string name="no_items">No items</string>
<string name="about_license">Show License</string>
<string name="about_notice">Show Notice</string>
More information about the Libreoffice-commits
mailing list