-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2way sync: Better view handling #13494
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can omit the binding prefix for emptyList.
Alternatively you can omit second binding as well.
|
||
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need null check, you can use this. |
||
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 | ||
} | ||
} | ||
} | ||
) | ||
} | ||
} |
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add @SuppressLint("NotifyDataSetChanged") since code updates InternalTwoWaySyncAdapter items in onCreate