Merge pull request #914 from owncloud/accessibility
authorDavid A. Velasco <dvelasco@owncloud.com>
Thu, 19 Mar 2015 11:59:17 +0000 (12:59 +0100)
committerDavid A. Velasco <dvelasco@owncloud.com>
Thu, 19 Mar 2015 11:59:17 +0000 (12:59 +0100)
Added accesibility descriptions as a mean to add automatic tests un UI.

1  2 
res/values/strings.xml
src/com/owncloud/android/ui/activity/FileDisplayActivity.java
src/com/owncloud/android/ui/adapter/FileListListAdapter.java

diff --combined res/values/strings.xml
        <string name="auth_no_net_conn_title">No network connection</string>
        <string name="auth_nossl_plain_ok_title">Secure connection unavailable.</string>
        <string name="auth_connection_established">Connection established</string>
-       <string name="auth_testing_connection">Testing connection&#8230;</string>
+       <string name="auth_testing_connection">Testing connection</string>
        <string name="auth_not_configured_title">Malformed server configuration</string>
        <string name="auth_account_not_new">An account for the same user and server already exists in the device</string>
        <string name="auth_account_not_the_same">The entered user does not match the user of this account</string>
        <string name="share_link_file_error">An error occurred while trying to share this file or folder</string>
        <string name="unshare_link_file_no_exist">Unable to unshare. Please check whether the file exists</string>
        <string name="unshare_link_file_error">An error occurred while trying to unshare this file or folder</string>
 +    <string name="share_link_password_title">Enter a password</string>
 +    <string name="share_link_empty_password">You must enter a password</string>
  
        <string name="activity_chooser_send_file_title">Send</string>
  
  
        <string name="subject_token">%1$s shared \"%2$s\" with you</string>
  
+     <string name="auth_refresh_button">Refresh connection</string>
+     <string name="auth_host_address">Server address</string>
  </resources>
  package com.owncloud.android.ui.activity;
  
  import java.io.File;
 -import java.io.IOException;
  
  import android.accounts.Account;
  import android.accounts.AccountManager;
  import android.accounts.AuthenticatorException;
 -import android.accounts.OperationCanceledException;
 -import android.annotation.SuppressLint;
  import android.annotation.TargetApi;
  import android.app.AlertDialog;
  import android.app.Dialog;
@@@ -1380,7 -1383,11 +1380,11 @@@ OnSslUntrustedCertListener, OnEnforceab
       * TODO
       */
      private void updateNavigationElementsInActionBar(OCFile chosenFile) {
-         ActionBar actionBar = getSupportActionBar(); 
+         ActionBar actionBar = getSupportActionBar();
+         // For adding content description tag to a title field in the action bar
+         int actionBarTitleId = getResources().getIdentifier("action_bar_title", "id", "android");
          if (chosenFile == null || mDualPane) {
              // only list of files - set for browsing through folders
              OCFile currentDir = getCurrentDir();
              actionBar.setDisplayShowTitleEnabled(!noRoot); 
              if (!noRoot) {
                  actionBar.setTitle(getString(R.string.default_display_name_for_root_folder));
+                 getWindow().getDecorView().findViewById(actionBarTitleId).setContentDescription(getString(R.string.default_display_name_for_root_folder));
              }
              actionBar.setNavigationMode(!noRoot ? ActionBar.NAVIGATION_MODE_STANDARD : ActionBar.NAVIGATION_MODE_LIST);
              actionBar.setListNavigationCallbacks(mDirectories, this);   // assuming mDirectories is updated
              actionBar.setDisplayShowTitleEnabled(true);
              actionBar.setTitle(chosenFile.getFileName());
              actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+             getWindow().getDecorView().findViewById(actionBarTitleId).setContentDescription(chosenFile.getFileName());
          }
      }
  
@@@ -30,7 -30,6 +30,7 @@@ import android.accounts.Account
  import android.content.Context;\r
  import android.content.SharedPreferences;\r
  import android.graphics.Bitmap;\r
 +import android.os.Build;\r
  import android.preference.PreferenceManager;\r
  import android.text.format.DateUtils;\r
  import android.view.LayoutInflater;\r
@@@ -38,7 -37,9 +38,8 @@@ import android.view.View
  import android.view.ViewGroup;\r
  import android.widget.AbsListView;\r
  import android.widget.BaseAdapter;\r
 -import android.widget.GridView;\r
  import android.widget.ImageView;\r
+ import android.widget.LinearLayout;\r
  import android.widget.ListAdapter;\r
  import android.widget.TextView;\r
  \r
@@@ -94,7 -95,6 +95,6 @@@ public class FileListListAdapter extend
          // Read sorting order, default to sort by name ascending\r
          FileStorageUtils.mSortOrder = mAppPreferences.getInt("sortOrder", 0);\r
          FileStorageUtils.mSortAscending = mAppPreferences.getBoolean("sortAscending", true);\r
