Merge "Use Activity resources in DecorContext" into nyc-dev
am: 6cc3199
* commit '6cc31990fc1952b9533cf9b695dd287b87a93e82':
Use Activity resources in DecorContext
Change-Id: Ie30b91a0c926c8ac84f2364a3267b5e0f22c30e7
This commit is contained in:
@@ -17,22 +17,27 @@
|
|||||||
package com.android.internal.policy;
|
package com.android.internal.policy;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.AssetManager;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.WindowManagerImpl;
|
import android.view.WindowManagerImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Context for decor views which can be seeded with pure application context and not depend on the
|
* Context for decor views which can be seeded with pure application context and not depend on the
|
||||||
* activity, but still provide some of the facilities that Activity has, e.g. themes.
|
* activity, but still provide some of the facilities that Activity has,
|
||||||
|
* e.g. themes, activity-based resources, etc.
|
||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
class DecorContext extends ContextThemeWrapper {
|
class DecorContext extends ContextThemeWrapper {
|
||||||
private PhoneWindow mPhoneWindow;
|
private PhoneWindow mPhoneWindow;
|
||||||
private WindowManager mWindowManager;
|
private WindowManager mWindowManager;
|
||||||
|
private Resources mActivityResources;
|
||||||
|
|
||||||
public DecorContext(Context context) {
|
public DecorContext(Context context, Resources activityResources) {
|
||||||
super(context, null);
|
super(context, null);
|
||||||
|
mActivityResources = activityResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPhoneWindow(PhoneWindow phoneWindow) {
|
void setPhoneWindow(PhoneWindow phoneWindow) {
|
||||||
@@ -52,4 +57,14 @@ class DecorContext extends ContextThemeWrapper {
|
|||||||
}
|
}
|
||||||
return super.getSystemService(name);
|
return super.getSystemService(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Resources getResources() {
|
||||||
|
return mActivityResources;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AssetManager getAssets() {
|
||||||
|
return mActivityResources.getAssets();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2297,7 +2297,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
|||||||
if (applicationContext == null) {
|
if (applicationContext == null) {
|
||||||
context = getContext();
|
context = getContext();
|
||||||
} else {
|
} else {
|
||||||
context = new DecorContext(applicationContext);
|
context = new DecorContext(applicationContext, getContext().getResources());
|
||||||
if (mTheme != -1) {
|
if (mTheme != -1) {
|
||||||
context.setTheme(mTheme);
|
context.setTheme(mTheme);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user