aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjinwu <jinwu@codeaurora.org>2016-01-05 12:41:29 +0800
committerZhao Wei Liew <zhaoweiliew@gmail.com>2016-10-28 15:58:12 -0700
commit85bde2eaf5bdf02889159ee982df1d278ce85c61 (patch)
tree2783eb9da1f4e08b3e553c623b98f4b033607c1c
parent4dab55e05a227bd666b92f312f050e6805e8526d (diff)
downloadandroid_packages_apps_CMFileManager-85bde2eaf5bdf02889159ee982df1d278ce85c61.tar.gz
android_packages_apps_CMFileManager-85bde2eaf5bdf02889159ee982df1d278ce85c61.tar.bz2
android_packages_apps_CMFileManager-85bde2eaf5bdf02889159ee982df1d278ce85c61.zip
CMFileManager: Modify disk usage graph's layout
Change the view's layout to a ScrollView, so when roating the DUT from landscape to portrait, every single piece of info is shown. Change-Id: Iedbef14dad5325056cbb560e98855593b5494c16 CRs-Fixed: 889743 (cherry picked from commit 6a044ae7c4d5898b26b667dcb576f15f6f931d93)
-rw-r--r--res/layout/filesystem_info_dialog.xml205
-rw-r--r--src/com/cyanogenmod/filemanager/ui/widgets/DiskUsageGraph.java25
2 files changed, 120 insertions, 110 deletions
diff --git a/res/layout/filesystem_info_dialog.xml b/res/layout/filesystem_info_dialog.xml
index 596a0266..dcde7b75 100644
--- a/res/layout/filesystem_info_dialog.xml
+++ b/res/layout/filesystem_info_dialog.xml
@@ -257,113 +257,124 @@
</ScrollView>
<!-- Disk Usage -->
- <LinearLayout
+ <ScrollView
android:id="@+id/filesystem_tab_diskusage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/filesystem_tabs"
+ android:scrollbars="vertical"
android:visibility="gone" >
- <com.cyanogenmod.filemanager.ui.widgets.DiskUsageGraph
- android:id="@+id/filesystem_disk_usage_graph"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight=".30"
- android:layout_margin="@dimen/extra_large_margin" />
-
- <TableLayout
- android:layout_width="0dip"
+ <LinearLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_weight=".70"
- android:layout_gravity="start|center_vertical"
- android:paddingBottom="@dimen/extra_large_margin"
- android:paddingTop="@dimen/default_margin"
- android:shrinkColumns="1" >
-
- <!-- Total -->
- <TableRow
- android:layout_marginStart="@dimen/extra_large_margin"
- android:layout_marginEnd="@dimen/extra_large_margin" >
-
- <TextView
- android:id="@+id/filesystem_info_total_disk_usage_label"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="@dimen/default_margin"
- android:gravity="start|center_vertical"
- android:text="@string/filesystem_info_dialog_total_disk_usage"
- android:textAppearance="@style/primary_text_appearance" />
+ android:orientation="vertical">
- <TextView
- android:id="@+id/filesystem_info_total_disk_usage"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="@dimen/default_margin"
- android:gravity="start|center_vertical"
- android:textAppearance="@style/secondary_text_appearance" />
- </TableRow>
-
- <!-- Used -->
- <TableRow
- android:layout_marginStart="@dimen/extra_large_margin"
- android:layout_marginEnd="@dimen/extra_large_margin" >
-
- <TextView
- android:id="@+id/filesystem_info_used_disk_usage_label"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="@dimen/default_margin"
- android:gravity="start|center_vertical"
- android:text="@string/filesystem_info_dialog_used_disk_usage"
- android:textAppearance="@style/primary_text_appearance" />
-
- <TextView
- android:id="@+id/filesystem_info_used_disk_usage"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="@dimen/default_margin"
- android:gravity="start|center_vertical"
- android:textAppearance="@style/secondary_text_appearance" />
- </TableRow>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
- <!-- Free -->
- <TableRow
- android:layout_marginStart="@dimen/extra_large_margin"
- android:layout_marginEnd="@dimen/extra_large_margin" >
+ <com.cyanogenmod.filemanager.ui.widgets.DiskUsageGraph
+ android:id="@+id/filesystem_disk_usage_graph"
+ android:layout_width="0dip"
+ android:layout_height="match_parent"
+ android:layout_weight=".30"
+ android:layout_margin="@dimen/extra_large_margin" />
- <TextView
- android:id="@+id/filesystem_info_free_disk_usage_label"
- android:layout_width="match_parent"
+ <TableLayout
+ android:layout_width="0dip"
android:layout_height="wrap_content"
- android:layout_margin="@dimen/default_margin"
- android:gravity="start|center_vertical"
- android:text="@string/filesystem_info_dialog_free_disk_usage"
- android:textAppearance="@style/primary_text_appearance" />
-
- <TextView
- android:id="@+id/filesystem_info_free_disk_usage"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_margin="@dimen/default_margin"
- android:gravity="start|center_vertical"
- android:textAppearance="@style/secondary_text_appearance" />
- </TableRow>
- </TableLayout>
- </LinearLayout>
-
- <GridLayout
- android:id="@+id/ll_legend"
- android:gravity="center"
- android:layout_centerHorizontal="true"
- android:visibility="invisible"
- android:layout_below="@id/filesystem_tab_diskusage"
- android:orientation="horizontal"
- android:columnCount="4"
- android:columnOrderPreserved="true"
- android:rowOrderPreserved="true"
- android:useDefaultMargins="true"
- android:padding="@dimen/legend_padding"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
+ android:layout_weight=".70"
+ android:layout_gravity="start|center_vertical"
+ android:paddingBottom="@dimen/extra_large_margin"
+ android:paddingTop="@dimen/default_margin"
+ android:shrinkColumns="1" >
+
+ <!-- Total -->
+ <TableRow
+ android:layout_marginStart="@dimen/extra_large_margin"
+ android:layout_marginEnd="@dimen/extra_large_margin" >
+
+ <TextView
+ android:id="@+id/filesystem_info_total_disk_usage_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:gravity="start|center_vertical"
+ android:text="@string/filesystem_info_dialog_total_disk_usage"
+ android:textAppearance="@style/primary_text_appearance" />
+
+ <TextView
+ android:id="@+id/filesystem_info_total_disk_usage"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:gravity="start|center_vertical"
+ android:textAppearance="@style/secondary_text_appearance" />
+ </TableRow>
+
+ <!-- Used -->
+ <TableRow
+ android:layout_marginStart="@dimen/extra_large_margin"
+ android:layout_marginEnd="@dimen/extra_large_margin" >
+
+ <TextView
+ android:id="@+id/filesystem_info_used_disk_usage_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:gravity="start|center_vertical"
+ android:text="@string/filesystem_info_dialog_used_disk_usage"
+ android:textAppearance="@style/primary_text_appearance" />
+
+ <TextView
+ android:id="@+id/filesystem_info_used_disk_usage"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:gravity="start|center_vertical"
+ android:textAppearance="@style/secondary_text_appearance" />
+ </TableRow>
+
+ <!-- Free -->
+ <TableRow
+ android:layout_marginStart="@dimen/extra_large_margin"
+ android:layout_marginEnd="@dimen/extra_large_margin" >
+
+ <TextView
+ android:id="@+id/filesystem_info_free_disk_usage_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:gravity="start|center_vertical"
+ android:text="@string/filesystem_info_dialog_free_disk_usage"
+ android:textAppearance="@style/primary_text_appearance" />
+
+ <TextView
+ android:id="@+id/filesystem_info_free_disk_usage"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:gravity="start|center_vertical"
+ android:textAppearance="@style/secondary_text_appearance" />
+ </TableRow>
+ </TableLayout>
+ </LinearLayout>
+
+ <GridLayout
+ android:id="@+id/ll_legend"
+ android:gravity="center"
+ android:layout_centerHorizontal="true"
+ android:visibility="invisible"
+ android:orientation="horizontal"
+ android:columnCount="4"
+ android:columnOrderPreserved="true"
+ android:rowOrderPreserved="true"
+ android:useDefaultMargins="true"
+ android:padding="@dimen/legend_padding"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+ </LinearLayout>
+ </ScrollView>
</RelativeLayout>
diff --git a/src/com/cyanogenmod/filemanager/ui/widgets/DiskUsageGraph.java b/src/com/cyanogenmod/filemanager/ui/widgets/DiskUsageGraph.java
index 075afa7d..4ba7b153 100644
--- a/src/com/cyanogenmod/filemanager/ui/widgets/DiskUsageGraph.java
+++ b/src/com/cyanogenmod/filemanager/ui/widgets/DiskUsageGraph.java
@@ -147,17 +147,6 @@ public class DiskUsageGraph extends View {
}
}
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
- int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
- int size = Math.min(parentWidth, parentHeight);
- this.setMeasuredDimension(size, size);
- }
-
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
// Redraw the disk usage graph when layout size changes
@@ -330,9 +319,19 @@ public class DiskUsageGraph extends View {
*/
@Override
public void run() {
- //Get information about the drawing zone, and adjust the size
+ final int width = getWidth();
+ final int height = getHeight();
+ if (width == 0 || height == 0) {
+ return;
+ }
+
+ // Calculate the widget size using the width and height params
Rect rect = new Rect();
- getDrawingRect(rect);
+ final int diameter = Math.min(width, height);
+ rect.left = (width - diameter) / 2;
+ rect.right = rect.left + diameter;
+ rect.top = (height - diameter) / 2;
+ rect.bottom = rect.top + diameter;
int stroke = (rect.width() / 2) / 2;
rect.left += stroke / 2;
rect.right -= stroke / 2;