| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.window; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.app.WindowConfiguration; |
| 22 |
import android.content.res.Configuration; |
| 23 |
import android.os.Parcel; |
| 24 |
import android.os.Parcelable; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public class TaskFragmentParentInfo implements Parcelable { |
| 31 |
@NonNull |
| 32 |
private final Configuration mConfiguration = new Configuration(); |
| 33 |
|
| 34 |
private final int mDisplayId; |
| 35 |
|
| 36 |
private final boolean mVisible; |
| 37 |
|
| 38 |
public TaskFragmentParentInfo(@NonNull Configuration configuration, int displayId, |
| 39 |
boolean visible) { |
| 40 |
mConfiguration.setTo(configuration); |
| 41 |
mDisplayId = displayId; |
| 42 |
mVisible = visible; |
| 43 |
} |
| 44 |
|
| 45 |
public TaskFragmentParentInfo(@NonNull TaskFragmentParentInfo info) { |
| 46 |
mConfiguration.setTo(info.getConfiguration()); |
| 47 |
mDisplayId = info.mDisplayId; |
| 48 |
mVisible = info.mVisible; |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
@NonNull |
| 53 |
public Configuration getConfiguration() { |
| 54 |
return mConfiguration; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
public int getDisplayId() { |
| 62 |
return mDisplayId; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
public boolean isVisible() { |
| 67 |
return mVisible; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
public boolean equalsForTaskFragmentOrganizer(@Nullable TaskFragmentParentInfo that) { |
| 79 |
if (that == null) { |
| 80 |
return false; |
| 81 |
} |
| 82 |
return getWindowingMode() == that.getWindowingMode() && mDisplayId == that.mDisplayId |
| 83 |
&& mVisible == that.mVisible; |
| 84 |
} |
| 85 |
|
| 86 |
@WindowConfiguration.WindowingMode |
| 87 |
private int getWindowingMode() { |
| 88 |
return mConfiguration.windowConfiguration.getWindowingMode(); |
| 89 |
} |
| 90 |
|
| 91 |
@Override |
| 92 |
public String toString() { |
| 93 |
return TaskFragmentParentInfo.class.getSimpleName() + ":{" |
| 94 |
+ "config=" + mConfiguration |
| 95 |
+ ", displayId=" + mDisplayId |
| 96 |
+ ", visible=" + mVisible |
| 97 |
+ "}"; |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
@Override |
| 107 |
public boolean equals(Object obj) { |
| 108 |
if (obj == this) { |
| 109 |
return true; |
| 110 |
} |
| 111 |
if (!(obj instanceof TaskFragmentParentInfo)) { |
| 112 |
return false; |
| 113 |
} |
| 114 |
final TaskFragmentParentInfo that = (TaskFragmentParentInfo) obj; |
| 115 |
return mConfiguration.equals(that.mConfiguration) |
| 116 |
&& mDisplayId == that.mDisplayId |
| 117 |
&& mVisible == that.mVisible; |
| 118 |
} |
| 119 |
|
| 120 |
@Override |
| 121 |
public int hashCode() { |
| 122 |
int result = mConfiguration.hashCode(); |
| 123 |
result = 31 * result + mDisplayId; |
| 124 |
result = 31 * result + (mVisible ? 1 : 0); |
| 125 |
return result; |
| 126 |
} |
| 127 |
|
| 128 |
@Override |
| 129 |
public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 130 |
mConfiguration.writeToParcel(dest, flags); |
| 131 |
dest.writeInt(mDisplayId); |
| 132 |
dest.writeBoolean(mVisible); |
| 133 |
} |
| 134 |
|
| 135 |
private TaskFragmentParentInfo(Parcel in) { |
| 136 |
mConfiguration.readFromParcel(in); |
| 137 |
mDisplayId = in.readInt(); |
| 138 |
mVisible = in.readBoolean(); |
| 139 |
} |
| 140 |
|
| 141 |
public static final Creator<TaskFragmentParentInfo> CREATOR = |
| 142 |
new Creator<TaskFragmentParentInfo>() { |
| 143 |
@Override |
| 144 |
public TaskFragmentParentInfo createFromParcel(Parcel in) { |
| 145 |
return new TaskFragmentParentInfo(in); |
| 146 |
} |
| 147 |
|
| 148 |
@Override |
| 149 |
public TaskFragmentParentInfo[] newArray(int size) { |
| 150 |
return new TaskFragmentParentInfo[size]; |
| 151 |
} |
| 152 |
}; |
| 153 |
|
| 154 |
@Override |
| 155 |
public int describeContents() { |
| 156 |
return 0; |
| 157 |
} |
| 158 |
} |