ソースを参照

Better view handling
- empty state

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>

tobiasKaminsky 9 ヶ月 前
コミット
0e61e27258

+ 58 - 2
app/src/main/java/com/owncloud/android/ui/activity/InternalTwoWaySyncActivity.kt

@@ -8,14 +8,25 @@
 package com.owncloud.android.ui.activity
 
 import android.os.Bundle
+import android.view.Menu
+import android.view.MenuInflater
+import android.view.MenuItem
+import android.view.View
+import androidx.core.view.MenuProvider
 import androidx.recyclerview.widget.LinearLayoutManager
 import com.nextcloud.client.di.Injectable
+import com.owncloud.android.R
 import com.owncloud.android.databinding.InternalTwoWaySyncLayoutBinding
 import com.owncloud.android.ui.adapter.InternalTwoWaySyncAdapter
+import com.owncloud.android.utils.theme.ViewThemeUtils
+import javax.inject.Inject
 
-class InternalTwoWaySyncActivity : BaseActivity(), Injectable {
+class InternalTwoWaySyncActivity : DrawerActivity(), Injectable {
     lateinit var binding: InternalTwoWaySyncLayoutBinding
 
+    @Inject
+    lateinit var viewThemeUtils: ViewThemeUtils
+
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
 
@@ -23,8 +34,53 @@ class InternalTwoWaySyncActivity : BaseActivity(), Injectable {
         setContentView(binding.root)
 
         binding.list.apply {
-            adapter = InternalTwoWaySyncAdapter(fileDataStorageManager, user.get(), context)
+            setEmptyView(binding.emptyList.emptyListView)
+
+            binding.emptyList.emptyListViewHeadline.apply {
+                visibility = View.VISIBLE
+                setText(R.string.internal_two_way_sync_list_empty_headline)
+            }
+            binding.emptyList.emptyListViewText.apply {
+                visibility = View.VISIBLE
+                setText(R.string.internal_two_way_sync_text)
+            }
+            binding.emptyList.emptyListIcon.apply {
+                visibility = View.VISIBLE
+                setImageDrawable(
+                    viewThemeUtils.platform.tintPrimaryDrawable(
+                        context,
+                        R.drawable.ic_sync
+                    )
+                )
+            }
+
+            adapter = InternalTwoWaySyncAdapter(fileDataStorageManager, user.get(), context).apply {
+                notifyDataSetChanged()
+            }
             layoutManager = LinearLayoutManager(context)
         }
+
+        setupToolbar()
+        updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_synced_folders))
+        if (supportActionBar != null) {
+            supportActionBar!!.setDisplayHomeAsUpEnabled(true)
+        }
+
+        addMenuProvider(
+            object : MenuProvider {
+                override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
+                }
+
+                override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
+                    return when (menuItem.itemId) {
+                        android.R.id.home -> {
+                            onBackPressed()
+                            true
+                        }
+                        else -> false
+                    }
+                }
+            }
+        )
     }
 }

+ 23 - 9
app/src/main/res/layout/internal_two_way_sync_layout.xml

@@ -1,18 +1,32 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
   ~ Nextcloud - Android Client
   ~
   ~ SPDX-FileCopyrightText: 2024 Tobias Kaminsky <tobias@kaminsky.me>
   ~ SPDX-License-Identifier: AGPL-3.0-or-later
   -->
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/drawer_layout"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    android:fitsSystemWindows="true"
+    tools:openDrawer="start">
 
-    <androidx.recyclerview.widget.RecyclerView
-        android:id="@+id/list"
+    <androidx.constraintlayout.widget.ConstraintLayout
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical" />
+        android:layout_height="match_parent">
 
-</androidx.constraintlayout.widget.ConstraintLayout>
+        <include layout="@layout/toolbar_standard" />
+
+        <com.owncloud.android.ui.EmptyRecyclerView
+            android:id="@+id/list"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical" />
+
+        <include
+            android:id="@+id/empty_list"
+            layout="@layout/empty_list" />
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+</androidx.drawerlayout.widget.DrawerLayout>

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -1248,4 +1248,6 @@
     <string name="please_select_a_server">Please select a server…</string>
     <string name="notification_icon_description">Unread notifications exist</string>
     <string name="unset_internal_two_way_sync_description">Remove folder from internal two way sync</string>
+    <string name="internal_two_way_sync_list_empty_headline">No two way sync folder yet</string>
+    <string name="internal_two_way_sync_text">To setup a two way sync folder, please enable it in details of desired folder.</string>
 </resources>