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
201 changes: 201 additions & 0 deletions app/schemas/dev.rocli.android.webdav.data.AppDatabase/6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
{
"formatVersion": 1,
"database": {
"version": 6,
"identityHash": "f96875f20609adce05d2e15876f55c35",
"entities": [
{
"tableName": "account",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT, `url` TEXT, `protocol` TEXT NOT NULL DEFAULT 'AUTO', `verify_certs` INTEGER NOT NULL, `auth_type` TEXT NOT NULL DEFAULT 'NONE', `username` TEXT, `password` TEXT, `client_cert` TEXT, `max_cache_file_size` INTEGER NOT NULL, `act_as_local_storage` INTEGER NOT NULL DEFAULT false, `header_profile` TEXT NOT NULL DEFAULT 'NONE', `cf_access_client_id` TEXT, `cf_access_client_secret` TEXT, `custom_headers` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "url",
"columnName": "url",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "protocol",
"columnName": "protocol",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "'AUTO'"
},
{
"fieldPath": "verifyCerts",
"columnName": "verify_certs",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "authType",
"columnName": "auth_type",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "'NONE'"
},
{
"fieldPath": "username",
"columnName": "username",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "password",
"columnName": "password",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "clientCert",
"columnName": "client_cert",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "maxCacheFileSize",
"columnName": "max_cache_file_size",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "actAsLocalStorage",
"columnName": "act_as_local_storage",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "false"
},
{
"fieldPath": "headerProfile",
"columnName": "header_profile",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "'NONE'"
},
{
"fieldPath": "cfAccessClientId",
"columnName": "cf_access_client_id",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "cfAccessClientSecret",
"columnName": "cf_access_client_secret",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "customHeaders",
"columnName": "custom_headers",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "cache_entry",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `account_id` INTEGER NOT NULL, `status` TEXT NOT NULL, `path` TEXT NOT NULL, `etag` TEXT, `content_length` INTEGER, `last_modified` INTEGER, FOREIGN KEY(`account_id`) REFERENCES `account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "accountId",
"columnName": "account_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "status",
"columnName": "status",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "path",
"columnName": "path",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "etag",
"columnName": "etag",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "contentLength",
"columnName": "content_length",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "lastModified",
"columnName": "last_modified",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [
{
"name": "index_cache_entry_account_id_path",
"unique": true,
"columnNames": [
"account_id",
"path"
],
"orders": [],
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_cache_entry_account_id_path` ON `${TABLE_NAME}` (`account_id`, `path`)"
}
],
"foreignKeys": [
{
"table": "account",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"account_id"
],
"referencedColumns": [
"id"
]
}
]
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'f96875f20609adce05d2e15876f55c35')"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.annotation.StringRes
import androidx.databinding.DataBindingUtil
import androidx.core.view.MenuHost
import androidx.core.view.MenuProvider
import androidx.lifecycle.Lifecycle
import androidx.navigation.fragment.findNavController
import com.mikepenz.aboutlibraries.LibsBuilder
import com.mikepenz.aboutlibraries.ui.LibsSupportFragment
Expand All @@ -37,7 +41,14 @@ class AboutFragment : LibsSupportFragment() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setHasOptionsMenu(true)
val menuHost: MenuHost = requireActivity()
menuHost.addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
menu.clear()
}

override fun onMenuItemSelected(menuItem: MenuItem): Boolean = false
}, viewLifecycleOwner, Lifecycle.State.RESUMED)

// Override the app name during instrumented tests so that
// we don't see "(Debug)" in the automatically generated screenshots.
Expand Down Expand Up @@ -98,7 +109,4 @@ class AboutFragment : LibsSupportFragment() {
startActivity(Intent.createChooser(mailIntent, getString(R.string.about_send_email)))
}

