message 'Session expires' in TextView instead of Toast
authormasensio <masensio@solidgear.es>
Sat, 17 Aug 2013 16:39:05 +0000 (18:39 +0200)
committermasensio <masensio@solidgear.es>
Sat, 17 Aug 2013 16:39:05 +0000 (18:39 +0200)
res/layout-land/account_setup.xml
res/layout/account_setup.xml
src/com/owncloud/android/authentication/AuthenticatorActivity.java

index 5b3ec5d..e00ade8 100644 (file)
                        android:onClick="onRefreshClick"\r
                                    android:text="@string/auth_check_server"\r
                                    android:visibility="gone" />\r
-               \r
+                               <TextView\r
+                                   android:id="@+id/auth_message"\r
+                                   android:layout_width="wrap_content"\r
+                                   android:layout_height="wrap_content"\r
+                                   android:layout_gravity="fill_horizontal"\r
+                                   android:text="@string/auth_expired_basic_auth_toast" \r
+                                   android:visibility="gone"\r
+                                   android:layout_marginBottom="10dp"/>\r
                            <FrameLayout \r
                                android:id="@+id/hostUrlFrame"\r
                                        android:layout_width="match_parent"\r
index 9a325ee..cab3d8b 100644 (file)
             android:onClick="onRefreshClick"\r
             android:text="@string/auth_check_server"\r
             android:visibility="gone" />\r
+        \r
+        <TextView\r
+            android:id="@+id/auth_message"\r
+            android:layout_width="wrap_content"\r
+            android:layout_height="wrap_content"\r
+            android:layout_gravity="fill_horizontal"\r
+            android:text="@string/auth_expired_basic_auth_toast"\r
+            android:visibility="gone"\r
+            android:layout_marginBottom="10dp" />\r
 \r
            <FrameLayout \r
                android:id="@+id/hostUrlFrame"\r
index e9da35a..a768821 100644 (file)
@@ -85,6 +85,8 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     public static final String EXTRA_ACTION = "ACTION";\r
     public static final String EXTRA_ENFORCED_UPDATE = "ENFORCE_UPDATE";\r
 \r
+    private static final String KEY_AUTH_MESSAGE_VISIBILITY = "AUTH_MESSAGE_VISIBILITY";\r
+    private static final String KEY_AUTH_MESSAGE_TEXT = "AUTH_MESSAGE_TEXT";\r
     private static final String KEY_HOST_URL_TEXT = "HOST_URL_TEXT";\r
     private static final String KEY_OC_VERSION = "OC_VERSION";\r
     private static final String KEY_ACCOUNT = "ACCOUNT";\r
@@ -116,7 +118,8 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     private String mHostBaseUrl;\r
     private OwnCloudVersion mDiscoveredVersion;\r
 \r
-    private int mServerStatusText, mServerStatusIcon;\r
+    private String mAuthMessageText;\r
+    private int mAuthMessageVisibility, mServerStatusText, mServerStatusIcon;\r
     private boolean mServerIsChecked, mServerIsValid, mIsSslConn;\r
     private int mAuthStatusText, mAuthStatusIcon;    \r
     private TextView mAuthStatusLayout;\r
@@ -134,6 +137,8 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     private byte mAction;\r
     private Account mAccount;\r
 \r
+    private TextView mAuthMessage;\r
+    \r
     private EditText mHostUrlInput;\r
     private boolean mHostUrlInputEnabled;\r
     private View mRefreshButton;\r
@@ -168,6 +173,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 \r
         /// set view and get references to view elements\r
         setContentView(R.layout.account_setup);\r
+        mAuthMessage = (TextView) findViewById(R.id.auth_message);\r
         mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput);\r
         mHostUrlInput.setText(getString(R.string.server_url));  // valid although R.string.server_url is an empty string\r
         mUsernameInput = (EditText) findViewById(R.id.account_username);\r
