mirror of
https://github.com/nextcloud/android.git
synced 2024-11-25 14:45:47 +03:00
Merge pull request #13494 from nextcloud/emptyList
2way sync: Better view handling
This commit is contained in:
commit
733f9cdfd9
3 changed files with 100 additions and 11 deletions
|
@ -7,13 +7,21 @@
|
|||
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
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.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.InternalTwoWaySyncLayoutBinding
|
||||
import com.owncloud.android.ui.adapter.InternalTwoWaySyncAdapter
|
||||
|
||||
class InternalTwoWaySyncActivity : BaseActivity(), Injectable {
|
||||
class InternalTwoWaySyncActivity : DrawerActivity(), Injectable {
|
||||
lateinit var binding: InternalTwoWaySyncLayoutBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
@ -22,9 +30,71 @@ class InternalTwoWaySyncActivity : BaseActivity(), Injectable {
|
|||
binding = InternalTwoWaySyncLayoutBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
binding.list.apply {
|
||||
adapter = InternalTwoWaySyncAdapter(fileDataStorageManager, user.get(), context)
|
||||
layoutManager = LinearLayoutManager(context)
|
||||
setupToolbar()
|
||||
setupActionBar()
|
||||
setupMenuProvider()
|
||||
setupTwoWaySyncAdapter()
|
||||
setupEmptyList()
|
||||
}
|
||||
|
||||
private fun setupActionBar() {
|
||||
updateActionBarTitleAndHomeButtonByString(getString(R.string.internal_two_way_sync_headline))
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun setupTwoWaySyncAdapter() {
|
||||
binding.run {
|
||||
list.run {
|
||||
setEmptyView(emptyList.emptyListView)
|
||||
adapter = InternalTwoWaySyncAdapter(fileDataStorageManager, user.get(), this@InternalTwoWaySyncActivity)
|
||||
layoutManager = LinearLayoutManager(this@InternalTwoWaySyncActivity)
|
||||
adapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupEmptyList() {
|
||||
binding.emptyList.run {
|
||||
emptyListViewHeadline.run {
|
||||
visibility = View.VISIBLE
|
||||
setText(R.string.internal_two_way_sync_list_empty_headline)
|
||||
}
|
||||
|
||||
emptyListViewText.run {
|
||||
visibility = View.VISIBLE
|
||||
setText(R.string.internal_two_way_sync_text)
|
||||
}
|
||||
|
||||
emptyListIcon.run {
|
||||
visibility = View.VISIBLE
|
||||
setImageDrawable(
|
||||
viewThemeUtils.platform.tintDrawable(
|
||||
context,
|
||||
R.drawable.ic_sync,
|
||||
ColorRole.PRIMARY
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupMenuProvider() {
|
||||
addMenuProvider(
|
||||
object : MenuProvider {
|
||||
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) = Unit
|
||||
|
||||
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||
return when (menuItem.itemId) {
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,30 @@
|
|||
~ 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"
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
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" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
|
|
|
@ -1248,4 +1248,7 @@
|
|||
<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">Two way sync not set up</string>
|
||||
<string name="internal_two_way_sync_text">To set up a two way sync folder, please enable it in the details tab of the folder in question.</string>
|
||||
<string name="internal_two_way_sync_headline">Internal two way sync</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue