-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
ShadowPhoneWindow.java
67 lines (55 loc) · 2.12 KB
/
ShadowPhoneWindow.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package org.robolectric.shadows;
import static android.os.Build.VERSION_CODES.M;
import static android.os.Build.VERSION_CODES.R;
import static org.robolectric.util.reflector.Reflector.reflector;
import android.graphics.drawable.Drawable;
import android.view.Gravity;
import android.view.Window;
import androidx.annotation.RequiresApi;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.RealObject;
import org.robolectric.util.reflector.ForType;
/** Shadow for PhoneWindow for APIs 23+ */
@Implements(
className = "com.android.internal.policy.PhoneWindow",
isInAndroidSdk = false,
minSdk = M)
public class ShadowPhoneWindow extends ShadowWindow {
protected @RealObject Window realWindow;
protected boolean decorFitsSystemWindows = true;
@Implementation(minSdk = M)
public void setTitle(CharSequence title) {
this.title = title;
reflector(DirectPhoneWindowReflector.class, realWindow).setTitle(title);
}
@Implementation(minSdk = M)
public void setBackgroundDrawable(Drawable drawable) {
this.backgroundDrawable = drawable;
reflector(DirectPhoneWindowReflector.class, realWindow).setBackgroundDrawable(drawable);
}
@Implementation
protected int getOptionsPanelGravity() {
return Gravity.CENTER | Gravity.BOTTOM;
}
@Implementation(minSdk = R)
protected void setDecorFitsSystemWindows(boolean decorFitsSystemWindows) {
this.decorFitsSystemWindows = decorFitsSystemWindows;
reflector(DirectPhoneWindowReflector.class, realWindow)
.setDecorFitsSystemWindows(decorFitsSystemWindows);
}
/**
* Returns true with the last value passed to {@link #setDecorFitsSystemWindows(boolean)}, or the
* default value (true).
*/
@RequiresApi(R)
public boolean getDecorFitsSystemWindows() {
return decorFitsSystemWindows;
}
@ForType(className = "com.android.internal.policy.PhoneWindow", direct = true)
interface DirectPhoneWindowReflector {
void setTitle(CharSequence title);
void setBackgroundDrawable(Drawable drawable);
void setDecorFitsSystemWindows(boolean decorFitsSystemWindows);
}
}