diff options
| author | Andrii Kulian <akulian@google.com> | 2016-03-28 00:24:59 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-03-28 00:25:01 +0000 |
| commit | 47869bd446e0de36bdb4848d3c286a15fc3fdbf7 (patch) | |
| tree | 5001eca714249fd370433bdced8f5bf8d7add2a7 /core/java | |
| parent | 3e670dc06d78333c617f7a8fc8afef1f2a8fb810 (diff) | |
| parent | 2e751b8c778fd991fcdcec3bc2d1f32a722f436b (diff) | |
Merge "Update ActivityInfo#WindowLayout apis (1/3)" into nyc-dev
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/content/pm/ActivityInfo.java | 118 | ||||
| -rw-r--r-- | core/java/android/content/pm/PackageParser.java | 13 |
2 files changed, 105 insertions, 26 deletions
diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java index 5da3c866077a..0f4cbbba707b 100644 --- a/core/java/android/content/pm/ActivityInfo.java +++ b/core/java/android/content/pm/ActivityInfo.java @@ -767,7 +767,11 @@ public class ActivityInfo extends ComponentInfo */ public int lockTaskLaunchMode; - public Layout layout; + /** + * Information about desired position and size of activity on the display when + * it is first started. + */ + public WindowLayout windowLayout; public ActivityInfo() { } @@ -788,7 +792,7 @@ public class ActivityInfo extends ComponentInfo parentActivityName = orig.parentActivityName; maxRecents = orig.maxRecents; lockTaskLaunchMode = orig.lockTaskLaunchMode; - layout = orig.layout; + windowLayout = orig.windowLayout; resizeMode = orig.resizeMode; } @@ -886,10 +890,10 @@ public class ActivityInfo extends ComponentInfo pw.println(prefix + "lockTaskLaunchMode=" + lockTaskLaunchModeToString(lockTaskLaunchMode)); } - if (layout != null) { - pw.println(prefix + "defaultLayout=" + layout.width + "|" - + layout.widthFraction + ", " + layout.height + "|" - + layout.heightFraction + ", " + layout.gravity); + if (windowLayout != null) { + pw.println(prefix + "windowLayout=" + windowLayout.width + "|" + + windowLayout.widthFraction + ", " + windowLayout.height + "|" + + windowLayout.heightFraction + ", " + windowLayout.gravity); } pw.println(prefix + "resizeMode=" + resizeModeToString(resizeMode)); super.dumpBack(pw, prefix, flags); @@ -922,14 +926,15 @@ public class ActivityInfo extends ComponentInfo dest.writeInt(persistableMode); dest.writeInt(maxRecents); dest.writeInt(lockTaskLaunchMode); - if (layout != null) { + if (windowLayout != null) { dest.writeInt(1); - dest.writeInt(layout.width); - dest.writeFloat(layout.widthFraction); - dest.writeInt(layout.height); - dest.writeFloat(layout.heightFraction); - dest.writeInt(layout.gravity); - dest.writeInt(layout.minimalSize); + dest.writeInt(windowLayout.width); + dest.writeFloat(windowLayout.widthFraction); + dest.writeInt(windowLayout.height); + dest.writeFloat(windowLayout.heightFraction); + dest.writeInt(windowLayout.gravity); + dest.writeInt(windowLayout.minimalWidth); + dest.writeInt(windowLayout.minimalHeight); } else { dest.writeInt(0); } @@ -964,36 +969,107 @@ public class ActivityInfo extends ComponentInfo maxRecents = source.readInt(); lockTaskLaunchMode = source.readInt(); if (source.readInt() == 1) { - layout = new Layout(source); + windowLayout = new WindowLayout(source); } resizeMode = source.readInt(); } - public static final class Layout { - public Layout(int width, float widthFraction, int height, float heightFraction, int gravity, - int minimalSize) { + /** + * Contains information about position and size of the activity on the display. + * + * Used in freeform mode to set desired position when activity is first launched. + * It describes how big the activity wants to be in both width and height, + * the minimal allowed size, and the gravity to be applied. + * + * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth + * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight + * @attr ref android.R.styleable#AndroidManifestLayout_gravity + * @attr ref android.R.styleable#AndroidManifestLayout_minimalWidth + * @attr ref android.R.styleable#AndroidManifestLayout_minimalHeight + */ + public static final class WindowLayout { + public WindowLayout(int width, float widthFraction, int height, float heightFraction, int gravity, + int minimalWidth, int minimalHeight) { this.width = width; this.widthFraction = widthFraction; this.height = height; this.heightFraction = heightFraction; this.gravity = gravity; - this.minimalSize = minimalSize; + this.minimalWidth = minimalWidth; + this.minimalHeight = minimalHeight; } - Layout(Parcel source) { + WindowLayout(Parcel source) { width = source.readInt(); widthFraction = source.readFloat(); height = source.readInt(); heightFraction = source.readFloat(); gravity = source.readInt(); - minimalSize = source.readInt(); + minimalWidth = source.readInt(); + minimalHeight = source.readInt(); } + /** + * Width of activity in pixels. + * + * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth + */ public final int width; + + /** + * Width of activity as a fraction of available display width. + * If both {@link #width} and this value are set this one will be preferred. + * + * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth + */ public final float widthFraction; + + /** + * Height of activity in pixels. + * + * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight + */ public final int height; + + /** + * Height of activity as a fraction of available display height. + * If both {@link #height} and this value are set this one will be preferred. + * + * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight + */ public final float heightFraction; + + /** + * Gravity of activity. + * Currently {@link android.view.Gravity#TOP}, {@link android.view.Gravity#BOTTOM}, + * {@link android.view.Gravity#LEFT} and {@link android.view.Gravity#RIGHT} are supported. + * + * @attr ref android.R.styleable#AndroidManifestLayout_gravity + */ public final int gravity; - public final int minimalSize; + + /** + * Minimal width of activity in pixels to be able to display its content. + * + * <p><strong>NOTE:</strong> A task's root activity value is applied to all additional + * activities launched in the task. That is if the root activity of a task set minimal + * width, then the system will set the same minimal width on all other activities in the + * task. It will also ignore any other minimal width attributes of non-root activities. + * + * @attr ref android.R.styleable#AndroidManifestLayout_minimalWidth + */ + public final int minimalWidth; + + /** + * Minimal height of activity in pixels to be able to display its content. + * + * <p><strong>NOTE:</strong> A task's root activity value is applied to all additional + * activities launched in the task. That is if the root activity of a task set minimal + * height, then the system will set the same minimal height on all other activities in the + * task. It will also ignore any other minimal height attributes of non-root activities. + * + * @attr ref android.R.styleable#AndroidManifestLayout_minimalHeight + */ + public final int minimalHeight; } } diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 84605bb14d7d..ea251f648034 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -3648,12 +3648,15 @@ public class PackageParser { int gravity = sw.getInt( com.android.internal.R.styleable.AndroidManifestLayout_gravity, Gravity.CENTER); - int minimalSize = sw.getDimensionPixelSize( - com.android.internal.R.styleable.AndroidManifestLayout_minimalSize, + int minimalWidth = sw.getDimensionPixelSize( + com.android.internal.R.styleable.AndroidManifestLayout_minimalWidth, + -1); + int minimalHeight = sw.getDimensionPixelSize( + com.android.internal.R.styleable.AndroidManifestLayout_minimalHeight, -1); sw.recycle(); - a.info.layout = new ActivityInfo.Layout(width, widthFraction, - height, heightFraction, gravity, minimalSize); + a.info.windowLayout = new ActivityInfo.WindowLayout(width, widthFraction, + height, heightFraction, gravity, minimalWidth, minimalHeight); } private Activity parseActivityAlias(Package owner, Resources res, @@ -3735,7 +3738,7 @@ public class PackageParser { info.uiOptions = target.info.uiOptions; info.parentActivityName = target.info.parentActivityName; info.maxRecents = target.info.maxRecents; - info.layout = target.info.layout; + info.windowLayout = target.info.windowLayout; info.resizeMode = target.info.resizeMode; info.encryptionAware = info.directBootAware = target.info.directBootAware; |
