Make the 'refresh' button enabled when visible, although the URL-input field is disab...
authorDavid A. Velasco <dvelasco@solidgear.es>
Mon, 24 Jun 2013 08:39:52 +0000 (10:39 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Mon, 24 Jun 2013 08:39:52 +0000 (10:39 +0200)
res/layout-land/account_setup.xml
res/layout/account_setup.xml
src/com/owncloud/android/authentication/AuthenticatorActivity.java

index dea86cd..d3622be 100644 (file)
                            android:orientation="vertical"\r
                            android:padding="8dp" >\r
                \r
-                               <EditText\r
-                                       android:id="@+id/hostUrlInput"\r
+                           <FrameLayout \r
                                        android:layout_width="match_parent"\r
                                        android:layout_height="wrap_content"\r
-                                       android:ems="10"\r
-                                       android:hint="@string/auth_host_url"\r
-                                       android:inputType="textUri"\r
-                                       android:drawablePadding="5dp"\r
-                                       >\r
-                                       <requestFocus />\r
-                               </EditText>\r
+                               >\r
+                                       <EditText\r
+                                               android:id="@+id/hostUrlInput"\r
+                                               android:layout_width="match_parent"\r
+                                               android:layout_height="wrap_content"\r
+                                               android:hint="@string/auth_host_url"\r
+                                               android:inputType="textUri"\r
+                                               android:drawablePadding="5dp"\r
+                                               android:paddingRight="55dp"\r
+                                               >\r
+                                               <requestFocus />\r
+                                       </EditText>\r
+                                       <ImageButton\r
+                                           android:id="@+id/refeshButton"\r
+                                           android:layout_width="48dp"\r
+                                           android:layout_height="48dp"\r
+                                           android:layout_gravity="center_vertical|right"\r
+                                           android:layout_marginRight="5dp"\r
+                                           android:padding="0dp"\r
+                                           android:scaleType="fitCenter"\r
+                                           android:src="@drawable/ic_action_refresh_black"\r
+                               android:onClick="onRefreshClick"\r
+                                           android:visibility="gone"\r
+                                               android:background="@android:color/transparent"\r
+                                           />\r
+                               </FrameLayout>\r
                \r
                                <TextView\r
                                        android:id="@+id/server_status_text"\r
index a218fa9..1c7921d 100644 (file)
             android:layout_marginTop="10dp"\r
             android:src="@drawable/logo" />\r
 \r
-               <EditText\r
-                       android:id="@+id/hostUrlInput"\r
+           <FrameLayout \r
                        android:layout_width="match_parent"\r
                        android:layout_height="wrap_content"\r
-                       android:ems="10"\r
-                       android:hint="@string/auth_host_url"\r
-                       android:inputType="textUri"\r
-                       android:drawablePadding="5dp"\r
-                       >\r
-                       <requestFocus />\r
-               </EditText>\r
-\r
-        <TextView\r
+               >\r
+                       <EditText\r
+                               android:id="@+id/hostUrlInput"\r
+                               android:layout_width="match_parent"\r
+                               android:layout_height="wrap_content"\r
+                               android:hint="@string/auth_host_url"\r
+                               android:inputType="textUri"\r
+                               android:drawablePadding="5dp"\r
+                               android:paddingRight="55dp"\r
+                               >\r
+                               <requestFocus />\r
+                       </EditText>\r
+                       <ImageButton\r
+                           android:id="@+id/refeshButton"\r
+                           android:layout_width="48dp"\r
+                           android:layout_height="48dp"\r
+                           android:layout_gravity="center_vertical|right"\r
+                           android:layout_marginRight="5dp"\r
+                           android:padding="0dp"\r
+                           android:scaleType="fitCenter"\r
+                           android:src="@drawable/ic_action_refresh_black"\r
+               android:onClick="onRefreshClick"\r
+                               android:visibility="gone"\r
+                               android:background="@android:color/transparent"\r
+                           />\r
+               </FrameLayout>\r
+\r
+               <TextView\r
             android:id="@+id/server_status_text"\r
             android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
index b929f63..cfafc24 100644 (file)
@@ -18,6 +18,8 @@
 \r
 package com.owncloud.android.authentication;\r
 \r
+import java.security.spec.MGF1ParameterSpec;\r
+\r
 import com.owncloud.android.AccountUtils;\r
 import com.owncloud.android.Log_OC;\r
 import com.owncloud.android.ui.dialog.SslValidatorDialog;\r
@@ -61,6 +63,7 @@ import android.view.inputmethod.EditorInfo;
 import android.widget.CheckBox;\r
 import android.widget.EditText;\r
 import android.widget.Button;\r
+import android.widget.ImageButton;\r
 import android.widget.TextView;\r
 import android.widget.Toast;\r
 import android.widget.TextView.OnEditorActionListener;\r
@@ -133,6 +136,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     private Account mAccount;\r
 \r
     private EditText mHostUrlInput;\r
+    private ImageButton mRefreshButton;\r
     private EditText mUsernameInput;\r
     private EditText mPasswordInput;\r
     private CheckBox mOAuth2Check;\r
@@ -159,6 +163,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         /// set view and get references to view elements\r
         setContentView(R.layout.account_setup);\r
         mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput);\r
