diff --git a/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java b/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java index 37b3eff37fad..c4b1cc81d559 100644 --- a/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -365,55 +365,60 @@ protected void onCreate(Bundle savedInstanceState) { if (TextUtils.isEmpty(getString(R.string.enforce_servers))) { initAuthorizationPreFragment(savedInstanceState); } else { - showAuthStatus(); - accountSetupBinding.hostUrlFrame.setVisibility(View.GONE); - accountSetupBinding.hostUrlInputHelperText.setVisibility(View.GONE); - accountSetupBinding.scanQr.setVisibility(View.GONE); - accountSetupBinding.serversSpinner.setVisibility(View.VISIBLE); - - ArrayAdapter adapter = new ArrayAdapter<>(this, R.layout.enforced_servers_spinner); - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - - ArrayList servers = new ArrayList<>(); - servers.add(""); - adapter.add(getString(R.string.please_select_a_server)); - - ArrayList t = new Gson().fromJson(getString(R.string.enforce_servers), - new TypeToken>() { - } - .getType()); - - for (EnforcedServer e : t) { - adapter.add(e.getName()); - servers.add(e.getUrl()); - } + showEnforcedServers(); + } + + initServerPreFragment(savedInstanceState); + ProcessLifecycleOwner.get().getLifecycle().addObserver(lifecycleEventObserver); - accountSetupBinding.serversSpinner.setAdapter(adapter); - accountSetupBinding.serversSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){ + // webViewUtil.checkWebViewVersion(); + } + } + + private void showEnforcedServers() { - @Override - public void onItemSelected(AdapterView parent, View view, int position, long id) { - String url = servers.get(position); - - if (URLUtil.isValidUrl(url)) { - accountSetupBinding.hostUrlInput.setText(url); - checkOcServer(); - } - } + showAuthStatus(); + accountSetupBinding.hostUrlFrame.setVisibility(View.GONE); + accountSetupBinding.hostUrlInputHelperText.setVisibility(View.GONE); + accountSetupBinding.scanQr.setVisibility(View.GONE); + accountSetupBinding.serversSpinner.setVisibility(View.VISIBLE); - @Override - public void onNothingSelected(AdapterView parent) { - // do nothing - } - }); + ArrayAdapter adapter = new ArrayAdapter<>(this, R.layout.enforced_servers_spinner); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + + ArrayList servers = new ArrayList<>(); + servers.add(""); + adapter.add(getString(R.string.please_select_a_server)); + + ArrayList t = new Gson().fromJson(getString(R.string.enforce_servers), + new TypeToken>() { + } + .getType()); + + for (EnforcedServer e : t) { + adapter.add(e.getName()); + servers.add(e.getUrl()); } - } - initServerPreFragment(savedInstanceState); - ProcessLifecycleOwner.get().getLifecycle().addObserver(lifecycleEventObserver); + accountSetupBinding.serversSpinner.setAdapter(adapter); + accountSetupBinding.serversSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){ - // webViewUtil.checkWebViewVersion(); - } + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + String url = servers.get(position); + + if (URLUtil.isValidUrl(url)) { + accountSetupBinding.hostUrlInput.setText(url); + checkOcServer(); + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + // do nothing + } + }); + } private final LifecycleEventObserver lifecycleEventObserver = ((lifecycleOwner, event) -> { if (event == Lifecycle.Event.ON_START && token != null) {