Search in sources :

Example 1 with RegistrationNumberInputController

use of org.thoughtcrime.securesms.registration.util.RegistrationNumberInputController in project Signal-Android by WhisperSystems.

the class EnterPhoneNumberFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setDebugLogSubmitMultiTapView(view.findViewById(R.id.verify_header));
    countryCode = view.findViewById(R.id.country_code);
    number = view.findViewById(R.id.number);
    countrySpinner = view.findViewById(R.id.country_spinner);
    cancel = view.findViewById(R.id.cancel_button);
    scrollView = view.findViewById(R.id.scroll_view);
    register = view.findViewById(R.id.registerButton);
    RegistrationNumberInputController controller = new RegistrationNumberInputController(requireContext(), countryCode, number, countrySpinner, true, this);
    register.setOnClickListener(v -> handleRegister(requireContext()));
    disposables.bindTo(getViewLifecycleOwner().getLifecycle());
    viewModel = new ViewModelProvider(requireActivity()).get(RegistrationViewModel.class);
    if (viewModel.isReregister()) {
        cancel.setVisibility(View.VISIBLE);
        cancel.setOnClickListener(v -> Navigation.findNavController(v).navigateUp());
    } else {
        cancel.setVisibility(View.GONE);
    }
    viewModel.getLiveNumber().observe(getViewLifecycleOwner(), controller::updateNumber);
    if (viewModel.hasCaptchaToken()) {
        ThreadUtil.runOnMainDelayed(() -> handleRegister(requireContext()), 250);
    }
    Toolbar toolbar = view.findViewById(R.id.toolbar);
    ((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar);
    ((AppCompatActivity) requireActivity()).getSupportActionBar().setTitle(null);
}
Also used : AppCompatActivity(androidx.appcompat.app.AppCompatActivity) RegistrationNumberInputController(org.thoughtcrime.securesms.registration.util.RegistrationNumberInputController) ViewModelProvider(androidx.lifecycle.ViewModelProvider) RegistrationViewModel(org.thoughtcrime.securesms.registration.viewmodel.RegistrationViewModel) Toolbar(androidx.appcompat.widget.Toolbar)

Example 2 with RegistrationNumberInputController

use of org.thoughtcrime.securesms.registration.util.RegistrationNumberInputController in project Signal-Android by signalapp.

the class EnterPhoneNumberFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setDebugLogSubmitMultiTapView(view.findViewById(R.id.verify_header));
    countryCode = view.findViewById(R.id.country_code);
    number = view.findViewById(R.id.number);
    countrySpinner = view.findViewById(R.id.country_spinner);
    cancel = view.findViewById(R.id.cancel_button);
    scrollView = view.findViewById(R.id.scroll_view);
    register = view.findViewById(R.id.registerButton);
    RegistrationNumberInputController controller = new RegistrationNumberInputController(requireContext(), countryCode, number, countrySpinner, true, this);
    register.setOnClickListener(v -> handleRegister(requireContext()));
    disposables.bindTo(getViewLifecycleOwner().getLifecycle());
    viewModel = new ViewModelProvider(requireActivity()).get(RegistrationViewModel.class);
    if (viewModel.isReregister()) {
        cancel.setVisibility(View.VISIBLE);
        cancel.setOnClickListener(v -> Navigation.findNavController(v).navigateUp());
    } else {
        cancel.setVisibility(View.GONE);
    }
    viewModel.getLiveNumber().observe(getViewLifecycleOwner(), controller::updateNumber);
    if (viewModel.hasCaptchaToken()) {
        ThreadUtil.runOnMainDelayed(() -> handleRegister(requireContext()), 250);
    }
    Toolbar toolbar = view.findViewById(R.id.toolbar);
    ((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar);
    ((AppCompatActivity) requireActivity()).getSupportActionBar().setTitle(null);
}
Also used : AppCompatActivity(androidx.appcompat.app.AppCompatActivity) RegistrationNumberInputController(org.thoughtcrime.securesms.registration.util.RegistrationNumberInputController) ViewModelProvider(androidx.lifecycle.ViewModelProvider) RegistrationViewModel(org.thoughtcrime.securesms.registration.viewmodel.RegistrationViewModel) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

AppCompatActivity (androidx.appcompat.app.AppCompatActivity)2 Toolbar (androidx.appcompat.widget.Toolbar)2 ViewModelProvider (androidx.lifecycle.ViewModelProvider)2 RegistrationNumberInputController (org.thoughtcrime.securesms.registration.util.RegistrationNumberInputController)2 RegistrationViewModel (org.thoughtcrime.securesms.registration.viewmodel.RegistrationViewModel)2