From 99c11fba17e4da7d69005c9186c5c11411293e05 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 25 Feb 2023 15:13:47 +0100 Subject: [PATCH] add stub hostname fragment --- .../xmpp/MessageTransformationTest.java | 2 +- .../android/ui/activity/SetupActivity.java | 3 + .../ui/fragment/setup/HostnameFragment.java | 23 ++- .../android/ui/model/SetupViewModel.java | 25 +++ app/src/main/res/layout/fragment_hostname.xml | 182 ++++++++++++++++++ .../main/res/navigation/setup_navigation.xml | 18 +- app/src/main/res/values/strings.xml | 2 + 7 files changed, 252 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/layout/fragment_hostname.xml diff --git a/app/src/androidTest/java/im/conversations/android/xmpp/MessageTransformationTest.java b/app/src/androidTest/java/im/conversations/android/xmpp/MessageTransformationTest.java index dd78e2b6f..9779618e4 100644 --- a/app/src/androidTest/java/im/conversations/android/xmpp/MessageTransformationTest.java +++ b/app/src/androidTest/java/im/conversations/android/xmpp/MessageTransformationTest.java @@ -84,7 +84,7 @@ public class MessageTransformationTest { final var message = Iterables.getOnlyElement(messages); final var onlyContent = Iterables.getOnlyElement(message.contents); Assert.assertEquals(GREETING, onlyContent.body); - Assert.assertEquals(Encryption.CLEARTEXT,message.encryption); + Assert.assertEquals(Encryption.CLEARTEXT, message.encryption); final var onlyReaction = Iterables.getOnlyElement(message.reactions); Assert.assertEquals("Y", onlyReaction.reaction); Assert.assertEquals(REMOTE, onlyReaction.reactionBy); diff --git a/app/src/main/java/im/conversations/android/ui/activity/SetupActivity.java b/app/src/main/java/im/conversations/android/ui/activity/SetupActivity.java index 8b4bc10b5..f4255eb19 100644 --- a/app/src/main/java/im/conversations/android/ui/activity/SetupActivity.java +++ b/app/src/main/java/im/conversations/android/ui/activity/SetupActivity.java @@ -41,6 +41,9 @@ public class SetupActivity extends BaseActivity { case ENTER_PASSWORD: navController.navigate(SetupNavigationDirections.enterPassword()); break; + case ENTER_HOSTNAME: + navController.navigate(SetupNavigationDirections.enterHostname()); + break; case DONE: startActivity(new Intent(this, MainActivity.class)); finish(); diff --git a/app/src/main/java/im/conversations/android/ui/fragment/setup/HostnameFragment.java b/app/src/main/java/im/conversations/android/ui/fragment/setup/HostnameFragment.java index d609c6700..68f30dbf4 100644 --- a/app/src/main/java/im/conversations/android/ui/fragment/setup/HostnameFragment.java +++ b/app/src/main/java/im/conversations/android/ui/fragment/setup/HostnameFragment.java @@ -1,3 +1,24 @@ package im.conversations.android.ui.fragment.setup; -public class HostnameFragment extends AbstractSetupFragment {} +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; +import im.conversations.android.R; +import im.conversations.android.databinding.FragmentHostnameBinding; + +public class HostnameFragment extends AbstractSetupFragment { + + @Override + public View onCreateView( + @NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + super.onCreateView(inflater, container, savedInstanceState); + FragmentHostnameBinding binding = + DataBindingUtil.inflate(inflater, R.layout.fragment_hostname, container, false); + binding.setSetupViewModel(setupViewModel); + binding.setLifecycleOwner(getViewLifecycleOwner()); + return binding.getRoot(); + } +} diff --git a/app/src/main/java/im/conversations/android/ui/model/SetupViewModel.java b/app/src/main/java/im/conversations/android/ui/model/SetupViewModel.java index 3665185f9..ab1588dcd 100644 --- a/app/src/main/java/im/conversations/android/ui/model/SetupViewModel.java +++ b/app/src/main/java/im/conversations/android/ui/model/SetupViewModel.java @@ -34,6 +34,9 @@ public class SetupViewModel extends AndroidViewModel { private final MutableLiveData xmppAddressError = new MutableLiveData<>(); private final MutableLiveData password = new MutableLiveData<>(); private final MutableLiveData passwordError = new MutableLiveData<>(); + private final MutableLiveData hostname = new MutableLiveData<>(); + private final MutableLiveData port = new MutableLiveData<>(); + private final MutableLiveData opportunisticTls = new MutableLiveData<>(); private final MutableLiveData loading = new MutableLiveData<>(false); private final MutableLiveData> redirection = new MutableLiveData<>(); @@ -69,6 +72,18 @@ public class SetupViewModel extends AndroidViewModel { return password; } + public MutableLiveData getHostname() { + return hostname; + } + + public MutableLiveData getPort() { + return port; + } + + public MutableLiveData getOpportunisticTls() { + return this.opportunisticTls; + } + public LiveData getPasswordError() { return Transformations.distinctUntilChanged(this.passwordError); } @@ -210,6 +225,16 @@ public class SetupViewModel extends AndroidViewModel { return true; } + public boolean submitHostname() { + final var account = this.account; + if (account == null) { + this.redirectIfNecessary(Target.ENTER_HOSTNAME, Target.ENTER_ADDRESS); + return true; + } + + return true; + } + public boolean submitPassword() { final var account = this.account; if (account == null) { diff --git a/app/src/main/res/layout/fragment_hostname.xml b/app/src/main/res/layout/fragment_hostname.xml new file mode 100644 index 000000000..ef3294482 --- /dev/null +++ b/app/src/main/res/layout/fragment_hostname.xml @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/navigation/setup_navigation.xml b/app/src/main/res/navigation/setup_navigation.xml index 51291c860..f5edef831 100644 --- a/app/src/main/res/navigation/setup_navigation.xml +++ b/app/src/main/res/navigation/setup_navigation.xml @@ -25,13 +25,29 @@ app:enterAnim="@anim/slide_from_right" app:exitAnim="@anim/slide_to_left" app:popEnterAnim="@anim/slide_from_left" - app:popExitAnim="@anim/slide_to_right" /> + app:popExitAnim="@anim/slide_to_right" + app:popUpTo="@+id/hostname" /> + + + + + Automatic download Sending Receiving + Opportunistic TLS (STARTTLS) + Info required