\r
          \r
          // initialise thumbnails cache on background thread\r
          new ThumbnailsCacheManager.InitDiskCacheTask().execute();\r
          if (file != null){\r
  \r
              ImageView fileIcon = (ImageView) view.findViewById(R.id.thumbnail);\r
\r
              fileIcon.setTag(file.getFileId());\r
              TextView fileName;\r
-             String name;\r
+             String name = file.getFileName();\r
\r
+             LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.ListItemLayout);\r
+             linearLayout.setContentDescription("LinearLayout-" + name);\r
  \r
              switch (viewType){\r
                  case LIST_ITEM:\r
  \r
                      if (!file.isFolder()) {\r
                          AbsListView parentList = (AbsListView)parent;\r
 -                        if (parentList.getChoiceMode() == AbsListView.CHOICE_MODE_NONE) {\r
 -                            checkBoxV.setVisibility(View.GONE);\r
 -                        } else {\r
 -                            if (parentList.isItemChecked(position)) {\r
 -                                checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);\r
 +                        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {\r
 +                            if (parentList.getChoiceMode() == AbsListView.CHOICE_MODE_NONE) {\r
 +                                checkBoxV.setVisibility(View.GONE);\r
                              } else {\r
 -                                checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);\r
 +                                if (parentList.isItemChecked(position)) {\r
 +                                    checkBoxV.setImageResource(\r
 +                                            android.R.drawable.checkbox_on_background);\r
 +                                } else {\r
 +                                    checkBoxV.setImageResource(\r
 +                                            android.R.drawable.checkbox_off_background);\r
 +                                }\r
 +                                checkBoxV.setVisibility(View.VISIBLE);\r
                              }\r
 -                            checkBoxV.setVisibility(View.VISIBLE);\r
                          }\r
  \r
                      } else { //Folder\r
                      // local state\r
                      ImageView localStateView = (ImageView) view.findViewById(R.id.localFileIndicator);\r
                      localStateView.bringToFront();\r
 -                    FileDownloaderBinder downloaderBinder = mTransferServiceGetter.getFileDownloaderBinder();\r
 -                    FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();\r
 -                    boolean downloading = (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file));\r
 -                    OperationsServiceBinder opsBinder = mTransferServiceGetter.getOperationsServiceBinder();\r
 -                    downloading |= (opsBinder != null && opsBinder.isSynchronizing(mAccount, file.getRemotePath()));\r
 +                    FileDownloaderBinder downloaderBinder =\r
 +                            mTransferServiceGetter.getFileDownloaderBinder();\r
 +                    FileUploaderBinder uploaderBinder =\r
 +                            mTransferServiceGetter.getFileUploaderBinder();\r
 +                    boolean downloading = (downloaderBinder != null &&\r
 +                            downloaderBinder.isDownloading(mAccount, file));\r
 +                    OperationsServiceBinder opsBinder =\r
 +                            mTransferServiceGetter.getOperationsServiceBinder();\r
 +                    downloading |= (opsBinder != null &&\r
 +                            opsBinder.isSynchronizing(mAccount, file.getRemotePath()));\r
                      if (downloading) {\r
                          localStateView.setImageResource(R.drawable.downloading_file_indicator);\r
                          localStateView.setVisibility(View.VISIBLE);\r
 -                    } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {\r
 +                    } else if (uploaderBinder != null &&\r
 +                            uploaderBinder.isUploading(mAccount, file)) {\r
                          localStateView.setImageResource(R.drawable.uploading_file_indicator);\r
                          localStateView.setVisibility(View.VISIBLE);\r
                      } else if (file.isDown()) {\r
  \r
                      // share with me icon\r
                      if (!file.isFolder()) {\r
 -                        ImageView sharedWithMeIconV = (ImageView) view.findViewById(R.id.sharedWithMeIcon);\r
 +                        ImageView sharedWithMeIconV = (ImageView)\r
 +                                view.findViewById(R.id.sharedWithMeIcon);\r
                          sharedWithMeIconV.bringToFront();\r
                          if (checkIfFileIsSharedWithMe(file)) {\r
                              sharedWithMeIconV.setVisibility(View.VISIBLE);\r
                          }\r
                      }\r
                  } else {\r
 -                    fileIcon.setImageResource(DisplayUtils.getFileTypeIconId(file.getMimetype(), file.getFileName()));\r
 +                    fileIcon.setImageResource(DisplayUtils.getFileTypeIconId(file.getMimetype(),\r
 +                            file.getFileName()));\r
                  }\r
\r
              } else {\r
                  // Folder\r
                  if (checkIfFileIsSharedWithMe(file)) {\r