@@ -209,6 +215,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 \r
         if (savedInstanceState == null) {\r
             /// connection state and info\r
+            mAuthMessageVisibility = View.GONE;\r
             mServerStatusText = mServerStatusIcon = 0;\r
             mServerIsValid = false;\r
             mServerIsChecked = false;\r
@@ -237,6 +244,8 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             \r
         } else {\r
             /// connection state and info\r
+            mAuthMessageVisibility = savedInstanceState.getInt(KEY_AUTH_MESSAGE_VISIBILITY);\r
+            mAuthMessageText = savedInstanceState.getString(KEY_AUTH_MESSAGE_TEXT);\r
             mServerIsValid = savedInstanceState.getBoolean(KEY_SERVER_VALID);\r
             mServerIsChecked = savedInstanceState.getBoolean(KEY_SERVER_CHECKED);\r
             mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT);\r
@@ -274,6 +283,12 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 \r
         }\r
 \r
+        if (mAuthMessageVisibility== View.VISIBLE) {\r
+            showAuthMessage(mAuthMessageText);\r
+        }\r
+        else {\r
+            hideAuthMessage();\r
+        }\r
         adaptViewAccordingToAuthenticationMethod();\r
         showServerStatus();\r
         showAuthStatus();\r
@@ -386,6 +401,8 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         super.onSaveInstanceState(outState);\r
 \r
         /// connection state and info\r
+        outState.putInt(KEY_AUTH_MESSAGE_VISIBILITY, mAuthMessage.getVisibility());\r
+        outState.putString(KEY_AUTH_MESSAGE_TEXT, mAuthMessage.getText().toString());\r
         outState.putInt(KEY_SERVER_STATUS_TEXT, mServerStatusText);\r
         outState.putInt(KEY_SERVER_STATUS_ICON, mServerStatusIcon);\r
         outState.putBoolean(KEY_SERVER_VALID, mServerIsValid);\r
@@ -441,13 +458,14 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         super.onResume();\r
         if (mAction == ACTION_UPDATE_TOKEN && mJustCreated && getIntent().getBooleanExtra(EXTRA_ENFORCED_UPDATE, false)) {\r
             if (AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mCurrentAuthTokenType)) {\r
-                Toast.makeText(this, R.string.auth_expired_oauth_token_toast, Toast.LENGTH_LONG).show();\r
-                \r
+                //Toast.makeText(this, R.string.auth_expired_oauth_token_toast, Toast.LENGTH_LONG).show();\r
+                showAuthMessage(getString(R.string.auth_expired_oauth_token_toast));\r
             } else if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mCurrentAuthTokenType)) {\r
-                Toast.makeText(this, R.string.auth_expired_saml_sso_token_toast, Toast.LENGTH_LONG).show();\r
-                \r
+                //Toast.makeText(this, R.string.auth_expired_saml_sso_token_toast, Toast.LENGTH_LONG).show();\r
+                showAuthMessage(getString(R.string.auth_expired_saml_sso_token_toast));\r
             } else {\r
-                Toast.makeText(this, R.string.auth_expired_basic_auth_toast, Toast.LENGTH_LONG).show();\r
+                //Toast.makeText(this, R.string.auth_expired_basic_auth_toast, Toast.LENGTH_LONG).show();\r
+                showAuthMessage(getString(R.string.auth_expired_basic_auth_toast));\r
             }\r
         }\r
 \r
@@ -642,6 +660,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             return;\r
         }\r
 \r
+        hideAuthMessage();\r
         if (AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mCurrentAuthTokenType)) {\r
             startOauthorization();\r
         } else if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mCurrentAuthTokenType)) { \r
@@ -1528,5 +1547,17 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     }\r
     \r
     \r
+    /** Show auth_message \r
+     * \r
+     * @param message\r
+     */\r
+    private void showAuthMessage(String message) {\r
+       mAuthMessage.setVisibility(View.VISIBLE);\r
+       mAuthMessage.setText(message);\r
+    }\r
+    \r
+    private void hideAuthMessage() {\r
+        mAuthMessage.setVisibility(View.GONE);\r
+    }\r
 \r
 }\r