File tree Expand file tree Collapse file tree
PluginCore/src/com/plugin/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -223,14 +223,30 @@ public static Context getDefaultPluginContext(@SuppressWarnings("rawtypes") Clas
223223 public static Context getNewPluginContext (@ SuppressWarnings ("rawtypes" ) Class clazz ) {
224224
225225 Context pluginContext = getDefaultPluginContext (clazz );
226+ //为了使5.0支持主题, 这里做api版本区分
227+ if (Build .VERSION .SDK_INT >= 14 && Build .VERSION .SDK_INT <= 20 ) {
228+
229+ if (pluginContext != null ) {
230+ pluginContext = PluginCreator .createPluginApplicationContext (sApplication ,
231+ pluginContext .getResources (), (DexClassLoader )pluginContext .getClassLoader ());
232+ pluginContext .setTheme (sApplication .getApplicationContext ().getApplicationInfo ().theme );
233+ }
234+
235+ return pluginContext ;
236+
237+ } else {
238+ PluginDescriptor pd = getPluginDescriptorByClassName (clazz .getName ());
226239
227- if (pluginContext != null ) {
228- pluginContext = PluginCreator .createPluginApplicationContext (sApplication ,
229- pluginContext .getResources (), (DexClassLoader )pluginContext .getClassLoader ());
230- pluginContext .setTheme (sApplication .getApplicationContext ().getApplicationInfo ().theme );
240+ Resources resFor5 = PluginCreator .createPluginResourceFor5 (sApplication , pd .getInstalledPath ());
241+
242+ if (pluginContext != null ) {
243+ pluginContext = PluginCreator .createPluginApplicationContext (sApplication ,
244+ resFor5 , (DexClassLoader )pluginContext .getClassLoader ());
245+ pluginContext .setTheme (sApplication .getApplicationContext ().getApplicationInfo ().theme );
246+ }
247+ return null ;
231248 }
232249
233- return pluginContext ;
234250 }
235251
236252 /**
You can’t perform that action at this time.
0 commit comments