Merge branch 'master' of https://github.com/owncloud/android into material_buttons
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AuthenticatorActivity.java
index 02ab3c7..418cdd5 100644 (file)
@@ -176,7 +176,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     private EditText mUsernameInput;\r
     private EditText mPasswordInput;\r
     private View mOkButton;\r
-    private View mCenteredRefreshButton;\r
     private TextView mAuthStatusView;\r
 \r
     private int mAuthStatusText = 0, mAuthStatusIcon = 0;\r
@@ -261,16 +260,22 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             }\r
         });\r
 \r
-        mCenteredRefreshButton = findViewById(R.id.centeredRefreshButton);\r
-        mCenteredRefreshButton.setOnClickListener(new View.OnClickListener() {\r
+        findViewById(R.id.centeredRefreshButton).setOnClickListener(new View.OnClickListener() {\r
+\r
+            @Override\r
+            public void onClick(View v) {\r
+                checkOcServer();\r
+            }\r
+        });\r
+\r
+        findViewById(R.id.embeddedRefreshButton).setOnClickListener(new View.OnClickListener() {\r
 \r
             @Override\r
             public void onClick(View v) {\r
                 checkOcServer();\r
             }\r
         });\r
-        \r
-        mOkButton = findViewById(R.id.buttonOK);\r
+\r
 \r
         /// initialize block to be moved to single Fragment to check server and get info about it \r
         initServerPreFragment(savedInstanceState);\r
@@ -702,7 +707,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         \r
         mHostUrlInput.removeTextChangedListener(mHostUrlInputWatcher);\r
         mHostUrlInput.setOnFocusChangeListener(null);\r
-        \r
+\r
         super.onPause();\r
     }\r
     \r
@@ -742,7 +747,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
                 mOAuthTokenEndpointText.getText().toString().trim());\r
         \r
         getServerInfoIntent.putExtra(\r
-                OperationsService.EXTRA_OAUTH2_QUERY_PARAMETERS, \r
+                OperationsService.EXTRA_OAUTH2_QUERY_PARAMETERS,\r
                 queryParameters);\r
         \r
         if (mOperationsServiceBinder != null) {\r
@@ -801,6 +806,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         showRefreshButton(false);\r
 \r
         if (uri.length() != 0) {\r
+            uri = stripIndexPhpOrAppsFiles(uri, mHostUrlInput);\r
+\r
             // Handle internationalized domain names\r
             uri = DisplayUtils.convertIdn(uri, true);\r
 \r
@@ -811,8 +818,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             Intent getServerInfoIntent = new Intent();\r
             getServerInfoIntent.setAction(OperationsService.ACTION_GET_SERVER_INFO);\r
             getServerInfoIntent.putExtra(\r
-                OperationsService.EXTRA_SERVER_URL,\r
-                normalizeUrlSuffix(uri)\r
+                    OperationsService.EXTRA_SERVER_URL,\r
+                    normalizeUrlSuffix(uri)\r
             );\r
             if (mOperationsServiceBinder != null) {\r
                 mWaitingForOpId = mOperationsServiceBinder.queueNewOperation(getServerInfoIntent);\r
@@ -1143,6 +1150,17 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         return url;\r
     }\r
 \r
+    private String stripIndexPhpOrAppsFiles(String url, EditText mHostUrlInput) {\r
+        if (url.endsWith("/index.php")) {\r
+            url = url.substring(0, url.lastIndexOf("/index.php"));\r
+            mHostUrlInput.setText(url);\r
+        } else if (url.contains("/index.php/apps/")) {\r
+            url = url.substring(0, url.lastIndexOf("/index.php/apps/"));\r
+            mHostUrlInput.setText(url);\r
+        }\r
+\r
+        return url;\r
+    }\r
 \r
     // TODO remove, if possible\r
     private String trimUrlWebdav(String url){       \r
@@ -1625,18 +1643,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     }\r
 \r
     /**\r
-     * Called when the refresh button in the input field for ownCloud host is clicked.\r
-     * \r
-     * Performs a new check on the URL in the input field.\r
-     * \r
-     * @param view      Refresh 'button'\r
-     */\r
-    public void onRefreshClick(View view) {\r
-        checkOcServer();\r
-    }\r
-\r
-\r
-    /**\r
      * Called when the eye icon in the password field is clicked.\r
      * \r
      * Toggles the visibility of the password in the field. \r