Android系统(127)---Android6.0存储中加入总内存和系统内存项和在西语下把,换成.

Android6.0存储中加入总内存和系统内存项

平台下patches/packages/apps/Settings/里面

1.存储中加入总内存和系统内存项

在 res/values-zh-rCN/strings.xml 中添加

[java]  view plain  copy
  1. <string name="write_settings_description" msgid="6868293938839954623">"此权限允许应用修改系统设置。"</string>  
  2.      <string name="write_settings_on" msgid="8230580416068832239">"允许"</string>  
  3.      <string name="write_settings_off" msgid="5156104383386336233">"不允许"</string>  
  4. +    <string name="storage_detail_system">"系统内存"</string>  
  5. +    <string name="storage_detail_total">"总内存"</string>  
  6.  </resources>  


在 /res/values-zh-rTW/strings.xml 中添加

[java]  view plain  copy
  1. <string name="write_settings_description" msgid="6868293938839954623">"這項權限允許應用程式修改系統設定。"</string>  
  2.      <string name="write_settings_on" msgid="8230580416068832239">"可"</string>  
  3.      <string name="write_settings_off" msgid="5156104383386336233">"否"</string>  
  4. +    <string name="storage_detail_system">"系统内存"</string>  
  5. +    <string name="storage_detail_total">"总内存"</string>  
  6.  </resources>  
[java]  view plain  copy
  1.   
在 /res/values/strings.xml 中添加

[java]  view plain  copy
  1. <string name="write_settings_on">Yes</string>  
  2.      <!-- Summary of app not allowed to write system settings [CHAR LIMIT=45] -->  
  3.      <string name="write_settings_off">No</string>  
  4. +    <string name="storage_detail_total">"Total Data"</string>  
  5. +    <string name="storage_detail_system">System Data</string>  
  6.  </resources>  

/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java 中添加

[java]  view plain  copy
  1. import android.content.Context;  
  2.  import android.content.DialogInterface;  
  3.  import android.content.Intent;  
  4. +import java.text.DecimalFormat;  
  5.  import android.content.pm.IPackageDataObserver;  
  6.  import android.content.pm.PackageInfo;  
  7.  import android.content.pm.PackageManager;  
  8. @@ -118,6 +119,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {  
  9.      private int mItemPoolIndex;  
  10.    
  11.      private Preference mExplore;  
  12. +    private Preference storage_detail_system;  
  13. +    private Preference storage_detail_total;  
  14.    
  15.      private boolean isVolumeValid() {  
  16.          return (mVolume != null) && (mVolume.getType() == VolumeInfo.TYPE_PRIVATE)  
  17. @@ -159,6 +162,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {  
  18.          mCurrentUser = mUserManager.getUserInfo(UserHandle.myUserId());  
  19.    
  20.          mExplore = buildAction(R.string.storage_menu_explore);  
  21. +        storage_detail_system = buildAction(R.string.storage_detail_system);   
  22. +        storage_detail_total  =  buildAction(R.string.storage_detail_total);  
  23.    
  24.          setHasOptionsMenu(true);  
  25.      }  
  26. @@ -216,6 +221,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {  
  27.          addItem(screen, R.string.storage_detail_cached, null, UserHandle.USER_NULL);  
  28.    
  29.          if (showShared) {  
  30. +            addPreference(screen, storage_detail_system);  
  31. +            addPreference(screen, storage_detail_total);  
  32.              addPreference(screen, mExplore);  
  33.          }  
  34.    
  35. @@ -224,13 +231,28 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {  
  36.          final long freeBytes = file.getFreeSpace();  
  37.          final long usedBytes = totalBytes - freeBytes;  
  38.    
  39. -        final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);  
  40. -        mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),  
  41. -                result.value, result.units));  
  42. -        mSummary.setSummary(getString(R.string.storage_volume_used,  
  43. -                Formatter.formatFileSize(context, totalBytes)));  
  44. -        mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));  
  45. -  
  46. +        if(showShared) {  
  47. +            final long  systemBytes = (long) ((8.0 * 1024 * 1024 * 1024) - totalBytes);  
  48. +            Log.d("zhongyeqing","systemBytes = "+systemBytes);  
  49. +            final BytesResult systemresult = Formatter.formatBytes(getResources(), systemBytes, 0);  
  50. +            storage_detail_system.setSummary(systemresult.value+systemresult.units);  
  51. +            storage_detail_total.setSummary("8.0 GB");  
  52. +  
  53. +            final BytesResult result = Formatter.formatBytes(getResources(), systemBytes+usedBytes, 0);  
  54. +            mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),  
  55. +                        result.value, result.units));  
  56. +            mSummary.setSummary(getString(R.string.storage_volume_used,  
  57. +                        Formatter.formatFileSize(context, (long) (8.0 * 1024 * 1024 * 1024))));  
  58. +            mSummary.setPercent((int) (((systemBytes+usedBytes) * 100) / (float) (8.0 * 1024 * 1024 * 1024)));  
  59. +  
  60. +        }else{  
  61. +            final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);  
  62. +            mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),  
  63. +                        result.value, result.units));  
  64. +            mSummary.setSummary(getString(R.string.storage_volume_used,  
  65. +                        Formatter.formatFileSize(context, totalBytes)));  
  66. +            mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));  
  67. +        }  
  68.          mMeasure.forceMeasure();  
  69.      }  


/src/com/android/settings/deviceinfo/PublicVolumeSettings.java 中添加

[java]  view plain  copy
  1. final long freeBytes = file.getFreeSpace();  
  2.              final long usedBytes = totalBytes - freeBytes;  
  3.    
  4. -            final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);  
  5. -            mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),  
  6. -                    result.value, result.units));  
  7. -            mSummary.setSummary(getString(R.string.storage_volume_used,  
  8. -                    Formatter.formatFileSize(context, totalBytes)));  
  9. -            mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));  
  10. +            if(VolumeInfo.ID_PRIVATE_INTERNAL.equals(mVolume.getId())) {  
  11. +                final long  systemBytes = (long) ((8.0 * 1024 * 1024 * 1024) - totalBytes);  
  12. +                final BytesResult result = Formatter.formatBytes(getResources(), systemBytes+usedBytes, 0);  
  13. +                mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),  
  14. +                            result.value, result.units));  
  15. +                mSummary.setSummary(getString(R.string.storage_volume_used,  
  16. +                            Formatter.formatFileSize(context, (long) (8.0 * 1024 * 1024 * 1024)))+"---");  
  17. +                mSummary.setPercent((int) (((usedBytes+systemBytes) * 100) / (float)(8.0 * 1024 * 1024 * 1024)));  
  18. +            }else{  
  19. +                final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);  
  20. +                mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),  
  21. +                            result.value, result.units));  
  22. +                mSummary.setSummary(getString(R.string.storage_volume_used,  
  23. +                            Formatter.formatFileSize(context, totalBytes)));  
  24. +                mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));  
  25. +            }  
  26.          }  
  27.    
  28.          if (mVolume.getState() == VolumeInfo.STATE_UNMOUNTED) {  

/src/com/android/settings/deviceinfo/StorageSettings.java 中添加

[java]  view plain  copy
  1. </pre><pre name="code" class="java">int privateCount = 0;  
  2.          long privateUsedBytes = 0;  
  3.          long privateTotalBytes = 0;  
  4. +        long  systemBytes = 0;  
  5.    
  6.          final List<VolumeInfo> volumes = mStorageManager.getVolumes();  
  7.          Collections.sort(volumes, VolumeInfo.getDescriptionComparator());  
  8. @@ -178,6 +179,9 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index  
  9.                      final File path = vol.getPath();  
  10.                      privateUsedBytes += path.getTotalSpace() - path.getFreeSpace();  
  11.                      privateTotalBytes += path.getTotalSpace();  
  12. +                    if(VolumeInfo.ID_PRIVATE_INTERNAL.equals(vol.getId())){  
  13. +                        systemBytes = (long) ((8.0 * 1024 * 1024 * 1024) - privateTotalBytes);  
  14. +                    }  
  15.                  }  
  16.              } else if (vol.getType() == VolumeInfo.TYPE_PUBLIC) {  
  17.                  mExternalCategory.addPreference(  
  18. @@ -217,12 +221,28 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index  
  19.              }  
  20.          }  
  21.    
  22. -        final BytesResult result = Formatter.formatBytes(getResources(), privateUsedBytes, 0);  
  23. -        mInternalSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),  
  24. -                result.value, result.units));  
  25. -        mInternalSummary.setSummary(getString(R.string.storage_volume_used_total,  
  26. -                Formatter.formatFileSize(context, privateTotalBytes)));  
  27. +        /* Vanzo:zhongyeqing on: Wed, 12 Oct 2016 23:08:22 +0800 
  28. +        * TODO: replace this line with your comment 
  29. +        if (systemBytes != 0){ 
  30. +        */  
  31. +        // End of Vanzo: zhongyeqing  
  32. +            final BytesResult result = Formatter.formatBytes(getResources(),systemBytes+privateUsedBytes, 0);  
  33. +            mInternalSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large),  
  34. +                        result.value, result.units));  
  35. +            //mInternalSummary.setSummary(getString(R.string.storage_volume_used_total,"8.0 GB"));   
  36. +            mInternalSummary.setSummary(getString(R.string.storage_volume_used_total,  
  37. +                        Formatter.formatFileSize(context, privateTotalBytes+systemBytes)));  
  38. +        /* Vanzo:zhongyeqing on: Wed, 12 Oct 2016 23:08:17 +0800 
  39. +        * TODO: replace this line with your comment 
  40. +        }else{ 
  41. +            final BytesResult result = Formatter.formatBytes(getResources(), privateUsedBytes, 0); 
  42. +            mInternalSummary.setSummary(getString(R.string.storage_volume_used_total, 
  43. +                        Formatter.formatFileSize(context, privateTotalBytes))); 
  44. + 
  45.   
  46. +        } 
  47. +        */  
  48. +        // End of Vanzo: zhongyeqing  
  49.          if (mInternalCategory.getPreferenceCount() > 0) {  
  50.              getPreferenceScreen().addPreference(mInternalCategory);  
  51.          }  

在 /src/com/android/settings/deviceinfo/StorageVolumePreference.java 中

[java]  view plain  copy
  1. final long freeBytes = path.getFreeSpace();  
  2.              final long totalBytes = path.getTotalSpace();  
  3.              final long usedBytes = totalBytes - freeBytes;  
  4. +            final long systemBytes = (long) ((8.0 * 1024 * 1024 * 1024) - totalBytes);  
  5.    
  6.              final String used = Formatter.formatFileSize(context, usedBytes);  
  7. +            final String usedSystem = Formatter.formatFileSize(context, usedBytes+systemBytes);  
  8.              final String total = Formatter.formatFileSize(context, totalBytes);  
  9. +            /* Vanzo:zhongyeqing on: Mon, 15 Aug 2016 14:40:17 +0800 
  10. +             * TODO: replace this line with your comment 
  11.              setSummary(context.getString(R.string.storage_volume_summary, used, total)); 
  12.              if (totalBytes != 0) { 
  13.                  mUsedPercent = (int) ((usedBytes * 100) / totalBytes); 
  14.              } 
  15. - 
  16. +            */  
  17. +            if(VolumeInfo.ID_PRIVATE_INTERNAL.equals(volume.getId())) {  
  18. +                setSummary(context.getString(R.string.storage_volume_summary, usedSystem, "8.0 GB"));  
  19. +                if (totalBytes != 0) {  
  20. +                    mUsedPercent = (int) (((usedBytes+systemBytes) * 100) / (float) (8.0 * 1024 * 1024 * 1024));  
  21. +                }  
  22. +            } else {  
  23. +                setSummary(context.getString(R.string.storage_volume_summary, used, total));  
  24. +                if (totalBytes != 0) {  
  25. +                    mUsedPercent = (int) ((usedBytes * 100) / totalBytes);  
  26. +                }  
  27. +            }  
  28. +            // End of Vanzo: zhongyeqing  
  29.              if (freeBytes < mStorageManager.getStorageLowBytes(path)) {  
  30.                  mColor = StorageSettings.COLOR_WARNING;  
  31.                  icon = context.getDrawable(R.drawable.ic_warning_24dp);  


2.下述代码为西语下 存储    和  内存 中的 , 改为 .
/src/com/android/settings/applications/ProcessStatsSummary.java  中

[java]  view plain  copy
  1. double freeRam = memInfo.realFreeRam;  
  2.          BytesResult usedResult = Formatter.formatBytes(context.getResources(), (long) usedRam,  
  3.                  Formatter.FLAG_SHORTER);  
  4. -        String totalString = Formatter.formatShortFileSize(context, (long) totalRam);  
  5. +        String totalString = (Formatter.formatShortFileSize(context, (long) totalRam)).replace(",",".");  
  6.          String freeString = Formatter.formatShortFileSize(context, (long) freeRam);  


/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java 中

[java]  view plain  copy
  1. private void updatePreference(StorageItemPreference pref, long size) {  
  2. -        pref.setSummary(Formatter.formatFileSize(getActivity(), size));  
  3. +        pref.setSummary((Formatter.formatFileSize(getActivity(), size)).replace(",","."));  
  4.      }  

再在第一段代码的基础上:

[java]  view plain  copy
  1. storage_detail_system.setSummary(systemresult.value+systemresult.units);  

变为 

[java]  view plain  copy
  1. storage_detail_system.setSummary((systemresult.value+systemresult.units).replace(",","."));  

[java]  view plain  copy
  1. result.value, result.units));  
[java]  view plain  copy
  1. 变为  
[java]  view plain  copy
  1. <pre name="code" class="java">(result.value).replace(",","."), result.units));  
[java]  view plain  copy
  1.   
[java]  view plain  copy
  1. <pre name="code" class="java">Formatter.formatFileSize(context, (long) (8.0 * 1024 * 1024 * 1024))));  
变为

 
  
[java]  view plain  copy
  1. <pre name="code" class="java">(Formatter.formatFileSize(context, (long) (8.0 * 1024 * 1024 * 1024))).replace(",",".")));  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值