Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37f3c8f5 authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

Fix bug #10624988 Incorrect mirroring of RAM and Internal Storage for Apps screens in Settings

- well this CL is only for preventing a wrong rendering (the real CL would need to be one latter
and would need to fix the onDraw(Canvas) for LinearColorBar so that it takes care of the layout direction)
- force LTR layout direction on the LinearColorBar, hence preventing the two TextView to render their
text "in the middle".
- use BidiFormatter to wrap number strings

Change-Id: Ie164e5509c0364a81c85a3ac69f97a89f20a4130
parent 5aacc542
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -39,6 +39,10 @@
                    android:text="@string/no_applications"
                    android:textAppearance="?android:attr/textAppearanceLarge" />
        </FrameLayout>
        <!-- Force layout direction to LTR for now as we want the text to be at the same position in
             any Locale included the RTL ones. Will need to fix LinearColorBar RTL support later.
             Please also note the left/right gravities that would also need to be changed for proper
             RTL support -->
        <view class="com.android.settings.applications.LinearColorBar"
                android:id="@+id/storage_color_bar"
                android:layout_marginStart="@dimen/settings_side_margin"
@@ -50,11 +54,13 @@
                android:clipChildren="false"
                android:clipToPadding="false"
                android:paddingTop="30dp"
                android:paddingBottom="1dp">
                android:paddingBottom="1dp"
                android:layoutDirection="ltr">
            <TextView android:id="@+id/usedStorageText"
                android:layout_width="0px"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="left"
                android:textAppearance="?android:attr/textAppearanceSmallInverse"
                android:textColor="#000"
                android:singleLine="true" />
@@ -75,7 +81,7 @@
                android:layout_width="0px"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="end"
                android:gravity="right"
                android:textAppearance="?android:attr/textAppearanceSmallInverse"
                android:textColor="#000"
                android:singleLine="true" />
+8 −3
Original line number Diff line number Diff line
@@ -37,6 +37,10 @@
                android:text="@string/no_running_services"
                android:textAppearance="?android:attr/textAppearanceLarge" />
    </FrameLayout>
    <!-- Force layout direction to LTR for now as we want the text to be at the same position in
         any Locale included the RTL ones. Will need to fix LinearColorBar RTL support later.
         Please also note the left/right gravities that would also need to be changed for proper
         RTL support -->
    <view class="com.android.settings.applications.LinearColorBar"
            android:id="@+id/color_bar"
            android:layout_marginStart="@dimen/settings_side_margin"
@@ -50,13 +54,14 @@
            android:paddingTop="30dp"
            android:paddingStart="4dp"
            android:paddingEnd="4dp"
            android:paddingBottom="1dp">
            android:paddingBottom="1dp"
            android:layoutDirection="ltr">
        <TextView android:id="@+id/foregroundText"
            android:layout_width="0px"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:focusable="true"
            android:gravity="start|bottom"
            android:gravity="left|bottom"
            android:textAppearance="?android:attr/textAppearanceSmallInverse"
            android:textColor="#000"
            android:singleLine="true" />
@@ -78,7 +83,7 @@
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:focusable="true"
            android:gravity="end|bottom"
            android:gravity="right|bottom"
            android:textAppearance="?android:attr/textAppearanceSmallInverse"
            android:textColor="#000"
            android:singleLine="true" />
+6 −4
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import android.provider.Settings;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.PagerTabStrip;
import android.support.v4.view.ViewPager;
import android.text.BidiFormatter;
import android.text.format.Formatter;
import android.util.Log;
import android.view.LayoutInflater;
@@ -385,20 +386,21 @@ public class ManageApplications extends Fragment implements
                return;
            }
            if (mTotalStorage > 0) {
                BidiFormatter bidiFormatter = BidiFormatter.getInstance();
                mColorBar.setRatios((mTotalStorage-mFreeStorage-mAppStorage)/(float)mTotalStorage,
                        mAppStorage/(float)mTotalStorage, mFreeStorage/(float)mTotalStorage);
                long usedStorage = mTotalStorage - mFreeStorage;
                if (mLastUsedStorage != usedStorage) {
                    mLastUsedStorage = usedStorage;
                    String sizeStr = Formatter.formatShortFileSize(
                            mOwner.getActivity(), usedStorage);
                    String sizeStr = bidiFormatter.unicodeWrap(
                            Formatter.formatShortFileSize(mOwner.getActivity(), usedStorage));
                    mUsedStorageText.setText(mOwner.getActivity().getResources().getString(
                            R.string.service_foreground_processes, sizeStr));
                }
                if (mLastFreeStorage != mFreeStorage) {
                    mLastFreeStorage = mFreeStorage;
                    String sizeStr = Formatter.formatShortFileSize(
                            mOwner.getActivity(), mFreeStorage);
                    String sizeStr = bidiFormatter.unicodeWrap(
                            Formatter.formatShortFileSize(mOwner.getActivity(), mFreeStorage));
                    mFreeStorageText.setText(mOwner.getActivity().getResources().getString(
                            R.string.service_background_processes, sizeStr));
                }
+7 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.settings.applications;

import android.text.BidiFormatter;
import com.android.internal.util.MemInfoReader;
import com.android.settings.R;

@@ -342,11 +343,14 @@ public class RunningProcessesView extends FrameLayout
                mLastBackgroundProcessMemory = mState.mBackgroundProcessMemory;
                mLastAvailMemory = availMem;
                long freeMem = mLastAvailMemory + mLastBackgroundProcessMemory;
                String sizeStr = Formatter.formatShortFileSize(getContext(), freeMem);
                BidiFormatter bidiFormatter = BidiFormatter.getInstance();
                String sizeStr = bidiFormatter.unicodeWrap(
                        Formatter.formatShortFileSize(getContext(), freeMem));
                mBackgroundProcessText.setText(getResources().getString(
                        R.string.service_background_processes, sizeStr));
                sizeStr = Formatter.formatShortFileSize(getContext(),
                        mMemInfoReader.getTotalSize() - freeMem);
                sizeStr = bidiFormatter.unicodeWrap(
                        Formatter.formatShortFileSize(getContext(),
                                mMemInfoReader.getTotalSize() - freeMem));
                mForegroundProcessText.setText(getResources().getString(
                        R.string.service_foreground_processes, sizeStr));
            }