Merge branch 'master' of https://github.com/owncloud/android into material_buttons
authorAndy Scherzinger <info@andy-scherzinger.de>
Sun, 22 Nov 2015 16:10:37 +0000 (17:10 +0100)
committerAndy Scherzinger <info@andy-scherzinger.de>
Sun, 22 Nov 2015 16:10:37 +0000 (17:10 +0100)
1  2 
src/com/owncloud/android/authentication/AuthenticatorActivity.java

@@@ -176,6 -176,7 +176,6 @@@ public class AuthenticatorActivity exte
      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
              }\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
 -        mOkButton = findViewById(R.id.buttonOK);\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
  \r
          /// initialize block to be moved to single Fragment to check server and get info about it \r
          initServerPreFragment(savedInstanceState);\r
          \r
          mHostUrlInput.removeTextChangedListener(mHostUrlInputWatcher);\r
          mHostUrlInput.setOnFocusChangeListener(null);\r
 -        \r
 +\r
          super.onPause();\r
      }\r
      \r
                  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
          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
              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
          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
      }\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