override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
menu.clear()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import android.widget.AutoCompleteTextView
import android.widget.Toast
import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.view.MenuHost
import androidx.core.view.MenuProvider
import androidx.core.view.children
import androidx.core.view.isVisible
import androidx.core.widget.doAfterTextChanged
Expand All @@ -21,6 +25,7 @@ import androidx.databinding.DataBindingUtil
import androidx.databinding.InverseBindingAdapter
import androidx.databinding.InverseBindingListener
import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
Expand Down Expand Up @@ -59,7 +64,7 @@ class AccountFragment : Fragment() {
@Inject
lateinit var clients: WebDavClientManager

private lateinit var menu: Menu
private var optionsMenu: Menu? = null

private val args: AccountFragmentArgs by navArgs()
private lateinit var binding: FragmentAccountBinding
Expand Down Expand Up @@ -183,22 +188,27 @@ class AccountFragment : Fragment() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setHasOptionsMenu(true)
}
val menuHost: MenuHost = requireActivity()
menuHost.addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
menu.clear()
menuInflater.inflate(R.menu.menu_account, menu)
if (args.id == -1L) {
menu.findItem(R.id.action_delete).isVisible = false
}
optionsMenu = menu
}

override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
menu.clear()
inflater.inflate(R.menu.menu_account, menu)
if (args.id == -1L) {
menu.findItem(R.id.action_delete).isVisible = false
}
this.menu = menu
override fun onMenuItemSelected(item: MenuItem): Boolean {
return handleMenuItem(item)
}
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
private fun handleMenuItem(item: MenuItem): Boolean {
val account = binding.account!!

when (item.itemId) {
return when (item.itemId) {
R.id.action_save -> {
if (validateForm(binding.textCertificate.text.toString().isNotBlank())) {
updateTestStatus(true)
Expand Down Expand Up @@ -239,6 +249,7 @@ class AccountFragment : Fragment() {
}
}
}
true
}
R.id.action_delete -> {
Dialogs.showRemoveAccountsDialog(requireContext(), listOf(account)) { _, _ ->
Expand All @@ -247,16 +258,16 @@ class AccountFragment : Fragment() {
WebDavProvider.notifyChangeRoots(requireContext())
close()
}
true
}
android.R.id.home -> {
tryClose()
true
}
else -> {
return false
false
}
}

return true
}

private fun updateUserPassVisibility() {
Expand All @@ -278,6 +289,23 @@ class AccountFragment : Fragment() {
// Custom headers button is visible only when Custom profile is selected
val customVisible = account.headerProfile == HeaderProfile.CUSTOM
binding.btnEditCustomHeaders.visibility = if (customVisible) View.VISIBLE else View.GONE

val anchorId = when {
cloudflareVisible -> binding.tvCfHelperText.id
customVisible -> binding.btnEditCustomHeaders.id
else -> binding.layoutHeaderProfile.id
}
updateAdvancedSectionAnchor(anchorId)
}

private fun updateAdvancedSectionAnchor(anchorId: Int) {
val topMargin = (binding.tvAdvanced.layoutParams as ConstraintLayout.LayoutParams).topMargin
ConstraintSet().apply {
clone(binding.layoutForm)
clear(binding.tvAdvanced.id, ConstraintSet.TOP)
connect(binding.tvAdvanced.id, ConstraintSet.TOP, anchorId, ConstraintSet.BOTTOM, topMargin)
applyTo(binding.layoutForm)
}
}

private fun validateForm(clientCert: Boolean = false): Boolean {
Expand Down Expand Up @@ -381,7 +409,7 @@ class AccountFragment : Fragment() {

private fun updateTestStatus(testing: Boolean) {
setTitle(if (testing) getString(R.string.webdav_testing_connection) else args.title)
menu.setGroupEnabled(R.id.menu_action_group, !testing)
optionsMenu?.setGroupEnabled(R.id.menu_action_group, !testing)
setIsLayoutEnabled(binding.layoutForm, !testing)
binding.progressIndicator.visibility = if (testing) View.VISIBLE else View.INVISIBLE
}
Expand Down
Loading