diff options
| -rw-r--r-- | api/current.txt | 10 | ||||
| -rw-r--r-- | api/system-current.txt | 10 | ||||
| -rw-r--r-- | core/java/android/content/pm/ActivityInfo.java | 47 | ||||
| -rw-r--r-- | core/java/android/content/pm/PackageParser.java | 42 | ||||
| -rw-r--r-- | core/res/res/values/attrs_manifest.xml | 14 |
5 files changed, 121 insertions, 2 deletions
diff --git a/api/current.txt b/api/current.txt index acc9c4b11024..03307af81d5b 100644 --- a/api/current.txt +++ b/api/current.txt @@ -8881,6 +8881,7 @@ package android.content.pm { field public int configChanges; field public int documentLaunchMode; field public int flags; + field public android.content.pm.ActivityInfo.InitialLayout initialLayout; field public int launchMode; field public int maxRecents; field public java.lang.String parentActivityName; @@ -8894,6 +8895,15 @@ package android.content.pm { field public int uiOptions; } + public static final class ActivityInfo.InitialLayout { + ctor public ActivityInfo.InitialLayout(int, float, int, float, int); + field public final int gravity; + field public final int height; + field public final float heightFraction; + field public final int width; + field public final float widthFraction; + } + public class ApplicationInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable { ctor public ApplicationInfo(); ctor public ApplicationInfo(android.content.pm.ApplicationInfo); diff --git a/api/system-current.txt b/api/system-current.txt index 955fb07e20a7..8daa33e4d086 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9139,6 +9139,7 @@ package android.content.pm { field public int configChanges; field public int documentLaunchMode; field public int flags; + field public android.content.pm.ActivityInfo.InitialLayout initialLayout; field public int launchMode; field public int maxRecents; field public java.lang.String parentActivityName; @@ -9152,6 +9153,15 @@ package android.content.pm { field public int uiOptions; } + public static final class ActivityInfo.InitialLayout { + ctor public ActivityInfo.InitialLayout(int, float, int, float, int); + field public final int gravity; + field public final int height; + field public final float heightFraction; + field public final int width; + field public final float widthFraction; + } + public class ApplicationInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable { ctor public ApplicationInfo(); ctor public ApplicationInfo(android.content.pm.ApplicationInfo); diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java index 43cc63b4a3c8..876fbf55765c 100644 --- a/core/java/android/content/pm/ActivityInfo.java +++ b/core/java/android/content/pm/ActivityInfo.java @@ -698,6 +698,8 @@ public class ActivityInfo extends ComponentInfo */ public int lockTaskLaunchMode; + public InitialLayout initialLayout; + public ActivityInfo() { } @@ -763,9 +765,14 @@ public class ActivityInfo extends ComponentInfo } pw.println(prefix + "resizeable=" + resizeable + " lockTaskLaunchMode=" + lockTaskLaunchModeToString(lockTaskLaunchMode)); + if (initialLayout != null) { + pw.println(prefix + "initialLayout=" + initialLayout.width + "|" + + initialLayout.widthFraction + ", " + initialLayout.height + "|" + + initialLayout.heightFraction + ", " + initialLayout.gravity); + } super.dumpBack(pw, prefix); } - + public String toString() { return "ActivityInfo{" + Integer.toHexString(System.identityHashCode(this)) @@ -793,6 +800,16 @@ public class ActivityInfo extends ComponentInfo dest.writeInt(maxRecents); dest.writeInt(resizeable ? 1 : 0); dest.writeInt(lockTaskLaunchMode); + if (initialLayout != null) { + dest.writeInt(1); + dest.writeInt(initialLayout.width); + dest.writeFloat(initialLayout.widthFraction); + dest.writeInt(initialLayout.height); + dest.writeFloat(initialLayout.heightFraction); + dest.writeInt(initialLayout.gravity); + } else { + dest.writeInt(0); + } } public static final Parcelable.Creator<ActivityInfo> CREATOR @@ -822,5 +839,33 @@ public class ActivityInfo extends ComponentInfo maxRecents = source.readInt(); resizeable = (source.readInt() == 1); lockTaskLaunchMode = source.readInt(); + if (source.readInt() == 1) { + initialLayout = new InitialLayout(source); + } + } + + public static final class InitialLayout { + public InitialLayout(int width, float widthFraction, int height, float heightFraction, + int gravity) { + this.width = width; + this.widthFraction = widthFraction; + this.height = height; + this.heightFraction = heightFraction; + this.gravity = gravity; + } + + InitialLayout(Parcel source) { + width = source.readInt(); + widthFraction = source.readFloat(); + height = source.readInt(); + heightFraction = source.readFloat(); + gravity = source.readInt(); + } + + public final int width; + public final float widthFraction; + public final int height; + public final float heightFraction; + public final int gravity; } } diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 924df1b39cb8..6443667ab1db 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -50,6 +50,7 @@ import android.util.Log; import android.util.Pair; import android.util.Slog; import android.util.TypedValue; +import android.view.Gravity; import com.android.internal.R; import com.android.internal.util.ArrayUtils; @@ -3260,10 +3261,12 @@ public class PackageParser { owner.preferredActivityFilters.add(intent); } } else if (parser.getName().equals("meta-data")) { - if ((a.metaData=parseMetaData(res, parser, attrs, a.metaData, + if ((a.metaData = parseMetaData(res, parser, attrs, a.metaData, outError)) == null) { return null; } + } else if (!receiver && parser.getName().equals("initial-layout")) { + parseInitialLayout(res, attrs, a); } else { if (!RIGID_PARSER) { Slog.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); @@ -3296,6 +3299,43 @@ public class PackageParser { return a; } + private void parseInitialLayout(Resources res, AttributeSet attrs, Activity a) { + TypedArray sw = res.obtainAttributes(attrs, + com.android.internal.R.styleable.AndroidManifestInitialLayout); + int width = -1; + float widthFraction = -1f; + int height = -1; + float heightFraction = -1f; + final int widthType = sw.getType( + com.android.internal.R.styleable.AndroidManifestInitialLayout_activity_width); + if (widthType == TypedValue.TYPE_FRACTION) { + widthFraction = sw.getFraction( + com.android.internal.R.styleable.AndroidManifestInitialLayout_activity_width, + 1, 1, -1); + } else if (widthType == TypedValue.TYPE_DIMENSION) { + width = sw.getDimensionPixelSize( + com.android.internal.R.styleable.AndroidManifestInitialLayout_activity_width, + -1); + } + final int heightType = sw.getType( + com.android.internal.R.styleable.AndroidManifestInitialLayout_activity_height); + if (heightType == TypedValue.TYPE_FRACTION) { + heightFraction = sw.getFraction( + com.android.internal.R.styleable.AndroidManifestInitialLayout_activity_height, + 1, 1, -1); + } else if (heightType == TypedValue.TYPE_DIMENSION) { + height = sw.getDimensionPixelSize( + com.android.internal.R.styleable.AndroidManifestInitialLayout_activity_height, + -1); + } + int gravity = sw.getInt( + com.android.internal.R.styleable.AndroidManifestInitialLayout_gravity, + Gravity.CENTER); + sw.recycle(); + a.info.initialLayout = new ActivityInfo.InitialLayout(width, widthFraction, + height, heightFraction, gravity); + } + private Activity parseActivityAlias(Package owner, Resources res, XmlPullParser parser, AttributeSet attrs, int flags, String[] outError) throws XmlPullParserException, IOException { diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index 1a45b3ac75b3..74fd1eccd4db 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -2195,4 +2195,18 @@ <attr name="name" /> </declare-styleable> + <!-- <code>initial-layout</code> tag allows configuring the initial layout for the activity + within multi-window environment. --> + <declare-styleable name="AndroidManifestInitialLayout" parent="AndroidManifestActivity"> + <!-- Initial width of the activity. Can be either a fixed value or fraction, in which case + the width will be constructed as a fraction of the total available width. --> + <attr name="activity_width" format="dimension|fraction" /> + <!-- Initial height of the activity. Can be either a fixed value or fraction, in which case + the height will be constructed as a fraction of the total available height. --> + <attr name="activity_height" format="dimension|fraction" /> + <!-- Where to initially position the activity inside the available space. Uses constants + defined in {@link android.view.Gravity}. --> + <attr name="gravity" /> + </declare-styleable> + </resources> |