Skip to content
Snippets Groups Projects
Commit 4b9d5cc9 authored by Pierre Nicolas's avatar Pierre Nicolas :joy: Committed by Adrien Béraud
Browse files

linkDevice: isolate import backup feature

Was linked to `import from another device` feature.

Change-Id: I279456854eaee19c7dc7974f454c5550550fd8da
parent 2350db0c
No related branches found
No related tags found
No related merge requests found
...@@ -110,8 +110,8 @@ class AccountWizardActivity : BaseActivity<AccountWizardPresenter>(), AccountWiz ...@@ -110,8 +110,8 @@ class AccountWizardActivity : BaseActivity<AccountWizardPresenter>(), AccountWiz
val model = viewModel.model val model = viewModel.model
if (!TextUtils.isEmpty(model.managementServer)) { if (!TextUtils.isEmpty(model.managementServer)) {
presenter.initJamiAccountConnect(model, getText(R.string.ring_account_default_name).toString()) presenter.initJamiAccountConnect(model, getText(R.string.ring_account_default_name).toString())
} else if (model.isLink) { } else if (model.archive != null) {
presenter.initJamiAccountLink(model, getText(R.string.ring_account_default_name).toString()) presenter.initJamiAccountBackup(model, getText(R.string.ring_account_default_name).toString())
} else { } else {
presenter.initJamiAccountCreation(model, getText(R.string.ring_account_default_name).toString()) presenter.initJamiAccountCreation(model, getText(R.string.ring_account_default_name).toString())
} }
...@@ -154,7 +154,7 @@ class AccountWizardActivity : BaseActivity<AccountWizardPresenter>(), AccountWiz ...@@ -154,7 +154,7 @@ class AccountWizardActivity : BaseActivity<AccountWizardPresenter>(), AccountWiz
val fragments = supportFragmentManager.fragments val fragments = supportFragmentManager.fragments
if (fragments.size > 0) { if (fragments.size > 0) {
val fragment = fragments[0] val fragment = fragments[0]
if (fragment is JamiLinkAccountFragment || fragment is JamiAccountConnectFragment) { if (fragment is JamiAccountConnectFragment || fragment is JamiImportBackupFragment) {
profileCreated(false) profileCreated(false)
} }
} }
......
...@@ -60,8 +60,8 @@ class HomeAccountCreationFragment : ...@@ -60,8 +60,8 @@ class HomeAccountCreationFragment :
archive = file archive = file
} }
replaceFragmentWithSlide( replaceFragmentWithSlide(
fragment = JamiLinkAccountFragment(), fragment = JamiImportBackupFragment(),
tag = JamiLinkAccountFragment.TAG, tag = JamiImportBackupFragment.TAG,
containerID = R.id.wizard_container containerID = R.id.wizard_container
) )
}) { e: Throwable -> }) { e: Throwable ->
......
/*
* Copyright (C) 2004-2024 Savoir-faire Linux Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package cx.ring.account
import android.content.Context
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import cx.ring.databinding.FragAccJamiBackupBinding
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class JamiImportBackupFragment : Fragment() {
private val model: AccountCreationViewModel by activityViewModels()
private var binding: FragAccJamiBackupBinding? = null
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View = FragAccJamiBackupBinding.inflate(inflater, container, false).apply {
linkButton.setOnClickListener { createAccount() }
existingPassword.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
override fun afterTextChanged(s: Editable) {
model.model.password = s.toString()
}
})
binding = this
}.root
override fun onDestroyView() {
super.onDestroyView()
binding = null
}
// override fun showPin(show: Boolean) {
// val binding = binding ?: return
// binding.linkButton.setText(if (show) R.string.account_link_device else R.string.account_link_archive_button)
// binding!!.linkButton.isEnabled = enable
// }
fun createAccount() {
(activity as AccountWizardActivity?)?.createAccount()
val imm = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
imm?.hideSoftInputFromWindow(binding!!.existingPassword.windowToken, 0)
}
companion object {
val TAG = JamiImportBackupFragment::class.simpleName!!
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Todo: Legacy -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_primary_dark"
android:gravity="center"
android:orientation="vertical"
android:paddingVertical="16dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/account_link_archive_button"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline5"
android:textColor="@color/color_primary_light"
android:textStyle="bold" />
<ImageView
android:id="@+id/background"
android:layout_width="@dimen/wizard_image_background"
android:layout_height="@dimen/wizard_image_background"
android:layout_centerHorizontal="true"
android:alpha="0.1"
android:contentDescription="@null"
android:src="@drawable/baseline_devices_24"
app:tint="@color/white" />
</RelativeLayout>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/background_rounded_12"
android:backgroundTint="@color/white">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingHorizontal="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/help_password_enter"
android:textAlignment="center"
android:paddingBottom="12dp"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/password_txt_box"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/existing_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/baseline_lock_24"
android:drawablePadding="5dp"
android:hint="@string/prompt_password"
android:imeOptions="actionNext"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/link_button"
style="@style/ButtonColored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="16dp"
android:text="@string/account_link_archive_button"
android:textSize="12sp"
android:theme="@style/ButtonColoredInverse" />
</LinearLayout>
</ScrollView>
</LinearLayout>
\ No newline at end of file
...@@ -127,7 +127,8 @@ class AccountWizardPresenter @Inject constructor( ...@@ -127,7 +127,8 @@ class AccountWizardPresenter @Inject constructor(
.observeOn(mUiScheduler) .observeOn(mUiScheduler)
.subscribe({ account: Account -> accountCreationModel.newAccount = account }) .subscribe({ account: Account -> accountCreationModel.newAccount = account })
{ e -> Log.e(TAG, "Can't create account", e) }) { e -> Log.e(TAG, "Can't create account", e) })
if (accountCreationModel.isLink) {
if (accountCreationModel.archive != null) {
view!!.displayProgress(true) view!!.displayProgress(true)
mCompositeDisposable.add(newAccount mCompositeDisposable.add(newAccount
.filter { a: Account -> a.registrationState != AccountConfig.RegistrationState.INITIALIZING } .filter { a: Account -> a.registrationState != AccountConfig.RegistrationState.INITIALIZING }
...@@ -189,7 +190,7 @@ class AccountWizardPresenter @Inject constructor( ...@@ -189,7 +190,7 @@ class AccountWizardPresenter @Inject constructor(
.filter { a: Account -> a.registrationState != AccountConfig.RegistrationState.INITIALIZING } .filter { a: Account -> a.registrationState != AccountConfig.RegistrationState.INITIALIZING }
.firstElement() .firstElement()
.subscribe { a: Account -> .subscribe { a: Account ->
if (!model.isLink && a.isJami && model.username.isNotEmpty()) if (model.archive == null && a.isJami && model.username.isNotEmpty())
mAccountService.registerName(a, model.username, AccountService.ACCOUNT_SCHEME_PASSWORD, model.password) mAccountService.registerName(a, model.username, AccountService.ACCOUNT_SCHEME_PASSWORD, model.password)
mAccountService.currentAccount = a mAccountService.currentAccount = a
if (model.isPush) { if (model.isPush) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment