OSDN Git Service

replace some ugly code with not-too-ugly code..
authorVasu Nori <vnori@google.com>
Fri, 25 Feb 2011 07:32:08 +0000 (23:32 -0800)
committerVasu Nori <vnori@google.com>
Fri, 25 Feb 2011 07:32:08 +0000 (23:32 -0800)
replaced this kind of code
   string + " " + number + "out of" + " " + number
with this
   String.format("%1$d out of %2$d", number, number);

Change-Id: If1cc296da48dd6823e9081a55b6eab2e3fcee552

res/values/strings.xml
src/com/android/settings/deviceinfo/MiscFilesHandler.java

index 49d939c..721b7e1 100644 (file)
@@ -3270,10 +3270,10 @@ found in the list of installed applications.</string>
     <string name="delete">Delete</string>
     <!-- Misc files [CHAR LIMIT=25] -->
     <string name="misc_files">Misc Files</string>
-    <!-- number of misc files selected [CHAR LIMIT=20] -->
-    <string name="misc_files_selected_count">selected</string>
-    <!-- the string 'out of' displayed when saying "selected N out of M" [CHAR LIMIT=20] -->
-    <string name="misc_files_selected_count_out_of">out of</string>
+    <!-- number of misc files selected [CHAR LIMIT=40] -->
+    <string name="misc_files_selected_count">selected %1$d out of %2$d</string>
+    <!-- number of bytes represented by the selected misc files [CHAR LIMIT=40] -->
+    <string name="misc_files_selected_count_bytes">%1$s out of %2$s</string>
     <!--  action to select all [CHAR LIMIT=30] -->
     <string name="select_all">Select All</string>
 </resources>
index 5a92115..15951c9 100644 (file)
@@ -48,8 +48,8 @@ import java.util.List;
  */
 public class MiscFilesHandler extends ListActivity {
     private static final String TAG = "MemorySettings";
-    private String mNumSelectedStr;
-    private String mNumSelectedOutOfStr;
+    private String mNumSelectedFormat;
+    private String mNumBytesSelectedFormat;
     private MemoryMearurementAdapter mAdapter;
     private LayoutInflater mInflater;
 
@@ -58,8 +58,8 @@ public class MiscFilesHandler extends ListActivity {
         super.onCreate(savedInstanceState);
         setFinishOnTouchOutside(true);
         setTitle(R.string.misc_files);
-        mNumSelectedStr = getString(R.string.misc_files_selected_count);
-        mNumSelectedOutOfStr = getString(R.string.misc_files_selected_count_out_of);
+        mNumSelectedFormat = getString(R.string.misc_files_selected_count);
+        mNumBytesSelectedFormat = getString(R.string.misc_files_selected_count_bytes);
         mAdapter = new MemoryMearurementAdapter(this);
         mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         setContentView(R.layout.settings_storage_miscfiles_list);
@@ -162,8 +162,7 @@ public class MiscFilesHandler extends ListActivity {
                 boolean checked) {
             ListView lv = getListView();
             int numChecked = lv.getCheckedItemCount();
-            mode.setTitle(mNumSelectedStr + " : " + numChecked +
-                    " " + mNumSelectedOutOfStr + " " + mAdapter.getCount());
+            mode.setTitle(String.format(mNumSelectedFormat, numChecked, mAdapter.getCount()));
 
             // total the sizes of all items selected so far
             SparseBooleanArray checkedItems = lv.getCheckedItemPositions();
@@ -176,9 +175,9 @@ public class MiscFilesHandler extends ListActivity {
                     }
                 }
             }
-            mode.setSubtitle(Formatter.formatFileSize(mContext, selectedDataSize) +
-                    " " + mNumSelectedOutOfStr + " " +
-                    Formatter.formatFileSize(mContext, mAdapter.getDataSize()));
+            mode.setSubtitle(String.format(mNumBytesSelectedFormat,
+                    Formatter.formatFileSize(mContext, selectedDataSize),
+                    Formatter.formatFileSize(mContext, mAdapter.getDataSize())));
         }
     }