Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.InputType;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
Expand Down Expand Up @@ -203,17 +204,18 @@ private void initButton(View rootView) {

private void showAddItemDialog(Context c) {
final EditText urlET = new EditText(c);
urlET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also add the no suggestions flag to disable auto correction when typing the url. But I guess most people will copy their instance urls and this flag disables the option to paste the first clipboard item from the keyboard.
What's your opinion? @Stypox @yausername

Suggested change
urlET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
urlET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
urlET.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

Copy link
Member

@Stypox Stypox Dec 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume most keyboards will stop suggesting things when they see a url text field. Mozilla Preview (fenix) uses the same flags in the bookmark editor: textUri means InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI (source)

So it is ok to have no TYPE_TEXT_FLAG_NO_SUGGESTIONS ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto correction is automatically disabled on TYPE_TEXT_VARIATION_URI. I don't see any harm is having suggestions on because many instances use dictionary words.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I this case my keyboard is behaving shitty :)
When typing, I still get auto-corrected. Never mind, I tested with another keyboard and things work as expected.

urlET.setHint(R.string.peertube_instance_add_help);
AlertDialog dialog = new AlertDialog.Builder(c)
.setTitle(R.string.peertube_instance_add_title)
.setIcon(R.drawable.place_holder_peertube)
.setView(urlET)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.finish, (dialog1, which) -> {
String url = urlET.getText().toString();
addInstance(url);
})
.create();
dialog.setView(urlET, 50, 0, 50, 0);
dialog.show();
}

Expand All @@ -237,6 +239,7 @@ private void addInstance(String url) {

@Nullable
private String cleanUrl(String url){
url = url.trim();
// if protocol not present, add https
if(!url.startsWith("http")){
url = "https://" + url;
Expand Down