Jelajahi Sumber

Merge pull request #215 from owncloud/branding_configurable_URL_input_field

Configurable url input field
masensio 11 tahun lalu
induk
melakukan
b4a85deafc

+ 14 - 1
res/layout-land/account_setup.xml

@@ -54,15 +54,28 @@
 			    android:gravity="center"
 			    android:orientation="vertical"
 			    android:padding="8dp" >
+			    
+				<Button
+				    android:id="@+id/centeredRefreshButton"
+				    android:layout_width="wrap_content"
+				    android:layout_height="wrap_content"
+				    android:layout_gravity="center_horizontal"
+					android:layout_marginBottom="10dp"
+            		android:onClick="onRefreshClick"
+				    android:text="@string/auth_check_server"
+				    android:visibility="gone" />
 		
 			    <FrameLayout 
+	        		android:id="@+id/hostUrlFrame"
 					android:layout_width="match_parent"
 					android:layout_height="wrap_content"
+					android:layout_marginBottom="10dp"
 			        >
 					<EditText
 						android:id="@+id/hostUrlInput"
 						android:layout_width="match_parent"
 						android:layout_height="wrap_content"
+						android:layout_gravity="bottom"
 						android:hint="@string/auth_host_url"
 						android:inputType="textUri"
 						android:drawablePadding="5dp"
@@ -71,7 +84,7 @@
 						<requestFocus />
 					</EditText>
 					<ImageButton
-					    android:id="@+id/refeshButton"
+					    android:id="@+id/embeddedRefreshButton"
 					    android:layout_width="48dp"
 					    android:layout_height="48dp"
 					    android:layout_gravity="center_vertical|right"

+ 14 - 1
res/layout/account_setup.xml

@@ -40,14 +40,27 @@
             android:layout_marginTop="10dp"
             android:src="@drawable/logo" />
 
+        <Button
+            android:id="@+id/centeredRefreshButton"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:layout_marginBottom="10dp"
+            android:onClick="onRefreshClick"
+            android:text="@string/auth_check_server"
+            android:visibility="gone" />
+
 	    <FrameLayout 
+	        android:id="@+id/hostUrlFrame"
 			android:layout_width="match_parent"
 			android:layout_height="wrap_content"
+            android:layout_marginBottom="10dp"
 	        >
 			<EditText
 				android:id="@+id/hostUrlInput"
 				android:layout_width="match_parent"
 				android:layout_height="wrap_content"
+				android:layout_gravity="bottom"
 				android:hint="@string/auth_host_url"
 				android:inputType="textUri"
 				android:drawablePadding="5dp"
@@ -56,7 +69,7 @@
 				<requestFocus />
 			</EditText>
 			<ImageButton
-			    android:id="@+id/refeshButton"
+			    android:id="@+id/embeddedRefreshButton"
 			    android:layout_width="48dp"
 			    android:layout_height="48dp"
 			    android:layout_gravity="center_vertical|right"

+ 5 - 0
res/values/branding.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="server_url"></string>
+    <bool name="show_server_url_input">true</bool>
+</resources>

+ 1 - 0
res/values/strings.xml

@@ -48,6 +48,7 @@
     <string name="prefs_log_summary_history">This shows the recorded logs</string>
     <string name="prefs_log_delete_history_button">Delete History</string>
     
+    <string name="auth_check_server">Check Server</string>
     <string name="auth_host_url">Server address</string>
     <string name="auth_username">Username</string>
     <string name="auth_password">Password</string>

+ 27 - 11
src/com/owncloud/android/authentication/AuthenticatorActivity.java

@@ -60,7 +60,6 @@ import android.view.inputmethod.EditorInfo;
 import android.widget.CheckBox;
 import android.widget.EditText;
 import android.widget.Button;
-import android.widget.ImageButton;
 import android.widget.TextView;
 import android.widget.Toast;
 import android.widget.TextView.OnEditorActionListener;
@@ -133,7 +132,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     private Account mAccount;
 
     private EditText mHostUrlInput;
-    private ImageButton mRefreshButton;
+    private View mRefreshButton;
     private EditText mUsernameInput;
     private EditText mPasswordInput;
     private CheckBox mOAuth2Check;
@@ -145,6 +144,8 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     private TextView mOAuthTokenEndpointText;
     
     private boolean mRefreshButtonEnabled;
+    
+    private boolean mHostUrlInputEnabled;
 
 
     /**
@@ -160,7 +161,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         /// set view and get references to view elements
         setContentView(R.layout.account_setup);
         mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput);
-        mRefreshButton = (ImageButton) findViewById(R.id.refeshButton);
+        mHostUrlInput.setText(getString(R.string.server_url));  // valid although R.string.server_url is an empty string
         mUsernameInput = (EditText) findViewById(R.id.account_username);
         mPasswordInput = (EditText) findViewById(R.id.account_password);
         mOAuthAuthEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_1);
@@ -168,6 +169,10 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check);
         mOkButton = findViewById(R.id.buttonOK);
         mAuthStatusLayout = (TextView) findViewById(R.id.auth_status_text); 
+        
+        /// set Host Url Input Enabled
+        mHostUrlInputEnabled = getResources().getBoolean(R.bool.show_server_url_input);
+        
 
         /// complete label for 'register account' button
         Button b = (Button) findViewById(R.id.account_register);
@@ -182,6 +187,16 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         mAccount = null;
         mHostBaseUrl = "";
         boolean refreshButtonEnabled = false;
+        
+        // URL input configuration applied
+        if (!mHostUrlInputEnabled)
+        {
+            findViewById(R.id.hostUrlFrame).setVisibility(View.GONE);
+            mRefreshButton = findViewById(R.id.centeredRefreshButton);
+
+        } else {
+            mRefreshButton = findViewById(R.id.embeddedRefreshButton);
+        }
 
         if (savedInstanceState == null) {
             /// connection state and info
@@ -211,7 +226,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             changeViewByOAuth2Check(oAuthRequired);
             mJustCreated = true;
             
-            if (mAction == ACTION_UPDATE_TOKEN) {
+            if (mAction == ACTION_UPDATE_TOKEN || !mHostUrlInputEnabled) {
                 checkOcServer(); 
             }
 
@@ -416,9 +431,6 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         if (view.getId() == R.id.hostUrlInput) {   
             if (!hasFocus) {
                 onUrlInputFocusLost((TextView) view);
-                if (!mServerIsValid) {
-                    showRefreshButton();
-                }
             }
             else {
                 hideRefreshButton();
@@ -446,12 +458,20 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             checkOcServer();
         } else {
             mOkButton.setEnabled(mServerIsValid);
+            if (!mServerIsValid) {
+                showRefreshButton();
+            }
         }
     }
 
 
     private void checkOcServer() {
         String uri = trimUrlWebdav(mHostUrlInput.getText().toString().trim());
+        
+        if (!mHostUrlInputEnabled){
+            uri = getString(R.string.server_url);
+        }
+        
         mServerIsValid = false;
         mServerIsChecked = false;
         mOkButton.setEnabled(false);
@@ -1195,14 +1215,10 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 
 
     private void showRefreshButton() {
-        /*mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0);
-        mRefreshButtonEnabled = true;*/
         mRefreshButton.setVisibility(View.VISIBLE);
     }
 
     private void hideRefreshButton() {
-        /*mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
-        mRefreshButtonEnabled = false;*/
         mRefreshButton.setVisibility(View.GONE);
     }