diff --git a/app/src/main/java/com/owncloud/android/ui/activity/InternalTwoWaySyncActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/InternalTwoWaySyncActivity.kt index e5489e6d94..db2bdf26ba 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/InternalTwoWaySyncActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/InternalTwoWaySyncActivity.kt @@ -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 + } + } + } + ) + } } diff --git a/app/src/main/res/layout/internal_two_way_sync_layout.xml b/app/src/main/res/layout/internal_two_way_sync_layout.xml index 69d985bcc1..f7ca5f32cd 100644 --- a/app/src/main/res/layout/internal_two_way_sync_layout.xml +++ b/app/src/main/res/layout/internal_two_way_sync_layout.xml @@ -5,14 +5,30 @@ ~ SPDX-FileCopyrightText: 2024 Tobias Kaminsky ~ SPDX-License-Identifier: AGPL-3.0-or-later --> - + android:layout_height="match_parent" + android:fitsSystemWindows="true" + tools:openDrawer="start"> - + android:layout_height="match_parent"> - + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fe4e5083d0..8c162e5cd9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1248,4 +1248,7 @@ Please select a server… Unread notifications exist Remove folder from internal two way sync + Two way sync not set up + To set up a two way sync folder, please enable it in the details tab of the folder in question. + Internal two way sync