diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java index 229bc9d8..0af61c2b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -283,9 +283,9 @@ public class SettingsFragment extends ToolbarFragment{ private void onLoggedOut(){ AccountSessionManager.getInstance().removeAccount(accountID); + getActivity().finish(); Intent intent=new Intent(getActivity(), MainActivity.class); startActivity(intent); - getActivity().finish(); } private void clearImageCache(){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/AccountActivationFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/AccountActivationFragment.java index 0f843c82..cd73cc9b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/AccountActivationFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/AccountActivationFragment.java @@ -21,6 +21,7 @@ import org.joinmastodon.android.api.requests.accounts.UpdateAccountCredentials; import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.fragments.HomeFragment; +import org.joinmastodon.android.fragments.SettingsFragment; import org.joinmastodon.android.model.Account; import org.joinmastodon.android.ui.utils.UiUtils; @@ -57,6 +58,12 @@ public class AccountActivationFragment extends AppKitFragment{ btn=view.findViewById(R.id.btn_next); btn.setOnClickListener(v->onButtonClick()); + btn.setOnLongClickListener(v->{ + Bundle args=new Bundle(); + args.putString("account", accountID); + Nav.go(getActivity(), SettingsFragment.class, args); + return true; + }); buttonBar=view.findViewById(R.id.button_bar); view.findViewById(R.id.btn_back).setOnClickListener(v->onBackButtonClick()); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogFragment.java index fb9d3d4b..6cd2273b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/onboarding/InstanceCatalogFragment.java @@ -12,6 +12,7 @@ import android.view.KeyEvent; import android.view.View; import android.view.ViewGroup; import android.view.WindowInsets; +import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; @@ -254,6 +255,7 @@ public class InstanceCatalogFragment extends BaseRecyclerFragmentupdateButtonState()); @@ -95,6 +96,8 @@ public class SignupFragment extends AppKitFragment{ email=view.findViewById(R.id.email); password=view.findViewById(R.id.password); avatar=view.findViewById(R.id.avatar); + reason=view.findViewById(R.id.reason); + reasonExplain=view.findViewById(R.id.reason_explain); View avaWrap=view.findViewById(R.id.ava_wrap); title.setText(getString(R.string.signup_title, instance.uri)); @@ -118,15 +121,22 @@ public class SignupFragment extends AppKitFragment{ username.addTextChangedListener(buttonStateUpdater); email.addTextChangedListener(buttonStateUpdater); password.addTextChangedListener(buttonStateUpdater); + reason.addTextChangedListener(buttonStateUpdater); username.addTextChangedListener(new ErrorClearingListener(username)); email.addTextChangedListener(new ErrorClearingListener(email)); password.addTextChangedListener(new ErrorClearingListener(password)); + reason.addTextChangedListener(new ErrorClearingListener(reason)); avaWrap.setOutlineProvider(OutlineProviders.roundedRect(22)); avaWrap.setClipToOutline(true); avaWrap.setOnClickListener(v->onAvatarClick()); + if(!instance.approvalRequired){ + reason.setVisibility(View.GONE); + reasonExplain.setVisibility(View.GONE); + } + return view; } @@ -186,7 +196,7 @@ public class SignupFragment extends AppKitFragment{ edit.setError(null); } errorFields.clear(); - new RegisterAccount(username, email, password.getText().toString(), getResources().getConfiguration().locale.getLanguage(), null) + new RegisterAccount(username, email, password.getText().toString(), getResources().getConfiguration().locale.getLanguage(), reason.getText().toString()) .setCallback(new Callback<>(){ @Override public void onSuccess(Token result){ @@ -209,10 +219,13 @@ public class SignupFragment extends AppKitFragment{ if(error instanceof MastodonDetailedErrorResponse){ Map> fieldErrors=((MastodonDetailedErrorResponse) error).detailedErrors; boolean first=true; + boolean anyFieldsSkipped=false; for(String fieldName:fieldErrors.keySet()){ EditText field=getFieldByName(fieldName); - if(field==null) + if(field==null){ + anyFieldsSkipped=true; continue; + } field.setError(fieldErrors.get(fieldName).stream().map(err->err.description).collect(Collectors.joining("\n"))); errorFields.add(field); if(first){ @@ -220,6 +233,8 @@ public class SignupFragment extends AppKitFragment{ field.requestFocus(); } } + if(anyFieldsSkipped) + error.showToast(getActivity()); }else{ error.showToast(getActivity()); } @@ -235,6 +250,7 @@ public class SignupFragment extends AppKitFragment{ case "email" -> email; case "username" -> username; case "password" -> password; + case "reason" -> reason; default -> null; }; } @@ -247,7 +263,7 @@ public class SignupFragment extends AppKitFragment{ } private void updateButtonState(){ - btn.setEnabled(username.length()>0 && email.length()>0 && email.getText().toString().contains("@") && password.length()>=8); + btn.setEnabled(username.length()>0 && email.length()>0 && email.getText().toString().contains("@") && password.length()>=8 && (!instance.approvalRequired || reason.length()>0)); } private void createAppAndGetToken(){ diff --git a/mastodon/src/main/res/layout/fragment_onboarding_signup.xml b/mastodon/src/main/res/layout/fragment_onboarding_signup.xml index d5039d20..59dc2db5 100644 --- a/mastodon/src/main/res/layout/fragment_onboarding_signup.xml +++ b/mastodon/src/main/res/layout/fragment_onboarding_signup.xml @@ -133,6 +133,28 @@ android:textColor="?android:textColorSecondary" android:text="@string/password_note"/> + + + + diff --git a/mastodon/src/main/res/layout/header_onboarding_instance_catalog.xml b/mastodon/src/main/res/layout/header_onboarding_instance_catalog.xml index 41ea2e99..58081e0f 100644 --- a/mastodon/src/main/res/layout/header_onboarding_instance_catalog.xml +++ b/mastodon/src/main/res/layout/header_onboarding_instance_catalog.xml @@ -46,7 +46,7 @@ android:id="@+id/search_edit" android:layout_width="match_parent" android:layout_height="wrap_content" - android:inputType="textFilter" + android:inputType="textFilter|textNoSuggestions" android:singleLine="true" android:imeOptions="actionGo" android:layout_marginLeft="16dp" diff --git a/mastodon/src/main/res/values/strings.xml b/mastodon/src/main/res/values/strings.xml index 271ff905..f3420c67 100644 --- a/mastodon/src/main/res/values/strings.xml +++ b/mastodon/src/main/res/values/strings.xml @@ -292,4 +292,6 @@ Open in browser Hide boosts from %s Show boosts from %s + why do you want to join? + This will help us review your application. \ No newline at end of file