8585import android .widget .Button ;
8686import android .widget .CheckBox ;
8787import android .widget .EditText ;
88+ import android .widget .ImageButton ;
8889import android .widget .ProgressBar ;
8990import android .widget .TextView ;
9091import android .widget .TextView .OnEditorActionListener ;
@@ -224,6 +225,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
224225 private EditText mPasswordInput ;
225226 private View mOkButton ;
226227 private TextView mAuthStatusView ;
228+ private ImageButton mTestServerButton ;
227229
228230 private WebView mLoginWebView ;
229231
@@ -246,6 +248,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
246248 private String webViewPassword ;
247249 private TextInputLayout mUsernameInputLayout ;
248250 private TextInputLayout mPasswordInputLayout ;
251+ private boolean forceOldLoginMethod = false ;
249252
250253 /**
251254 * {@inheritDoc}
@@ -300,18 +303,6 @@ protected void onCreate(Bundle savedInstanceState) {
300303 /// initialize general UI elements
301304 initOverallUi ();
302305
303- mUsernameInputLayout = (TextInputLayout ) findViewById (R .id .input_layout_account_username );
304- mPasswordInputLayout = (TextInputLayout ) findViewById (R .id .input_layout_account_password );
305-
306- mOkButton = findViewById (R .id .buttonOK );
307- mOkButton .setOnClickListener (new View .OnClickListener () {
308-
309- @ Override
310- public void onClick (View v ) {
311- onOkClick ();
312- }
313- });
314-
315306 findViewById (R .id .centeredRefreshButton ).setOnClickListener (new View .OnClickListener () {
316307
317308 @ Override
@@ -421,22 +412,37 @@ public void onReceivedError(WebView view, int errorCode, String description, Str
421412 mLoginWebView .loadData (DisplayUtils .getData (getResources ().openRawResource (R .raw .custom_error )),"text/html; charset=UTF-8" , null );
422413 }
423414 });
424- }
425415
426- // private Certificate getX509Certificate(SslCertificate sslCertificate) {
427- // Bundle bundle = SslCertificate.saveState(sslCertificate);
428- // byte[] bytes = bundle.getByteArray("x509-certificate");
429- // if (bytes == null) {
430- // return null;
431- // } else {
432- // try {
433- // CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
434- // return certFactory.generateCertificate(new ByteArrayInputStream(bytes));
435- // } catch (CertificateException e) {
436- // return null;
437- // }
438- // }
439- // }
416+ // show snackbar after 60s to switch back to old login method
417+ new Handler ().postDelayed (new Runnable () {
418+ @ Override
419+ public void run () {
420+ Snackbar .make (mLoginWebView , "Go back to old login method" , Snackbar .LENGTH_INDEFINITE )
421+ .setAction ("BACK" , new View .OnClickListener () {
422+ @ Override
423+ public void onClick (View v ) {
424+ mLoginWebView .setVisibility (View .INVISIBLE );
425+
426+ setContentView (R .layout .account_setup );
427+
428+ // initialize general UI elements
429+ initOverallUi ();
430+
431+ mHostUrlInput .setText (baseURL );
432+ mPasswordInputLayout .setVisibility (View .VISIBLE );
433+ mUsernameInput .requestFocus ();
434+ mOAuth2Check .setVisibility (View .INVISIBLE );
435+ mAuthStatusView .setVisibility (View .INVISIBLE );
436+ mServerStatusView .setVisibility (View .INVISIBLE );
437+ mTestServerButton .setVisibility (View .INVISIBLE );
438+ forceOldLoginMethod = true ;
439+
440+ checkOcServer ();
441+ }
442+ }).show ();
443+ }
444+ }, 60000 );
445+ }
440446
441447 private void parseAndLoginFromWebView (String dataString ) {
442448 String prefix = getString (R .string .login_data_own_scheme ) + PROTOCOL_SUFFIX + "login/" ;
@@ -547,6 +553,18 @@ private String chooseAuthTokenType(boolean oauth, boolean saml) {
547553 * Configures elements in the user interface under direct control of the Activity.
548554 */
549555 private void initOverallUi () {
556+ mHostUrlInput = (CustomEditText ) findViewById (R .id .hostUrlInput );
557+ mUsernameInputLayout = (TextInputLayout ) findViewById (R .id .input_layout_account_username );
558+ mPasswordInputLayout = (TextInputLayout ) findViewById (R .id .input_layout_account_password );
559+ mPasswordInput = (EditText ) findViewById (R .id .account_password );
560+ mUsernameInput = (EditText ) findViewById (R .id .account_username );
561+ mAuthStatusView = (TextView ) findViewById (R .id .auth_status_text );
562+ mOAuth2Check = (CheckBox ) findViewById (R .id .oauth_onOff_check );
563+ mServerStatusView = (TextView ) findViewById (R .id .server_status_text );
564+ mTestServerButton = (ImageButton ) findViewById (R .id .testServerButton );
565+
566+ mOkButton = findViewById (R .id .buttonOK );
567+ mOkButton .setOnClickListener (v -> onOkClick ());
550568
551569 /// step 1 - load and process relevant inputs (resources, intent, savedInstanceState)
552570 boolean isWelcomeLinkVisible = getResources ().getBoolean (R .bool .show_welcome_link );
@@ -1380,7 +1398,7 @@ private void onGetServerInfoFinish(RemoteOperationResult result) {
13801398 // 4. we got the authentication method required by the server
13811399 mServerInfo = (GetServerInfoOperation .ServerInfo ) (result .getData ().get (0 ));
13821400
1383- webViewLoginMethod = mServerInfo .mVersion .isWebLoginSupported ();
1401+ webViewLoginMethod = mServerInfo .mVersion .isWebLoginSupported () && ! forceOldLoginMethod ;
13841402
13851403 if (webViewUser != null && !webViewUser .isEmpty () &&
13861404 webViewPassword != null && !webViewPassword .isEmpty ()) {
@@ -2006,7 +2024,7 @@ public void onRegisterClick(View view) {
20062024 * to the last check on the ownCloud server.
20072025 */
20082026 private void showServerStatus () {
2009- if (mServerStatusIcon == 0 && mServerStatusText == 0 ) {
2027+ if (mServerStatusIcon == 0 && mServerStatusText == 0 || forceOldLoginMethod ) {
20102028 mServerStatusView .setVisibility (View .INVISIBLE );
20112029 } else {
20122030 mServerStatusView .setText (mServerStatusText );
0 commit comments