+        mRefreshButton = (ImageButton) findViewById(R.id.refeshButton);\r
         mUsernameInput = (EditText) findViewById(R.id.account_username);\r
         mPasswordInput = (EditText) findViewById(R.id.account_password);\r
         mOAuthAuthEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_1);\r
@@ -179,6 +184,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         mAction = getIntent().getByteExtra(EXTRA_ACTION, ACTION_CREATE); \r
         mAccount = null;\r
         mHostBaseUrl = "";\r
+        boolean refreshButtonEnabled = false;\r
 \r
         if (savedInstanceState == null) {\r
             /// connection state and info\r
@@ -207,6 +213,10 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             mOAuth2Check.setChecked(oAuthRequired);\r
             changeViewByOAuth2Check(oAuthRequired);\r
             mJustCreated = true;\r
+            \r
+            if (mAction == ACTION_UPDATE_TOKEN) {\r
+                checkOcServer(); \r
+            }\r
 \r
         } else {\r
             /// connection state and info\r
@@ -237,18 +247,13 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             }            \r
             \r
             // refresh button enabled\r
-            mRefreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED);\r
+            refreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED);\r
+            \r
 \r
         }\r
 \r
         showServerStatus();\r
         showAuthStatus();\r
-        if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) showRefreshButton();\r
-        mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes\r
-\r
-        if (!OAUTH_MODE_OPTIONAL.equals(getString(R.string.oauth2_mode))) {\r
-            mOAuth2Check.setVisibility(View.GONE);\r
-        }\r
 \r
         if (mAction == ACTION_UPDATE_TOKEN) {\r
             /// lock things that should not change\r
@@ -257,24 +262,20 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             mUsernameInput.setEnabled(false);\r
             mUsernameInput.setFocusable(false);\r
             mOAuth2Check.setVisibility(View.GONE);\r
-            if (!mServerIsValid && mOcServerChkOperation == null) {\r
-                checkOcServer(); \r
-            }\r
+        }\r
+        \r
+        //if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) showRefreshButton();\r
+        if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled) showRefreshButton();\r
+        mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes\r
+\r
+        if (!OAUTH_MODE_OPTIONAL.equals(getString(R.string.oauth2_mode))) {\r
+            mOAuth2Check.setVisibility(View.GONE);\r
         }\r
 \r
         mPasswordInput.setText("");     // clean password to avoid social hacking (disadvantage: password in removed if the device is turned aside)\r
 \r
         /// bind view elements to listeners\r
         mHostUrlInput.setOnFocusChangeListener(this);\r
-        mHostUrlInput.setOnTouchListener(new RightDrawableOnTouchListener() {\r
-            @Override\r
-            public boolean onDrawableTouch(final MotionEvent event) {\r
-                if (event.getAction() == MotionEvent.ACTION_UP) {\r
-                    AuthenticatorActivity.this.onRefreshClick();\r
-                }\r
-                return true;\r
-            }\r
-        });\r
         mHostUrlInput.addTextChangedListener(new TextWatcher() {\r
 \r
             @Override\r
@@ -340,7 +341,8 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         }\r
         \r
         // refresh button enabled\r
-        outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, mRefreshButtonEnabled);\r
+        //outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, mRefreshButtonEnabled);\r
+        outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, (mRefreshButton.getVisibility() == View.VISIBLE));\r
 \r
     }\r
 \r
@@ -1196,13 +1198,15 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 \r
 \r
     private void showRefreshButton() {\r
-        mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0);\r
-        mRefreshButtonEnabled = true;\r
+        /*mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0);\r
+        mRefreshButtonEnabled = true;*/\r
+        mRefreshButton.setVisibility(View.VISIBLE);\r
     }\r
 \r
     private void hideRefreshButton() {\r
-        mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);\r
-        mRefreshButtonEnabled = false;\r
+        /*mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);\r
+        mRefreshButtonEnabled = false;*/\r
+        mRefreshButton.setVisibility(View.GONE);\r
     }\r
 \r
     /**\r
@@ -1212,7 +1216,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
      * \r
      * @param view      Refresh 'button'\r
      */\r
-    public void onRefreshClick() {\r
+    public void onRefreshClick(View view) {\r
         checkOcServer();\r
     }\r
     \r