diff --git a/jami-android/app/src/main/java/cx/ring/account/HomeAccountCreationFragment.kt b/jami-android/app/src/main/java/cx/ring/account/HomeAccountCreationFragment.kt index 08d7e0b586f2034f5476b6709b7c1574f8979212..06e567a52a36e5a81912bc33c11412727ee11e54 100644 --- a/jami-android/app/src/main/java/cx/ring/account/HomeAccountCreationFragment.kt +++ b/jami-android/app/src/main/java/cx/ring/account/HomeAccountCreationFragment.kt @@ -56,7 +56,6 @@ class HomeAccountCreationFragment : .observeOn(AndroidSchedulers.mainThread()) .subscribe({ file: File -> model.model = AccountCreationModel().apply { - isLink = true archive = file } replaceFragmentWithSlide( @@ -108,17 +107,11 @@ class HomeAccountCreationFragment : } override fun goToAccountLink() { - model.model = AccountCreationModel().apply { - isLink = true - } linkDeviceActivityLauncher .launch(Intent(requireContext(), LinkDeviceImportSideActivity::class.java)) } override fun goToAccountConnect() { - model.model = AccountCreationModel().apply { - isLink = true - } replaceFragmentWithSlide(JamiAccountConnectFragment(), JamiAccountConnectFragment.TAG, R.id.wizard_container) } diff --git a/jami-android/app/src/main/java/cx/ring/account/JamiAccountSummaryFragment.kt b/jami-android/app/src/main/java/cx/ring/account/JamiAccountSummaryFragment.kt index 4e8de96a50cc553732634191de1cde24a9f63b56..33c78b4fe86ddcef09a2ac5164585f364284ffad 100644 --- a/jami-android/app/src/main/java/cx/ring/account/JamiAccountSummaryFragment.kt +++ b/jami-android/app/src/main/java/cx/ring/account/JamiAccountSummaryFragment.kt @@ -280,34 +280,6 @@ class JamiAccountSummaryFragment : setSwitchStatus(account) } - private fun showWizard(accountId: String) { - LinkDeviceFragment.newInstance(accountId) - .show(parentFragmentManager, LinkDeviceFragment.TAG) - } - - override fun showNetworkError() { - dismissWaitDialog() - MaterialAlertDialogBuilder(requireContext()) - .setTitle(R.string.account_export_end_network_title) - .setMessage(R.string.account_export_end_network_message) - .setPositiveButton(android.R.string.ok, null) - .show() - } - - override fun showPasswordError() { - dismissWaitDialog() - } - - override fun showGenericError() { - dismissWaitDialog() - MaterialAlertDialogBuilder(requireContext()) - .setTitle(R.string.account_export_end_error_title) - .setMessage(R.string.account_export_end_error_message) - .setPositiveButton(android.R.string.ok, null) - .show() - } - - override fun showPIN(pin: String) {} private fun profileContainerClicked(account: Account) { val inflater = LayoutInflater.from(activity) val view = DialogProfileBinding.inflate(inflater).apply { diff --git a/jami-android/app/src/main/java/cx/ring/account/JamiLinkAccountFragment.kt b/jami-android/app/src/main/java/cx/ring/account/JamiLinkAccountFragment.kt deleted file mode 100644 index 875415747732c01c6e85c56d802b0469c33df0a1..0000000000000000000000000000000000000000 --- a/jami-android/app/src/main/java/cx/ring/account/JamiLinkAccountFragment.kt +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (C) 2004-2025 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.content.res.Configuration -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 androidx.lifecycle.ViewModelProvider -import androidx.viewpager2.adapter.FragmentStateAdapter -import com.google.android.material.tabs.TabLayout -import com.google.android.material.tabs.TabLayoutMediator -import cx.ring.R -import cx.ring.account.pinInput.EditTextPinInputFragment -import cx.ring.account.pinInput.EditTextPinInputViewModel -import cx.ring.account.pinInput.QrCodePinInputFragment -import cx.ring.account.pinInput.QrCodePinInputViewModel -import cx.ring.databinding.FragAccJamiLinkBinding -import cx.ring.mvp.BaseSupportFragment -import dagger.hilt.android.AndroidEntryPoint -import net.jami.account.JamiLinkAccountPresenter -import net.jami.account.JamiLinkAccountView - -@AndroidEntryPoint -class JamiLinkAccountFragment : - BaseSupportFragment<JamiLinkAccountPresenter, JamiLinkAccountView>(), - JamiLinkAccountView { - private val model: AccountCreationViewModel by activityViewModels() - private var binding: FragAccJamiLinkBinding? = null - - // the 2 view models connected to this fragment - private val qrCodePinInputViewModel by lazy { - ViewModelProvider(this)[QrCodePinInputViewModel::class.java] - } - private val editTextPinInputViewModel by lazy { - ViewModelProvider(this)[EditTextPinInputViewModel::class.java] - } - - private fun setLayout( - inflater: LayoutInflater, - container: ViewGroup?, - ): View = FragAccJamiLinkBinding.inflate(inflater, container, false).apply { - - val adapter = SectionsPagerAdapter(this@JamiLinkAccountFragment) - adapter.addFragment(QrCodePinInputFragment(), getString(R.string.connect_device_scanqr)) - adapter.addFragment(EditTextPinInputFragment(), getString(R.string.connect_device_enterPIN)) - pager.adapter = adapter - pager.currentItem = 0 - TabLayoutMediator(tabLayout, pager) { tab, position -> - tab.text = adapter.getTabTitle(position) - }.attach() - - tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { - override fun onTabSelected(tab: TabLayout.Tab?) { - presenter.resetPin() - // emit the pin again when switching tabs - if (tab?.position == 0) { - qrCodePinInputViewModel.emitPinAgain() - } else { - editTextPinInputViewModel.emitPinAgain() - } - } - - override fun onTabUnselected(tab: TabLayout.Tab?) {} - - override fun onTabReselected(tab: TabLayout.Tab?) {} - }) - - linkButton.setOnClickListener { presenter.linkClicked() } - - 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) { - presenter.passwordChanged(s.toString()) - } - }) - - binding = this - }.root - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View = setLayout(inflater, container) - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - qrCodePinInputViewModel.init({ presenter.pinChanged(it) }, { presenter.resetPin() }) - editTextPinInputViewModel.init({ presenter.pinChanged(it) }, { presenter.resetPin() }) - } - - override fun onConfigurationChanged(newConfig: Configuration) { - super.onConfigurationChanged(newConfig) - val rootView = (view as ViewGroup) - rootView.removeAllViews() - rootView.addView(setLayout(LayoutInflater.from(activity), rootView)) - } - - override fun onDestroyView() { - super.onDestroyView() - binding = null - } - - override fun initPresenter(presenter: JamiLinkAccountPresenter) { - presenter.init(model.model) - } - - override fun enableLinkButton(enable: Boolean) { - binding!!.linkButton.isEnabled = enable - } - - override fun showPin(show: Boolean) { - val binding = binding ?: return - binding.pager.visibility = if (show) View.VISIBLE else View.GONE - binding.tabLayout.visibility = if (show) View.VISIBLE else View.GONE - binding.linkButton.setText(if (show) R.string.account_link_device else R.string.account_link_archive_button) - } - - override fun createAccount() { - (activity as AccountWizardActivity?)?.createAccount() - val imm = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager - imm?.hideSoftInputFromWindow(binding!!.existingPassword.windowToken, 0) - } - - override fun cancel() { - activity?.onBackPressedDispatcher?.onBackPressed() - } - - internal class SectionsPagerAdapter(hostFragment: Fragment) : FragmentStateAdapter(hostFragment) { - private val mFragmentList = ArrayList<Fragment>(2) - private val mFragmentTitleList = ArrayList<String>(2) - - fun getTabTitle(position: Int): String { - return mFragmentTitleList[position] - } - - fun addFragment(fragment: Fragment, title: String) { - mFragmentList.add(fragment) - mFragmentTitleList.add(title) - } - - override fun getItemCount(): Int { - return mFragmentList.size - } - - override fun createFragment(position: Int): Fragment { - return mFragmentList[position] - } - - } - companion object { - val TAG = JamiLinkAccountFragment::class.simpleName!! - } -} \ No newline at end of file diff --git a/jami-android/app/src/main/java/cx/ring/account/pinInput/EditTextPinInputFragment.kt b/jami-android/app/src/main/java/cx/ring/account/pinInput/EditTextPinInputFragment.kt deleted file mode 100644 index 61231e70f42942c00c4d068007278cd0db498f0c..0000000000000000000000000000000000000000 --- a/jami-android/app/src/main/java/cx/ring/account/pinInput/EditTextPinInputFragment.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2004-2025 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.pinInput - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.core.widget.doOnTextChanged -import androidx.fragment.app.Fragment -import androidx.fragment.app.viewModels -import com.google.android.material.textfield.TextInputEditText -import cx.ring.R -import cx.ring.databinding.EditTextPinInputBinding -import dagger.hilt.android.AndroidEntryPoint - -@AndroidEntryPoint -class EditTextPinInputFragment : Fragment() { - - private val viewModel: EditTextPinInputViewModel by viewModels({ requireParentFragment() }) - private var binding: EditTextPinInputBinding? = null - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View = EditTextPinInputBinding.inflate(inflater, container, false).apply { - binding = this - }.root - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - // to have the text entered in the text field - val enterPinEditText: TextInputEditText = view.findViewById(R.id.enter_pin) - val startingAt = 17 - enterPinEditText.doOnTextChanged { pin, _, _, _ -> - viewModel.checkPin(pin.toString()).let { - // if the pin is not valid and it is at length 17 (format of the pin) there is an - // error - if (it == PinValidity.ERROR && enterPinEditText.length() == startingAt) { - showErrorPanel() - } - } - } - } - - override fun onDestroyView() { - super.onDestroyView() - binding = null - } - - private fun showErrorPanel() { - binding?.enterPin?.error = getString(R.string.error_format_not_supported) - binding?.enterPin?.requestFocus() - } - -} \ No newline at end of file diff --git a/jami-android/app/src/main/java/cx/ring/account/pinInput/PinInputViewModel.kt b/jami-android/app/src/main/java/cx/ring/account/pinInput/PinInputViewModel.kt deleted file mode 100644 index 5d2b45369727f616bcd1a6f230d6337cdc29ed56..0000000000000000000000000000000000000000 --- a/jami-android/app/src/main/java/cx/ring/account/pinInput/PinInputViewModel.kt +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2004-2025 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.pinInput - -import androidx.lifecycle.ViewModel -import dagger.hilt.android.lifecycle.HiltViewModel -import net.jami.services.HardwareService -import javax.inject.Inject - -@HiltViewModel -class QrCodePinInputViewModel @Inject constructor( - private val mHardwareService: HardwareService -) : PinInputViewModel() { - fun cameraPermissionChanged(isGranted: Boolean) { - if (isGranted && mHardwareService.isVideoAvailable) { - mHardwareService.initVideo() - .onErrorComplete() - .blockingAwait() - } - } -} - -class EditTextPinInputViewModel : PinInputViewModel() - -// State of the pin input -enum class PinValidity { - VALID, ERROR -} - -abstract class PinInputViewModel : ViewModel() { - // validPinCallback is used to store the valid pin we entered in a tab - // and restore it when we return to that tab -> enables the connect button - private lateinit var validPinCallback: (String) -> Unit - - // resetPinCallback is used to reset the pin when switching tabs -> disables the connect button - private lateinit var resetPinCallback: () -> Unit - private var pin: String = "" - - fun init(callback: (String) -> Unit, reset: () -> Unit) { - validPinCallback = callback - resetPinCallback = reset - } - - /** - * Will be called by the view when the pin is entered. - * If the pin is valid, validPinCallback will be called with the pin as parameter. - * else resetPinCallback will be called. - * @param pinToVerify the pin to verify - * @return the validity of the pin - */ - fun checkPin(pinToVerify: String): PinValidity { - // only allow alphanumeric characters in pin format - val regex = Regex("^[A-Za-z0-9]{8}-[A-Za-z0-9]{8}$") - // return the pin if it's valid, else reset it and return an error - return if (regex.matches(pinToVerify)) { - pin = pinToVerify - validPinCallback(pin) - PinValidity.VALID - } else { - pin = "" - resetPinCallback() - PinValidity.ERROR - } - } - - fun emitPinAgain() { - if (pin != "") validPinCallback(pin) - } - -} \ No newline at end of file diff --git a/jami-android/app/src/main/java/cx/ring/account/pinInput/QrCodePinInputFragment.kt b/jami-android/app/src/main/java/cx/ring/account/pinInput/QrCodePinInputFragment.kt deleted file mode 100644 index c4d2d9c7fe06bd95e644bf52d4b4f8d5604e2d43..0000000000000000000000000000000000000000 --- a/jami-android/app/src/main/java/cx/ring/account/pinInput/QrCodePinInputFragment.kt +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2004-2025 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.pinInput - -import android.Manifest -import android.content.pm.PackageManager -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.activity.result.contract.ActivityResultContracts -import androidx.core.content.ContextCompat -import androidx.fragment.app.Fragment -import androidx.fragment.app.viewModels -import com.google.zxing.BarcodeFormat -import com.journeyapps.barcodescanner.DefaultDecoderFactory -import cx.ring.databinding.QrCodePinInputBinding -import dagger.hilt.android.AndroidEntryPoint - -@AndroidEntryPoint -class QrCodePinInputFragment : Fragment() { - private val viewModel: QrCodePinInputViewModel by viewModels({ requireParentFragment() }) - private lateinit var binding: QrCodePinInputBinding - - private var cameraPermissionIsRefusedFlag = false // to not ask for permission again if refused - // check the permission to use the camera - private val requestCameraPermission = - registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted -> - if (granted) { - showErrorPanel(isError = false) - initializeBarcode() - viewModel.cameraPermissionChanged(true) - } else { - cameraPermissionIsRefusedFlag = true - showErrorPanel(isError = true) - } - } - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View = - QrCodePinInputBinding.inflate(inflater, container, false).apply { - binding = this - }.root - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - binding.barcodeScanner.setStatusText("") - } - - override fun onResume() { - super.onResume() - manageCameraPermission() - } - - override fun onPause() { - super.onPause() - binding.barcodeScanner.pause() - } - - // the views below are the states of the QR code scanner : valid or error - private fun showValid() { - binding.apply { - barcodeScanner.visibility = View.GONE - background.visibility = View.VISIBLE - qrCodeLayout.visibility = View.VISIBLE - checkboxValid.visibility = View.VISIBLE - } - } - - private fun showError() { - binding.apply { - barcodeScanner.visibility = View.VISIBLE - textInvalid.visibility = View.VISIBLE - } - } - - private fun showErrorPanel(isError: Boolean) { - if (isError) { - binding.barcodeScanner.visibility = View.GONE - binding.errorMsgTxt.visibility = View.VISIBLE - } else { - binding.barcodeScanner.visibility = View.VISIBLE - binding.errorMsgTxt.visibility = View.VISIBLE - } - } - - // this is the function that is called when the QR code is scanned - private fun initializeBarcode() { - binding.barcodeScanner.apply { - binding.barcodeScanner.decoderFactory = - DefaultDecoderFactory(listOf(BarcodeFormat.QR_CODE)) - decodeContinuous { it -> - // check if the pin is a valid one (method in viewModel) - viewModel.checkPin(it.text).let { - if (it == PinValidity.VALID) { - showValid() - } else { - showError() - } - } - } - } - } - - private fun hasCameraPermission(): Boolean = - ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.CAMERA) == - PackageManager.PERMISSION_GRANTED - - private fun manageCameraPermission() { - if (!hasCameraPermission()) { - if (!cameraPermissionIsRefusedFlag) // if the permission is refused, don't ask again - requestCameraPermission.launch(Manifest.permission.CAMERA) - else showErrorPanel(isError = true) - } - else{ - showErrorPanel(isError = false) - initializeBarcode() - binding.barcodeScanner.resume() - } - } -} \ No newline at end of file diff --git a/jami-android/app/src/main/java/cx/ring/fragments/LinkDeviceFragment.kt b/jami-android/app/src/main/java/cx/ring/fragments/LinkDeviceFragment.kt deleted file mode 100644 index 8a7127378b63bfc6d5ca652927075d63d8be98e8..0000000000000000000000000000000000000000 --- a/jami-android/app/src/main/java/cx/ring/fragments/LinkDeviceFragment.kt +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (C) 2004-2025 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.fragments - -import android.app.Dialog -import android.content.ClipData -import android.content.ClipboardManager -import android.content.Context -import android.graphics.Bitmap -import android.os.Build -import android.os.Bundle -import android.os.CountDownTimer -import android.text.format.DateUtils -import android.util.Log -import android.view.KeyEvent -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.view.inputmethod.EditorInfo -import android.widget.TextView -import android.widget.Toast -import com.google.android.material.bottomsheet.BottomSheetBehavior -import com.google.android.material.bottomsheet.BottomSheetDialog -import com.google.android.material.dialog.MaterialAlertDialogBuilder -import cx.ring.R -import cx.ring.account.AccountEditionFragment -import cx.ring.databinding.FragLinkDeviceBinding -import cx.ring.mvp.BaseBottomSheetFragment -import cx.ring.utils.KeyboardVisibilityManager.hideKeyboard -import cx.ring.utils.TextUtils.copyAndShow -import dagger.hilt.android.AndroidEntryPoint -import net.jami.account.LinkDevicePresenter -import net.jami.account.LinkDeviceView -import net.jami.model.Account -import net.jami.utils.QRCodeUtils - -@AndroidEntryPoint -class LinkDeviceFragment : BaseBottomSheetFragment<LinkDevicePresenter>(), LinkDeviceView { - private var mBinding: FragLinkDeviceBinding? = null - private var mAccountHasPassword = true - private var counter: CountDownTimer? = null - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View = FragLinkDeviceBinding.inflate(inflater, container, false).apply { - btnStartExport.setOnClickListener { startAccountExport() } - password.setOnEditorActionListener { pwd: TextView, actionId: Int, event: KeyEvent? -> - onPasswordEditorAction(pwd, actionId, event) - } - pin.setOnClickListener { copyAndShow(requireContext(), PIN_LABEL, pin.text.toString()) } - - mBinding = this - pageContainer.visibility = View.GONE - }.root - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - arguments?.let { arguments -> - arguments.getString(AccountEditionFragment.ACCOUNT_ID_KEY)?.let { accountId -> - presenter.setAccountId(accountId) - } - } - // go directly to the qr and pin page if there is no account password - if (!mAccountHasPassword) startAccountExport() - } - - override fun onDestroyView() { - mBinding = null - super.onDestroyView() - } - - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - val dialog = super.onCreateDialog(savedInstanceState) - (dialog as BottomSheetDialog).behavior.apply { - state = BottomSheetBehavior.STATE_EXPANDED - skipCollapsed = true - } - return dialog - } - - override fun showExportingProgress() { - mBinding?.apply { - progressBar.visibility = View.VISIBLE - accountLinkInfo.visibility = View.GONE - btnStartExport.visibility = View.GONE - passwordLayout.visibility = View.GONE - } - } - - override fun dismissExportingProgress() { - mBinding?.apply { - progressBar.visibility = View.GONE - accountLinkInfo.visibility = if (mAccountHasPassword) View.VISIBLE else View.GONE - btnStartExport.visibility = View.VISIBLE - passwordLayout.visibility = if (mAccountHasPassword) View.VISIBLE else View.GONE - } - } - - fun regeneratePin() { - mBinding?.apply { - progressBar.visibility = View.GONE - btnStartExport.visibility = View.VISIBLE - passwordLayout.visibility = if (mAccountHasPassword) View.VISIBLE else View.GONE - if (!mAccountHasPassword) { - mBinding!!.accountLinkInfo.text = getString(R.string.account_generate_export_invalid_two) - } - accountLinkInfo.visibility = View.VISIBLE - } - } - - override fun accountChanged(account: Account) { - mAccountHasPassword = account.hasPassword() - } - - override fun showNetworkError() { - dismiss() - MaterialAlertDialogBuilder(requireContext()) - .setTitle(R.string.account_export_end_network_title) - .setMessage(R.string.account_export_end_network_message) - .setPositiveButton(android.R.string.ok, null) - .show() - } - - override fun showPasswordError() { - mBinding!!.passwordLayout.error = getString(R.string.account_export_end_decryption_message) - mBinding!!.password.setText("") - mBinding!!.pageContainer.visibility = View.GONE - } - - override fun showGenericError() { - dismiss() - MaterialAlertDialogBuilder(requireContext()) - .setTitle(R.string.account_export_end_error_title) - .setMessage(R.string.account_export_end_error_message) - .setPositiveButton(android.R.string.ok, null) - .show() - } - - override fun onStop() { - super.onStop() - counter?.cancel() - counter = null - } - - override fun showPIN(pin: String) { - val binding = mBinding ?: return - dismissExportingProgress() - // encode the qr code with the pin generated - val qrCodeData = QRCodeUtils.encodeStringAsQRCodeData( - pin, - resources.getColor(R.color.black, null), - resources.getColor(R.color.white, null) - ) - var bitmap = qrCodeData?.let { - Bitmap.createBitmap(it.width, qrCodeData.height, Bitmap.Config.ARGB_8888).apply { - setPixels(qrCodeData.data, 0, qrCodeData.width, 0, 0, qrCodeData.width, qrCodeData.height) - } - } - binding.qrImage.setImageBitmap(bitmap) - // show the pin generated in the interface - binding.pin.text = pin - val start = System.currentTimeMillis() - // to have the count down of 10 min - val duration = 10 * DateUtils.MINUTE_IN_MILLIS - counter = object : CountDownTimer(duration, DateUtils.MINUTE_IN_MILLIS) { - override fun onTick(millisUntilFinished: Long) { - val expIn = DateUtils.getRelativeTimeSpanString( - start + duration, - System.currentTimeMillis(), - 0L - ) - binding.pinTimeValid.text = getString(R.string.account_link_time_valid, expIn) - } - - override fun onFinish() { - // return to the generate pin page - hideKeyboard(activity) - // change the text because the pin is now invalid - if (!mAccountHasPassword) mBinding!!.accountLinkInfo.text = - R.string.account_generate_export_invalid.toString() - if (mAccountHasPassword) { - val infoText = getString(R.string.account_generate_export_invalid) - mBinding!!.accountLinkInfo.text = infoText - } - mBinding!!.pageContainer.visibility = View.GONE - regeneratePin() - // liberate the memory - bitmap?.recycle() - bitmap = null - } - }.start() - mBinding!!.pin.visibility = View.VISIBLE - mBinding?.apply { - pageContainer.visibility = View.VISIBLE - accountLinkInfo.visibility = View.GONE - btnStartExport.visibility = View.GONE - passwordLayout.visibility = View.GONE - accountLinkInfo.visibility = View.GONE - password.text = null - } - hideKeyboard(activity) - } - - private fun startAccountExport() { - mBinding?.let { binding -> - binding.passwordLayout.error = null - presenter.startAccountExport(binding.password.text.toString()) - } - } - - private fun onPasswordEditorAction(pwd: TextView, actionId: Int, event: KeyEvent?): Boolean { - Log.i(TAG, "onEditorAction " + actionId + " " + event?.toString()) - if (actionId == EditorInfo.IME_ACTION_DONE) { - if (pwd.text.isEmpty()) { - pwd.error = getString(R.string.account_enter_password) - } else { - startAccountExport() - return true - } - } - return false - } - - companion object { - val TAG = LinkDeviceFragment::class.simpleName!! - const val PIN_LABEL = "PIN_LABEL" - fun newInstance(accountId: String) = LinkDeviceFragment().apply { - arguments = Bundle().apply { - putString(AccountEditionFragment.ACCOUNT_ID_KEY, accountId) - } - } - } -} \ No newline at end of file diff --git a/jami-android/app/src/main/java/cx/ring/tv/account/TVAccountExport.kt b/jami-android/app/src/main/java/cx/ring/tv/account/TVAccountExport.kt index 577067e3b51f2d82b5f2de5b7c0e55516daca926..dfc36b9dbd589570379204633e134296d5ec96ed 100644 --- a/jami-android/app/src/main/java/cx/ring/tv/account/TVAccountExport.kt +++ b/jami-android/app/src/main/java/cx/ring/tv/account/TVAccountExport.kt @@ -19,14 +19,7 @@ package cx.ring.tv.account import android.app.AlertDialog import android.app.DownloadManager import android.content.Context -import android.graphics.Typeface import android.os.Bundle -import android.text.Layout -import android.text.Spannable -import android.text.SpannableString -import android.text.style.AlignmentSpan -import android.text.style.RelativeSizeSpan -import android.text.style.StyleSpan import android.view.View import androidx.leanback.widget.GuidanceStylist.Guidance import androidx.leanback.widget.GuidedAction @@ -52,28 +45,31 @@ class TVAccountExport : JamiGuidedStepFragment<JamiAccountSummaryPresenter, Jami } override fun onCreateGuidance(savedInstanceState: Bundle?): Guidance { + // Todo: finish to clean up. val title = getString(R.string.account_export_title) val breadcrumb = "" - val description = getString(R.string.account_link_export_info_light) val icon = requireContext().getDrawable(R.drawable.baseline_devices_24) - return Guidance(title, description, breadcrumb, icon) + return Guidance(title, null, breadcrumb, icon) } override fun onCreateActions(actions: MutableList<GuidedAction>, savedInstanceState: Bundle?) { val context = requireContext() - if (mHasPassword) { - addPasswordAction(context, actions, PASSWORD, getString(R.string.account_enter_password), "", "") - } else { - addAction(context, actions, ACTION, R.string.account_start_export_button) - } + // Todo: finish to clean up. +// if (mHasPassword) { +// addPasswordAction(context, actions, PASSWORD, getString(R.string.account_enter_password), "", "") +// } else { + addAction(context, actions, ACTION, R.string.account_start_export_button) +// } } override fun onGuidedActionClicked(action: GuidedAction) { - presenter.startAccountExport("") + // Todo: finish to clean up. +// presenter.startAccountExport("") } override fun onGuidedActionEditedAndProceed(action: GuidedAction): Long { - presenter.startAccountExport(action.description.toString()) + // Todo: finish to clean up. +// presenter.startAccountExport(action.description.toString()) return GuidedAction.ACTION_ID_NEXT } @@ -92,61 +88,6 @@ class TVAccountExport : JamiGuidedStepFragment<JamiAccountSummaryPresenter, Jami override fun showPasswordProgressDialog() {} override fun accountChanged(account: Account, profile: Profile) {} - override fun showNetworkError() { - mWaitDialog?.dismiss() - AlertDialog.Builder(activity) - .setTitle(R.string.account_export_end_network_title) - .setMessage(R.string.account_export_end_network_message) - .setPositiveButton(android.R.string.ok, null) - .show() - } - - override fun showPasswordError() { - mWaitDialog?.dismiss() - AlertDialog.Builder(activity) - .setTitle(R.string.account_export_end_error_title) - .setMessage(R.string.account_export_end_decryption_message) - .setPositiveButton(android.R.string.ok, null) - .show() - } - - override fun showGenericError() { - mWaitDialog?.dismiss() - AlertDialog.Builder(activity) - .setTitle(R.string.account_export_end_error_title) - .setMessage(R.string.account_export_end_error_message) - .setPositiveButton(android.R.string.ok, null) - .show() - } - - override fun showPIN(pin: String) { - mWaitDialog?.dismiss() - val pined = getString(R.string.account_end_export_infos).replace("%%", pin) - val styledResultText = SpannableString(pined) - val pos = pined.lastIndexOf(pin) - styledResultText.setSpan( - AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), - pos, - pos + pin.length, - Spannable.SPAN_EXCLUSIVE_EXCLUSIVE - ) - styledResultText.setSpan( - StyleSpan(Typeface.BOLD), - pos, - pos + pin.length, - Spannable.SPAN_EXCLUSIVE_EXCLUSIVE - ) - styledResultText.setSpan( - RelativeSizeSpan(2.8f), - pos, - pos + pin.length, - Spannable.SPAN_EXCLUSIVE_EXCLUSIVE - ) - AlertDialog.Builder(activity) - .setMessage(styledResultText) - .setPositiveButton(android.R.string.ok) { _, _ -> parentFragmentManager.popBackStack() } - .show() - } override fun passwordChangeEnded(accountId: String, ok: Boolean, newPassword: String) {} override fun displayCompleteArchive(dest: File) { diff --git a/jami-android/app/src/main/java/cx/ring/tv/account/TVAccountWizard.kt b/jami-android/app/src/main/java/cx/ring/tv/account/TVAccountWizard.kt index d774fb79514adc256e5a1007c8e48d6bee39c5e9..907995e47d54fb5141cca9d97be52fd645ee8b79 100644 --- a/jami-android/app/src/main/java/cx/ring/tv/account/TVAccountWizard.kt +++ b/jami-android/app/src/main/java/cx/ring/tv/account/TVAccountWizard.kt @@ -41,7 +41,6 @@ import net.jami.model.AccountCreationModel @AndroidEntryPoint class TVAccountWizard : BaseActivity<AccountWizardPresenter>(), AccountWizardView { private var mProgress: AlertDialog? = null - private var mLinkAccount = false private var mAccountType: String? = null private var mAlertDialog: AlertDialog? = null private var mJamsAccount = false @@ -65,17 +64,10 @@ class TVAccountWizard : BaseActivity<AccountWizardPresenter>(), AccountWizardVie TVHomeAccountCreationFragment(), android.R.id.content ) - } else { - mLinkAccount = savedInstanceState.getBoolean("mLinkAccount") } presenter.init(getIntent().action ?: AccountConfig.ACCOUNT_TYPE_JAMI) } - override fun onSaveInstanceState(outState: Bundle) { - super.onSaveInstanceState(outState) - outState.putBoolean("mLinkAccount", mLinkAccount) - } - override fun onDestroy() { mProgress?.let { progress -> progress.dismiss() @@ -91,9 +83,6 @@ class TVAccountWizard : BaseActivity<AccountWizardPresenter>(), AccountWizardVie if (!model.managementServer.isNullOrEmpty()) { presenter.initJamiAccountConnect(model, defaultAccountName) mJamsAccount = true - } else if (model.isLink) { - presenter.initJamiAccountLink(model, defaultAccountName) - mJamsAccount = false } else { presenter.initJamiAccountCreation(model, defaultAccountName) mJamsAccount = false diff --git a/jami-android/app/src/main/java/cx/ring/tv/account/TVHomeAccountCreationFragment.kt b/jami-android/app/src/main/java/cx/ring/tv/account/TVHomeAccountCreationFragment.kt index 77e03e4616ee82b96106e526520abc75dca57b18..474865ef46ef37e7eb98a4116109c8b0e233ee44 100644 --- a/jami-android/app/src/main/java/cx/ring/tv/account/TVHomeAccountCreationFragment.kt +++ b/jami-android/app/src/main/java/cx/ring/tv/account/TVHomeAccountCreationFragment.kt @@ -33,23 +33,14 @@ class TVHomeAccountCreationFragment : JamiGuidedStepFragment<HomeAccountCreation private val model: AccountCreationViewModel by activityViewModels() override fun goToAccountCreation() { - model.model = AccountCreationModel().apply { - isLink = false - } add(parentFragmentManager, TVJamiAccountCreationFragment()) } - override fun goToAccountLink() { - model.model = AccountCreationModel().apply { - isLink = true - } - add(parentFragmentManager, TVJamiLinkAccountFragment()) + override fun goToAccountLink() { // Todo: Legacy code. Implement new UI instead of TVJamiLinkAccountFragment. +// add(parentFragmentManager, TVJamiLinkAccountFragment()) } override fun goToAccountConnect() { - model.model = AccountCreationModel().apply { - isLink = true - } add(parentFragmentManager, TVJamiAccountConnectFragment()) } diff --git a/jami-android/app/src/main/java/cx/ring/tv/account/TVJamiLinkAccountFragment.kt b/jami-android/app/src/main/java/cx/ring/tv/account/TVJamiLinkAccountFragment.kt deleted file mode 100644 index 667ae1e92fe562947f5c82a764e2deaddb990417..0000000000000000000000000000000000000000 --- a/jami-android/app/src/main/java/cx/ring/tv/account/TVJamiLinkAccountFragment.kt +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2004-2025 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.tv.account - -import android.graphics.Bitmap -import android.os.Bundle -import android.view.View -import androidx.fragment.app.activityViewModels -import androidx.leanback.widget.GuidanceStylist.Guidance -import androidx.leanback.widget.GuidedAction -import cx.ring.R -import cx.ring.account.AccountCreationViewModel -import dagger.hilt.android.AndroidEntryPoint -import net.jami.account.JamiLinkAccountPresenter -import net.jami.account.JamiLinkAccountView -import net.jami.utils.StringUtils.toPassword - -@AndroidEntryPoint -class TVJamiLinkAccountFragment : JamiGuidedStepFragment<JamiLinkAccountPresenter, JamiLinkAccountView>(), - JamiLinkAccountView { - private val model: AccountCreationViewModel by activityViewModels() - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - val m = model.model - presenter.init(m) - if (m.photo != null) { - guidanceStylist.iconView?.setImageBitmap(m.photo as Bitmap?) - } - } - - override fun onCreateGuidance(savedInstanceState: Bundle?): Guidance { - val title = getString(R.string.account_link_title) - val breadcrumb = "" - val description = """ - ${getString(R.string.help_password_enter)} - ${getString(R.string.help_pin_enter)} - """.trimIndent() - val icon = requireContext().getDrawable(R.drawable.ic_contact_picture_fallback) - return Guidance(title, description, breadcrumb, icon) - } - - override fun onCreateActions(actions: MutableList<GuidedAction>, savedInstanceState: Bundle?) { - val context = requireContext() - addPasswordAction(context, actions, PASSWORD, getString(R.string.account_enter_password), "", "") - addPasswordAction(context, actions, PIN, getString(R.string.account_link_prompt_pin), "", "") - addDisabledAction(context, actions, LINK, getString(R.string.account_link_title), "", null, true) - } - - override fun onProvideTheme(): Int = R.style.Theme_Ring_Leanback_GuidedStep_First - - override fun onGuidedActionClicked(action: GuidedAction) { - if (action.id == LINK) { - presenter.linkClicked() - } - } - - override fun enableLinkButton(enable: Boolean) { - findActionPositionById(LINK).takeUnless { it == -1 }?.also { position -> - actions[position]?.isEnabled = enable - notifyActionChanged(position) - } - } - - override fun showPin(show: Boolean) { - // TODO - } - - override fun createAccount() { - (activity as TVAccountWizard?)?.createAccount() - } - - override fun onGuidedActionEditedAndProceed(action: GuidedAction): Long { - val password = action.editDescription.toString() - action.description = if (password.isNotEmpty()) toPassword(password) else getString(R.string.account_enter_password) - when (action.id) { - PASSWORD -> { - notifyActionChanged(findActionPositionById(PASSWORD)) - presenter.passwordChanged(password) - } - PIN -> { - notifyActionChanged(findActionPositionById(PIN)) - presenter.pinChanged(action.editDescription.toString()) - } - } - return GuidedAction.ACTION_ID_NEXT - } - - override fun cancel() { - activity?.onBackPressedDispatcher?.onBackPressed() - } - - companion object { - private const val PASSWORD = 1L - private const val PIN = 2L - private const val LINK = 3L - } -} \ No newline at end of file diff --git a/jami-android/app/src/main/res/layout-land/frag_acc_jami_link.xml b/jami-android/app/src/main/res/layout-land/frag_acc_jami_link.xml deleted file mode 100644 index aa8e692f689380c60dd26d5bf60c48ced773f42b..0000000000000000000000000000000000000000 --- a/jami-android/app/src/main/res/layout-land/frag_acc_jami_link.xml +++ /dev/null @@ -1,129 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<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="horizontal" - android:paddingVertical="16dp"> - - <Space - android:layout_width="1dp" - android:layout_height="0dp" - android:layout_weight="1" /> - - <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_device" - 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> - - <Space - android:layout_width="1dp" - android:layout_height="0dp" - android:layout_weight="1" /> - - <ScrollView - android:id="@+id/scroll_view" - 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"> - - <com.google.android.material.tabs.TabLayout - android:id="@+id/tab_layout" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:background="@color/white"> - - <com.google.android.material.tabs.TabItem - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/connect_device_scanqr" /> - - <com.google.android.material.tabs.TabItem - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/connect_device_enterPIN" /> - </com.google.android.material.tabs.TabLayout> - - <androidx.viewpager2.widget.ViewPager2 - android:id="@+id/pager" - android:layout_width="@dimen/wizard_card_width" - android:layout_height="@dimen/wizard_card_width" - tools:background="@color/grey_400" /> - - <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: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:enabled="false" - android:text="@string/account_link_button" - android:textSize="12sp" - android:theme="@style/ButtonColoredInverse" /> - - </LinearLayout> - - </ScrollView> - - <Space - android:layout_width="1dp" - android:layout_height="0dp" - android:layout_weight="1" /> - -</LinearLayout> \ No newline at end of file diff --git a/jami-android/app/src/main/res/layout/edit_text_pin_input.xml b/jami-android/app/src/main/res/layout/edit_text_pin_input.xml deleted file mode 100644 index 1d00e2cb69c5b5074d5e398399a1da3de0b0c97d..0000000000000000000000000000000000000000 --- a/jami-android/app/src/main/res/layout/edit_text_pin_input.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" - android:gravity="center"> - - <com.google.android.material.textfield.TextInputLayout - android:id="@+id/pin_box" - style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingHorizontal="20dp" - app:counterEnabled="true" - app:counterMaxLength="17"> - - <com.google.android.material.textfield.TextInputEditText - android:id="@+id/enter_pin" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:hint="@string/account_link_prompt_pin_manually" - android:imeOptions="actionNext" - android:inputType="textNoSuggestions" /> - </com.google.android.material.textfield.TextInputLayout> - -</LinearLayout> \ No newline at end of file diff --git a/jami-android/app/src/main/res/layout/frag_acc_jami_link.xml b/jami-android/app/src/main/res/layout/frag_acc_jami_link.xml deleted file mode 100644 index bdb7c42c13942fc7a6d2d8c2432c4323bba1386d..0000000000000000000000000000000000000000 --- a/jami-android/app/src/main/res/layout/frag_acc_jami_link.xml +++ /dev/null @@ -1,112 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<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_device" - 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"> - - <com.google.android.material.tabs.TabLayout - android:id="@+id/tab_layout" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:background="@color/white"> - - <com.google.android.material.tabs.TabItem - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/connect_device_scanqr" /> - - <com.google.android.material.tabs.TabItem - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/connect_device_enterPIN" /> - </com.google.android.material.tabs.TabLayout> - - <androidx.viewpager2.widget.ViewPager2 - android:id="@+id/pager" - android:layout_width="@dimen/wizard_card_width" - android:layout_height="@dimen/wizard_card_width" - tools:background="@color/grey_400" /> - - <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:textStyle="bold" /> - - <com.google.android.material.textfield.TextInputLayout - android:id="@+id/password_txt_box" - 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:enabled="false" - android:text="@string/account_link_button" - android:textSize="12sp" - android:theme="@style/ButtonColoredInverse" /> - - </LinearLayout> - - </ScrollView> - -</LinearLayout> \ No newline at end of file diff --git a/jami-android/app/src/main/res/layout/frag_link_device.xml b/jami-android/app/src/main/res/layout/frag_link_device.xml deleted file mode 100644 index 2f4595740858eb0202361f217d3f7c79211e1c43..0000000000000000000000000000000000000000 --- a/jami-android/app/src/main/res/layout/frag_link_device.xml +++ /dev/null @@ -1,150 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<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="wrap_content" - android:gravity="center_horizontal" - android:orientation="vertical" - android:paddingBottom="15dp"> - - <LinearLayout - android:id="@+id/page_container" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:gravity="center_horizontal" - android:orientation="vertical"> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="16dp" - android:layout_marginBottom="16dp" - android:text="@string/account_link_device_title" - android:textAlignment="center" - android:textSize="16sp" - android:textStyle="bold" /> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="10dp" - android:layout_marginEnd="10dp" - android:text="@string/account_link_info" - android:textAlignment="center" - android:textSize="16sp" /> - - <FrameLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_margin="16dp" - android:background="@drawable/background_qrcode" - android:padding="6dp"> - - <ImageView - android:id="@+id/qr_image" - android:layout_width="150dp" - android:layout_height="150dp" - android:layout_gravity="center" - android:contentDescription="@string/content_description_qr_generated" - android:scaleType="fitCenter" - tools:src="@drawable/baseline_qr_code_2_black_24dp" /> - </FrameLayout> - - <TextView - android:id="@+id/pin" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:background="@drawable/background_pin_code" - android:drawablePadding="10dp" - android:paddingHorizontal="20dp" - android:paddingVertical="12dp" - android:textColor="@color/colorPrimary" - android:textSize="26sp" - app:drawableEndCompat="@drawable/baseline_content_copy_28" - app:drawableTint="@color/colorPrimary" - tools:text="abcdefgh-12345678" /> - - <TextView - android:id="@+id/pin_time_valid" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:backgroundTint="@color/colorPrimaryTranslucent" - android:paddingTop="12dp" - android:paddingBottom="15dp" - android:textAlignment="center" - android:textSize="16sp" - tools:text="The PIN code is valid for 09:27" /> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingBottom="8dp" - android:text="@string/account_generate_export_device" - android:textAlignment="center" - android:textSize="14sp" - android:textStyle="bold" /> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="10dp" - android:layout_marginEnd="10dp" - android:text="@string/account_generate_export_info" - android:textAlignment="center" - android:textSize="14sp" /> - </LinearLayout> - - <TextView - android:id="@+id/account_link_info" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingLeft="16dp" - android:paddingTop="16dp" - android:paddingRight="16dp" - android:paddingBottom="16dp" - android:text="@string/account_link_password" - android:textAlignment="center" - android:textIsSelectable="true" - android:textSize="14sp" /> - - <com.google.android.material.textfield.TextInputLayout - android:id="@+id/password_layout" - style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingLeft="16dp" - android:paddingRight="16dp" - android:paddingBottom="16dp" - app:passwordToggleEnabled="true" - app:passwordToggleTint="@color/colorPrimary"> - - <com.google.android.material.textfield.TextInputEditText - android:id="@+id/password" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:drawableStart="@drawable/baseline_lock_24" - android:drawablePadding="5dp" - android:drawableTint="@color/colorPrimary" - 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/btn_start_export" - style="@style/ButtonColored" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginBottom="8dp" - android:text="@string/account_link_generate_button" /> - - <androidx.core.widget.ContentLoadingProgressBar - android:id="@+id/progress_bar" - style="?android:attr/progressBarStyleLarge" - android:layout_width="80dp" - android:layout_height="80dp" - android:layout_margin="35dp" - android:visibility="gone" /> - -</LinearLayout> \ No newline at end of file diff --git a/jami-android/app/src/main/res/layout/qr_code_pin_input.xml b/jami-android/app/src/main/res/layout/qr_code_pin_input.xml deleted file mode 100644 index 4c5a20b5f78784ae29551848993c2d103e3c87f5..0000000000000000000000000000000000000000 --- a/jami-android/app/src/main/res/layout/qr_code_pin_input.xml +++ /dev/null @@ -1,75 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout 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"> - - <TextView - android:id="@+id/error_msg_txt" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:background="?attr/colorError" - android:gravity="center_vertical|center_horizontal" - android:padding="16dp" - android:text="@string/error_scan_no_camera_permissions" - android:textColor="?attr/colorOnError" - android:textSize="14sp" - tools:elevation="5dp" - tools:textColor="@color/white" - tools:visibility="visible" /> - - <com.journeyapps.barcodescanner.DecoratedBarcodeView - android:id="@+id/barcode_scanner" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_gravity="center" /> - - <TextView - android:id="@+id/text_invalid" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentBottom="true" - android:layout_centerHorizontal="true" - android:layout_marginBottom="35dp" - android:drawablePadding="6dp" - android:gravity="center_vertical" - android:text="@string/qr_invalid" - android:textColor="@color/white" - android:textSize="14sp" - android:visibility="invisible" - app:drawableStartCompat="@drawable/baseline_cancel_24" - app:drawableTint="@color/colorError" /> - - <RelativeLayout - android:id="@+id/qr_code_layout" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="#272727" - android:orientation="vertical" - android:visibility="invisible" - tools:visibility="visible"> - - <ImageView - android:id="@+id/checkbox_valid" - android:layout_width="20dp" - android:layout_height="20dp" - android:layout_centerInParent="true" - android:contentDescription="@string/content_description_checkbox" - android:src="@drawable/baseline_check_circle_24" - android:visibility="invisible" - app:tint="#00AF6C" - tools:visibility="visible" /> - - <ImageView - android:id="@+id/background" - android:layout_width="170dp" - android:layout_height="170dp" - android:layout_centerInParent="true" - android:alpha="0.1" - android:contentDescription="@null" - android:src="@drawable/baseline_devices_24" - app:tint="@color/black" /> - </RelativeLayout> - -</RelativeLayout> diff --git a/jami-android/app/src/main/res/values/strings.xml b/jami-android/app/src/main/res/values/strings.xml index b748e3ca5e19d115a5da760491d7503ff43c75a3..622b2540ff6847e09463e5bf7c02e1ecbbbe4e91 100644 --- a/jami-android/app/src/main/res/values/strings.xml +++ b/jami-android/app/src/main/res/values/strings.xml @@ -393,7 +393,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. <string name="help_password_choose">Choose a strong password you will remember to protect your Jami account.</string> <string name="help_password_enter">Enter your main Jami account password.</string> <string name="help_server_enter">Enter URL of management server.</string> - <string name="help_pin_enter">Enter the PIN from another configured Jami account. Use the “Export Jami account” feature to obtain a PIN.</string> <string name="pin_copied">PIN code copied to clipboard.</string> <string name="copied_clipboard">Copied to clipboard.</string> <string name="wizard_next">Next</string> diff --git a/jami-android/app/src/main/res/values/strings_account.xml b/jami-android/app/src/main/res/values/strings_account.xml index 979fe8aa3980339c68e40e3781c92db8324109d0..c300a1c42f2490bbfc1320d27409c2df331e1a9e 100644 --- a/jami-android/app/src/main/res/values/strings_account.xml +++ b/jami-android/app/src/main/res/values/strings_account.xml @@ -198,10 +198,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. <string name="account_export_file">Backup account</string> <string name="account_export_file_summary">Backup your account on your device to restore it later.</string> <string name="account_export_end_decryption_message">Incorrect password. Please try again with the correct password.</string> - <string name="account_export_end_network_title">Network error</string> - <string name="account_export_end_network_message">A network error occurred while exporting the account. Check your connectivity.</string> - <string name="account_export_end_error_title">Error</string> - <string name="account_export_end_error_message">An unknown error occurred while exporting the account.</string> <string name="account_enter_password">Enter password</string> <string name="account_share_body">Contact me using “%1$s” on the Jami distributed communication platform: %2$s</string> <string name="account_share_body_with_username">Contact me using “%1$s” or my public username “%2$s” on the Jami distributed communication platform: %3$s</string> @@ -243,16 +239,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. <string name="account_link_device">Connect from another device</string> <string name="account_link_button">Connect from network</string> <string name="account_link_archive_button">Connect from backup</string> - <string name="account_link_prompt_pin">Enter PIN code</string> - <string name="account_new_button">Join Jami</string> + <string name="account_new_button">Create a Jami account</string> <string name="account_link_export_button">Link a new device</string> <string name="account_link_show_button">Show %d more linked device</string> <string name="account_link_hide_button">Hide linked device</string> - <string name="account_link_export_info">To use this account on other devices, you must first expose it on Jami. This will generate a PIN code that you must enter on the new device to set up the account. The PIN code will expire in 10 minutes.</string> <string name="account_start_export_button">Generate PIN code</string> <string name="account_end_export_button">close</string> - <string name="account_end_export_infos">Your PIN code is:\n\n%%\n\nTo complete the process, you need to open Jami on the new device. Create a new account with “Link this device to an account”. The PIN code will expire in 10 minutes.</string> - <string name="account_link_export_info_light">To use this account on other devices, you must first expose it on Jami. This will generate a PIN code that you must enter on the new device to set up the account. The PIN code will expire in 10 minutes.</string> <string name="account_export_title">Link account to other devices</string> <string name="account_connect_server_button">Connect to management server</string> <string name="account_connect_button">Connect</string> @@ -288,7 +280,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. <string name="account_creation_home">Welcome to Jami</string> <string name="account_creation_profile">Create your profile</string> <string name="account_creation_ring">Create your Jami account</string> - <string name="account_link_title">Link this device</string> <string name="account_sip_cannot_be_registered">An error occurred while registering the SIP account.</string> <!-- Edit profile--> @@ -310,9 +301,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. <string name="account_disabled_indicator">Disabled</string> <!-- Link a new device --> - <string name="account_link_prompt_pin_manually">Enter PIN code manually</string> - <string name="qr_invalid">Not a Jami Authentication QR code</string> - <string name="content_description_checkbox">Your QR code is valid</string> <string name="error_format_not_supported">This format is not supported.</string> <string name="account_link_info">On the new Jami app, scan the QR code or enter manually the PIN code.</string> <string name="account_link_device_title">Link a new device</string> @@ -326,8 +314,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. <string name="account_generate_export_invalid">The PIN code is no longer valid.\nEnter the password and generate another one to link the new device.</string> <string name="account_generate_export_invalid_two">The PIN code is no longer valid.\nGenerate another one to link the new device.</string> <string name="help_pin_info">Fill if the account is password-encrypted</string> - <string name="connect_device_scanqr">Scan QR code</string> - <string name="connect_device_enterPIN">Or enter PIN code</string> <string name="account_link_device_button">Connect</string> <!-- Biometry --> diff --git a/jami-android/libjamiclient/src/main/kotlin/net/jami/account/AccountWizardPresenter.kt b/jami-android/libjamiclient/src/main/kotlin/net/jami/account/AccountWizardPresenter.kt index 586762e83ad100a021d9c89f8b25d8fd1134e9ad..7c071785887b4a62fedfee6614646361667bc8ec 100644 --- a/jami-android/libjamiclient/src/main/kotlin/net/jami/account/AccountWizardPresenter.kt +++ b/jami-android/libjamiclient/src/main/kotlin/net/jami/account/AccountWizardPresenter.kt @@ -99,7 +99,10 @@ class AccountWizardPresenter @Inject constructor( createAccount(accountCreationModel, newAccount) } - fun initJamiAccountLink(accountCreationModel: AccountCreationModel, defaultAccountName: String) { + fun initJamiAccountBackup( + accountCreationModel: AccountCreationModel, + defaultAccountName: String + ) { val newAccount = initJamiAccountDetails(defaultAccountName) .map<Map<String, String>> { accountDetails -> val settings = mPreferences.settings @@ -111,7 +114,8 @@ class AccountWizardPresenter @Inject constructor( accountDetails[ConfigKey.ARCHIVE_PASSWORD.key] = accountCreationModel.password } if (accountCreationModel.archive != null) { - accountDetails[ConfigKey.ARCHIVE_PATH.key] = accountCreationModel.archive!!.absolutePath + accountDetails[ConfigKey.ARCHIVE_PATH.key] = + accountCreationModel.archive!!.absolutePath } else if (accountCreationModel.pin.isNotEmpty()) { accountDetails[ConfigKey.ARCHIVE_PIN.key] = accountCreationModel.pin } @@ -120,9 +124,15 @@ class AccountWizardPresenter @Inject constructor( createAccount(accountCreationModel, newAccount) } - private fun createAccount(accountCreationModel: AccountCreationModel, details: Single<Map<String, String>>) { - val newAccount = details.flatMapObservable { accountDetails -> createNewAccount(accountCreationModel, accountDetails) } + private fun createAccount( + accountCreationModel: AccountCreationModel, + details: Single<Map<String, String>> + ) { + val newAccount = details.flatMapObservable { accountDetails -> + createNewAccount(accountCreationModel, accountDetails) + } accountCreationModel.accountObservable = newAccount + mCompositeDisposable.add(newAccount .observeOn(mUiScheduler) .subscribe({ account: Account -> accountCreationModel.newAccount = account }) @@ -142,7 +152,7 @@ class AccountWizardPresenter @Inject constructor( val newState = acc.registrationState if (newState == AccountConfig.RegistrationState.ERROR_GENERIC) { mCreatingAccount = false - if (accountCreationModel.archive == null) view.displayCannotBeFoundError() else view.displayGenericError() + view.displayGenericError() } else { view.goToProfileCreation() } diff --git a/jami-android/libjamiclient/src/main/kotlin/net/jami/account/JamiAccountSummaryPresenter.kt b/jami-android/libjamiclient/src/main/kotlin/net/jami/account/JamiAccountSummaryPresenter.kt index c3143cf6aa0b1a837d03a521fa8aea4e3b0e2eea..b7367ca011f521e05fe936091a1047b58542a7a7 100644 --- a/jami-android/libjamiclient/src/main/kotlin/net/jami/account/JamiAccountSummaryPresenter.kt +++ b/jami-android/libjamiclient/src/main/kotlin/net/jami/account/JamiAccountSummaryPresenter.kt @@ -25,7 +25,6 @@ import net.jami.services.HardwareService import net.jami.services.VCardService import net.jami.utils.Log import java.io.File -import java.net.SocketException import javax.inject.Inject import javax.inject.Named @@ -42,23 +41,6 @@ class JamiAccountSummaryPresenter @Inject constructor( mAccountService.registerName(account, name, scheme, password) } - fun startAccountExport(password: String?) { - if (view == null || mAccountID == null) { - return - } - view?.showExportingProgressDialog() - mCompositeDisposable.add(mAccountService - .exportOnRing(mAccountID!!, password!!) - .observeOn(mUiScheduler) - .subscribe({ pin: String -> view?.showPIN(pin) }) { error: Throwable -> - when (error) { - is IllegalArgumentException -> view?.showPasswordError() - is SocketException -> view?.showNetworkError() - else -> view?.showGenericError() - } - }) - } - fun setAccountId(accountId: String) { mCompositeDisposable.clear() mAccountID = accountId diff --git a/jami-android/libjamiclient/src/main/kotlin/net/jami/account/JamiAccountSummaryView.kt b/jami-android/libjamiclient/src/main/kotlin/net/jami/account/JamiAccountSummaryView.kt index 5c43a251cfff5c2e8a194f9dd0a1c0c463e0ffb7..058ee22e049709dcc994d97d304b80f2ac010e5c 100644 --- a/jami-android/libjamiclient/src/main/kotlin/net/jami/account/JamiAccountSummaryView.kt +++ b/jami-android/libjamiclient/src/main/kotlin/net/jami/account/JamiAccountSummaryView.kt @@ -24,10 +24,6 @@ interface JamiAccountSummaryView { fun showExportingProgressDialog() fun showPasswordProgressDialog() fun accountChanged(account: Account, profile: Profile) - fun showNetworkError() - fun showPasswordError() - fun showGenericError() - fun showPIN(pin: String) fun passwordChangeEnded(accountId: String, ok: Boolean, newPassword: String = "") fun displayCompleteArchive(dest: File) fun gotToImageCapture() diff --git a/jami-android/libjamiclient/src/main/kotlin/net/jami/account/JamiLinkAccountPresenter.kt b/jami-android/libjamiclient/src/main/kotlin/net/jami/account/JamiLinkAccountPresenter.kt deleted file mode 100644 index 65197d14345e47ec6b987849fd919efa92419985..0000000000000000000000000000000000000000 --- a/jami-android/libjamiclient/src/main/kotlin/net/jami/account/JamiLinkAccountPresenter.kt +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2004-2025 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 net.jami.account - -import net.jami.model.AccountCreationModel -import net.jami.mvp.RootPresenter -import javax.inject.Inject - -class JamiLinkAccountPresenter @Inject constructor() : RootPresenter<JamiLinkAccountView>() { - private var mAccountCreationModel: AccountCreationModel? = null - - fun init(accountCreationModel: AccountCreationModel?) { - mAccountCreationModel = accountCreationModel - if (mAccountCreationModel == null) { - view?.cancel() - return - } - val hasArchive = mAccountCreationModel?.archive != null - val view = view - if (view != null) { - view.showPin(!hasArchive) - view.enableLinkButton(hasArchive) - } - } - - fun passwordChanged(password: String) { - mAccountCreationModel?.password = password - showHideLinkButton() - } - - fun pinChanged(pin: String) { - mAccountCreationModel?.pin = pin - showHideLinkButton() - } - - fun resetPin() { - mAccountCreationModel?.pin = "" - showHideLinkButton() - } - - fun linkClicked() { - if (isFormValid) { - view?.createAccount() - } - } - - private fun showHideLinkButton() { - view?.enableLinkButton(isFormValid) - } - - private val isFormValid: Boolean - get() = mAccountCreationModel?.archive != null || mAccountCreationModel!!.pin.isNotEmpty() -} \ No newline at end of file diff --git a/jami-android/libjamiclient/src/main/kotlin/net/jami/account/JamiLinkAccountView.kt b/jami-android/libjamiclient/src/main/kotlin/net/jami/account/JamiLinkAccountView.kt deleted file mode 100644 index 57082b3f434848aa146a5edb36c533e27f5f7a4a..0000000000000000000000000000000000000000 --- a/jami-android/libjamiclient/src/main/kotlin/net/jami/account/JamiLinkAccountView.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2004-2025 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 net.jami.account - -import net.jami.model.AccountCreationModel - -interface JamiLinkAccountView { - fun enableLinkButton(enable: Boolean) - fun showPin(show: Boolean) - fun createAccount() - fun cancel() -} \ No newline at end of file diff --git a/jami-android/libjamiclient/src/main/kotlin/net/jami/account/LinkDevicePresenter.kt b/jami-android/libjamiclient/src/main/kotlin/net/jami/account/LinkDevicePresenter.kt deleted file mode 100644 index 9e9e0a8726cb8cef8b10667dbc5535abb5f5c4ad..0000000000000000000000000000000000000000 --- a/jami-android/libjamiclient/src/main/kotlin/net/jami/account/LinkDevicePresenter.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2004-2025 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 net.jami.account - -import io.reactivex.rxjava3.core.Scheduler -import net.jami.model.Account -import net.jami.mvp.RootPresenter -import net.jami.services.AccountService -import java.net.SocketException -import javax.inject.Inject -import javax.inject.Named - -class LinkDevicePresenter @Inject constructor( - private val accountService: AccountService, - @Named("UiScheduler") - private val uiScheduler: Scheduler -) : RootPresenter<LinkDeviceView>() { - private var mAccountID: String? = null - - fun startAccountExport(password: String) { - val v = view ?: return - v.showExportingProgress() - mCompositeDisposable.add(accountService - .exportOnRing(mAccountID!!, password) - .observeOn(uiScheduler) - .subscribe({ pin: String -> view?.showPIN(pin) }) - { error: Throwable -> - view?.dismissExportingProgress() - when (error) { - is IllegalArgumentException -> view?.showPasswordError() - is SocketException -> view?.showNetworkError() - else -> view?.showGenericError() - } - }) - } - - fun setAccountId(accountID: String) { - mCompositeDisposable.clear() - mAccountID = accountID - accountService.getAccount(accountID)?.let { account -> - view?.accountChanged(account) - } - mCompositeDisposable.add(accountService.getObservableAccountUpdates(accountID) - .observeOn(uiScheduler) - .subscribe { a: Account -> view?.accountChanged(a) }) - } - - companion object { - private val TAG = LinkDevicePresenter::class.simpleName!! - } -} \ No newline at end of file diff --git a/jami-android/libjamiclient/src/main/kotlin/net/jami/account/LinkDeviceView.kt b/jami-android/libjamiclient/src/main/kotlin/net/jami/account/LinkDeviceView.kt deleted file mode 100644 index dc19d8daf4a59c81f27debe129eae4460c896a63..0000000000000000000000000000000000000000 --- a/jami-android/libjamiclient/src/main/kotlin/net/jami/account/LinkDeviceView.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2004-2025 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 net.jami.account - -import net.jami.model.Account - -interface LinkDeviceView { - fun showExportingProgress() - fun dismissExportingProgress() - fun accountChanged(account: Account) - fun showNetworkError() - fun showPasswordError() - fun showGenericError() - fun showPIN(pin: String) -} \ No newline at end of file diff --git a/jami-android/libjamiclient/src/main/kotlin/net/jami/model/AccountCreationModel.kt b/jami-android/libjamiclient/src/main/kotlin/net/jami/model/AccountCreationModel.kt index fe3410acf3169bdca2cc635e31932fc72613d9c2..3e44d7c59c3b8bbf97fb365392a06bb2f165e273 100644 --- a/jami-android/libjamiclient/src/main/kotlin/net/jami/model/AccountCreationModel.kt +++ b/jami-android/libjamiclient/src/main/kotlin/net/jami/model/AccountCreationModel.kt @@ -16,9 +16,7 @@ */ package net.jami.model -import ezvcard.VCard import io.reactivex.rxjava3.core.Observable -import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.subjects.BehaviorSubject import io.reactivex.rxjava3.subjects.Subject import java.io.File @@ -28,7 +26,6 @@ class AccountCreationModel { var username = "" var password = "" var archive: File? = null - var isLink = false var isPush = true var newAccount: Account? = null