Compare commits

...

9 Commits

Author SHA1 Message Date
ZhanGSKen
ea10d1b540 <apputils>APK 9.2.11 release Publish. 2025-01-23 03:33:58 +08:00
ZhanGSKen
81f6ff592e 应用类调整 2025-01-23 03:33:26 +08:00
ZhanGSKen
e6f22e9212 <libapputils>Library Release 9.2.10 2025-01-23 03:05:52 +08:00
ZhanGSKen
8ce8f383fa <apputils>APK 9.2.10 release Publish. 2025-01-23 03:05:41 +08:00
ZhanGSKen
35d32b384f 应用类重构 2025-01-23 03:05:08 +08:00
ZhanGSKen
85e86ddf05 <libapputils>Library Release 9.2.9 2025-01-23 02:44:03 +08:00
ZhanGSKen
99bf804625 <apputils>APK 9.2.9 release Publish. 2025-01-23 02:43:51 +08:00
ZhanGSKen
261259e61e 应用类重构 2025-01-23 02:43:15 +08:00
ZhanGSKen
9aaf3433bd <libapputils>Library Release 9.2.8 2025-01-23 02:30:30 +08:00
11 changed files with 53 additions and 65 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Thu Jan 23 02:30:17 HKT 2025
stageCount=9
#Thu Jan 23 03:33:58 HKT 2025
stageCount=12
libraryProject=libapputils
baseVersion=9.2
publishVersion=9.2.8
publishVersion=9.2.11
buildCount=0
baseBetaVersion=9.2.9
baseBetaVersion=9.2.12

View File

@@ -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,14 +19,6 @@ public class App extends GlobalApplication {
@Override
public void onCreate() {
super.onCreate();
// 初始化 WinBoll 框架
WinBollUtils.init(this);
// 初始化 Toast 框架
ToastUtils.init(this);
// 设置 Toast 布局样式
//ToastUtils.setView(R.layout.view_toast);
ToastUtils.setStyle(new WhiteToastStyle());
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
}
}

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Thu Jan 23 02:30:17 HKT 2025
stageCount=9
#Thu Jan 23 03:33:58 HKT 2025
stageCount=12
libraryProject=libapputils
baseVersion=9.2
publishVersion=9.2.8
publishVersion=9.2.11
buildCount=0
baseBetaVersion=9.2.9
baseBetaVersion=9.2.12

View File

@@ -17,12 +17,10 @@ public class MyActivityLifecycleCallbacks implements Application.ActivityLifecyc
public static final String TAG = "MyActivityLifecycleCallbacks";
Application mApplication;
public String mInfo = "";
public MyActivityLifecycleCallbacks(Application application) {
mApplication = application;
public MyActivityLifecycleCallbacks() {
}
void createActivityeInfo(Activity activity) {

View File

@@ -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);
@@ -365,7 +365,11 @@ abstract public class WinBollActivity extends AppCompatActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
LogUtils.d(TAG, "onOptionsItemSelected");
if (item.getItemId() == R.id.item_log) {
if (item.getItemId() == R.id.item_testcrashreport) {
for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
getString(i);
}
} else if (item.getItemId() == R.id.item_log) {
// LogUtils.d(TAG, "item_log not yet.");
// Intent intent = new Intent(this, LogActivity.class);
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);

View File

@@ -171,11 +171,11 @@ public class WinBollActivityManager {
//ToastUtils.show("finishAll() activity");
if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
//ToastUtils.show("activity != null ...");
if (WinBollUtils.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.getWinBollUI_TYPE() == WinBollUtils.WinBollUI_TYPE.Aplication) {
} else if (WinBollGlobalApplication.getWinBollUI_TYPE() == WinBollGlobalApplication.WinBollUI_TYPE.Aplication) {
// 结束窗口保留最近任务栏,建议前台服务类应用使用,可以保持应用的系统自觉性。
activity.finish();
//ToastUtils.show("finishAll() activity.finish();");

View File

@@ -9,24 +9,9 @@ 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;
Application mApplication;
WinBollUtils(Application application) {
mApplication = application;
}
static synchronized WinBollUtils getInstance(Application application) {
if (_WinBollUtils == null) {
_WinBollUtils = new WinBollUtils(application);
}
return _WinBollUtils;
}
public static final String TAG = "WinBollGlobalApplication";
public static enum WinBollUI_TYPE {
Aplication, // 退出应用后保持最近任务栏任务记录主窗口
@@ -42,8 +27,8 @@ public class WinBollUtils {
// 标记当前应用是否处于调试状态
static volatile boolean isDebug = false;
public static void setIsDebug(boolean isDebug) {
WinBollUtils.isDebug = isDebug;
public synchronized static void setIsDebug(boolean isDebug) {
WinBollGlobalApplication.isDebug = isDebug;
}
public static boolean isDebug() {
@@ -53,7 +38,7 @@ public class WinBollUtils {
//
// 设置 WinBoll 应用 UI 类型
//
public static void setWinBollUI_TYPE(WinBollUI_TYPE mWinBollUI_TYPE) {
public synchronized static void setWinBollUI_TYPE(WinBollUI_TYPE mWinBollUI_TYPE) {
_mWinBollUI_TYPE = mWinBollUI_TYPE;
}
@@ -68,14 +53,22 @@ public class WinBollUtils {
return mMyActivityLifecycleCallbacks;
}
public static void init(Application application) {
WinBollUtils winBollUtils = WinBollUtils.getInstance(application);
@Override
public void onCreate() {
super.onCreate();
// 应用环境初始化, 基本调试环境
//
// 初始化日志模块
LogUtils.init(application);
LogUtils.init(this);
// 初始化 Toast 框架
ToastUtils.init(this);
// 设置 Toast 布局样式
//ToastUtils.setView(R.layout.view_toast);
ToastUtils.setStyle(new WhiteToastStyle());
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
// 设置应用调试标志
DebugBean debugBean = DebugBean.loadBean(application, DebugBean.class);
DebugBean debugBean = DebugBean.loadBean(this, DebugBean.class);
if (debugBean == null) {
//ToastUtils.show("debugBean == null");
setIsDebug(false);
@@ -85,8 +78,8 @@ public class WinBollUtils {
}
// 应用窗口管理模块参数设置
//
winBollUtils.mMyActivityLifecycleCallbacks = new MyActivityLifecycleCallbacks(application);
application.registerActivityLifecycleCallbacks(winBollUtils.mMyActivityLifecycleCallbacks);
//mMyActivityLifecycleCallbacks = new MyActivityLifecycleCallbacks();
//registerActivityLifecycleCallbacks(mMyActivityLifecycleCallbacks);
// 设置默认 WinBoll 应用 UI 类型
setWinBollUI_TYPE(WinBollUI_TYPE.Service);
//ToastUtils.show("WinBollUI_TYPE " + getWinBollUI_TYPE());

View File

@@ -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

View File

@@ -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()) {

View File

@@ -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;
@@ -105,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;
@@ -116,7 +116,7 @@ public class AboutView extends LinearLayout {
mszHomePage = mszWinBollServerHost + "/studio/details.php?app=" + mszAppAPKFolderName;
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);
@@ -207,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 {
@@ -273,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();
@@ -285,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();
@@ -311,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());

View File

@@ -15,6 +15,9 @@
<item android:title="DebugTools">
<menu>
<item
android:id="@+id/item_testcrashreport"
android:title="Test Application Crash Report"/>
<item
android:id="@+id/item_unittest"
android:title="UnitTest"/>