添加新的应用级别入口
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Wed Nov 05 08:47:36 GMT 2025
|
||||
#Mon Nov 10 00:01:30 GMT 2025
|
||||
stageCount=18
|
||||
libraryProject=
|
||||
baseVersion=15.0
|
||||
publishVersion=15.0.17
|
||||
buildCount=29
|
||||
buildCount=35
|
||||
baseBetaVersion=15.0.18
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">悟空笔记#</string>
|
||||
<string name="app_laojun_name">老君道說#</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Positions +</string>
|
||||
<string name="app_name">Positions</string>
|
||||
|
||||
<string name="app_laojun_name">Positions +</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -47,6 +47,21 @@
|
||||
|
||||
</activity>
|
||||
|
||||
<!-- 新增:应用启动Alias入口(桌面会显示两个图标) -->
|
||||
<activity-alias
|
||||
android:name=".MainActivityLaojun"
|
||||
android:targetActivity=".MainActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/app_laojun_name"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
|
||||
<!-- 配置为启动入口 -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
<meta-data
|
||||
android:name="android.max_aspect"
|
||||
android:value="4.0"/>
|
||||
|
||||
@@ -14,7 +14,6 @@ import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewGroup;
|
||||
@@ -24,7 +23,9 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.positions.activities.WinBoLLActivity;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Closeable;
|
||||
@@ -44,11 +45,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class App extends GlobalApplication {
|
||||
|
||||
public static volatile AppLevel _mAppLevel = AppLevel.WUKONG;
|
||||
|
||||
private static Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
setIsDebuging(BuildConfig.DEBUG);
|
||||
|
||||
WinBoLLActivityManager.init(this);
|
||||
@@ -64,6 +68,27 @@ public class App extends GlobalApplication {
|
||||
//CrashHandler.getInstance().registerPart(this);
|
||||
}
|
||||
|
||||
|
||||
public static void setAppLevel(WinBoLLActivity activity) {
|
||||
// 根据应用当前启动入口设定整体应用级别
|
||||
String launchComponent = activity.getComponentName().getClassName();
|
||||
boolean isAliasLaunch = launchComponent.endsWith("MainActivityLaojun");
|
||||
|
||||
if (isAliasLaunch) {
|
||||
// Alias入口启动逻辑(如切换应用级别、加载专属配置)
|
||||
LogUtils.d(TAG, "通过Alias入口启动,切换为LAOJUN级别");
|
||||
ToastUtils.show("通过Alias入口启动,切换为LAOJUN级别");
|
||||
App._mAppLevel = AppLevel.LAOJUN; // 结合之前定义的枚举
|
||||
// 执行Alias专属初始化...
|
||||
} else {
|
||||
// 原入口启动逻辑
|
||||
LogUtils.d(TAG, "通过原入口启动,默认WUKONG级别");
|
||||
ToastUtils.show("通过原入口启动,默认WUKONG级别");
|
||||
App._mAppLevel = AppLevel.WUKONG;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void write(InputStream input, OutputStream output) throws IOException {
|
||||
byte[] buf = new byte[1024 * 8];
|
||||
int len;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package cc.winboll.studio.positions;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/11/10 07:23
|
||||
* @Describe 应用级别类型枚举
|
||||
*/
|
||||
public enum AppLevel {
|
||||
WUKONG("wukong", "悟空级别"),
|
||||
LAOJUN("laojun", "老君级别");
|
||||
|
||||
public static final String TAG = "AppLevel";
|
||||
|
||||
// 枚举属性
|
||||
private final String code; // 编码(如 "wukong")
|
||||
private final String desc; // 描述
|
||||
|
||||
// 构造方法(Java 7 需显式定义)
|
||||
AppLevel(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
// Getter 方法(获取枚举属性)
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
// 可选:根据 code 获取枚举项(便于业务使用)
|
||||
public static AppLevel getByCode(String code) {
|
||||
for (AppLevel level : values()) {
|
||||
if (level.code.equals(code)) {
|
||||
return level;
|
||||
}
|
||||
}
|
||||
return null; // 或抛出异常,根据业务需求调整
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ import androidx.core.content.ContextCompat;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.positions.activities.LocationActivity;
|
||||
import cc.winboll.studio.positions.activities.WinBoLLActivity;
|
||||
import cc.winboll.studio.positions.services.MainService;
|
||||
import cc.winboll.studio.positions.utils.AppConfigsUtil;
|
||||
import cc.winboll.studio.positions.utils.ServiceUtil;
|
||||
|
||||
@@ -82,6 +82,7 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main); // 关联主页面布局
|
||||
App.setAppLevel(this);
|
||||
|
||||
// 1. 初始化顶部 Toolbar(保留原逻辑,设置页面标题)
|
||||
initToolbar();
|
||||
@@ -95,6 +96,7 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
//bindDistanceService();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
@@ -114,9 +116,9 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
mToolbar = (Toolbar) findViewById(R.id.toolbar); // Java 7 显式 findViewById + 强转
|
||||
setSupportActionBar(mToolbar);
|
||||
// 给ActionBar设置标题(先判断非空,避免空指针异常)
|
||||
if (getSupportActionBar() != null) {
|
||||
/*if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setTitle(getString(R.string.app_name));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">悟空笔记</string>
|
||||
<string name="app_laojun_name">老君道說</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<resources>
|
||||
<string name="app_name">Positions</string>
|
||||
<string name="app_laojun_name">Positions</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user