Compare commits
14 Commits
apputils-v
...
apputils-v
Author | SHA1 | Date | |
---|---|---|---|
![]() |
99bf804625 | ||
![]() |
261259e61e | ||
![]() |
9aaf3433bd | ||
![]() |
b739510951 | ||
![]() |
903359d9a2 | ||
![]() |
69e7e72ed8 | ||
![]() |
a96ba362b4 | ||
![]() |
6447bcf924 | ||
![]() |
18ed325731 | ||
![]() |
16e3d10b63 | ||
![]() |
8b0e8b00ae | ||
![]() |
7f61ff1470 | ||
![]() |
c4e0c23a0c | ||
![]() |
c7d26bbc3d |
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Wed Jan 22 21:22:05 HKT 2025
|
||||
stageCount=5
|
||||
#Thu Jan 23 02:43:51 HKT 2025
|
||||
stageCount=10
|
||||
libraryProject=libapputils
|
||||
baseVersion=9.2
|
||||
publishVersion=9.2.4
|
||||
publishVersion=9.2.9
|
||||
buildCount=0
|
||||
baseBetaVersion=9.2.5
|
||||
baseBetaVersion=9.2.10
|
||||
|
@@ -5,14 +5,12 @@ package cc.winboll.studio.apputils;
|
||||
* @Date 2024/12/08 15:10:51
|
||||
* @Describe 全局应用类
|
||||
*/
|
||||
import android.app.Application;
|
||||
import android.view.Gravity;
|
||||
import cc.winboll.studio.GlobalApplication;
|
||||
import cc.winboll.studio.libapputils.app.WinBollGlobalApplication;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.hjq.toast.style.WhiteToastStyle;
|
||||
import cc.winboll.studio.libapputils.app.WinBollUtils;
|
||||
|
||||
public class App extends GlobalApplication {
|
||||
public class App extends WinBollGlobalApplication {
|
||||
|
||||
public static final String TAG = "App";
|
||||
|
||||
@@ -21,9 +19,12 @@ public class App extends GlobalApplication {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
// 初始化 WinBoll 框架
|
||||
WinBollUtils.getInstance(this).init(this);
|
||||
|
||||
// 初始化 Toast 框架
|
||||
ToastUtils.init(this);
|
||||
// 设置 Toast 布局样式
|
||||
//ToastUtils.setView(R.layout.view_toast);
|
||||
ToastUtils.setStyle(new WhiteToastStyle());
|
||||
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -174,6 +174,8 @@ final public class MainActivity extends WinBollActivity {
|
||||
appInfo.setAppIcon(cc.winboll.studio.libapputils.R.drawable.ic_winboll);
|
||||
appInfo.setAppDescription("APPUtils Description");
|
||||
appInfo.setAppGitName("APP");
|
||||
appInfo.setAppGitAPPBranch("apputils");
|
||||
appInfo.setAppGitAPPSubProjectFolder("apputils");
|
||||
appInfo.setAppHomePage("https://www.winboll.cc/studio/details.php?app=APP");
|
||||
appInfo.setAppAPKName("APPUtils");
|
||||
appInfo.setAppAPKFolderName("APPUtils");
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Wed Jan 22 21:22:05 HKT 2025
|
||||
stageCount=5
|
||||
#Thu Jan 23 02:43:51 HKT 2025
|
||||
stageCount=10
|
||||
libraryProject=libapputils
|
||||
baseVersion=9.2
|
||||
publishVersion=9.2.4
|
||||
publishVersion=9.2.9
|
||||
buildCount=0
|
||||
baseBetaVersion=9.2.5
|
||||
baseBetaVersion=9.2.10
|
||||
|
@@ -81,7 +81,7 @@ public class AssetsHtmlActivity extends WinBollActivity {
|
||||
if (szTemp != null && !szTemp.trim().equals("")) {
|
||||
mszHtmlFileName = szTemp.trim();
|
||||
}
|
||||
ToastUtils.show(mszHtmlFileName);
|
||||
//ToastUtils.show(mszHtmlFileName);
|
||||
}
|
||||
|
||||
// 与其他应用分享 html 帮助
|
||||
|
@@ -64,7 +64,7 @@ abstract public class WinBollActivity extends AppCompatActivity {
|
||||
// 传入的Intent action在Activity清单的intent-filter的action节点里有定义
|
||||
if (intent.getAction() != null) {
|
||||
if (intent.getAction().equals(cc.winboll.studio.libapputils.intent.action.DEBUGVIEW)) {
|
||||
WinBollUtils.setIsDebug(true);
|
||||
WinBollGlobalApplication.setIsDebug(true);
|
||||
//ToastUtils.show!("WinBollApplication.setIsDebug(true) by action : " + intent.getAction());
|
||||
|
||||
}
|
||||
@@ -356,7 +356,7 @@ abstract public class WinBollActivity extends AppCompatActivity {
|
||||
if (isAddWinBollToolBar()) {
|
||||
getMenuInflater().inflate(R.menu.toolbar_winboll_shared_main, menu);
|
||||
}
|
||||
if (WinBollUtils.isDebug()) {
|
||||
if (WinBollGlobalApplication.isDebug()) {
|
||||
getMenuInflater().inflate(R.menu.toolbar_studio_debug, menu);
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
|
@@ -171,11 +171,11 @@ public class WinBollActivityManager {
|
||||
//ToastUtils.show("finishAll() activity");
|
||||
if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
|
||||
//ToastUtils.show("activity != null ...");
|
||||
if (WinBollUtils.getInstance(mContext).getWinBollUI_TYPE() == WinBollUtils.WinBollUI_TYPE.Service) {
|
||||
if (WinBollGlobalApplication.getWinBollUI_TYPE() == WinBollGlobalApplication.WinBollUI_TYPE.Service) {
|
||||
// 结束窗口和最近任务栏, 建议前台服务类应用使用,可以方便用户再次调用 UI 操作。
|
||||
activity.finishAndRemoveTask();
|
||||
//ToastUtils.show("finishAll() activity.finishAndRemoveTask();");
|
||||
} else if (WinBollUtils.getInstance(mContext).getWinBollUI_TYPE() == WinBollUtils.WinBollUI_TYPE.Aplication) {
|
||||
} else if (WinBollGlobalApplication.getWinBollUI_TYPE() == WinBollGlobalApplication.WinBollUI_TYPE.Aplication) {
|
||||
// 结束窗口保留最近任务栏,建议前台服务类应用使用,可以保持应用的系统自觉性。
|
||||
activity.finish();
|
||||
//ToastUtils.show("finishAll() activity.finish();");
|
||||
|
@@ -7,25 +7,11 @@ import cc.winboll.studio.libapputils.bean.DebugBean;
|
||||
import cc.winboll.studio.libapputils.log.LogUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.hjq.toast.style.WhiteToastStyle;
|
||||
import cc.winboll.studio.GlobalApplication;
|
||||
|
||||
public class WinBollUtils {
|
||||
public class WinBollGlobalApplication extends GlobalApplication {
|
||||
|
||||
public static final String TAG = "WinBollUtils";
|
||||
|
||||
//
|
||||
// 单件结构模块
|
||||
//
|
||||
static volatile WinBollUtils _WinBollUtils;
|
||||
Context mContext;
|
||||
WinBollUtils(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
public static synchronized WinBollUtils getInstance(Context context) {
|
||||
if (_WinBollUtils == null) {
|
||||
_WinBollUtils = new WinBollUtils(context);
|
||||
}
|
||||
return _WinBollUtils;
|
||||
}
|
||||
public static final String TAG = "WinBollGlobalApplication";
|
||||
|
||||
public static enum WinBollUI_TYPE {
|
||||
Aplication, // 退出应用后,保持最近任务栏任务记录主窗口
|
||||
@@ -42,7 +28,7 @@ public class WinBollUtils {
|
||||
static volatile boolean isDebug = false;
|
||||
|
||||
public static void setIsDebug(boolean isDebug) {
|
||||
WinBollUtils.isDebug = isDebug;
|
||||
WinBollGlobalApplication.isDebug = isDebug;
|
||||
}
|
||||
|
||||
public static boolean isDebug() {
|
||||
@@ -59,7 +45,7 @@ public class WinBollUtils {
|
||||
//
|
||||
// 获取 WinBoll 应用 UI 类型
|
||||
//
|
||||
public static WinBollUI_TYPE getWinBollUI_TYPE() {
|
||||
public synchronized static WinBollUI_TYPE getWinBollUI_TYPE() {
|
||||
return _mWinBollUI_TYPE;
|
||||
}
|
||||
|
||||
@@ -67,19 +53,15 @@ public class WinBollUtils {
|
||||
return mMyActivityLifecycleCallbacks;
|
||||
}
|
||||
|
||||
public void init(Application application) {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
// 应用环境初始化, 基本调试环境
|
||||
//
|
||||
// 初始化日志模块
|
||||
LogUtils.init(mContext);
|
||||
// 初始化 Toast 框架
|
||||
ToastUtils.init(application);
|
||||
// 设置 Toast 布局样式
|
||||
//ToastUtils.setView(R.layout.view_toast);
|
||||
ToastUtils.setStyle(new WhiteToastStyle());
|
||||
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
|
||||
LogUtils.init(this);
|
||||
// 设置应用调试标志
|
||||
DebugBean debugBean = DebugBean.loadBean(mContext, DebugBean.class);
|
||||
DebugBean debugBean = DebugBean.loadBean(this, DebugBean.class);
|
||||
if (debugBean == null) {
|
||||
//ToastUtils.show("debugBean == null");
|
||||
setIsDebug(false);
|
||||
@@ -89,8 +71,8 @@ public class WinBollUtils {
|
||||
}
|
||||
// 应用窗口管理模块参数设置
|
||||
//
|
||||
mMyActivityLifecycleCallbacks = new MyActivityLifecycleCallbacks(application);
|
||||
application.registerActivityLifecycleCallbacks(mMyActivityLifecycleCallbacks);
|
||||
mMyActivityLifecycleCallbacks = new MyActivityLifecycleCallbacks(this);
|
||||
registerActivityLifecycleCallbacks(mMyActivityLifecycleCallbacks);
|
||||
// 设置默认 WinBoll 应用 UI 类型
|
||||
setWinBollUI_TYPE(WinBollUI_TYPE.Service);
|
||||
//ToastUtils.show("WinBollUI_TYPE " + getWinBollUI_TYPE());
|
@@ -20,6 +20,10 @@ public class APPInfo implements Serializable {
|
||||
String appDescription;
|
||||
// 应用Git仓库地址
|
||||
String appGitName;
|
||||
// 应用Git仓库分支
|
||||
String appGitAPPBranch;
|
||||
// 应用Git仓库子项目文件夹
|
||||
String appGitAPPSubProjectFolder;
|
||||
// 应用主页
|
||||
String appHomePage;
|
||||
// 应用包名称
|
||||
@@ -27,27 +31,46 @@ public class APPInfo implements Serializable {
|
||||
// 应用包存储文件夹名称
|
||||
String appAPKFolderName;
|
||||
|
||||
public APPInfo(String appName, int appIcon, String appDescription, String appGitName, String appHomePage, String appAPKName, String appAPKFolderName) {
|
||||
public APPInfo(String appName, int appIcon, String appDescription, String appGitName, String appGitAPPBranch, String appGitAPPSubProjectFolder, String appHomePage, String appAPKName, String appAPKFolderName) {
|
||||
this.appName = appName;
|
||||
this.appIcon = appIcon;
|
||||
this.appDescription = appDescription;
|
||||
this.appGitName = appGitName;
|
||||
this.appGitAPPBranch = appGitAPPBranch;
|
||||
this.appGitAPPSubProjectFolder = appGitAPPSubProjectFolder;
|
||||
this.appHomePage = appHomePage;
|
||||
this.appAPKName = appAPKName;
|
||||
this.appAPKFolderName = appAPKFolderName;
|
||||
}
|
||||
|
||||
|
||||
public APPInfo() {
|
||||
this.appName = "WinBoll-APP";
|
||||
this.appIcon = R.drawable.ic_launcher;
|
||||
this.appDescription = "WinBoll APP";
|
||||
this.appGitName = "APP";
|
||||
this.appGitAPPBranch = "app";
|
||||
this.appGitAPPSubProjectFolder = "app";
|
||||
this.appHomePage = "https://www.winboll.cc/studio/details.php?app=APP";
|
||||
this.appAPKName = "APP";
|
||||
this.appAPKFolderName = "APP";
|
||||
}
|
||||
|
||||
public void setAppGitAPPBranch(String appGitAPPBranch) {
|
||||
this.appGitAPPBranch = appGitAPPBranch;
|
||||
}
|
||||
|
||||
public String getAppGitAPPBranch() {
|
||||
return appGitAPPBranch;
|
||||
}
|
||||
|
||||
public void setAppGitAPPSubProjectFolder(String appGitAPPSubProjectFolder) {
|
||||
this.appGitAPPSubProjectFolder = appGitAPPSubProjectFolder;
|
||||
}
|
||||
|
||||
public String getAppGitAPPSubProjectFolder() {
|
||||
return appGitAPPSubProjectFolder;
|
||||
}
|
||||
|
||||
public void setAppIcon(int appIcon) {
|
||||
this.appIcon = appIcon;
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ import android.os.Bundle;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libapputils.R;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivity;
|
||||
import cc.winboll.studio.libapputils.app.WinBollUtils;
|
||||
import cc.winboll.studio.libapputils.app.WinBollGlobalApplication;
|
||||
|
||||
public class LogActivity extends WinBollActivity {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class LogActivity extends WinBollActivity {
|
||||
setContentView(R.layout.activity_log);
|
||||
mLogView = findViewById(R.id.logview);
|
||||
|
||||
if (WinBollUtils.isDebug()) { mLogView.start(); }
|
||||
if (WinBollGlobalApplication.isDebug()) { mLogView.start(); }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -7,7 +7,7 @@ package cc.winboll.studio.libapputils.log;
|
||||
* @Describe 应用日志类
|
||||
*/
|
||||
import android.content.Context;
|
||||
import cc.winboll.studio.libapputils.app.WinBollUtils;
|
||||
import cc.winboll.studio.libapputils.app.WinBollGlobalApplication;
|
||||
import cc.winboll.studio.libapputils.util.FileUtils;
|
||||
import dalvik.system.DexFile;
|
||||
import java.io.BufferedReader;
|
||||
@@ -61,7 +61,7 @@ public class LogUtils {
|
||||
// 初始化函数
|
||||
//
|
||||
public static void init(Context context, LOG_LEVEL logLevel) {
|
||||
if (WinBollUtils.isDebug()) {
|
||||
if (WinBollGlobalApplication.isDebug()) {
|
||||
// 初始化日志缓存文件路径
|
||||
_mfLogCacheDir = new File(context.getApplicationContext().getExternalCacheDir(), TAG);
|
||||
if (!_mfLogCacheDir.exists()) {
|
||||
|
@@ -19,7 +19,7 @@ import android.widget.LinearLayout;
|
||||
import cc.winboll.studio.libapputils.R;
|
||||
import cc.winboll.studio.libapputils.app.AppVersionUtils;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivityManager;
|
||||
import cc.winboll.studio.libapputils.app.WinBollUtils;
|
||||
import cc.winboll.studio.libapputils.app.WinBollGlobalApplication;
|
||||
import cc.winboll.studio.libapputils.bean.APPInfo;
|
||||
import cc.winboll.studio.libapputils.bean.DebugBean;
|
||||
import cc.winboll.studio.libapputils.log.LogUtils;
|
||||
@@ -88,6 +88,8 @@ public class AboutView extends LinearLayout {
|
||||
appInfo.setAppAPKFolderName(typedArray.getString(R.styleable.AboutView_app_apkfoldername));
|
||||
appInfo.setAppAPKName(typedArray.getString(R.styleable.AboutView_app_apkname));
|
||||
appInfo.setAppGitName(typedArray.getString(R.styleable.AboutView_app_gitname));
|
||||
appInfo.setAppGitAPPBranch(typedArray.getString(R.styleable.AboutView_app_gitappbranch));
|
||||
appInfo.setAppGitAPPSubProjectFolder(typedArray.getString(R.styleable.AboutView_app_gitappsubprojectfolder));
|
||||
appInfo.setAppDescription(typedArray.getString(R.styleable.AboutView_appdescription));
|
||||
appInfo.setAppIcon(typedArray.getResourceId(R.styleable.AboutView_appicon, R.drawable.ic_winboll));
|
||||
// 返回一个绑定资源结束的信号给资源
|
||||
@@ -103,7 +105,7 @@ public class AboutView extends LinearLayout {
|
||||
mszAppDescription = mAPPInfo.getAppDescription();
|
||||
mnAppIcon = mAPPInfo.getAppIcon();
|
||||
|
||||
mszWinBollServerHost = WinBollUtils.isDebug() ? "https://dev.winboll.cc": "https://www.winboll.cc";
|
||||
mszWinBollServerHost = WinBollGlobalApplication.isDebug() ? "https://dev.winboll.cc": "https://www.winboll.cc";
|
||||
|
||||
try {
|
||||
mszAppVersionName = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionName;
|
||||
@@ -112,9 +114,9 @@ public class AboutView extends LinearLayout {
|
||||
}
|
||||
mszCurrentAppPackageName = mszAppAPKName + "_" + mszAppVersionName + ".apk";
|
||||
mszHomePage = mszWinBollServerHost + "/studio/details.php?app=" + mszAppAPKFolderName;
|
||||
mszGitea = "https://gitea.winboll.cc/Studio/" + mszAppGitName + ".git";
|
||||
mszGitea = "https://gitea.winboll.cc/Studio/" + mszAppGitName + "/src/branch/" + mAPPInfo.getAppGitAPPBranch() + "/" + mAPPInfo.getAppGitAPPSubProjectFolder();
|
||||
|
||||
if (WinBollUtils.isDebug()) {
|
||||
if (WinBollGlobalApplication.isDebug()) {
|
||||
LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||
View addedView = inflater.inflate(R.layout.view_about_dev, this, false);
|
||||
LinearLayout llMain = addedView.findViewById(R.id.viewaboutdevLinearLayout1);
|
||||
@@ -205,7 +207,7 @@ public class AboutView extends LinearLayout {
|
||||
// 定义应用调试按钮
|
||||
//
|
||||
Element elementAppMode;
|
||||
if (WinBollUtils.isDebug()) {
|
||||
if (WinBollGlobalApplication.isDebug()) {
|
||||
elementAppMode = new Element(mContext.getString(R.string.app_normal), R.drawable.ic_winboll);
|
||||
elementAppMode.setOnClickListener(mAppNormalOnClickListener);
|
||||
} else {
|
||||
@@ -271,7 +273,7 @@ public class AboutView extends LinearLayout {
|
||||
if (intent != null) {
|
||||
intent.setAction(cc.winboll.studio.libapputils.intent.action.DEBUGVIEW);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
WinBollUtils.setIsDebug(true);
|
||||
WinBollGlobalApplication.setIsDebug(true);
|
||||
DebugBean.saveBean(context, new DebugBean(true));
|
||||
|
||||
WinBollActivityManager.getInstance(context).finishAll();
|
||||
@@ -283,7 +285,7 @@ public class AboutView extends LinearLayout {
|
||||
Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
|
||||
if (intent != null) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
WinBollUtils.setIsDebug(false);
|
||||
WinBollGlobalApplication.setIsDebug(false);
|
||||
DebugBean.saveBean(context, new DebugBean(false));
|
||||
|
||||
WinBollActivityManager.getInstance(context).finishAll();
|
||||
@@ -309,7 +311,7 @@ public class AboutView extends LinearLayout {
|
||||
String szUrl = mszWinBollServerHost + "/studio/details.php?app=" + mszAppAPKFolderName;
|
||||
// 构建包含认证信息的请求
|
||||
String credential = "";
|
||||
if (WinBollUtils.isDebug()) {
|
||||
if (WinBollGlobalApplication.isDebug()) {
|
||||
credential = Credentials.basic(metDevUserName.getText().toString(), metDevUserPassword.getText().toString());
|
||||
PrefUtils.saveString(mContext, "metDevUserName", metDevUserName.getText().toString());
|
||||
PrefUtils.saveString(mContext, "metDevUserPassword", metDevUserPassword.getText().toString());
|
||||
|
@@ -5,6 +5,8 @@
|
||||
<attr name="app_apkfoldername" format="string" />
|
||||
<attr name="app_apkname" format="string" />
|
||||
<attr name="app_gitname" format="string" />
|
||||
<attr name="app_gitappbranch" format="string" />
|
||||
<attr name="app_gitappsubprojectfolder" format="string" />
|
||||
<attr name="appdescription" format="string" />
|
||||
<attr name="appicon" format="reference" />
|
||||
</declare-styleable>
|
||||
|
Reference in New Issue
Block a user