Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {
Expand All @@ -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
}
}
}
)
}
}
30 changes: 23 additions & 7 deletions app/src/main/res/layout/internal_two_way_sync_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1238,4 +1238,7 @@
<string name="sync">Sync</string>
<string name="please_select_a_server">Please select a server…</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>