Skip to content

Commit

Permalink
Better view handling
Browse files Browse the repository at this point in the history
- empty state

Signed-off-by: tobiasKaminsky <[email protected]>
  • Loading branch information
tobiasKaminsky committed Aug 30, 2024
1 parent 4e07670 commit f318a33
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,79 @@
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)

binding = InternalTwoWaySyncLayoutBinding.inflate(layoutInflater)
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
}
}
}
)
}
}
32 changes: 23 additions & 9 deletions app/src/main/res/layout/internal_two_way_sync_layout.xml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
~ 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 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1236,4 +1236,6 @@
<string name="file_name_validator_error_forbidden_file_extensions">.%s is a forbidden file extension</string>
<string name="file_name_validator_error_ends_with_space_period">Name ends with a space or a period</string>
<string name="sync">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>

0 comments on commit f318a33

Please sign in to comment.