mirror of
https://github.com/etesync/android
synced 2024-12-23 07:08:16 +00:00
Fix crashes with fragments that don't have a default constructor.
This commit is contained in:
parent
198657d008
commit
e3dc70bc11
@ -60,7 +60,7 @@ class MigrateV2Activity : BaseActivity() {
|
|||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
setTitle(R.string.migrate_v2_wizard_welcome_title)
|
setTitle(R.string.migrate_v2_wizard_welcome_title)
|
||||||
supportFragmentManager.commit {
|
supportFragmentManager.commit {
|
||||||
replace(R.id.fragment_container, WizardWelcomeFragment(accountV1))
|
replace(R.id.fragment_container, WizardWelcomeFragment.newInstance(accountV1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,7 +85,9 @@ fun reportErrorHelper(context: Context, e: Throwable) {
|
|||||||
.setPositiveButton(android.R.string.yes) { _, _ -> }.show()
|
.setPositiveButton(android.R.string.yes) { _, _ -> }.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
class WizardWelcomeFragment(private val accountV1: Account) : Fragment() {
|
class WizardWelcomeFragment : Fragment() {
|
||||||
|
internal lateinit var accountV1: Account
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
val ret = inflater.inflate(R.layout.migrate_v2_wizard_welcome, container, false)
|
val ret = inflater.inflate(R.layout.migrate_v2_wizard_welcome, container, false)
|
||||||
|
|
||||||
@ -101,21 +103,29 @@ class WizardWelcomeFragment(private val accountV1: Account) : Fragment() {
|
|||||||
private fun initUi(inflater: LayoutInflater, v: View) {
|
private fun initUi(inflater: LayoutInflater, v: View) {
|
||||||
v.findViewById<Button>(R.id.signup).setOnClickListener {
|
v.findViewById<Button>(R.id.signup).setOnClickListener {
|
||||||
parentFragmentManager.commit {
|
parentFragmentManager.commit {
|
||||||
replace(R.id.fragment_container, SignupFragment(accountV1))
|
replace(R.id.fragment_container, SignupFragment.newInstance(accountV1))
|
||||||
addToBackStack(null)
|
addToBackStack(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
v.findViewById<Button>(R.id.login).setOnClickListener {
|
v.findViewById<Button>(R.id.login).setOnClickListener {
|
||||||
parentFragmentManager.commit {
|
parentFragmentManager.commit {
|
||||||
replace(R.id.fragment_container, LoginFragment(accountV1))
|
replace(R.id.fragment_container, LoginFragment.newInstance(accountV1))
|
||||||
addToBackStack(null)
|
addToBackStack(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(accountV1: Account): WizardWelcomeFragment {
|
||||||
|
val ret = WizardWelcomeFragment()
|
||||||
|
ret.accountV1 = accountV1
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SignupFragment(private val accountV1: Account) : Fragment() {
|
class SignupFragment : Fragment() {
|
||||||
internal lateinit var editUserName: TextInputLayout
|
internal lateinit var editUserName: TextInputLayout
|
||||||
internal lateinit var editEmail: TextInputLayout
|
internal lateinit var editEmail: TextInputLayout
|
||||||
internal lateinit var editPassword: TextInputLayout
|
internal lateinit var editPassword: TextInputLayout
|
||||||
@ -123,6 +133,8 @@ class SignupFragment(private val accountV1: Account) : Fragment() {
|
|||||||
internal lateinit var showAdvanced: CheckedTextView
|
internal lateinit var showAdvanced: CheckedTextView
|
||||||
internal lateinit var customServer: TextInputEditText
|
internal lateinit var customServer: TextInputEditText
|
||||||
|
|
||||||
|
internal lateinit var accountV1: Account
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
val v = inflater.inflate(R.layout.signup_fragment, container, false)
|
val v = inflater.inflate(R.layout.signup_fragment, container, false)
|
||||||
@ -145,7 +157,7 @@ class SignupFragment(private val accountV1: Account) : Fragment() {
|
|||||||
createAccount.setOnClickListener {
|
createAccount.setOnClickListener {
|
||||||
val credentials = validateData()
|
val credentials = validateData()
|
||||||
if (credentials != null) {
|
if (credentials != null) {
|
||||||
SignupDoFragment(accountV1, credentials).show(requireFragmentManager(), null)
|
SignupDoFragment.newInstance(accountV1, credentials).show(requireFragmentManager(), null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,11 +222,22 @@ class SignupFragment(private val accountV1: Account) : Fragment() {
|
|||||||
|
|
||||||
return if (valid) SignupCredentials(uri, userName, email, password) else null
|
return if (valid) SignupCredentials(uri, userName, email, password) else null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(accountV1: Account): SignupFragment {
|
||||||
|
val ret = SignupFragment()
|
||||||
|
ret.accountV1 = accountV1
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SignupDoFragment(private val accountV1: Account, private val signupCredentials: SignupCredentials) : DialogFragment() {
|
class SignupDoFragment : DialogFragment() {
|
||||||
private val model: ConfigurationViewModel by activityViewModels()
|
private val model: ConfigurationViewModel by activityViewModels()
|
||||||
|
|
||||||
|
internal lateinit var accountV1: Account
|
||||||
|
internal lateinit var signupCredentials: SignupCredentials
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val progress = ProgressDialog(activity)
|
val progress = ProgressDialog(activity)
|
||||||
progress.setTitle(R.string.setting_up_encryption)
|
progress.setTitle(R.string.setting_up_encryption)
|
||||||
@ -273,7 +296,7 @@ class SignupDoFragment(private val accountV1: Account, private val signupCredent
|
|||||||
val etebase = EtebaseAccount.restore(client, it.etebaseSession!!, null)
|
val etebase = EtebaseAccount.restore(client, it.etebaseSession!!, null)
|
||||||
uiThread {
|
uiThread {
|
||||||
fragmentManager?.commit {
|
fragmentManager?.commit {
|
||||||
replace(R.id.fragment_container, WizardCollectionsFragment(accountV1, etebase))
|
replace(R.id.fragment_container, WizardCollectionsFragment.newInstance(accountV1, etebase))
|
||||||
addToBackStack(null)
|
addToBackStack(null)
|
||||||
}
|
}
|
||||||
dismissAllowingStateLoss()
|
dismissAllowingStateLoss()
|
||||||
@ -282,16 +305,26 @@ class SignupDoFragment(private val accountV1: Account, private val signupCredent
|
|||||||
} }
|
} }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(accountV1: Account, signupCredentials: SignupCredentials): SignupDoFragment {
|
||||||
|
val ret = SignupDoFragment()
|
||||||
|
ret.accountV1 = accountV1
|
||||||
|
ret.signupCredentials = signupCredentials
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class LoginFragment(private val accountV1: Account) : Fragment() {
|
class LoginFragment() : Fragment() {
|
||||||
internal lateinit var editUserName: EditText
|
internal lateinit var editUserName: EditText
|
||||||
internal lateinit var editUrlPassword: TextInputLayout
|
internal lateinit var editUrlPassword: TextInputLayout
|
||||||
|
|
||||||
internal lateinit var showAdvanced: CheckedTextView
|
internal lateinit var showAdvanced: CheckedTextView
|
||||||
internal lateinit var customServer: EditText
|
internal lateinit var customServer: EditText
|
||||||
|
|
||||||
|
internal lateinit var accountV1: Account
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
val v = inflater.inflate(R.layout.login_credentials_fragment, container, false)
|
val v = inflater.inflate(R.layout.login_credentials_fragment, container, false)
|
||||||
@ -307,7 +340,7 @@ class LoginFragment(private val accountV1: Account) : Fragment() {
|
|||||||
login.setOnClickListener {
|
login.setOnClickListener {
|
||||||
val credentials = validateLoginData()
|
val credentials = validateLoginData()
|
||||||
if (credentials != null)
|
if (credentials != null)
|
||||||
LoginDoFragment(accountV1, credentials).show(fragmentManager!!, null)
|
LoginDoFragment.newInstance(accountV1, credentials).show(fragmentManager!!, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
val forgotPassword = v.findViewById<View>(R.id.forgot_password) as TextView
|
val forgotPassword = v.findViewById<View>(R.id.forgot_password) as TextView
|
||||||
@ -365,11 +398,22 @@ class LoginFragment(private val accountV1: Account) : Fragment() {
|
|||||||
|
|
||||||
return if (valid) LoginCredentials(uri, userName, password) else null
|
return if (valid) LoginCredentials(uri, userName, password) else null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(accountV1: Account): LoginFragment {
|
||||||
|
val ret = LoginFragment()
|
||||||
|
ret.accountV1 = accountV1
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoginDoFragment(private val accountV1: Account, private val loginCredentials: LoginCredentials) : DialogFragment() {
|
class LoginDoFragment() : DialogFragment() {
|
||||||
private val model: ConfigurationViewModel by activityViewModels()
|
private val model: ConfigurationViewModel by activityViewModels()
|
||||||
|
|
||||||
|
internal lateinit var accountV1: Account
|
||||||
|
internal lateinit var loginCredentials: LoginCredentials
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val progress = ProgressDialog(activity)
|
val progress = ProgressDialog(activity)
|
||||||
progress.setTitle(R.string.setting_up_encryption)
|
progress.setTitle(R.string.setting_up_encryption)
|
||||||
@ -397,7 +441,7 @@ class LoginDoFragment(private val accountV1: Account, private val loginCredentia
|
|||||||
val etebase = EtebaseAccount.restore(client, it.etebaseSession!!, null)
|
val etebase = EtebaseAccount.restore(client, it.etebaseSession!!, null)
|
||||||
uiThread {
|
uiThread {
|
||||||
fragmentManager?.commit {
|
fragmentManager?.commit {
|
||||||
replace(R.id.fragment_container, WizardCollectionsFragment(accountV1, etebase))
|
replace(R.id.fragment_container, WizardCollectionsFragment.newInstance(accountV1, etebase))
|
||||||
addToBackStack(null)
|
addToBackStack(null)
|
||||||
}
|
}
|
||||||
dismissAllowingStateLoss()
|
dismissAllowingStateLoss()
|
||||||
@ -406,13 +450,25 @@ class LoginDoFragment(private val accountV1: Account, private val loginCredentia
|
|||||||
} }
|
} }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(accountV1: Account, loginCredentials: LoginCredentials): LoginDoFragment {
|
||||||
|
val ret = LoginDoFragment()
|
||||||
|
ret.accountV1 = accountV1
|
||||||
|
ret.loginCredentials = loginCredentials
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WizardCollectionsFragment(private val accountV1: Account, private val etebase: EtebaseAccount) : Fragment() {
|
class WizardCollectionsFragment() : Fragment() {
|
||||||
private val loadingModel: LoadingViewModel by viewModels()
|
private val loadingModel: LoadingViewModel by viewModels()
|
||||||
private lateinit var info: AccountActivity.AccountInfo
|
private lateinit var info: AccountActivity.AccountInfo
|
||||||
private val migrateJournals = HashMap<String, AccountActivity.CollectionListItemInfo>()
|
private val migrateJournals = HashMap<String, AccountActivity.CollectionListItemInfo>()
|
||||||
|
|
||||||
|
internal lateinit var accountV1: Account
|
||||||
|
internal lateinit var etebase: EtebaseAccount
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
val ret = inflater.inflate(R.layout.migrate_v2_collections, container, false)
|
val ret = inflater.inflate(R.layout.migrate_v2_collections, container, false)
|
||||||
|
|
||||||
@ -427,7 +483,7 @@ class WizardCollectionsFragment(private val accountV1: Account, private val eteb
|
|||||||
|
|
||||||
private fun initUi(inflater: LayoutInflater, v: View) {
|
private fun initUi(inflater: LayoutInflater, v: View) {
|
||||||
v.findViewById<Button>(R.id.button_create).setOnClickListener {
|
v.findViewById<Button>(R.id.button_create).setOnClickListener {
|
||||||
MigrateCollectionsDoFragment(etebase, this.migrateJournals).show(parentFragmentManager, null)
|
MigrateCollectionsDoFragment.newInstance(etebase, this.migrateJournals).show(parentFragmentManager, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
v.findViewById<Button>(R.id.button_skip).setOnClickListener {
|
v.findViewById<Button>(R.id.button_skip).setOnClickListener {
|
||||||
@ -580,15 +636,26 @@ class WizardCollectionsFragment(private val accountV1: Account, private val eteb
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(accountV1: Account, etebase: EtebaseAccount): WizardCollectionsFragment {
|
||||||
|
val ret = WizardCollectionsFragment()
|
||||||
|
ret.accountV1 = accountV1
|
||||||
|
ret.etebase = etebase
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class MigrateCollectionsDoFragment(private val etebase: EtebaseAccount,
|
class MigrateCollectionsDoFragment : DialogFragment() {
|
||||||
private val migrateJournals: HashMap<String, AccountActivity.CollectionListItemInfo>) : DialogFragment() {
|
|
||||||
private val configurationModel: ConfigurationViewModel by activityViewModels()
|
private val configurationModel: ConfigurationViewModel by activityViewModels()
|
||||||
private lateinit var progress: ProgressDialog
|
private lateinit var progress: ProgressDialog
|
||||||
private val CHUNK_SIZE = 20
|
private val CHUNK_SIZE = 20
|
||||||
|
|
||||||
|
internal lateinit var etebase: EtebaseAccount
|
||||||
|
internal lateinit var migrateJournals: HashMap<String, AccountActivity.CollectionListItemInfo>
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
progress = ProgressDialog(activity)
|
progress = ProgressDialog(activity)
|
||||||
progress.setTitle(R.string.migrate_v2_wizard_migrate_title)
|
progress.setTitle(R.string.migrate_v2_wizard_migrate_title)
|
||||||
@ -740,4 +807,15 @@ class MigrateCollectionsDoFragment(private val etebase: EtebaseAccount,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(etebase: EtebaseAccount,
|
||||||
|
migrateJournals: HashMap<String, AccountActivity.CollectionListItemInfo>): MigrateCollectionsDoFragment {
|
||||||
|
val ret = MigrateCollectionsDoFragment()
|
||||||
|
ret.etebase = etebase
|
||||||
|
ret.migrateJournals = migrateJournals
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -52,7 +52,7 @@ class CollectionActivity() : BaseActivity() {
|
|||||||
val cachedCollection = CachedCollection(it.colMgr.create(colType, meta, ""), meta, colType)
|
val cachedCollection = CachedCollection(it.colMgr.create(colType, meta, ""), meta, colType)
|
||||||
uiThread {
|
uiThread {
|
||||||
supportFragmentManager.commit {
|
supportFragmentManager.commit {
|
||||||
replace(R.id.fragment_container, EditCollectionFragment(cachedCollection, true))
|
replace(R.id.fragment_container, EditCollectionFragment.newInstance(cachedCollection, true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,12 @@ import java.text.SimpleDateFormat
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.Future
|
import java.util.concurrent.Future
|
||||||
|
|
||||||
class CollectionItemFragment(private val cachedItem: CachedItem) : Fragment() {
|
class CollectionItemFragment : Fragment() {
|
||||||
private val model: AccountViewModel by activityViewModels()
|
private val model: AccountViewModel by activityViewModels()
|
||||||
private val collectionModel: CollectionViewModel by activityViewModels()
|
private val collectionModel: CollectionViewModel by activityViewModels()
|
||||||
|
|
||||||
|
private lateinit var cachedItem: CachedItem
|
||||||
|
|
||||||
private var emailInvitationEvent: Event? = null
|
private var emailInvitationEvent: Event? = null
|
||||||
private var emailInvitationEventString: String? = null
|
private var emailInvitationEventString: String? = null
|
||||||
|
|
||||||
@ -156,6 +158,14 @@ class CollectionItemFragment(private val cachedItem: CachedItem) : Fragment() {
|
|||||||
.create()
|
.create()
|
||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(cachedItem: CachedItem): CollectionItemFragment {
|
||||||
|
val ret = CollectionItemFragment()
|
||||||
|
ret.cachedItem = cachedItem
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TabsAdapter(fm: FragmentManager, private val mainFragment: CollectionItemFragment, private val context: Context, private val cachedCollection: CachedCollection, private val cachedItem: CachedItem) : FragmentPagerAdapter(fm) {
|
private class TabsAdapter(fm: FragmentManager, private val mainFragment: CollectionItemFragment, private val context: Context, private val cachedCollection: CachedCollection, private val cachedItem: CachedItem) : FragmentPagerAdapter(fm) {
|
||||||
@ -177,17 +187,18 @@ private class TabsAdapter(fm: FragmentManager, private val mainFragment: Collect
|
|||||||
|
|
||||||
override fun getItem(position: Int): Fragment {
|
override fun getItem(position: Int): Fragment {
|
||||||
return if (position == 0) {
|
return if (position == 0) {
|
||||||
PrettyFragment(mainFragment, cachedCollection, cachedItem.content)
|
PrettyFragment.newInstance(mainFragment, cachedCollection, cachedItem.content)
|
||||||
} else if (position == 1) {
|
} else if (position == 1) {
|
||||||
TextFragment(cachedItem.content)
|
TextFragment.newInstance(cachedItem.content)
|
||||||
} else {
|
} else {
|
||||||
ItemRevisionsListFragment(cachedCollection, cachedItem)
|
ItemRevisionsListFragment.newInstance(cachedCollection, cachedItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TextFragment(private val content: String) : Fragment() {
|
class TextFragment : Fragment() {
|
||||||
|
private lateinit var content: String
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
val v = inflater.inflate(R.layout.text_fragment, container, false)
|
val v = inflater.inflate(R.layout.text_fragment, container, false)
|
||||||
|
|
||||||
@ -197,10 +208,21 @@ class TextFragment(private val content: String) : Fragment() {
|
|||||||
|
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(content: String): TextFragment {
|
||||||
|
val ret = TextFragment()
|
||||||
|
ret.content = content
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PrettyFragment(private val mainFragment: CollectionItemFragment, private val cachedCollection: CachedCollection, private val content: String) : Fragment() {
|
class PrettyFragment : Fragment() {
|
||||||
private var asyncTask: Future<Unit>? = null
|
private var asyncTask: Future<Unit>? = null
|
||||||
|
private lateinit var mainFragment: CollectionItemFragment
|
||||||
|
private lateinit var cachedCollection: CachedCollection
|
||||||
|
private lateinit var content: String
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
var v: View? = null
|
var v: View? = null
|
||||||
@ -482,6 +504,14 @@ class PrettyFragment(private val mainFragment: CollectionItemFragment, private v
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
fun newInstance(mainFragment: CollectionItemFragment, cachedCollection: CachedCollection, content: String): PrettyFragment {
|
||||||
|
val ret = PrettyFragment()
|
||||||
|
ret.mainFragment= mainFragment
|
||||||
|
ret.cachedCollection = cachedCollection
|
||||||
|
ret.content = content
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
private fun addInfoItem(context: Context, parent: ViewGroup, type: String, label: String?, value: String?): View {
|
private fun addInfoItem(context: Context, parent: ViewGroup, type: String, label: String?, value: String?): View {
|
||||||
val layout = parent.findViewById<View>(R.id.container) as ViewGroup
|
val layout = parent.findViewById<View>(R.id.container) as ViewGroup
|
||||||
val infoItem = LayoutInflater.from(context).inflate(R.layout.contact_info_item, layout, false)
|
val infoItem = LayoutInflater.from(context).inflate(R.layout.contact_info_item, layout, false)
|
||||||
|
@ -105,7 +105,7 @@ class CollectionMembersFragment : Fragment() {
|
|||||||
val username = view.findViewById<EditText>(R.id.username).text.toString()
|
val username = view.findViewById<EditText>(R.id.username).text.toString()
|
||||||
val readOnly = view.findViewById<CheckBox>(R.id.read_only).isChecked
|
val readOnly = view.findViewById<CheckBox>(R.id.read_only).isChecked
|
||||||
|
|
||||||
val frag = AddMemberFragment(model.value!!, collectionModel.value!!, username, if (readOnly) CollectionAccessLevel.ReadOnly else CollectionAccessLevel.ReadWrite)
|
val frag = AddMemberFragment.newInstance(model.value!!, collectionModel.value!!, username, if (readOnly) CollectionAccessLevel.ReadOnly else CollectionAccessLevel.ReadWrite)
|
||||||
frag.show(childFragmentManager, null)
|
frag.show(childFragmentManager, null)
|
||||||
}
|
}
|
||||||
.setNegativeButton(android.R.string.no) { _, _ -> }
|
.setNegativeButton(android.R.string.no) { _, _ -> }
|
||||||
@ -114,7 +114,12 @@ class CollectionMembersFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddMemberFragment(private val accountHolder: AccountHolder, private val cachedCollection: CachedCollection, private val username: String, private val accessLevel: CollectionAccessLevel) : DialogFragment() {
|
class AddMemberFragment : DialogFragment() {
|
||||||
|
private lateinit var accountHolder: AccountHolder
|
||||||
|
private lateinit var cachedCollection: CachedCollection
|
||||||
|
private lateinit var username: String
|
||||||
|
private lateinit var accessLevel: CollectionAccessLevel
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val progress = ProgressDialog(context)
|
val progress = ProgressDialog(context)
|
||||||
progress.setTitle(R.string.collection_members_adding)
|
progress.setTitle(R.string.collection_members_adding)
|
||||||
@ -174,4 +179,16 @@ class AddMemberFragment(private val accountHolder: AccountHolder, private val ca
|
|||||||
.setPositiveButton(android.R.string.yes) { _, _ -> }.show()
|
.setPositiveButton(android.R.string.yes) { _, _ -> }.show()
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(accountHolder: AccountHolder, cachedCollection: CachedCollection,
|
||||||
|
username: String, accessLevel: CollectionAccessLevel): AddMemberFragment {
|
||||||
|
val ret = AddMemberFragment()
|
||||||
|
ret.accountHolder = accountHolder
|
||||||
|
ret.cachedCollection = cachedCollection
|
||||||
|
ret.username = username
|
||||||
|
ret.accessLevel = accessLevel
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -24,12 +24,15 @@ import org.jetbrains.anko.doAsync
|
|||||||
import org.jetbrains.anko.uiThread
|
import org.jetbrains.anko.uiThread
|
||||||
import yuku.ambilwarna.AmbilWarnaDialog
|
import yuku.ambilwarna.AmbilWarnaDialog
|
||||||
|
|
||||||
class EditCollectionFragment(private val cachedCollection: CachedCollection, private val isCreating: Boolean = false) : Fragment() {
|
class EditCollectionFragment : Fragment() {
|
||||||
private val model: AccountViewModel by activityViewModels()
|
private val model: AccountViewModel by activityViewModels()
|
||||||
private val collectionModel: CollectionViewModel by activityViewModels()
|
private val collectionModel: CollectionViewModel by activityViewModels()
|
||||||
private val itemsModel: ItemsViewModel by activityViewModels()
|
private val itemsModel: ItemsViewModel by activityViewModels()
|
||||||
private val loadingModel: LoadingViewModel by viewModels()
|
private val loadingModel: LoadingViewModel by viewModels()
|
||||||
|
|
||||||
|
private lateinit var cachedCollection: CachedCollection
|
||||||
|
private var isCreating: Boolean = false
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
val ret = inflater.inflate(R.layout.activity_create_collection, container, false)
|
val ret = inflater.inflate(R.layout.activity_create_collection, container, false)
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
@ -260,4 +263,13 @@ class EditCollectionFragment(private val cachedCollection: CachedCollection, pri
|
|||||||
}
|
}
|
||||||
collectionModel.loadCollection(model.value!!, col.uid)
|
collectionModel.loadCollection(model.value!!, col.uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(cachedCollection: CachedCollection, isCreating: Boolean = false): EditCollectionFragment {
|
||||||
|
val ret = EditCollectionFragment()
|
||||||
|
ret.cachedCollection = cachedCollection
|
||||||
|
ret.isCreating = isCreating
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -59,12 +59,12 @@ class ImportCollectionFragment : Fragment() {
|
|||||||
card.setOnClickListener {
|
card.setOnClickListener {
|
||||||
if (cachedCollection.collectionType == Constants.ETEBASE_TYPE_CALENDAR) {
|
if (cachedCollection.collectionType == Constants.ETEBASE_TYPE_CALENDAR) {
|
||||||
parentFragmentManager.commit {
|
parentFragmentManager.commit {
|
||||||
replace(R.id.fragment_container, LocalCalendarImportFragment(accountHolder.account, cachedCollection.col.uid))
|
replace(R.id.fragment_container, LocalCalendarImportFragment.newInstance(accountHolder.account, cachedCollection.col.uid))
|
||||||
addToBackStack(null)
|
addToBackStack(null)
|
||||||
}
|
}
|
||||||
} else if (cachedCollection.collectionType == Constants.ETEBASE_TYPE_ADDRESS_BOOK) {
|
} else if (cachedCollection.collectionType == Constants.ETEBASE_TYPE_ADDRESS_BOOK) {
|
||||||
parentFragmentManager.commit {
|
parentFragmentManager.commit {
|
||||||
replace(R.id.fragment_container, LocalContactImportFragment(accountHolder.account, cachedCollection.col.uid))
|
replace(R.id.fragment_container, LocalContactImportFragment.newInstance(accountHolder.account, cachedCollection.col.uid))
|
||||||
addToBackStack(null)
|
addToBackStack(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,14 @@ import java.util.*
|
|||||||
import java.util.concurrent.Future
|
import java.util.concurrent.Future
|
||||||
|
|
||||||
|
|
||||||
class ItemRevisionsListFragment(private val cachedCollection: CachedCollection, private val cachedItem: CachedItem) : ListFragment(), AdapterView.OnItemClickListener {
|
class ItemRevisionsListFragment : ListFragment(), AdapterView.OnItemClickListener {
|
||||||
private val model: AccountViewModel by activityViewModels()
|
private val model: AccountViewModel by activityViewModels()
|
||||||
private val revisionsModel: RevisionsViewModel by viewModels()
|
private val revisionsModel: RevisionsViewModel by viewModels()
|
||||||
private var state: Parcelable? = null
|
private var state: Parcelable? = null
|
||||||
|
|
||||||
|
private lateinit var cachedCollection: CachedCollection
|
||||||
|
private lateinit var cachedItem: CachedItem
|
||||||
|
|
||||||
private var emptyTextView: TextView? = null
|
private var emptyTextView: TextView? = null
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
@ -83,7 +86,7 @@ class ItemRevisionsListFragment(private val cachedCollection: CachedCollection,
|
|||||||
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||||
val item = listAdapter?.getItem(position) as CachedItem
|
val item = listAdapter?.getItem(position) as CachedItem
|
||||||
activity?.supportFragmentManager?.commit {
|
activity?.supportFragmentManager?.commit {
|
||||||
replace(R.id.fragment_container, CollectionItemFragment(item))
|
replace(R.id.fragment_container, CollectionItemFragment.newInstance(item))
|
||||||
addToBackStack(null)
|
addToBackStack(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,6 +113,15 @@ class ItemRevisionsListFragment(private val cachedCollection: CachedCollection,
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(cachedCollection: CachedCollection, cachedItem: CachedItem): ItemRevisionsListFragment {
|
||||||
|
val ret = ItemRevisionsListFragment()
|
||||||
|
ret.cachedCollection = cachedCollection
|
||||||
|
ret.cachedItem = cachedItem
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class ListEntriesFragment : ListFragment(), AdapterView.OnItemClickListener {
|
|||||||
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||||
val item = listAdapter?.getItem(position) as CachedItem
|
val item = listAdapter?.getItem(position) as CachedItem
|
||||||
activity?.supportFragmentManager?.commit {
|
activity?.supportFragmentManager?.commit {
|
||||||
replace(R.id.fragment_container, CollectionItemFragment(item))
|
replace(R.id.fragment_container, CollectionItemFragment.newInstance(item))
|
||||||
addToBackStack(EditCollectionFragment::class.java.name)
|
addToBackStack(EditCollectionFragment::class.java.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,9 @@ import org.jetbrains.anko.uiThread
|
|||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.util.concurrent.Future
|
import java.util.concurrent.Future
|
||||||
|
|
||||||
class SignupFragment(private val initialUsername: String?, private val initialPassword: String?) : Fragment() {
|
class SignupFragment : Fragment() {
|
||||||
|
internal var initialUsername: String? = null
|
||||||
|
internal var initialPassword: String? = null
|
||||||
internal lateinit var editUserName: TextInputLayout
|
internal lateinit var editUserName: TextInputLayout
|
||||||
internal lateinit var editEmail: TextInputLayout
|
internal lateinit var editEmail: TextInputLayout
|
||||||
internal lateinit var editPassword: TextInputLayout
|
internal lateinit var editPassword: TextInputLayout
|
||||||
@ -81,7 +83,7 @@ class SignupFragment(private val initialUsername: String?, private val initialPa
|
|||||||
createAccount.setOnClickListener {
|
createAccount.setOnClickListener {
|
||||||
val credentials = validateData()
|
val credentials = validateData()
|
||||||
if (credentials != null) {
|
if (credentials != null) {
|
||||||
SignupDoFragment(credentials).show(requireFragmentManager(), null)
|
SignupDoFragment.newInstance(credentials).show(requireFragmentManager(), null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,13 +148,24 @@ class SignupFragment(private val initialUsername: String?, private val initialPa
|
|||||||
|
|
||||||
return if (valid) SignupCredentials(uri, userName, email, password) else null
|
return if (valid) SignupCredentials(uri, userName, email, password) else null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(initialUsername: String?, initialPassword: String?): SignupFragment {
|
||||||
|
val ret = SignupFragment()
|
||||||
|
ret.initialUsername = initialUsername
|
||||||
|
ret.initialPassword = initialPassword
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SignupDoFragment(private val signupCredentials: SignupCredentials) : DialogFragment() {
|
class SignupDoFragment: DialogFragment() {
|
||||||
private val model: ConfigurationViewModel by viewModels()
|
private val model: ConfigurationViewModel by viewModels()
|
||||||
|
|
||||||
|
private lateinit var signupCredentials: SignupCredentials
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val progress = ProgressDialog(activity)
|
val progress = ProgressDialog(activity)
|
||||||
progress.setTitle(R.string.setting_up_encryption)
|
progress.setTitle(R.string.setting_up_encryption)
|
||||||
@ -184,6 +197,14 @@ class SignupDoFragment(private val signupCredentials: SignupCredentials) : Dialo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(signupCredentials: SignupCredentials): SignupDoFragment {
|
||||||
|
val ret = SignupDoFragment()
|
||||||
|
ret.signupCredentials = signupCredentials
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConfigurationViewModel : ViewModel() {
|
class ConfigurationViewModel : ViewModel() {
|
||||||
|
@ -114,7 +114,7 @@ class ViewCollectionFragment : Fragment() {
|
|||||||
R.id.on_edit -> {
|
R.id.on_edit -> {
|
||||||
if (cachedCollection.col.accessLevel == CollectionAccessLevel.Admin) {
|
if (cachedCollection.col.accessLevel == CollectionAccessLevel.Admin) {
|
||||||
parentFragmentManager.commit {
|
parentFragmentManager.commit {
|
||||||
replace(R.id.fragment_container, EditCollectionFragment(cachedCollection))
|
replace(R.id.fragment_container, EditCollectionFragment.newInstance(cachedCollection))
|
||||||
addToBackStack(EditCollectionFragment::class.java.name)
|
addToBackStack(EditCollectionFragment::class.java.name)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -46,13 +46,13 @@ class ImportActivity : BaseActivity(), SelectImportMethod, DialogInterface {
|
|||||||
if (info.enumType == CollectionInfo.Type.CALENDAR) {
|
if (info.enumType == CollectionInfo.Type.CALENDAR) {
|
||||||
supportFragmentManager.beginTransaction()
|
supportFragmentManager.beginTransaction()
|
||||||
.replace(android.R.id.content,
|
.replace(android.R.id.content,
|
||||||
LocalCalendarImportFragment.newInstance(account, info))
|
LocalCalendarImportFragment.newInstance(account, info.uid!!))
|
||||||
.addToBackStack(LocalCalendarImportFragment::class.java.name)
|
.addToBackStack(LocalCalendarImportFragment::class.java.name)
|
||||||
.commit()
|
.commit()
|
||||||
} else if (info.enumType == CollectionInfo.Type.ADDRESS_BOOK) {
|
} else if (info.enumType == CollectionInfo.Type.ADDRESS_BOOK) {
|
||||||
supportFragmentManager.beginTransaction()
|
supportFragmentManager.beginTransaction()
|
||||||
.replace(android.R.id.content,
|
.replace(android.R.id.content,
|
||||||
LocalContactImportFragment.newInstance(account, info))
|
LocalContactImportFragment.newInstance(account, info.uid!!))
|
||||||
.addToBackStack(LocalContactImportFragment::class.java.name)
|
.addToBackStack(LocalContactImportFragment::class.java.name)
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,10 @@ import java.io.InputStream
|
|||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
|
|
||||||
|
|
||||||
class ImportFragment(private val account: Account, private val uid: String, private val enumType: CollectionInfo.Type) : DialogFragment() {
|
class ImportFragment : DialogFragment() {
|
||||||
|
private lateinit var account: Account
|
||||||
|
private lateinit var uid: String
|
||||||
|
private lateinit var enumType: CollectionInfo.Type
|
||||||
|
|
||||||
private var inputStream: InputStream? = null
|
private var inputStream: InputStream? = null
|
||||||
|
|
||||||
@ -435,7 +438,11 @@ class ImportFragment(private val account: Account, private val uid: String, priv
|
|||||||
private val TAG_PROGRESS_MAX = "progressMax"
|
private val TAG_PROGRESS_MAX = "progressMax"
|
||||||
|
|
||||||
fun newInstance(account: Account, info: CollectionInfo): ImportFragment {
|
fun newInstance(account: Account, info: CollectionInfo): ImportFragment {
|
||||||
return ImportFragment(account, info.uid!!, info.enumType!!)
|
val ret = ImportFragment()
|
||||||
|
ret.account = account
|
||||||
|
ret.uid = info.uid!!
|
||||||
|
ret.enumType = info.enumType!!
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
fun newInstance(account: Account, cachedCollection: CachedCollection): ImportFragment {
|
fun newInstance(account: Account, cachedCollection: CachedCollection): ImportFragment {
|
||||||
@ -445,7 +452,11 @@ class ImportFragment(private val account: Account, private val uid: String, priv
|
|||||||
ETEBASE_TYPE_ADDRESS_BOOK -> CollectionInfo.Type.ADDRESS_BOOK
|
ETEBASE_TYPE_ADDRESS_BOOK -> CollectionInfo.Type.ADDRESS_BOOK
|
||||||
else -> throw Exception("Got unsupported collection type")
|
else -> throw Exception("Got unsupported collection type")
|
||||||
}
|
}
|
||||||
return ImportFragment(account, cachedCollection.col.uid, enumType)
|
val ret = ImportFragment()
|
||||||
|
ret.account = account
|
||||||
|
ret.uid = cachedCollection.col.uid
|
||||||
|
ret.enumType = enumType
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,10 @@ import com.etesync.syncadapter.resource.LocalCalendar
|
|||||||
import com.etesync.syncadapter.resource.LocalEvent
|
import com.etesync.syncadapter.resource.LocalEvent
|
||||||
|
|
||||||
|
|
||||||
class LocalCalendarImportFragment(private val account: Account, private val uid: String) : ListFragment() {
|
class LocalCalendarImportFragment : ListFragment() {
|
||||||
|
private lateinit var account: Account
|
||||||
|
private lateinit var uid: String
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
retainInstance = true
|
retainInstance = true
|
||||||
@ -249,8 +252,11 @@ class LocalCalendarImportFragment(private val account: Account, private val uid:
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun newInstance(account: Account, info: CollectionInfo): LocalCalendarImportFragment {
|
fun newInstance(account: Account, uid: String): LocalCalendarImportFragment {
|
||||||
return LocalCalendarImportFragment(account, info.uid!!)
|
val ret = LocalCalendarImportFragment()
|
||||||
|
ret.account = account
|
||||||
|
ret.uid = uid
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,10 @@ import com.etesync.syncadapter.resource.LocalGroup
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
class LocalContactImportFragment(private val account: Account, private val uid: String) : Fragment() {
|
class LocalContactImportFragment : Fragment() {
|
||||||
|
private lateinit var account: Account
|
||||||
|
private lateinit var uid: String
|
||||||
|
|
||||||
private var recyclerView: RecyclerView? = null
|
private var recyclerView: RecyclerView? = null
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@ -316,8 +319,11 @@ class LocalContactImportFragment(private val account: Account, private val uid:
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun newInstance(account: Account, info: CollectionInfo): LocalContactImportFragment {
|
fun newInstance(account: Account, uid: String): LocalContactImportFragment {
|
||||||
return LocalContactImportFragment(account, info.uid!!)
|
val ret = LocalContactImportFragment()
|
||||||
|
ret.account = account
|
||||||
|
ret.uid = uid
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ class LoginCredentialsFragment : Fragment() {
|
|||||||
val createAccount = v.findViewById<View>(R.id.create_account) as Button
|
val createAccount = v.findViewById<View>(R.id.create_account) as Button
|
||||||
createAccount.setOnClickListener {
|
createAccount.setOnClickListener {
|
||||||
parentFragmentManager.commit {
|
parentFragmentManager.commit {
|
||||||
replace(android.R.id.content, SignupFragment(editUserName.text.toString(), editUrlPassword.editText?.text.toString()))
|
replace(android.R.id.content, SignupFragment.newInstance(editUserName.text.toString(), editUrlPassword.editText?.text.toString()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user