关键字:
"欢迎使用"
关键字所在地址:
./res/layout/longpress_cling_welcome_content.xml: android:text="@string/first_run_cling_title"
搜索关键字 “longpress_cling_welcome_content”
./src/com/android/launcher3/LauncherClings.java: mInflater.inflate(showWelcome ? R.layout.longpress_cling_welcome_content
根据2可以得知LauncherClings.java 中的 showLongPressCling 函数是主要位置
public void showLongPressCling(boolean showWelcome) {
......
final ViewGroup content = (ViewGroup) cling.findViewById(R.id.cling_content);
mInflater.inflate(showWelcome ? R.layout.longpress_cling_welcome_content
: R.layout.longpress_cling_content, content); //TODO 欢迎页加载
content.findViewById(R.id.cling_dismiss_longpress_info).setOnClickListener(this);
if (TAG_CROP_TOP_AND_SIDES.equals(content.getTag())) {
Drawable bg = new BorderCropDrawable(mLauncher.getResources().getDrawable(R.drawable.cling_bg),
true, true, true, false);
content.setBackground(bg);
}
root.addView(cling);
if (showWelcome) {
// This is the first cling being shown. No need to animate.
return;
}
// Animate
......
}
那么如何修改去掉让欢迎页呢?
在Launcher.java 初始化中搜索 showLongPressCling这个函数的调用
1、在onCreate()中
@Override
protected void onCreate(Bundle savedInstanceState) {
......
//*/ 注释这部分代码块 @{
if (shouldShowIntroScreen()) {
showIntroScreen();
} else {
showFirstRunActivity();
showFirstRunClings(); //第一步
}
//*/ @}
}
2、调用showFirstRunClings()
@Thunk void showFirstRunClings() {
// The two first run cling paths are mutually exclusive, if the launcher is preinstalled
// on the device, then we always show the first run cling experience (or if there is no
// launcher2). Otherwise, we prompt the user upon started for migration
LauncherClings launcherClings = new LauncherClings(this);
if (launcherClings.shouldShowFirstRunOrMigrationClings()) {
mClings = launcherClings;
if (mModel.canMigrateFromOldLauncherDb(this)) {
launcherClings.showMigrationCling();
} else {
launcherClings.showLongPressCling(true); //第二步
}
}
}
3、 去掉代码中注释部分即可实现去掉欢迎界面
我们继续追踪代码逻辑,在 showFirstRunClings() 函数中,有一个判断决定是否弹出欢迎页面或引导页面
if (launcherClings.shouldShowFirstRunOrMigrationClings())
我们接着看 shouldShowFirstRunOrMigrationClings 这个函数
private static final String MIGRATION_CLING_DISMISSED_KEY = "cling_gel.migration.dismissed";
private static final String WORKSPACE_CLING_DISMISSED_KEY = "cling_gel.workspace.dismissed";
public boolean shouldShowFirstRunOrMigrationClings() {
SharedPreferences sharedPrefs = mLauncher.getSharedPrefs();
return areClingsEnabled() &&
!sharedPrefs.getBoolean(WORKSPACE_CLING_DISMISSED_KEY, false) &&
!sharedPrefs.getBoolean(MIGRATION_CLING_DISMISSED_KEY, false);
}
从如上代码可以看出 return 的值受到 两个 sharedpreferences 值的影响,只需要修改默认值,就可以
控制逻辑的判断,从而关闭页面。
去除Launcher3 开机欢迎页,修改 SharedPreferences :
地址:/data/data/com.android.launcher3/shared_prefs/com.android.launcher3.prefs.xml
步骤:
@1.
添加一条
到xml文件中
@2.
adb push C:\Users\Administrator\com.android.launcher3.prefs.xml /data/data/com.android.launcher3/shared_prefs/
@3.
adb reboot