android.content.pm.ActivityInfo#getThemeResource()源码实例Demo

下面列出了android.content.pm.ActivityInfo#getThemeResource() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Neptune   文件: PluginPackageInfo.java
public int getThemeResource(String activity) {
    ActivityInfo info = getActivityInfo(activity);
    if (info == null || info.getThemeResource() == 0) {
        // 支持不同系统的默认Theme
        if (Build.VERSION.SDK_INT >= 24) {
            return android.R.style.Theme_DeviceDefault_Light_DarkActionBar;
        } else if (Build.VERSION.SDK_INT >= 14) {
            return android.R.style.Theme_DeviceDefault;
        } else if (Build.VERSION.SDK_INT >= 11) {
            return android.R.style.Theme_Holo;
        } else {
            return android.R.style.Theme;
        }
    }
    return info.getThemeResource();
}
 
源代码2 项目: Neptune   文件: InstrActivityProxy1.java
@Override
public void setTheme(int resId) {
    if (VersionUtils.hasNougat()) {
        String[] temp = parsePkgAndClsFromIntent();
        if (mNeedUpdateConfiguration && (temp != null || mLoadedApk != null)) {
            if (null != temp && temp.length == 2) {
                tryToInitPluginLoadApk(temp[0]);
            }
            if (mLoadedApk != null && temp != null) {
                ActivityInfo actInfo = mLoadedApk.getActivityInfoByClassName(temp[1]);
                if (actInfo != null) {
                    int resTheme = actInfo.getThemeResource();
                    if (mNeedUpdateConfiguration) {
                        changeActivityInfo(InstrActivityProxy1.this, temp[0], actInfo);
                        super.setTheme(resTheme);
                        mNeedUpdateConfiguration = false;
                        return;
                    }
                }
            }
        }
        super.setTheme(resId);
    } else {
        getTheme().applyStyle(resId, true);
    }
}
 
源代码3 项目: GPT   文件: ApkTargetMapping.java
@Override
public int getThemeResource(String activity) {
    if (activity == null) {
        return android.R.style.Theme;
    }
    ActivityInfo info = mAcitivtyMap.get(activity);

    /**
     * 指定默认theme为android.R.style.Theme
     * 有些OPPO手机上,把theme设置成0,其实会把Theme设置成holo主题,带ActionBar,导致插件黑屏,目前插件SDK不支持ActionBar。
     *
     * ### 以上注释为 megapp 框架,新框架已经没有问题,gpt框架支持actionbar。
     */
    if (info == null || info.getThemeResource() == 0) {
        return 0; // 使用系统默认
    }
    return info.getThemeResource();
}
 
源代码4 项目: Android-Plugin-Framework   文件: PluginInjector.java
/**
 * 主题的选择顺序为 先选择插件Activity配置的主题,再选择插件Application配置的主题,
 * 如果是非独立插件,再选择宿主Activity主题
 * 如果是独立插件,再选择系统默认主题
 * @param activityInfo
 * @param pluginActivityInfo
 * @param pd
 * @return
 */
private static int getPluginTheme(ActivityInfo activityInfo, PluginActivityInfo pluginActivityInfo, PluginDescriptor pd) {
	int pluginAppTheme = 0;
	if (pluginActivityInfo != null ) {
		pluginAppTheme = ResourceUtil.parseResId(pluginActivityInfo.getTheme());
	}
	if (pluginAppTheme == 0) {
		pluginAppTheme = pd.getApplicationTheme();
	}

	if (pluginAppTheme == 0 && pd.isStandalone()) {
		pluginAppTheme = android.R.style.Theme_DeviceDefault;
	}

	if (pluginAppTheme == 0) {
		//If the activity defines a theme, that is used; else, the application theme is used.
		pluginAppTheme = activityInfo.getThemeResource();
	}
	return pluginAppTheme;
}
 
源代码5 项目: PluginLoader   文件: PluginInjector.java
private static int getPluginTheme(ActivityInfo activityInfo, PluginActivityInfo pluginActivityInfo, PluginDescriptor pd) {
	int pluginAppTheme = 0;
	if (pluginActivityInfo != null ) {
		pluginAppTheme = ResourceUtil.getResourceId(pluginActivityInfo.getTheme());
	}
	if (pluginAppTheme == 0) {
		pluginAppTheme = pd.getApplicationTheme();
	}
	if (pluginAppTheme == 0) {
		pluginAppTheme = activityInfo.getThemeResource();
	}
	return pluginAppTheme;
}
 
源代码6 项目: Phantom   文件: LaunchModeManager.java
/**
 * 获取一个占位activity
 *
 * @param pluginActivity 插件activity
 * @param launchMode     插件activity启动模式
 * @param isFixed        是否建立固定映射关系
 * @return 占位activity
 * @throws ProxyActivityLessException 占位activity不够异常
 */
private String findActivity(String pluginActivity, int launchMode, boolean isFixed)
        throws ProxyActivityLessException {

    String activity = MODE_STANDARD;
    ActivityPool pool = null;

    switch (launchMode) {
        case ActivityInfo.LAUNCH_MULTIPLE:
            final PhantomCore phantomCore = PhantomCore.getInstance();
            final ComponentName componentName = ComponentName.unflattenFromString(pluginActivity);
            if (componentName != null) {
                final ActivityInfo ai = phantomCore.findActivityInfo(componentName);
                final PluginInfo pluginInfo = phantomCore.findPluginInfoByActivityName(componentName);
                final int themeResourceId = ai == null ? -1 : ai.getThemeResource();
                if (themeResourceId != -1 && pluginInfo != null) {
                    final Resources resources = pluginInfo.getPluginResources();
                    if (resources != null) {
                        final Resources.Theme theme = resources.newTheme();
                        theme.applyStyle(themeResourceId, true);
                        final TypedArray sa = theme.obtainStyledAttributes(
                                new int[]{android.R.attr.windowIsTranslucent});
                        final boolean translucent = sa.getBoolean(0, false);
                        sa.recycle();
                        activity = translucent ? MODE_STANDARD_TRANSLUCENT : MODE_STANDARD;
                    }
                }
            }
            break;
        case ActivityInfo.LAUNCH_SINGLE_TOP:
            pool = mSingleTopPool;
            break;
        case ActivityInfo.LAUNCH_SINGLE_INSTANCE:
            pool = mSingleInstancePool;
            break;
        case ActivityInfo.LAUNCH_SINGLE_TASK:
            pool = mSingleTaskPool;
            break;
        default:
            break;
    }

    if (null != pool) {
        activity = isFixed ? pool.resolveFixedActivity(pluginActivity) : pool.resolveActivity(pluginActivity);
    }

    String msg = String.format("resolve %s Activity for %s proxy is %s, fixed is %s",
            launchModeToString(launchMode), pluginActivity, activity, isFixed);
    VLog.d(msg);
    if (null == activity) {
        //占位activity不够使用, 这种情况不做处理,宿主提供足够的占位activity
        //这里不做主动回收,如果做主动回收可能会使程序正常执行流程发送改变
        ProxyActivityLessException pae = new ProxyActivityLessException(msg);
        LogReporter.reportException(pae, null);
        mCache.clean();
        throw pae;
    }

    return activity;
}