Compare commits
59 Commits
powerbell-
...
apputils-v
Author | SHA1 | Date | |
---|---|---|---|
![]() |
19db567a7d | ||
![]() |
b14add854e | ||
![]() |
104d9fa283 | ||
![]() |
dd041e5d78 | ||
![]() |
2f019ae176 | ||
![]() |
b5b4fbd3f5 | ||
![]() |
548dcf74ed | ||
![]() |
547bf894c6 | ||
![]() |
09e6429726 | ||
![]() |
3ad9bb262e | ||
![]() |
15992da22f | ||
![]() |
7fb4e665f9 | ||
![]() |
6a82889926 | ||
![]() |
7272cc4e5b | ||
![]() |
1f7d112a8a | ||
![]() |
936e214015 | ||
![]() |
46e95d1b1f | ||
![]() |
15173f7af3 | ||
![]() |
6f3b6c40af | ||
![]() |
42ffba69e5 | ||
![]() |
f021e8a1a3 | ||
![]() |
02ce7dedb0 | ||
![]() |
8e290cd5e6 | ||
![]() |
37f2aa5f1b | ||
![]() |
10cc69940b | ||
![]() |
bfdff9ff2f | ||
![]() |
12c6129a61 | ||
![]() |
ea10d1b540 | ||
![]() |
81f6ff592e | ||
![]() |
e6f22e9212 | ||
![]() |
8ce8f383fa | ||
![]() |
35d32b384f | ||
![]() |
85e86ddf05 | ||
![]() |
99bf804625 | ||
![]() |
261259e61e | ||
![]() |
9aaf3433bd | ||
![]() |
b739510951 | ||
![]() |
903359d9a2 | ||
![]() |
69e7e72ed8 | ||
![]() |
a96ba362b4 | ||
![]() |
6447bcf924 | ||
![]() |
18ed325731 | ||
![]() |
16e3d10b63 | ||
![]() |
8b0e8b00ae | ||
![]() |
7f61ff1470 | ||
![]() |
c4e0c23a0c | ||
![]() |
c7d26bbc3d | ||
![]() |
4968bbaeae | ||
![]() |
8e6b06e366 | ||
![]() |
ae7fb2984a | ||
![]() |
a4d009f8fb | ||
![]() |
5a549e9652 | ||
![]() |
e2d71ae088 | ||
![]() |
506d2619f2 | ||
![]() |
17fa805a7f | ||
![]() |
1dcf8cd007 | ||
![]() |
d86d50212e | ||
![]() |
af2e09c02a | ||
![]() |
de6361b19b |
@@ -29,7 +29,7 @@ android {
|
||||
// versionName 更新后需要手动设置
|
||||
// 项目模块目录的 build.gradle 文件的 stageCount=0
|
||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||
versionName "9.2"
|
||||
versionName "9.3"
|
||||
if(true) {
|
||||
versionName = genVersionName("${versionName}")
|
||||
}
|
||||
@@ -50,6 +50,6 @@ android {
|
||||
|
||||
dependencies {
|
||||
api project(':libapputils')
|
||||
api 'cc.winboll.studio:libappbase:1.0.3'
|
||||
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Sat Jan 18 13:03:10 HKT 2025
|
||||
#Thu Feb 06 11:02:45 HKT 2025
|
||||
stageCount=2
|
||||
libraryProject=libapputils
|
||||
baseVersion=9.2
|
||||
publishVersion=9.2.1
|
||||
baseVersion=9.3
|
||||
publishVersion=9.3.1
|
||||
buildCount=0
|
||||
baseBetaVersion=9.2.2
|
||||
baseBetaVersion=9.3.2
|
||||
|
@@ -27,10 +27,8 @@
|
||||
|
||||
</activity>
|
||||
|
||||
<activity android:name=".TestWinBollActivity"/>
|
||||
|
||||
<activity android:name=".TestStringToQrCodeViewActivity"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
|
@@ -5,27 +5,86 @@ package cc.winboll.studio.apputils;
|
||||
* @Date 2024/12/08 15:10:51
|
||||
* @Describe 全局应用类
|
||||
*/
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.view.Gravity;
|
||||
import cc.winboll.studio.libapputils.app.WinBollApplication;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libapputils.app.MyActivityLifecycleCallbacks;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivityManager;
|
||||
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;
|
||||
|
||||
public class App extends WinBollApplication {
|
||||
public class App extends GlobalApplication {
|
||||
|
||||
public static final String TAG = "App";
|
||||
|
||||
public static final String _ACTION_DEBUGVIEW = WinBollApplication.class.getName() + "_ACTION_DEBUGVIEW";
|
||||
public static final String _ACTION_DEBUGVIEW = App.class.getName() + "_ACTION_DEBUGVIEW";
|
||||
|
||||
//static volatile WinBollApplication _WinBollApplication = null;
|
||||
MyActivityLifecycleCallbacks mMyActivityLifecycleCallbacks;
|
||||
|
||||
// 标记当前应用是否处于调试状态
|
||||
static volatile boolean isDebug = false;
|
||||
|
||||
public synchronized static void setIsDebug(boolean isDebug) {
|
||||
App.isDebug = isDebug;
|
||||
}
|
||||
|
||||
public static boolean isDebug() {
|
||||
return isDebug;
|
||||
}
|
||||
|
||||
MyActivityLifecycleCallbacks getMyActivityLifecycleCallbacks() {
|
||||
return mMyActivityLifecycleCallbacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getApplicationContext() {
|
||||
return super.getApplicationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Application getApplication() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
// 初始化 Toast 框架
|
||||
// 应用环境初始化, 基本调试环境
|
||||
//
|
||||
ToastUtils.init(this);
|
||||
// 设置 Toast 布局样式
|
||||
//ToastUtils.setView(R.layout.view_toast);
|
||||
ToastUtils.setStyle(new WhiteToastStyle());
|
||||
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
|
||||
}
|
||||
// 初始化日志模块
|
||||
LogUtils.init(this);
|
||||
|
||||
try {
|
||||
// 初始化 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(this, DebugBean.class);
|
||||
if (debugBean == null) {
|
||||
//ToastUtils.show("debugBean == null");
|
||||
setIsDebug(false);
|
||||
} else {
|
||||
//ToastUtils.show("saveDebugStatus(" + String.valueOf(debugBean.isDebuging()) + ")");
|
||||
setIsDebug(debugBean.isDebuging());
|
||||
}
|
||||
// 应用窗口管理模块参数设置
|
||||
//
|
||||
mMyActivityLifecycleCallbacks = new MyActivityLifecycleCallbacks();
|
||||
registerActivityLifecycleCallbacks(mMyActivityLifecycleCallbacks);
|
||||
// 设置默认 WinBoll 应用 UI 类型
|
||||
WinBollActivityManager.getInstance(this).setWinBollUI_TYPE(WinBollActivityManager.WinBollUI_TYPE.Service);
|
||||
//ToastUtils.show("WinBollUI_TYPE " + getWinBollUI_TYPE());
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,28 +1,81 @@
|
||||
package cc.winboll.studio.apputils;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.apputils.R;
|
||||
import cc.winboll.studio.libapputils.activities.AssetsHtmlActivity;
|
||||
import cc.winboll.studio.libapputils.activities.QRCodeDecodeActivity;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivity;
|
||||
import cc.winboll.studio.libapputils.app.AboutActivityFactory;
|
||||
import cc.winboll.studio.libapputils.app.IWinBollActivity;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivityManager;
|
||||
import cc.winboll.studio.libapputils.bean.APPInfo;
|
||||
import cc.winboll.studio.libapputils.log.LogActivity;
|
||||
import cc.winboll.studio.libapputils.log.LogUtils;
|
||||
import cc.winboll.studio.libapputils.view.AboutView;
|
||||
import cc.winboll.studio.libapputils.view.YesNoAlertDialog;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
final public class MainActivity extends WinBollActivity {
|
||||
final public class MainActivity extends AppCompatActivity implements IWinBollActivity {
|
||||
|
||||
public static final String TAG = "MainActivity";
|
||||
|
||||
public static final int REQUEST_QRCODEDECODE_ACTIVITY = 0;
|
||||
|
||||
Toolbar mToolbar;
|
||||
|
||||
@Override
|
||||
protected boolean isEnableDisplayHomeAsUp() {
|
||||
public AppCompatActivity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public APPInfo getAppInfo() {
|
||||
String szBranchName = "apputils";
|
||||
|
||||
APPInfo appInfo = AboutActivityFactory.buildDefaultAPPInfo();
|
||||
appInfo.setAppName("APPUtils");
|
||||
appInfo.setAppIcon(cc.winboll.studio.libapputils.R.drawable.ic_winboll);
|
||||
appInfo.setAppDescription("APPUtils Description");
|
||||
appInfo.setAppGitName("APP");
|
||||
appInfo.setAppGitOwner("Studio");
|
||||
appInfo.setAppGitAPPBranch(szBranchName);
|
||||
appInfo.setAppGitAPPSubProjectFolder(szBranchName);
|
||||
appInfo.setAppHomePage("https://www.winboll.cc/studio/details.php?app=APP");
|
||||
appInfo.setAppAPKName("APPUtils");
|
||||
appInfo.setAppAPKFolderName("APPUtils");
|
||||
return appInfo;
|
||||
//return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAddWinBollToolBar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Toolbar initToolBar() {
|
||||
return findViewById(R.id.activitymainToolbar1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnableDisplayHomeAsUp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31,8 +84,19 @@ final public class MainActivity extends WinBollActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
//Toolbar toolbar = findViewById(R.id.activitymainToolbar1);
|
||||
//setActionBar(toolbar);
|
||||
// 初始化工具栏
|
||||
mToolbar = findViewById(R.id.activitymainToolbar1);
|
||||
setSupportActionBar(mToolbar);
|
||||
if (isEnableDisplayHomeAsUp()) {
|
||||
// 显示后退按钮
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
getSupportActionBar().setSubtitle(getTag());
|
||||
|
||||
checkResolveActivity();
|
||||
archiveInstance();
|
||||
|
||||
|
||||
|
||||
// 接收并处理 Intent 数据,函数 Intent 处理接收就直接返回
|
||||
//if (prosessIntents(getIntent())) return;
|
||||
@@ -44,44 +108,94 @@ final public class MainActivity extends WinBollActivity {
|
||||
// LogUtils.d(TAG, "BuildConfig.DEBUG : " + Boolean.toString(BuildConfig.DEBUG));
|
||||
}
|
||||
|
||||
boolean checkResolveActivity() {
|
||||
PackageManager packageManager = getPackageManager();
|
||||
//Intent intent = new Intent("your_action_here");
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if (resolveInfoList.size() > 0) {
|
||||
// 传入的Intent action在Activity清单的intent-filter的action节点里有定义
|
||||
if (intent.getAction() != null) {
|
||||
if (intent.getAction().equals(cc.winboll.studio.libapputils.intent.action.DEBUGVIEW)) {
|
||||
App.setIsDebug(true);
|
||||
//ToastUtils.show!("WinBollApplication.setIsDebug(true) by action : " + intent.getAction());
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
// 传入的Intent action在Activity清单的intent-filter的action节点里没有定义
|
||||
//ToastUtils.show("false : " + intent.getAction());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// action在清单文件中没有声明
|
||||
ToastUtils.show("false");
|
||||
return false;
|
||||
}
|
||||
|
||||
void archiveInstance() {
|
||||
Intent intent = getIntent();
|
||||
StringBuilder sb = new StringBuilder("\n### Archive Instance ###\n");
|
||||
|
||||
if (intent != null) {
|
||||
ComponentName componentName = intent.getComponent();
|
||||
if (componentName != null) {
|
||||
String packageName = componentName.getPackageName();
|
||||
//Log.d("AppStarter", "启动本应用的应用包名: " + packageName);
|
||||
sb.append("启动本应用的应用包名: \n" + packageName);
|
||||
}
|
||||
|
||||
sb.append("\nImplicit Intent Tracker :\n接收到的 Intent 动作: \n" + intent.getAction());
|
||||
Set<String> categories = intent.getCategories();
|
||||
if (categories != null) {
|
||||
for (String category : categories) {
|
||||
sb.append("\n接收到的 Intent 类别 :\n" + category);
|
||||
}
|
||||
}
|
||||
Uri data = intent.getData();
|
||||
if (data != null) {
|
||||
sb.append("\n接收到的 Intent 数据 :\n" + data.toString());
|
||||
}
|
||||
} else {
|
||||
sb.append("Intent is null.");
|
||||
}
|
||||
sb.append("\n\n");
|
||||
LogUtils.d(TAG, sb.toString());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
// 缓存当前 activity
|
||||
WinBollActivityManager.getInstance(this).add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
WinBollActivityManager.getInstance(this).registeRemove(this);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
public void onTestLogClick(View view) {
|
||||
LogUtils.d(TAG, "onTestLogClick");
|
||||
Toast.makeText(getApplication(), "onTestLogClick", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public void onLogUtilsClick(View view) {
|
||||
Intent intent = new Intent(this, LogActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
// Intent intent = new Intent(this, LogActivity.class);
|
||||
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
// intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
// startActivity(intent);
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
// setSubTitle("");
|
||||
//WinBollActivityManager.getInstance().printAvtivityListInfo();
|
||||
WinBollActivityManager.getInstance(this).startWinBollActivity(this, LogActivity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// exit();
|
||||
}
|
||||
|
||||
// void exit() {
|
||||
// YesNoAlertDialog.OnDialogResultListener listener = new YesNoAlertDialog.OnDialogResultListener(){
|
||||
//
|
||||
// @Override
|
||||
// public void onYes() {
|
||||
// WinBollActivityManager.getInstance(getApplicationContext()).finishAll();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNo() {
|
||||
// }
|
||||
// };
|
||||
// YesNoAlertDialog.show(this, "[ " + getString(R.string.app_name) + " ]", "Exit(Yes/No).\nIs close all activity?", listener);
|
||||
// }
|
||||
|
||||
//
|
||||
// 处理传入的 Intent 数据
|
||||
//
|
||||
@@ -125,58 +239,108 @@ final public class MainActivity extends WinBollActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAddWinBollToolBar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Toolbar initToolBar() {
|
||||
return findViewById(R.id.activitymainToolbar1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
//ToastUtils.show("onCreateOptionsMenu");
|
||||
getMenuInflater().inflate(R.menu.toolbar_main, menu);
|
||||
if (isAddWinBollToolBar()) {
|
||||
//ToastUtils.show("mIWinBoll.isAddWinBollToolBar()");
|
||||
getMenuInflater().inflate(R.menu.toolbar_winboll_shared_main, menu);
|
||||
}
|
||||
if (App.isDebug()) {
|
||||
getMenuInflater().inflate(R.menu.toolbar_studio_debug, menu);
|
||||
}
|
||||
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.item_testwinboll) {
|
||||
WinBollActivityManager.getInstance(this).startWinBollActivity(this, TestWinBollActivity.class);
|
||||
if (item.getItemId() == R.id.item_exit) {
|
||||
exit();
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.item_about) {
|
||||
AboutActivityFactory.showAboutActivity(this, getAppInfo());
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.item_teststringtoqrcodeview) {
|
||||
WinBollActivityManager.getInstance(this).startWinBollActivity(this, TestStringToQrCodeViewActivity.class);
|
||||
} else if (item.getItemId() == R.id.item_testqrcodedecodeactivity) {
|
||||
Intent intent = new Intent(this, QRCodeDecodeActivity.class);
|
||||
startActivityForResult(intent, REQUEST_QRCODEDECODE_ACTIVITY);
|
||||
} else if (item.getItemId() == R.id.item_testcrashreport) {
|
||||
for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
|
||||
getString(i);
|
||||
}
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.item_log) {
|
||||
WinBollActivityManager.getInstance(this).startWinBollActivity(this, LogActivity.class);
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.item_exitdebug) {
|
||||
AboutView.setApp2NormalMode(this);
|
||||
return true;
|
||||
} else if (item.getItemId() == android.R.id.home) {
|
||||
WinBollActivityManager.getInstance(this).finish(this);
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
void about() {
|
||||
// Intent intent = new Intent(this, AboutActivity.class);
|
||||
// intent.putExtra(AboutActivity.EXTRA_APPINFO, AboutActivityFactory.buildAPPBranchInfo(this));
|
||||
// WinBollActivityManager.getInstance(this).startWinBollActivity(this, intent, AboutActivity.class);
|
||||
}
|
||||
|
||||
void exit() {
|
||||
YesNoAlertDialog.OnDialogResultListener listener = new YesNoAlertDialog.OnDialogResultListener(){
|
||||
|
||||
@Override
|
||||
public void onYes() {
|
||||
WinBollActivityManager.getInstance(getApplicationContext()).finishAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNo() {
|
||||
}
|
||||
};
|
||||
YesNoAlertDialog.show(this, "[ " + getString(R.string.app_name) + " ]", "Exit(Yes/No).\nIs close all activity?", listener);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (WinBollActivityManager.getInstance(getApplicationContext()).isFirstIWinBollActivity(this)) {
|
||||
exit();
|
||||
} else {
|
||||
WinBollActivityManager.getInstance(this).finish(this);
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
public void onTestAboutActivity(View view) {
|
||||
about();
|
||||
}
|
||||
|
||||
public void onTestJavascriptHtmlActivity(View view) {
|
||||
Intent intent = new Intent(this, AssetsHtmlActivity.class);
|
||||
intent.putExtra(AssetsHtmlActivity.EXTRA_HTMLFILENAME, "javascript_test.html");
|
||||
WinBollActivityManager.getInstance(this).startWinBollActivity(this, intent, AssetsHtmlActivity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
case REQUEST_QRCODEDECODE_ACTIVITY : {
|
||||
String text = data.getStringExtra(QRCodeDecodeActivity.EXTRA_RESULT);
|
||||
ToastUtils.show(text);
|
||||
break;
|
||||
}
|
||||
default : {
|
||||
ToastUtils.show(String.format("%d, %d", requestCode, resultCode));
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*@Override
|
||||
protected void onActivithyResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
case REQUEST_QRCODEDECODE_ACTIVITY : {
|
||||
if (data != null) {
|
||||
String text = data.getStringExtra(QRCodeDecodeActivity.EXTRA_RESULT);
|
||||
ToastUtils.show(text);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default : {
|
||||
//ToastUtils.show(String.format("%d, %d", requestCode, resultCode));
|
||||
super.prosessActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@@ -1,19 +1,31 @@
|
||||
package cc.winboll.studio.apputils;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivity;
|
||||
import cc.winboll.studio.libapputils.app.IWinBollActivity;
|
||||
import cc.winboll.studio.libapputils.bean.APPInfo;
|
||||
import cc.winboll.studio.libapputils.view.StringToQrCodeView;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2025/01/17 19:50:46
|
||||
*/
|
||||
public class TestStringToQrCodeViewActivity extends WinBollActivity {
|
||||
|
||||
public class TestStringToQrCodeViewActivity extends AppCompatActivity implements IWinBollActivity {
|
||||
|
||||
public static final String TAG = "TestStringToQrCodeViewActivity";
|
||||
|
||||
|
||||
StringToQrCodeView mStringToQrCodeView;
|
||||
|
||||
@Override
|
||||
public AppCompatActivity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public APPInfo getAppInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
@@ -21,17 +33,17 @@ public class TestStringToQrCodeViewActivity extends WinBollActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Toolbar initToolBar() {
|
||||
public Toolbar initToolBar() {
|
||||
return findViewById(R.id.activityteststringtoqrcodeviewToolbar1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnableDisplayHomeAsUp() {
|
||||
public boolean isEnableDisplayHomeAsUp() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAddWinBollToolBar() {
|
||||
public boolean isAddWinBollToolBar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -41,10 +53,4 @@ public class TestStringToQrCodeViewActivity extends WinBollActivity {
|
||||
setContentView(R.layout.activity_teststringtoqrcodeview);
|
||||
mStringToQrCodeView = findViewById(R.id.activityteststringtoqrcodeviewStringToQrCodeView1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
setSubTitle(TAG);
|
||||
}
|
||||
}
|
||||
|
@@ -1,52 +0,0 @@
|
||||
package cc.winboll.studio.apputils;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libapputils.activities.AssetsHtmlActivity;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivity;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivityManager;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2025/01/13 15:09:46
|
||||
*/
|
||||
public class TestWinBollActivity extends WinBollActivity {
|
||||
|
||||
public static final String TAG = "TestWinBollActivity";
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Toolbar initToolBar() {
|
||||
return findViewById(R.id.activitytestwinbollToolbar1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnableDisplayHomeAsUp() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAddWinBollToolBar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_testwinboll);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
setSubTitle(TAG);
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -54,6 +54,20 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right">
|
||||
|
||||
<cc.winboll.studio.libapputils.view.AboutBranchButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="About"
|
||||
android:textAllCaps="false"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@@ -38,7 +38,7 @@ dependencies {
|
||||
api 'androidx.fragment:fragment:1.0.0'
|
||||
api 'com.google.android.material:material:1.0.0'
|
||||
|
||||
api 'cc.winboll.studio:libappbase:1.0.3'
|
||||
api 'cc.winboll.studio:libappbase:1.2.0'
|
||||
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Sat Jan 18 13:02:39 HKT 2025
|
||||
#Thu Feb 06 11:02:45 HKT 2025
|
||||
stageCount=2
|
||||
libraryProject=libapputils
|
||||
baseVersion=9.2
|
||||
publishVersion=9.2.1
|
||||
baseVersion=9.3
|
||||
publishVersion=9.3.1
|
||||
buildCount=0
|
||||
baseBetaVersion=9.2.2
|
||||
baseBetaVersion=9.3.2
|
||||
|
@@ -18,6 +18,9 @@
|
||||
<!-- 拍摄照片和视频 -->
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
|
||||
<!-- 拥有完全的网络访问权限 -->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<application android:networkSecurityConfig="@xml/network_security_config">
|
||||
|
||||
<activity
|
||||
@@ -45,4 +48,4 @@
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
|
@@ -1,70 +1,81 @@
|
||||
package cc.winboll.studio.libapputils.activities;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libapputils.R;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivity;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivityManager;
|
||||
import cc.winboll.studio.libapputils.log.LogUtils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2024/07/14 13:20:33
|
||||
* @Describe AboutFragment Test
|
||||
* @Describe 应用介绍页
|
||||
*/
|
||||
final public class AboutActivity extends WinBollActivity {
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libapputils.R;
|
||||
import cc.winboll.studio.libapputils.app.IWinBollActivity;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivityManager;
|
||||
import cc.winboll.studio.libapputils.bean.APPInfo;
|
||||
import cc.winboll.studio.libapputils.view.AboutView;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
|
||||
final public class AboutActivity extends AppCompatActivity implements IWinBollActivity {
|
||||
|
||||
public static final String TAG = "AboutActivity";
|
||||
|
||||
public static final String EXTRA_APPINFO = "EXTRA_APPINFO";
|
||||
|
||||
|
||||
APPInfo mAPPInfo;
|
||||
|
||||
@Override
|
||||
public AppCompatActivity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public APPInfo getAppInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnableDisplayHomeAsUp() {
|
||||
public boolean isEnableDisplayHomeAsUp() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAddWinBollToolBar() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Toolbar initToolBar() {
|
||||
return findViewById(R.id.activityaboutToolbar1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about);
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
mAPPInfo = (APPInfo)intent.getSerializableExtra(EXTRA_APPINFO);
|
||||
}
|
||||
if (mAPPInfo == null) {
|
||||
mAPPInfo = new APPInfo();
|
||||
}
|
||||
|
||||
/*AboutView aboutView = findViewById(R.id.activityaboutAboutView1);
|
||||
aboutView.setOnRequestDevUserInfoAutofillListener(new AboutView.OnRequestDevUserInfoAutofillListener(){
|
||||
AboutView aboutView = new AboutView(this, mAPPInfo);
|
||||
LinearLayout llMain = findViewById(R.id.activityaboutLinearLayout1);
|
||||
llMain.addView(aboutView);
|
||||
|
||||
@Override
|
||||
public void requestAutofill(EditText etDevUserName, EditText etDevUserPassword) {
|
||||
AutofillManager autofillManager = (AutofillManager) getSystemService(AutofillManager.class);
|
||||
if (autofillManager!= null) {
|
||||
//ToastUtils.show("0");
|
||||
autofillManager.requestAutofill(findViewById(R.id.usernameEditText));
|
||||
autofillManager.requestAutofill(findViewById(R.id.passwordEditText));
|
||||
}
|
||||
}
|
||||
});*/
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
setSubTitle(TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAddWinBollToolBar() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Toolbar initToolBar() {
|
||||
return findViewById(R.id.activityaboutToolbar1);
|
||||
//ToastUtils.show(TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,15 +84,11 @@ final public class AboutActivity extends WinBollActivity {
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.item_help) {
|
||||
WinBollActivityManager.getInstance(this).startWinBollActivity(this, AssetsHtmlActivity.class);
|
||||
}
|
||||
// else if (item.getItemId() == android.R.id.home) {
|
||||
// WinBollActivityManager.getInstance(this).finish(this);
|
||||
// }
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
@@ -11,22 +11,23 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libapputils.R;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivity;
|
||||
import cc.winboll.studio.libapputils.app.IWinBollActivity;
|
||||
import cc.winboll.studio.libapputils.log.LogUtils;
|
||||
import cc.winboll.studio.libapputils.view.SimpleWebView;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import android.os.PersistableBundle;
|
||||
import cc.winboll.studio.libapputils.bean.APPInfo;
|
||||
|
||||
public class AssetsHtmlActivity extends WinBollActivity {
|
||||
public class AssetsHtmlActivity extends AppCompatActivity implements IWinBollActivity {
|
||||
|
||||
public static final String TAG = "AssetsHtmlActivity";
|
||||
|
||||
|
||||
public static final String EXTRA_HTMLFILENAME = "EXTRA_HTMLFILENAME";
|
||||
|
||||
|
||||
String mszHelpIndexFilePath = "";
|
||||
Uri mszHelpIndexFileUri;
|
||||
Context mContext;
|
||||
@@ -34,24 +35,34 @@ public class AssetsHtmlActivity extends WinBollActivity {
|
||||
// Assets 文件夹里的 Html 文件的名称
|
||||
String mszHtmlFileName;
|
||||
|
||||
@Override
|
||||
public AppCompatActivity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public APPInfo getAppInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnableDisplayHomeAsUp() {
|
||||
public boolean isEnableDisplayHomeAsUp() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean isAddWinBollToolBar() {
|
||||
public boolean isAddWinBollToolBar() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Toolbar initToolBar() {
|
||||
public Toolbar initToolBar() {
|
||||
return findViewById(R.id.activityassetshtmlToolbar1);
|
||||
}
|
||||
|
||||
@@ -81,7 +92,7 @@ public class AssetsHtmlActivity extends WinBollActivity {
|
||||
if (szTemp != null && !szTemp.trim().equals("")) {
|
||||
mszHtmlFileName = szTemp.trim();
|
||||
}
|
||||
ToastUtils.show(mszHtmlFileName);
|
||||
//ToastUtils.show(mszHtmlFileName);
|
||||
}
|
||||
|
||||
// 与其他应用分享 html 帮助
|
||||
@@ -107,13 +118,6 @@ public class AssetsHtmlActivity extends WinBollActivity {
|
||||
// myWebView.loadUrl(mszHelpIndexFileUri.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
|
||||
super.onPostCreate(savedInstanceState, persistentState);
|
||||
setSubTitle(mszHtmlFileName);
|
||||
//setSubTitle(TAG);
|
||||
}
|
||||
|
||||
//
|
||||
void initWebViewFromAssets(String szHtmlFileName) {
|
||||
try {
|
||||
|
@@ -9,25 +9,38 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import cc.winboll.studio.libapputils.R;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivity;
|
||||
import cc.winboll.studio.libapputils.app.IWinBollActivity;
|
||||
import cc.winboll.studio.libapputils.bean.APPInfo;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.journeyapps.barcodescanner.BarcodeCallback;
|
||||
import com.journeyapps.barcodescanner.BarcodeResult;
|
||||
import com.journeyapps.barcodescanner.DecoratedBarcodeView;
|
||||
import java.util.List;
|
||||
|
||||
public class QRCodeDecodeActivity extends WinBollActivity {
|
||||
public class QRCodeDecodeActivity extends AppCompatActivity implements IWinBollActivity {
|
||||
|
||||
public static final String TAG = "QRCodeDecodeActivity";
|
||||
public static final String EXTRA_RESULT = "EXTRA_RESULT";
|
||||
|
||||
public static final String EXTRA_RESULT = "EXTRA_RESULT";
|
||||
private static final int REQUEST_CAMERA_PERMISSION = 1;
|
||||
|
||||
TextView resultTextView;
|
||||
DecoratedBarcodeView barcodeView;
|
||||
|
||||
@Override
|
||||
public AppCompatActivity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public APPInfo getAppInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
@@ -35,18 +48,18 @@ public class QRCodeDecodeActivity extends WinBollActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnableDisplayHomeAsUp() {
|
||||
public boolean isEnableDisplayHomeAsUp() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean isAddWinBollToolBar() {
|
||||
public boolean isAddWinBollToolBar() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Toolbar initToolBar() {
|
||||
public Toolbar initToolBar() {
|
||||
return findViewById(R.id.activityqrcodedecodeToolbar1);
|
||||
}
|
||||
|
||||
@@ -66,7 +79,7 @@ public class QRCodeDecodeActivity extends WinBollActivity {
|
||||
startScanning();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void startScanning() {
|
||||
|
@@ -1,240 +0,0 @@
|
||||
package cc.winboll.studio.libapputils.ads;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2024/12/09 15:37:35
|
||||
* @Describe WinBoll 应用推广视图
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.RelativeLayout;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
|
||||
public class ADsView extends RelativeLayout {
|
||||
|
||||
public static final String TAG = "ADsView";
|
||||
|
||||
public volatile boolean mIsHandling;
|
||||
public volatile boolean mIsAddNewLog;
|
||||
|
||||
Context mContext;
|
||||
WebView mWebView;
|
||||
//ScrollView mScrollView;
|
||||
//TextView mTextView;
|
||||
//CheckBox mSelectableCheckBox;
|
||||
//LogViewThread mLogViewThread;
|
||||
//LogViewHandler mLogViewHandler;
|
||||
//Spinner mLogLevelSpinner;
|
||||
//ArrayAdapter<CharSequence> mLogLevelSpinnerAdapter;
|
||||
|
||||
public ADsView(Context context) {
|
||||
super(context);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public ADsView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public ADsView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public ADsView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
// public void start() {
|
||||
// mLogViewThread = new LogViewThread(LogView.this);
|
||||
// mLogViewThread.start();
|
||||
// // 显示日志
|
||||
// showAndScrollLogView();
|
||||
// }
|
||||
//
|
||||
// public void scrollLogUp() {
|
||||
// mScrollView.post(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// mScrollView.fullScroll(ScrollView.FOCUS_DOWN);
|
||||
// // 日志显示结束
|
||||
// mLogViewHandler.setIsHandling(false);
|
||||
// // 检查是否添加了新日志
|
||||
// if (mLogViewHandler.isAddNewLog()) {
|
||||
// // 有新日志添加,先更改新日志标志
|
||||
// mLogViewHandler.setIsAddNewLog(false);
|
||||
// // 再次发送显示日志的显示
|
||||
// Message message = mLogViewHandler.obtainMessage(LogViewHandler.MSG_LOGVIEW_UPDATE);
|
||||
// mLogViewHandler.sendMessage(message);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
void initView(Context context) {
|
||||
mContext = context;
|
||||
|
||||
// mLogViewHandler = new LogViewHandler();
|
||||
// 加载视图布局
|
||||
View viewMain = inflate(mContext, cc.winboll.studio.libapputils.R.layout.view_ads, null);
|
||||
mWebView = viewMain.findViewById(cc.winboll.studio.libapputils.R.id.viewadsWebView1);
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
view.loadUrl(url);
|
||||
ToastUtils.show(url);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// // 初始化日志子控件视图
|
||||
// //
|
||||
// mScrollView = findViewById(cc.winboll.studio.libapputils.R.id.viewlogScrollViewLog);
|
||||
// mTextView = findViewById(cc.winboll.studio.libapputils.R.id.viewlogTextViewLog);
|
||||
// // 获取Log Level spinner实例
|
||||
// mLogLevelSpinner = findViewById(cc.winboll.studio.libapputils.R.id.viewlogSpinner1);
|
||||
//
|
||||
// (findViewById(cc.winboll.studio.libapputils.R.id.viewlogButtonClean)).setOnClickListener(new View.OnClickListener(){
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// LogUtils.cleanLog();
|
||||
// LogUtils.d(TAG, "Log is cleaned.");
|
||||
// }
|
||||
// });
|
||||
// (findViewById(cc.winboll.studio.libapputils.R.id.viewlogButtonCopy)).setOnClickListener(new View.OnClickListener(){
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
//
|
||||
// ClipboardManager cm = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
// cm.setPrimaryClip(ClipData.newPlainText(mContext.getPackageName(), LogUtils.loadLog()));
|
||||
// LogUtils.d(TAG, "Log is copied.");
|
||||
// }
|
||||
// });
|
||||
// mSelectableCheckBox = findViewById(cc.winboll.studio.libapputils.R.id.viewlogCheckBoxSelectable);
|
||||
// mSelectableCheckBox.setOnClickListener(new View.OnClickListener(){
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// if (mSelectableCheckBox.isChecked()) {
|
||||
// setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
|
||||
// } else {
|
||||
// setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// // 设置日志级别列表
|
||||
// ArrayList<String> adapterItems = new ArrayList<>();
|
||||
// for (LogUtils.LOG_LEVEL e : LogUtils.LOG_LEVEL.values()) {
|
||||
// adapterItems.add(e.name());
|
||||
// }
|
||||
// // 假设你有一个字符串数组作为选项列表
|
||||
// //String[] options = {"Option 1", "Option 2", "Option 3"};
|
||||
// // 创建一个ArrayAdapter来绑定数据到spinner
|
||||
// mLogLevelSpinnerAdapter = ArrayAdapter.createFromResource(
|
||||
// context, cc.winboll.studio.libapputils.R.array.enum_loglevel_array, android.R.layout.simple_spinner_item);
|
||||
// mLogLevelSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
//
|
||||
// // 设置适配器并将它应用到spinner上
|
||||
// mLogLevelSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // 设置下拉视图样式
|
||||
// mLogLevelSpinner.setAdapter(mLogLevelSpinnerAdapter);
|
||||
// // 为Spinner添加监听器
|
||||
// mLogLevelSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
// @Override
|
||||
// public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
// //String selectedOption = mLogLevelSpinnerAdapter.getItem(position);
|
||||
// // 处理选中的选项...
|
||||
// LogUtils.setLogLevel(LogUtils.LOG_LEVEL.values()[position]);
|
||||
// }
|
||||
// @Override
|
||||
// public void onNothingSelected(AdapterView<?> parent) {
|
||||
// // 如果没有选择,则执行此操作...
|
||||
// }
|
||||
// });
|
||||
// // 获取默认值的索引
|
||||
// int defaultValueIndex = LogUtils.getLogLevel().ordinal();
|
||||
//
|
||||
// if (defaultValueIndex != -1) {
|
||||
// // 如果找到了默认值,设置默认选项
|
||||
// mLogLevelSpinner.setSelection(defaultValueIndex);
|
||||
// }
|
||||
//
|
||||
// // 设置滚动时不聚焦日志
|
||||
// setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
|
||||
}
|
||||
|
||||
public void loadUrl(String url) {
|
||||
mWebView.loadUrl(url);
|
||||
//webView.loadUrl("https://www.winboll.cc");
|
||||
//webView.loadUrl("https://ads.winboll.cc");
|
||||
}
|
||||
|
||||
// public void updateLogView() {
|
||||
// if (mLogViewHandler.isHandling() == true) {
|
||||
// // 正在处理日志显示,
|
||||
// // 就先设置一个新日志标志位
|
||||
// // 以便日志显示完后,再次显示新日志内容
|
||||
// mLogViewHandler.setIsAddNewLog(true);
|
||||
// } else {
|
||||
// //LogUtils.d(TAG, "LogListener showLog(String path)");
|
||||
// Message message = mLogViewHandler.obtainMessage(LogViewHandler.MSG_LOGVIEW_UPDATE);
|
||||
// mLogViewHandler.sendMessage(message);
|
||||
// mLogViewHandler.setIsAddNewLog(false);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// void showAndScrollLogView() {
|
||||
// mTextView.setText(LogUtils.loadLog());
|
||||
// scrollLogUp();
|
||||
// }
|
||||
//
|
||||
// class LogViewHandler extends Handler {
|
||||
//
|
||||
// final static int MSG_LOGVIEW_UPDATE = 0;
|
||||
// volatile boolean isHandling;
|
||||
// volatile boolean isAddNewLog;
|
||||
//
|
||||
// public LogViewHandler() {
|
||||
// setIsHandling(false);
|
||||
// setIsAddNewLog(false);
|
||||
// }
|
||||
//
|
||||
// public void setIsHandling(boolean isHandling) {
|
||||
// this.isHandling = isHandling;
|
||||
// }
|
||||
//
|
||||
// public boolean isHandling() {
|
||||
// return isHandling;
|
||||
// }
|
||||
//
|
||||
// public void setIsAddNewLog(boolean isAddNewLog) {
|
||||
// this.isAddNewLog = isAddNewLog;
|
||||
// }
|
||||
//
|
||||
// public boolean isAddNewLog() {
|
||||
// return isAddNewLog;
|
||||
// }
|
||||
//
|
||||
// public void handleMessage(Message msg) {
|
||||
// switch (msg.what) {
|
||||
// case MSG_LOGVIEW_UPDATE:{
|
||||
// if (isHandling() == false) {
|
||||
// setIsHandling(true);
|
||||
// showAndScrollLogView();
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// super.handleMessage(msg);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
package cc.winboll.studio.libapputils.app;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import cc.winboll.studio.libapputils.activities.AboutActivity;
|
||||
import cc.winboll.studio.libapputils.app.AboutActivityFactory;
|
||||
import cc.winboll.studio.libapputils.bean.APPInfo;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2025/02/06 08:45:23
|
||||
* @Describe 关于活动窗口的介绍窗口工厂
|
||||
*/
|
||||
public class AboutActivityFactory {
|
||||
|
||||
public static final String TAG = "AboutActivityFactory";
|
||||
|
||||
public static APPInfo buildDefaultAPPInfo() {
|
||||
String szBranchName = "";
|
||||
|
||||
APPInfo appInfo = new APPInfo();
|
||||
appInfo.setAppName("APP");
|
||||
appInfo.setAppIcon(cc.winboll.studio.libapputils.R.drawable.ic_winboll);
|
||||
appInfo.setAppDescription("APP Description");
|
||||
appInfo.setAppGitName("APP");
|
||||
appInfo.setAppGitOwner("Studio");
|
||||
appInfo.setAppGitAPPBranch(szBranchName);
|
||||
appInfo.setAppGitAPPSubProjectFolder(szBranchName);
|
||||
appInfo.setAppHomePage("https://www.winboll.cc/studio/details.php?app=APP");
|
||||
appInfo.setAppAPKName("APP");
|
||||
appInfo.setAppAPKFolderName("APP");
|
||||
return appInfo;
|
||||
}
|
||||
|
||||
public static void showAboutActivity(Context context, APPInfo appInfo) {
|
||||
/*String szPN = ((IWinBollActivity)context).getActivityPackageName();
|
||||
//String szPN = context.getPackageName();
|
||||
String szBranchName = "";
|
||||
if (szPN != null) {
|
||||
//String szPN = "cc.winboll.studio.apputils.beta";
|
||||
String regex = "cc\\.winboll\\.studio\\.([^.]+)\\.*";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(szPN);
|
||||
if (matcher.find()) {
|
||||
szBranchName = matcher.group(1);
|
||||
}
|
||||
}*/
|
||||
//ToastUtils.show(szPN);
|
||||
|
||||
Intent intent = new Intent(context, AboutActivity.class);
|
||||
intent.putExtra(AboutActivity.EXTRA_APPINFO, (appInfo == null) ? AboutActivityFactory.buildDefaultAPPInfo():appInfo);
|
||||
WinBollActivityManager.getInstance(context).startWinBollActivity(context, intent, AboutActivity.class);
|
||||
}
|
||||
}
|
@@ -5,7 +5,7 @@ package cc.winboll.studio.libapputils.app;
|
||||
* @Date 2024/08/12 14:45:35
|
||||
* @Describe 应用版本工具集
|
||||
*/
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import cc.winboll.studio.libapputils.log.LogUtils;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -23,6 +23,7 @@ public class AppVersionUtils {
|
||||
// true 新版本 == 当前版本
|
||||
//
|
||||
public static boolean isHasNewVersion2(String szCurrentName, String szNextName) {
|
||||
LogUtils.d(TAG, String.format("isHasNewVersion2\nszCurrentName : %s\nszNextName : %s", szCurrentName, szNextName));
|
||||
//szCurrentName = "AES_6.2.0-beta0_3234.apk";
|
||||
//szNextName = "AES_6.1.12.apk";
|
||||
//szCurrentName = "AES_6.2.0-beta0_3234.apk";
|
||||
@@ -77,8 +78,9 @@ public class AppVersionUtils {
|
||||
//LogUtils.d(TAG, "App version is the newest. ");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isHasNewStageReleaseVersion(String szCurrentName, String szNextName) {
|
||||
LogUtils.d(TAG, String.format("isHasNewStageReleaseVersion\nszCurrentName : %s\nszNextName : %s", szCurrentName, szNextName));
|
||||
//szCurrentName = "AES_6.2.12.apk";
|
||||
//szNextName = "AES_6.3.12.apk";
|
||||
if (checkNewVersion(getCodeInPackageName(szCurrentName), getCodeInPackageName(szNextName))) {
|
||||
@@ -96,6 +98,10 @@ public class AppVersionUtils {
|
||||
// 返回 :true 新版本 > 当前版本
|
||||
//
|
||||
public static Boolean checkNewVersion(String szCurrentCode, String szNextCode) {
|
||||
if (szCurrentCode == null || szCurrentCode.equals("") || szNextCode == null || szNextCode.equals("")) {
|
||||
LogUtils.d(TAG, String.format("checkNewVersion unexpected parameters:\nszCurrentCode : %s\nszNextCode : %s", szCurrentCode, szNextCode));
|
||||
return false;
|
||||
}
|
||||
boolean isNew = false;
|
||||
String[] appVersionCurrent = szCurrentCode.split("\\.");
|
||||
String[] appVersionNext = szNextCode.split("\\.");
|
||||
@@ -106,7 +112,7 @@ public class AppVersionUtils {
|
||||
if (Integer.parseInt(appVersionNext[i]) > Integer.parseInt(appVersionCurrent[i])) {
|
||||
isNew = true;
|
||||
return isNew;
|
||||
} else if(Integer.parseInt(appVersionNext[i]) == Integer.parseInt(appVersionCurrent[i])) {
|
||||
} else if (Integer.parseInt(appVersionNext[i]) == Integer.parseInt(appVersionCurrent[i])) {
|
||||
continue ;
|
||||
} else {
|
||||
isNew = false;
|
||||
@@ -122,14 +128,17 @@ public class AppVersionUtils {
|
||||
// 如 :AppUtils_7.0.4.apk 版本号为 7.0.4
|
||||
//
|
||||
public static String getCodeInPackageName(String apkName) {
|
||||
LogUtils.d(TAG, String.format("getCodeInPackageName apkName : %s", apkName));
|
||||
//String apkName = "AppUtils_7.0.0.apk";
|
||||
Pattern pattern = Pattern.compile("\\d+\\.\\d+\\.\\d+");
|
||||
Matcher matcher = pattern.matcher(apkName);
|
||||
if (matcher.find()) {
|
||||
String version = matcher.group();
|
||||
LogUtils.d(TAG, String.format("version is %s", version));
|
||||
return version;
|
||||
//System.out.println("Version number: " + version); // 输出:7.0.0
|
||||
}
|
||||
LogUtils.d(TAG, String.format("No result."));
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -149,5 +158,4 @@ public class AppVersionUtils {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,25 @@
|
||||
package cc.winboll.studio.libapputils.app;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2025/02/04 10:20:16
|
||||
* @Describe WinBoll Activity 接口
|
||||
*/
|
||||
import android.view.View;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libapputils.bean.APPInfo;
|
||||
|
||||
public interface IWinBollActivity {
|
||||
|
||||
public static final String TAG = "IWinBollActivity";
|
||||
|
||||
// 获取当前具有 IWinBoll 特征的 AppCompatActivity 活动窗口
|
||||
AppCompatActivity getActivity();
|
||||
|
||||
abstract public APPInfo getAppInfo();
|
||||
abstract public String getTag();
|
||||
abstract Toolbar initToolBar();
|
||||
abstract boolean isEnableDisplayHomeAsUp();
|
||||
abstract boolean isAddWinBollToolBar();
|
||||
}
|
@@ -6,22 +6,20 @@ package cc.winboll.studio.libapputils.app;
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import cc.winboll.studio.libapputils.log.LogUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.util.Set;
|
||||
import android.content.Context;
|
||||
|
||||
public class MyActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks {
|
||||
|
||||
public static final String TAG = "MyActivityLifecycleCallbacks";
|
||||
|
||||
|
||||
public String mInfo = "";
|
||||
|
||||
public MyActivityLifecycleCallbacks(WinBollApplication application) {
|
||||
|
||||
public MyActivityLifecycleCallbacks() {
|
||||
}
|
||||
|
||||
void createActivityeInfo(Activity activity) {
|
||||
|
@@ -1,479 +0,0 @@
|
||||
package cc.winboll.studio.libapputils.app;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2024/08/12 14:32:08
|
||||
* @Describe WinBoll 活动窗口基础类
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import cc.winboll.studio.libapputils.R;
|
||||
import cc.winboll.studio.libapputils.activities.AboutActivity;
|
||||
import cc.winboll.studio.libapputils.log.LogActivity;
|
||||
import cc.winboll.studio.libapputils.log.LogUtils;
|
||||
import cc.winboll.studio.libapputils.view.AboutView;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
abstract public class WinBollActivity extends AppCompatActivity {
|
||||
|
||||
public static final String TAG = "WinBollActivity";
|
||||
|
||||
public static final int REQUEST_LOG_ACTIVITY = 0;
|
||||
|
||||
Toolbar mToolBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
checkResolveActivity();
|
||||
LogUtils.d(TAG, "onCreate");
|
||||
super.onCreate(savedInstanceState);
|
||||
archiveInstance();
|
||||
|
||||
}
|
||||
|
||||
boolean checkResolveActivity() {
|
||||
PackageManager packageManager = getPackageManager();
|
||||
//Intent intent = new Intent("your_action_here");
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if (resolveInfoList.size() > 0) {
|
||||
// 传入的Intent action在Activity清单的intent-filter的action节点里有定义
|
||||
if (intent.getAction() != null) {
|
||||
if (intent.getAction().equals(cc.winboll.studio.libapputils.intent.action.DEBUGVIEW)) {
|
||||
WinBollApplication.setIsDebug(true);
|
||||
//ToastUtils.show!("WinBollApplication.setIsDebug(true) by action : " + intent.getAction());
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
// 传入的Intent action在Activity清单的intent-filter的action节点里没有定义
|
||||
//ToastUtils.show("false : " + intent.getAction());
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ResolveInfo resolveInfo = pm.resolveActivity(intent, 0);
|
||||
if (resolveInfo != null) {
|
||||
// action在清单文件中有声明
|
||||
|
||||
} else {
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
// action在清单文件中没有声明
|
||||
ToastUtils.show("false");
|
||||
return false;
|
||||
}
|
||||
|
||||
void archiveInstance() {
|
||||
Intent intent = getIntent();
|
||||
StringBuilder sb = new StringBuilder("\n### Archive Instance ###\n");
|
||||
|
||||
if (intent != null) {
|
||||
ComponentName componentName = intent.getComponent();
|
||||
if (componentName != null) {
|
||||
String packageName = componentName.getPackageName();
|
||||
//Log.d("AppStarter", "启动本应用的应用包名: " + packageName);
|
||||
sb.append("启动本应用的应用包名: \n" + packageName);
|
||||
}
|
||||
|
||||
sb.append("\nImplicit Intent Tracker :\n接收到的 Intent 动作: \n" + intent.getAction());
|
||||
Set<String> categories = intent.getCategories();
|
||||
if (categories != null) {
|
||||
for (String category : categories) {
|
||||
sb.append("\n接收到的 Intent 类别 :\n" + category);
|
||||
}
|
||||
}
|
||||
Uri data = intent.getData();
|
||||
if (data != null) {
|
||||
sb.append("\n接收到的 Intent 数据 :\n" + data.toString());
|
||||
}
|
||||
} else {
|
||||
sb.append("Intent is null.");
|
||||
}
|
||||
sb.append("\n\n");
|
||||
LogUtils.d(TAG, sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
mToolBar = initToolBar();
|
||||
setSupportActionBar(mToolBar);
|
||||
if (isEnableDisplayHomeAsUp() && mToolBar != null) {
|
||||
// 显示后退按钮
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
// 缓存当前 activity
|
||||
LogUtils.d(TAG, "ActManager.getInstance().add(this);");
|
||||
//ToastUtils.show("getTag() " + getTag());
|
||||
WinBollActivityManager.getInstance(this).add(this);
|
||||
//WinBollActivityManager.getInstance().printAvtivityListInfo();
|
||||
//ToastUtils.show("WinBollUI_TYPE " + WinBollApplication.getWinBollUI_TYPE());
|
||||
//boolean isDebuging = WinBollApplication.loadDebugStatusIsDebuging();
|
||||
//ToastUtils.show(String.valueOf(isDebuging));
|
||||
//WinBollApplication.setIsDebug(true);
|
||||
|
||||
setSubTitle(getTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recreate() {
|
||||
super.recreate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
WinBollActivityManager.getInstance(this).registeRemove(this);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentView(int layoutResID) {
|
||||
super.setContentView(layoutResID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends View> T findViewById(int id) {
|
||||
return super.findViewById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuInflater getMenuInflater() {
|
||||
return super.getMenuInflater();
|
||||
}
|
||||
|
||||
public WinBollActivity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getApplicationContext() {
|
||||
return super.getApplicationContext();
|
||||
}
|
||||
|
||||
public <T extends FragmentManager> T getWinBollActivitySupportFragmentManager() {
|
||||
return (T)super.getSupportFragmentManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionBar getSupportActionBar() {
|
||||
return super.getSupportActionBar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSupportActionBar(Toolbar toolbar) {
|
||||
super.setSupportActionBar(toolbar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActionBar(android.widget.Toolbar toolbar) {
|
||||
super.setActionBar(toolbar);
|
||||
}
|
||||
|
||||
public void setSubTitle(CharSequence title) {
|
||||
LogUtils.d(TAG, "setSubTitle");
|
||||
if (super.getSupportActionBar() != null) {
|
||||
super.getSupportActionBar().setSubtitle(title);
|
||||
LogUtils.d(TAG, String.format("setSubtitle title : %s", title));
|
||||
}
|
||||
}
|
||||
|
||||
public CharSequence getSubTitle() {
|
||||
if (super.getSupportActionBar() != null) {
|
||||
return super.getSupportActionBar().getSubtitle();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle(CharSequence title) {
|
||||
//super.setTitle(title);
|
||||
if (super.getSupportActionBar() != null) {
|
||||
super.getSupportActionBar().setTitle(title);
|
||||
LogUtils.d(TAG, String.format("setSubtitle title : %s", title));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle(int titleId) {
|
||||
//super.setTitle(titleId);
|
||||
if (super.getSupportActionBar() != null) {
|
||||
super.getSupportActionBar().setTitle(titleId);
|
||||
//LogUtils.d(TAG, String.format("setSubtitle title : %s", title));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTheme(Resources.Theme theme) {
|
||||
super.setTheme(theme);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTheme(int resid) {
|
||||
super.setTheme(resid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitleColor(int textColor) {
|
||||
super.setTitleColor(textColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentView(View view, ViewGroup.LayoutParams params) {
|
||||
super.setContentView(view, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentView(View view) {
|
||||
super.setContentView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SharedPreferences getSharedPreferences(String name, int mode) {
|
||||
return super.getSharedPreferences(name, mode);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean releaseInstance() {
|
||||
return super.releaseInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter, int flags) {
|
||||
return super.registerReceiver(receiver, filter, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter, String broadcastPermission, Handler scheduler) {
|
||||
return super.registerReceiver(receiver, filter, broadcastPermission, scheduler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter, String broadcastPermission, Handler scheduler, int flags) {
|
||||
return super.registerReceiver(receiver, filter, broadcastPermission, scheduler, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivities(Intent[] intents) {
|
||||
super.startActivities(intents);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityFromFragment(Fragment fragment, Intent intent, int requestCode) {
|
||||
super.startActivityFromFragment(fragment, intent, requestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityFromFragment(android.app.Fragment fragment, Intent intent, int requestCode, Bundle options) {
|
||||
super.startActivityFromFragment(fragment, intent, requestCode, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityFromChild(Activity child, Intent intent, int requestCode, Bundle options) {
|
||||
super.startActivityFromChild(child, intent, requestCode, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivities(Intent[] intents, Bundle options) {
|
||||
super.startActivities(intents, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startActivityIfNeeded(Intent intent, int requestCode) {
|
||||
return super.startActivityIfNeeded(intent, requestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startActivityIfNeeded(Intent intent, int requestCode, Bundle options) {
|
||||
return super.startActivityIfNeeded(intent, requestCode, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityFromChild(Activity child, Intent intent, int requestCode) {
|
||||
super.startActivityFromChild(child, intent, requestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentName startService(Intent service) {
|
||||
return super.startService(service);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityForResult(Intent intent, int requestCode) {
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
|
||||
super.startActivityForResult(intent, requestCode, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityFromFragment(android.app.Fragment fragment, Intent intent, int requestCode) {
|
||||
super.startActivityFromFragment(fragment, intent, requestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityFromFragment(Fragment requestIndex, Intent fragment, int intent, Bundle requestCode) {
|
||||
super.startActivityFromFragment(requestIndex, fragment, intent, requestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivity(Intent intent, Bundle options) {
|
||||
super.startActivity(intent, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
if (isAddWinBollToolBar()) {
|
||||
getMenuInflater().inflate(R.menu.toolbar_winboll_shared_main, menu);
|
||||
}
|
||||
if (WinBollApplication.isDebug()) {
|
||||
getMenuInflater().inflate(R.menu.toolbar_studio_debug, menu);
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
LogUtils.d(TAG, "onOptionsItemSelected");
|
||||
if (item.getItemId() == R.id.item_log) {
|
||||
LogUtils.d(TAG, "item_log not yet.");
|
||||
//WinBollActivityManager.getInstance().printAvtivityListInfo();
|
||||
//WinBollActivityManager.getInstance(this).startWinBollActivity(this, LogActivity.class);
|
||||
} else if (item.getItemId() == R.id.item_exit) {
|
||||
WinBollActivityManager.getInstance(this).finishAll();
|
||||
} else if (item.getItemId() == R.id.item_info) {
|
||||
WinBollApplication application = (WinBollApplication) getApplication();
|
||||
application.getMyActivityLifecycleCallbacks().showActivityeInfo();
|
||||
} else if (item.getItemId() == R.id.item_exitdebug) {
|
||||
AboutView.setApp2NormalMode(getApplicationContext());
|
||||
} else if (item.getItemId() == R.id.item_about) {
|
||||
startAboutActivity();
|
||||
} else if (item.getItemId() == android.R.id.home) {
|
||||
WinBollActivityManager.getInstance(this).finish(this);
|
||||
}
|
||||
// else if (item.getItemId() == android.R.id.home) {
|
||||
// 回到主窗口速度缓慢,方法备用。现在用 WinBollActivityManager resumeActivity 和 finish 方法管理。
|
||||
// _mMainWinBollActivity 是 WinBollActivity 的静态属性
|
||||
// onCreate 函数下 _mMainWinBollActivity 为空时就用 _mMainWinBollActivity = this 赋值。
|
||||
//startWinBollActivity(new Intent(_mMainWinBollActivity, _mMainWinBollActivity.getClass()), _mMainWinBollActivity.getTag(), _mMainWinBollActivity);
|
||||
//}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
//super.onBackPressed();
|
||||
//ToastUtils.show("onBackPressed");
|
||||
WinBollActivityManager.getInstance(this).finish(this);
|
||||
}
|
||||
|
||||
|
||||
/*public void getInstanse() {
|
||||
startWinBollActivity(new Intent(), getTag(), null);
|
||||
}*/
|
||||
|
||||
//
|
||||
// activity: 为 null 时,
|
||||
// intent.putExtra 函数 "tag" 参数为 tag
|
||||
// activity: 不为 null 时,
|
||||
// intent.putExtra 函数 "tag" 参数为 activity.getTag()
|
||||
//
|
||||
// protected <T extends WinBollActivity> void startWinBollActivity(Intent intent, String tag, T activity) {
|
||||
// LogUtils.d(TAG, "startWinBollActivityForResult tag " + tag);
|
||||
// //ToastUtils.show("startWinBollActivityForResult tag " + tag);
|
||||
// //打开多任务窗口 flags
|
||||
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
// intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
// if (activity != null) {
|
||||
// intent.putExtra("tag", activity.getTag());
|
||||
// } else {
|
||||
// intent.putExtra("tag", tag);
|
||||
// }
|
||||
// //ToastUtils.show("super.startActivityForResult(intent, requestCode); tag " + tag);
|
||||
// LogUtils.d(TAG, "startActivityForResult(intent, requestCode);" + tag);
|
||||
// startActivity(intent);
|
||||
// }
|
||||
|
||||
//
|
||||
// activity: 为 null 时,
|
||||
// intent.putExtra 函数 "tag" 参数为 tag
|
||||
// activity: 不为 null 时,
|
||||
// intent.putExtra 函数 "tag" 参数为 activity.getTag()
|
||||
//
|
||||
protected <T extends AboutActivity> void startAboutActivity() {
|
||||
Intent intent = new Intent(this, AboutActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
intent.putExtra("tag", AboutActivity.TAG);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivity(Intent intent) {
|
||||
//绑定唯一标识 tag,存在 则根据 taskId 移动到前台
|
||||
String tag = intent.getStringExtra("tag");
|
||||
//ToastUtils.show("startActivityForResult tag " + tag);
|
||||
//WinBollActivityManager.getInstance(this).printAvtivityListInfo();
|
||||
if (WinBollActivityManager.getInstance(this).isActive(tag)) {
|
||||
//ToastUtils.show("resumeActivity");
|
||||
LogUtils.d(TAG, "resumeActivity");
|
||||
WinBollActivityManager.getInstance(this).resumeActivity(this, tag);
|
||||
} else {
|
||||
//ToastUtils.show("super.startActivity(intent);");
|
||||
super.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int targetFragment, Intent data) {
|
||||
LogUtils.d(TAG, "onActivityResult");
|
||||
switch (requestCode) {
|
||||
case REQUEST_LOG_ACTIVITY : {
|
||||
LogUtils.d(TAG, "REQUEST_LOG_ACTIVITY");
|
||||
break;
|
||||
}
|
||||
default : {
|
||||
super.onActivityResult(requestCode, targetFragment, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAddWinBollInfoMenu() {
|
||||
return true;
|
||||
}
|
||||
|
||||
abstract public String getTag();
|
||||
abstract protected Toolbar initToolBar();
|
||||
abstract protected boolean isEnableDisplayHomeAsUp();
|
||||
abstract protected boolean isAddWinBollToolBar();
|
||||
}
|
@@ -20,17 +20,26 @@ import java.util.Map;
|
||||
public class WinBollActivityManager {
|
||||
|
||||
public static final String TAG = "WinBollActivityManager";
|
||||
public static final String EXTRA_TAG = "EXTRA_TAG";
|
||||
|
||||
public static enum WinBollUI_TYPE {
|
||||
Aplication, // 退出应用后,保持最近任务栏任务记录主窗口
|
||||
Service // 退出应用后,清理所有最近任务栏任务记录窗口
|
||||
};
|
||||
|
||||
// 应用类型标志
|
||||
volatile static WinBollUI_TYPE _mWinBollUI_TYPE = WinBollUI_TYPE.Service;
|
||||
|
||||
Context mContext;
|
||||
MyActivityLifecycleCallbacks mMyActivityLifecycleCallbacks;
|
||||
static WinBollActivityManager _mWinBollActivityManager;
|
||||
static Map<String, WinBollActivity> _mapActivityList;
|
||||
//static ArrayList<WinBollActivity> _mWinBollActivityList;
|
||||
static Map<String, IWinBollActivity> _mapIWinBollList;
|
||||
IWinBollActivity firstIWinBollActivity;
|
||||
|
||||
public WinBollActivityManager(Context context) {
|
||||
mContext = context;
|
||||
LogUtils.d(TAG, "WinBollActivityManager()");
|
||||
_mapActivityList = new HashMap<String, WinBollActivity>();
|
||||
//_mWinBollActivityList = new ArrayList<WinBollActivity>();
|
||||
_mapIWinBollList = new HashMap<String, IWinBollActivity>();
|
||||
}
|
||||
|
||||
public static synchronized WinBollActivityManager getInstance(Context context) {
|
||||
@@ -42,35 +51,46 @@ public class WinBollActivityManager {
|
||||
return _mWinBollActivityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把Activity添加到管理中
|
||||
*/
|
||||
public <T extends WinBollActivity> void add(T activity) {
|
||||
/*for (int i = 0; i < _mWinBollActivityList.size(); i++) {
|
||||
LogUtils.d(TAG, String.format("add for i %d\nget(i).getTag() %s", i, _mWinBollActivityList.get(i).getTag()));
|
||||
if (_mWinBollActivityList.get(i).getTag().equals(activity.getTag())) {
|
||||
_mWinBollActivityList.add(i, activity);
|
||||
_mWinBollActivityList.remove(i);
|
||||
LogUtils.d(TAG, String.format("Replace activity : %s\nSize %d", activity.getTag(), _mWinBollActivityList.size()));
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
if (isActive(activity.getTag())) {
|
||||
LogUtils.d(TAG, String.format("add(...) %s is active.", activity.getTag()));
|
||||
//
|
||||
// 设置 WinBoll 应用 UI 类型
|
||||
//
|
||||
public synchronized static void setWinBollUI_TYPE(WinBollUI_TYPE mWinBollUI_TYPE) {
|
||||
_mWinBollUI_TYPE = mWinBollUI_TYPE;
|
||||
}
|
||||
|
||||
//
|
||||
// 获取 WinBoll 应用 UI 类型
|
||||
//
|
||||
public synchronized static WinBollUI_TYPE getWinBollUI_TYPE() {
|
||||
return _mWinBollUI_TYPE;
|
||||
}
|
||||
|
||||
//
|
||||
// 把Activity添加到管理中
|
||||
//
|
||||
public <T extends IWinBollActivity> void add(T iWinBoll) {
|
||||
if (isActive(iWinBoll.getTag())) {
|
||||
LogUtils.d(TAG, String.format("add(...) %s is active.", iWinBoll.getTag()));
|
||||
} else {
|
||||
_mapActivityList.put(activity.getTag(), activity);
|
||||
LogUtils.d(TAG, String.format("Add activity : %s\n_mapActivityList.size() : %d", activity.getTag(), _mapActivityList.size()));
|
||||
// 设置起始活动窗口,以便最后退出时提问
|
||||
if (firstIWinBollActivity == null && _mapIWinBollList.size() == 0) {
|
||||
firstIWinBollActivity = iWinBoll;
|
||||
}
|
||||
|
||||
// 添加到活动窗口列表
|
||||
_mapIWinBollList.put(iWinBoll.getTag(), iWinBoll);
|
||||
LogUtils.d(TAG, String.format("Add activity : %s\n_mapActivityList.size() : %d", iWinBoll.getTag(), _mapIWinBollList.size()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// activity: 为 null 时,
|
||||
// intent.putExtra 函数 "tag" 参数为 tag
|
||||
// intent.putExtra 函数 EXTRA_TAG 参数为 tag
|
||||
// activity: 不为 null 时,
|
||||
// intent.putExtra 函数 "tag" 参数为 activity.getTag()
|
||||
//
|
||||
public <T extends WinBollActivity> void startWinBollActivity(Context context, Class<T> clazz) {
|
||||
public <T extends IWinBollActivity> void startWinBollActivity(Context context, Class<T> clazz) {
|
||||
try {
|
||||
// 如果窗口已存在就重启窗口
|
||||
String tag = clazz.newInstance().getTag();
|
||||
@@ -84,14 +104,15 @@ public class WinBollActivityManager {
|
||||
//打开多任务窗口 flags
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
intent.putExtra("tag", tag);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(EXTRA_TAG, tag);
|
||||
mContext.startActivity(intent);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends WinBollActivity> void startWinBollActivity(Context context, Intent intent, Class<T> clazz) {
|
||||
public <T extends IWinBollActivity> void startWinBollActivity(Context context, Intent intent, Class<T> clazz) {
|
||||
try {
|
||||
// 如果窗口已存在就重启窗口
|
||||
String tag = clazz.newInstance().getTag();
|
||||
@@ -105,25 +126,30 @@ public class WinBollActivityManager {
|
||||
//打开多任务窗口 flags
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
intent.putExtra("tag", tag);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(EXTRA_TAG, tag);
|
||||
mContext.startActivity(intent);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断 tag绑定的 MyActivity是否存在
|
||||
*/
|
||||
public boolean isFirstIWinBollActivity(IWinBollActivity iWinBollActivity) {
|
||||
return firstIWinBollActivity != null && firstIWinBollActivity == iWinBollActivity;
|
||||
}
|
||||
|
||||
//
|
||||
// 判断 tag绑定的 MyActivity是否存在
|
||||
//
|
||||
public boolean isActive(String tag) {
|
||||
printAvtivityListInfo();
|
||||
WinBollActivity activity = getWinBollActivity(tag);
|
||||
if (activity != null) {
|
||||
//printAvtivityListInfo();
|
||||
IWinBollActivity iWinBoll = getIWinBoll(tag);
|
||||
if (iWinBoll != null) {
|
||||
LogUtils.d(TAG, "isActive(...) activity != null tag " + tag);
|
||||
//ToastUtils.show("activity != null tag " + tag);
|
||||
//判断是否为 BaseActivity,如果已经销毁,则移除
|
||||
if (activity.isFinishing() || activity.isDestroyed()) {
|
||||
_mapActivityList.remove(activity.getTag());
|
||||
if (iWinBoll.getActivity().isFinishing() || iWinBoll.getActivity().isDestroyed()) {
|
||||
_mapIWinBollList.remove(iWinBoll.getTag());
|
||||
//_mWinBollActivityList.remove(activity);
|
||||
LogUtils.d(TAG, String.format("isActive(...) remove activity.\ntag : %s", tag));
|
||||
return false;
|
||||
@@ -137,75 +163,75 @@ public class WinBollActivityManager {
|
||||
}
|
||||
}
|
||||
|
||||
static WinBollActivity getWinBollActivity(String tag) {
|
||||
return _mapActivityList.get(tag);
|
||||
static IWinBollActivity getIWinBoll(String tag) {
|
||||
return _mapIWinBollList.get(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
||||
*/
|
||||
public <T extends WinBollActivity> void resumeActivity(Context context, String tag) {
|
||||
//
|
||||
// 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
||||
//
|
||||
public <T extends IWinBollActivity> void resumeActivity(Context context, String tag) {
|
||||
LogUtils.d(TAG, "resumeActivty");
|
||||
T activity = (T)getWinBollActivity(tag);
|
||||
LogUtils.d(TAG, "activity " + activity.getTag());
|
||||
if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
|
||||
resumeActivity(context, activity);
|
||||
T iWinBoll = (T)getIWinBoll(tag);
|
||||
//LogUtils.d(TAG, "activity " + activity.getTag());
|
||||
if (iWinBoll != null && !iWinBoll.getActivity().isFinishing() && !iWinBoll.getActivity().isDestroyed()) {
|
||||
resumeActivity(context, iWinBoll);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
||||
*/
|
||||
public <T extends WinBollActivity> void resumeActivity(Context context, T activity) {
|
||||
ActivityManager am = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
//
|
||||
// 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
||||
//
|
||||
public <T extends IWinBollActivity> void resumeActivity(Context context, T iWinBoll) {
|
||||
ActivityManager am = (ActivityManager) iWinBoll.getActivity().getSystemService(Context.ACTIVITY_SERVICE);
|
||||
//返回启动它的根任务(home 或者 MainActivity)
|
||||
Intent intent = new Intent(context, activity.getClass());
|
||||
Intent intent = new Intent(context, iWinBoll.getClass());
|
||||
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
|
||||
stackBuilder.addNextIntentWithParentStack(intent);
|
||||
stackBuilder.startActivities();
|
||||
//moveTaskToFront(YourTaskId, 0);
|
||||
LogUtils.d(TAG, "am.moveTaskToFront");
|
||||
//ToastUtils.show("resumeActivity am.moveTaskToFront");
|
||||
am.moveTaskToFront(activity.getTaskId(), ActivityManager.MOVE_TASK_NO_USER_ACTION);
|
||||
am.moveTaskToFront(iWinBoll.getActivity().getTaskId(), ActivityManager.MOVE_TASK_NO_USER_ACTION);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 结束所有 Activity
|
||||
*/
|
||||
//
|
||||
// 结束所有 Activity
|
||||
//
|
||||
public void finishAll() {
|
||||
try {
|
||||
LogUtils.d(TAG, "finishAll no yet.");
|
||||
//ToastUtils.show(String.format("finishAll() size : %d", _mWinBollActivityList.size()));
|
||||
// for (int i = _mWinBollActivityList.size() - 1; i > -1; i--) {
|
||||
// WinBollActivity activity = _mWinBollActivityList.get(i);
|
||||
// ToastUtils.show("finishAll() activity");
|
||||
// if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
|
||||
// //ToastUtils.show("activity != null ...");
|
||||
// if (WinBollApplication.getWinBollUI_TYPE() == WinBollApplication.WinBollUI_TYPE.Service) {
|
||||
// // 结束窗口和最近任务栏, 建议前台服务类应用使用,可以方便用户再次调用 UI 操作。
|
||||
// activity.finishAndRemoveTask();
|
||||
// //ToastUtils.show("finishAll() activity.finishAndRemoveTask();");
|
||||
// } else if (WinBollApplication.getWinBollUI_TYPE() == WinBollApplication.WinBollUI_TYPE.Aplication) {
|
||||
// // 结束窗口保留最近任务栏,建议前台服务类应用使用,可以保持应用的系统自觉性。
|
||||
// activity.finish();
|
||||
// //ToastUtils.show("finishAll() activity.finish();");
|
||||
// } else {
|
||||
// ToastUtils.show("WinBollApplication.WinBollUI_TYPE error.");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
for (String key : _mapIWinBollList.keySet()) {
|
||||
//System.out.println("Key: " + key + ", Value: " + _mapActivityList.get(key));
|
||||
IWinBollActivity iWinBoll = _mapIWinBollList.get(key);
|
||||
//ToastUtils.show("finishAll() activity");
|
||||
if (iWinBoll != null && !iWinBoll.getActivity().isFinishing() && !iWinBoll.getActivity().isDestroyed()) {
|
||||
//ToastUtils.show("activity != null ...");
|
||||
if (getWinBollUI_TYPE() == WinBollUI_TYPE.Service) {
|
||||
// 结束窗口和最近任务栏, 建议前台服务类应用使用,可以方便用户再次调用 UI 操作。
|
||||
iWinBoll.getActivity().finishAndRemoveTask();
|
||||
//ToastUtils.show("finishAll() activity.finishAndRemoveTask();");
|
||||
} else if (getWinBollUI_TYPE() == WinBollUI_TYPE.Aplication) {
|
||||
// 结束窗口保留最近任务栏,建议前台服务类应用使用,可以保持应用的系统自觉性。
|
||||
iWinBoll.getActivity().finish();
|
||||
//ToastUtils.show("finishAll() activity.finish();");
|
||||
} else {
|
||||
LogUtils.d(TAG, "WinBollApplication.WinBollUI_TYPE error.");
|
||||
//ToastUtils.show("WinBollApplication.WinBollUI_TYPE error.");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束指定Activity
|
||||
*/
|
||||
public <T extends WinBollActivity> void finish(T activity) {
|
||||
//
|
||||
// 结束指定Activity
|
||||
//
|
||||
public <T extends IWinBollActivity> void finish(T iWinBoll) {
|
||||
try {
|
||||
if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
|
||||
if (iWinBoll != null && !iWinBoll.getActivity().isFinishing() && !iWinBoll.getActivity().isDestroyed()) {
|
||||
//根据tag 移除 MyActivity
|
||||
//String tag= activity.getTag();
|
||||
//_mWinBollActivityList.remove(tag);
|
||||
@@ -220,27 +246,11 @@ public class WinBollActivityManager {
|
||||
// ★:0 1 2 3 [4] >> 3
|
||||
// ★:[0] >> 直接关闭当前窗口
|
||||
LogUtils.d(TAG, "finish no yet.");
|
||||
WinBollActivity preActivity = getPreActivity(activity);
|
||||
activity.finish();
|
||||
if (preActivity != null) {
|
||||
resumeActivity(mContext, preActivity);
|
||||
IWinBollActivity preIWinBoll = getPreIWinBoll(iWinBoll);
|
||||
iWinBoll.getActivity().finish();
|
||||
if (preIWinBoll != null) {
|
||||
resumeActivity(mContext, preIWinBoll);
|
||||
}
|
||||
|
||||
// for (int i = 0; i < _mWinBollActivityList.size(); i++) {
|
||||
// if (_mWinBollActivityList.get(i).getTag().equals(activity.getTag())) {
|
||||
// //ToastUtils.show(String.format("equals i : %d\nTag : %s\nSize : %d", i, activity.getTag(), _mWinBollActivityList.size()));
|
||||
// if (i == 0) {
|
||||
// finishAll();
|
||||
// //ToastUtils.show("finish finishAll");
|
||||
// return;
|
||||
// }
|
||||
// if (i > 0) {
|
||||
// activity.finish();
|
||||
// resumeActivity(mContext, _mWinBollActivityList.get(i - 1));
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -248,21 +258,24 @@ public class WinBollActivityManager {
|
||||
}
|
||||
}
|
||||
|
||||
WinBollActivity getPreActivity(WinBollActivity activity) {
|
||||
//
|
||||
// 获取窗口队列中的前一个窗口
|
||||
//
|
||||
IWinBollActivity getPreIWinBoll(IWinBollActivity iWinBoll) {
|
||||
try {
|
||||
boolean bingo = false;
|
||||
WinBollActivity preActivity = null;
|
||||
for (Map.Entry<String, WinBollActivity> entity : _mapActivityList.entrySet()) {
|
||||
if (entity.getKey().equals(activity.getTag())) {
|
||||
IWinBollActivity preIWinBoll = null;
|
||||
for (Map.Entry<String, IWinBollActivity> entity : _mapIWinBollList.entrySet()) {
|
||||
if (entity.getKey().equals(iWinBoll.getTag())) {
|
||||
bingo = true;
|
||||
LogUtils.d(TAG, "bingo");
|
||||
break;
|
||||
}
|
||||
preActivity = entity.getValue();
|
||||
preIWinBoll = entity.getValue();
|
||||
}
|
||||
|
||||
if (bingo) {
|
||||
return preActivity;
|
||||
return preIWinBoll;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
@@ -271,36 +284,28 @@ public class WinBollActivityManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public <T extends WinBollActivity> boolean registeRemove(T activity) {
|
||||
// for (int i = 0; i < _mWinBollActivityList.size(); i++) {
|
||||
// if (registeRemove(activity, i)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
WinBollActivity activityTest = _mapActivityList.get(activity.getTag());
|
||||
if (activityTest != null) {
|
||||
_mapActivityList.remove(activity.getTag());
|
||||
//
|
||||
// 从管理列表中移除管理项
|
||||
//
|
||||
public <T extends IWinBollActivity> boolean registeRemove(T activity) {
|
||||
IWinBollActivity iWinBollTest = _mapIWinBollList.get(activity.getTag());
|
||||
if (iWinBollTest != null) {
|
||||
_mapIWinBollList.remove(activity.getTag());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// public <T extends WinBollActivity> boolean registeRemove(T activity, int position) {
|
||||
// if (_mWinBollActivityList.get(position) == activity) {
|
||||
// _mWinBollActivityList.remove(position);
|
||||
// //ToastUtils.show(String.format("registeRemove remove.\nTag %s\nposition %d", activity.getTag(), position));
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
public static void printAvtivityListInfo() {
|
||||
//
|
||||
// 打印管理列表项列表里的信息
|
||||
//
|
||||
public static void printIWinBollListInfo() {
|
||||
//LogUtils.d(TAG, "printAvtivityListInfo");
|
||||
if (!_mapActivityList.isEmpty()) {
|
||||
StringBuilder sb = new StringBuilder("Map entries : " + Integer.toString(_mapActivityList.size()));
|
||||
Iterator<Map.Entry<String, WinBollActivity>> iterator = _mapActivityList.entrySet().iterator();
|
||||
if (!_mapIWinBollList.isEmpty()) {
|
||||
StringBuilder sb = new StringBuilder("Map entries : " + Integer.toString(_mapIWinBollList.size()));
|
||||
Iterator<Map.Entry<String, IWinBollActivity>> iterator = _mapIWinBollList.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, WinBollActivity> entry = iterator.next();
|
||||
Map.Entry<String, IWinBollActivity> entry = iterator.next();
|
||||
sb.append("\nKey: " + entry.getKey() + ", \nValue: " + entry.getValue().getTag());
|
||||
//ToastUtils.show("\nKey: " + entry.getKey() + ", Value: " + entry.getValue().getTag());
|
||||
}
|
||||
@@ -310,6 +315,4 @@ public class WinBollActivityManager {
|
||||
LogUtils.d(TAG, "The map is empty.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,76 +0,0 @@
|
||||
package cc.winboll.studio.libapputils.app;
|
||||
|
||||
import cc.winboll.studio.libapputils.bean.DebugBean;
|
||||
import cc.winboll.studio.libapputils.log.LogUtils;
|
||||
|
||||
public class WinBollApplication extends cc.winboll.studio.libappbase.GlobalApplication {
|
||||
|
||||
public static final String TAG = "WinBollApplication";
|
||||
|
||||
public static enum WinBollUI_TYPE {
|
||||
Aplication, // 退出应用后,保持最近任务栏任务记录主窗口
|
||||
Service // 退出应用后,清理所有最近任务栏任务记录窗口
|
||||
};
|
||||
|
||||
// 应用类型标志
|
||||
volatile static WinBollUI_TYPE _mWinBollUI_TYPE = WinBollUI_TYPE.Service;
|
||||
|
||||
static volatile WinBollApplication _WinBollApplication = null;
|
||||
MyActivityLifecycleCallbacks mMyActivityLifecycleCallbacks;
|
||||
|
||||
// 标记当前应用是否处于调试状态
|
||||
static volatile boolean isDebug = false;
|
||||
|
||||
public static void setIsDebug(boolean isDebug) {
|
||||
WinBollApplication.isDebug = isDebug;
|
||||
}
|
||||
|
||||
public static boolean isDebug() {
|
||||
return isDebug;
|
||||
}
|
||||
|
||||
//
|
||||
// 设置 WinBoll 应用 UI 类型
|
||||
//
|
||||
public static void setWinBollUI_TYPE(WinBollUI_TYPE mWinBollUI_TYPE) {
|
||||
_mWinBollUI_TYPE = mWinBollUI_TYPE;
|
||||
}
|
||||
|
||||
//
|
||||
// 获取 WinBoll 应用 UI 类型
|
||||
//
|
||||
public static WinBollUI_TYPE getWinBollUI_TYPE() {
|
||||
return _mWinBollUI_TYPE;
|
||||
}
|
||||
|
||||
MyActivityLifecycleCallbacks getMyActivityLifecycleCallbacks() {
|
||||
return mMyActivityLifecycleCallbacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
_WinBollApplication = this;
|
||||
// 应用环境初始化, 基本调试环境
|
||||
//
|
||||
CrashHandler.init(this);
|
||||
LogUtils.init(this);
|
||||
|
||||
DebugBean debugBean = DebugBean.loadBean(this, DebugBean.class);
|
||||
if (debugBean == null) {
|
||||
//ToastUtils.show("debugBean == null");
|
||||
setIsDebug(false);
|
||||
} else {
|
||||
//ToastUtils.show("saveDebugStatus(" + String.valueOf(debugBean.isDebuging()) + ")");
|
||||
setIsDebug(debugBean.isDebuging());
|
||||
}
|
||||
|
||||
// 应用运行状态环境设置
|
||||
//
|
||||
mMyActivityLifecycleCallbacks = new MyActivityLifecycleCallbacks(this);
|
||||
registerActivityLifecycleCallbacks(mMyActivityLifecycleCallbacks);
|
||||
// 设置默认 WinBoll 应用 UI 类型
|
||||
setWinBollUI_TYPE(WinBollUI_TYPE.Service);
|
||||
//ToastUtils.show("WinBollUI_TYPE " + getWinBollUI_TYPE());
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package cc.winboll.studio.libapputils.app;
|
||||
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2025/02/04 10:19:34
|
||||
* @Describe WinBoll 工厂
|
||||
*/
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class WinBollFactory {
|
||||
|
||||
public static final String TAG = "WinBollFactory";
|
||||
|
||||
public static AppCompatActivity buildAppCompatActivity(IWinBollActivity iWinBoll) {
|
||||
return iWinBoll.getActivity();
|
||||
}
|
||||
}
|
@@ -0,0 +1,142 @@
|
||||
package cc.winboll.studio.libapputils.bean;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2025/01/20 14:19:02
|
||||
* @Describe 应用信息类
|
||||
*/
|
||||
import cc.winboll.studio.libapputils.R;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class APPInfo implements Serializable {
|
||||
|
||||
public static final String TAG = "APPInfo";
|
||||
|
||||
// 应用名称
|
||||
String appName;
|
||||
// 应用图标
|
||||
int appIcon;
|
||||
// 应用描述
|
||||
String appDescription;
|
||||
// 应用Git仓库地址
|
||||
String appGitName;
|
||||
// 应用Git仓库拥有者
|
||||
String appGitOwner;
|
||||
// 应用Git仓库分支
|
||||
String appGitAPPBranch;
|
||||
// 应用Git仓库子项目文件夹
|
||||
String appGitAPPSubProjectFolder;
|
||||
// 应用主页
|
||||
String appHomePage;
|
||||
// 应用包名称
|
||||
String appAPKName;
|
||||
// 应用包存储文件夹名称
|
||||
String appAPKFolderName;
|
||||
|
||||
public APPInfo(String appName, int appIcon, String appDescription, String appGitName, String appGitOwner, String appGitAPPBranch, String appGitAPPSubProjectFolder, String appHomePage, String appAPKName, String appAPKFolderName) {
|
||||
this.appName = appName;
|
||||
this.appIcon = appIcon;
|
||||
this.appDescription = appDescription;
|
||||
this.appGitName = appGitName;
|
||||
this.appGitOwner = appGitOwner;
|
||||
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.appGitOwner = "Studio";
|
||||
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 setAppGitOwner(String appGitOwner) {
|
||||
this.appGitOwner = appGitOwner;
|
||||
}
|
||||
|
||||
public String getAppGitOwner() {
|
||||
return appGitOwner;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public int getAppIcon() {
|
||||
return appIcon;
|
||||
}
|
||||
|
||||
public void setAppDescription(String appDescription) {
|
||||
this.appDescription = appDescription;
|
||||
}
|
||||
|
||||
public String getAppDescription() {
|
||||
return appDescription;
|
||||
}
|
||||
|
||||
public void setAppAPKFolderName(String appAPKFolderName) {
|
||||
this.appAPKFolderName = appAPKFolderName;
|
||||
}
|
||||
|
||||
public String getAppAPKFolderName() {
|
||||
return appAPKFolderName;
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
||||
public void setAppGitName(String appGitName) {
|
||||
this.appGitName = appGitName;
|
||||
}
|
||||
|
||||
public String getAppGitName() {
|
||||
return appGitName;
|
||||
}
|
||||
|
||||
public void setAppHomePage(String appHomePage) {
|
||||
this.appHomePage = appHomePage;
|
||||
}
|
||||
|
||||
public String getAppHomePage() {
|
||||
return appHomePage;
|
||||
}
|
||||
|
||||
public void setAppAPKName(String appAPKName) {
|
||||
this.appAPKName = appAPKName;
|
||||
}
|
||||
|
||||
public String getAppAPKName() {
|
||||
return appAPKName;
|
||||
}
|
||||
}
|
||||
|
@@ -1,30 +1,53 @@
|
||||
package cc.winboll.studio.libapputils.log;
|
||||
|
||||
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.ads.ADsView;
|
||||
import cc.winboll.studio.libapputils.app.WinBollApplication;
|
||||
import android.view.View;
|
||||
import android.app.Activity;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2024/08/12 15:07:58
|
||||
* @Describe WinBoll 应用日志窗口
|
||||
*/
|
||||
public class LogActivity extends Activity {
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libapputils.R;
|
||||
import cc.winboll.studio.libapputils.app.IWinBollActivity;
|
||||
import cc.winboll.studio.libapputils.bean.APPInfo;
|
||||
|
||||
public class LogActivity extends AppCompatActivity implements IWinBollActivity {
|
||||
|
||||
public static final String TAG = "LogActivity";
|
||||
|
||||
LogView mLogView;
|
||||
//ADsView mADsView;
|
||||
|
||||
@Override
|
||||
public AppCompatActivity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected boolean isEnableDisplayHomeAsUp() {
|
||||
// return false;
|
||||
// }
|
||||
@Override
|
||||
public APPInfo getAppInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Toolbar initToolBar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnableDisplayHomeAsUp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAddWinBollToolBar() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -32,12 +55,8 @@ public class LogActivity extends Activity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_log);
|
||||
mLogView = findViewById(R.id.logview);
|
||||
//mADsView = findViewById(R.id.adsview);
|
||||
//mADsView.loadUrl("https://www.winboll.cc");
|
||||
//mLogView.setVisibility(WinBollApplication.isDebug()?View.GONE:View.VISIBLE);
|
||||
//mADsView.setVisibility(WinBollApplication.isDebug()?View.GONE:View.VISIBLE);
|
||||
|
||||
if(WinBollApplication.isDebug()) { mLogView.start(); }
|
||||
|
||||
if (GlobalApplication.isDebuging()) { mLogView.start(); }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,21 +65,4 @@ public class LogActivity extends Activity {
|
||||
super.onResume();
|
||||
mLogView.start();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected boolean isAddWinBollToolBar() {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected Toolbar initToolBar() {
|
||||
// LogUtils.d(TAG, "initToolBar");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getTag() {
|
||||
// LogUtils.d(TAG, "getTag");
|
||||
// return TAG;
|
||||
// }
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ package cc.winboll.studio.libapputils.log;
|
||||
* @Describe 应用日志类
|
||||
*/
|
||||
import android.content.Context;
|
||||
import cc.winboll.studio.libapputils.app.WinBollApplication;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
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 (WinBollApplication.isDebug()) {
|
||||
if (GlobalApplication.isDebuging()) {
|
||||
// 初始化日志缓存文件路径
|
||||
_mfLogCacheDir = new File(context.getApplicationContext().getExternalCacheDir(), TAG);
|
||||
if (!_mfLogCacheDir.exists()) {
|
||||
@@ -174,8 +174,9 @@ public class LogUtils {
|
||||
mapTAGList.put(tagValue, false);
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException | IllegalAccessException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
} catch (NoClassDefFoundError | ClassNotFoundException | IllegalAccessException e) {
|
||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
||||
//LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
//Toast.makeText(context, TAG + " : " + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,34 @@
|
||||
package cc.winboll.studio.libapputils.view;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2025/02/06 09:02:28
|
||||
* @Describe 应用分支介绍按钮
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import cc.winboll.studio.libapputils.activities.AboutActivity;
|
||||
import cc.winboll.studio.libapputils.app.AboutActivityFactory;
|
||||
import cc.winboll.studio.libapputils.app.IWinBollActivity;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivityManager;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class AboutBranchButton extends Button {
|
||||
|
||||
public static final String TAG = "AboutBranchButton";
|
||||
|
||||
public AboutBranchButton(final Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
AboutActivityFactory.showAboutActivity(context, ((IWinBollActivity)context).getAppInfo());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -16,10 +16,11 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
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.WinBollApplication;
|
||||
import cc.winboll.studio.libapputils.bean.APPInfo;
|
||||
import cc.winboll.studio.libapputils.bean.DebugBean;
|
||||
import cc.winboll.studio.libapputils.log.LogUtils;
|
||||
import cc.winboll.studio.libapputils.util.PrefUtils;
|
||||
@@ -41,6 +42,8 @@ public class AboutView extends LinearLayout {
|
||||
public static final int MSG_APPUPDATE_CHECKED = 0;
|
||||
|
||||
Context mContext;
|
||||
APPInfo mAPPInfo;
|
||||
|
||||
WinBollServiceStatusView mWinBollServiceStatusView;
|
||||
OnRequestDevUserInfoAutofillListener mOnRequestDevUserInfoAutofillListener;
|
||||
String mszAppName = "";
|
||||
@@ -55,38 +58,70 @@ public class AboutView extends LinearLayout {
|
||||
String mszGitea = "";
|
||||
int mnAppIcon = 0;
|
||||
String mszWinBollServerHost;
|
||||
String mszReleaseAPKName;
|
||||
//String mszReleaseAPKName;
|
||||
EditText metDevUserName;
|
||||
EditText metDevUserPassword;
|
||||
|
||||
public AboutView(Context context, APPInfo appInfo) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
|
||||
setAPPInfo(appInfo);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public AboutView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mContext = context;
|
||||
|
||||
initView(context, attrs);
|
||||
}
|
||||
|
||||
void initView(Context context, AttributeSet attrs) {
|
||||
mContext = context;
|
||||
mszWinBollServerHost = WinBollApplication.isDebug() ? "http://10.8.0.13": "https://www.winboll.cc";
|
||||
public void setAPPInfo(APPInfo appInfo) {
|
||||
mAPPInfo = appInfo;
|
||||
}
|
||||
|
||||
APPInfo createAppInfo(Context context, AttributeSet attrs) {
|
||||
APPInfo appInfo = new APPInfo();
|
||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.AboutView);
|
||||
mszAppName = typedArray.getString(R.styleable.AboutView_app_name);
|
||||
mszAppAPKFolderName = typedArray.getString(R.styleable.AboutView_app_apkfoldername);
|
||||
mszAppAPKName = typedArray.getString(R.styleable.AboutView_app_apkname);
|
||||
mszAppGitName = typedArray.getString(R.styleable.AboutView_app_gitname);
|
||||
mszAppDescription = typedArray.getString(R.styleable.AboutView_appdescription);
|
||||
mnAppIcon = typedArray.getResourceId(R.styleable.AboutView_appicon, R.drawable.ic_winboll);
|
||||
appInfo.setAppName(typedArray.getString(R.styleable.AboutView_app_name));
|
||||
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.setAppGitOwner(typedArray.getString(R.styleable.AboutView_app_gitowner));
|
||||
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));
|
||||
// 返回一个绑定资源结束的信号给资源
|
||||
typedArray.recycle();
|
||||
return appInfo;
|
||||
}
|
||||
|
||||
void initView(Context context) {
|
||||
mszAppName = mAPPInfo.getAppName();
|
||||
mszAppAPKFolderName = mAPPInfo.getAppAPKFolderName();
|
||||
mszAppAPKName = mAPPInfo.getAppAPKName();
|
||||
mszAppGitName = mAPPInfo.getAppGitName();
|
||||
mszAppDescription = mAPPInfo.getAppDescription();
|
||||
mnAppIcon = mAPPInfo.getAppIcon();
|
||||
|
||||
mszWinBollServerHost = GlobalApplication.isDebuging() ? "https://dev.winboll.cc": "https://www.winboll.cc";
|
||||
|
||||
try {
|
||||
mszAppVersionName = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
mszCurrentAppPackageName = mszAppName + "_" + mszAppVersionName + ".apk";
|
||||
mszCurrentAppPackageName = mszAppAPKName + "_" + mszAppVersionName + ".apk";
|
||||
mszHomePage = mszWinBollServerHost + "/studio/details.php?app=" + mszAppAPKFolderName;
|
||||
mszGitea = "https://gitea.winboll.cc/Studio/" + mszAppGitName + ".git";
|
||||
if(mAPPInfo.getAppGitAPPBranch().equals("")) {
|
||||
mszGitea = "https://gitea.winboll.cc/" + mAPPInfo.getAppGitOwner() + "/" + mszAppGitName;
|
||||
} else {
|
||||
mszGitea = "https://gitea.winboll.cc/" + mAPPInfo.getAppGitOwner() + "/" + mszAppGitName + "/src/branch/" + mAPPInfo.getAppGitAPPBranch() + "/" + mAPPInfo.getAppGitAPPSubProjectFolder();
|
||||
}
|
||||
|
||||
if (WinBollApplication.isDebug()) {
|
||||
if (GlobalApplication.isDebuging()) {
|
||||
LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||
View addedView = inflater.inflate(R.layout.view_about_dev, this, false);
|
||||
LinearLayout llMain = addedView.findViewById(R.id.viewaboutdevLinearLayout1);
|
||||
@@ -120,15 +155,21 @@ public class AboutView extends LinearLayout {
|
||||
//llMain.addView(createAboutPage());
|
||||
|
||||
// 就读取正式版应用包版本号,设置 Release 应用包文件名
|
||||
String szReleaseAppVersionName = "";
|
||||
try {
|
||||
szReleaseAppVersionName = mContext.getPackageManager().getPackageInfo(subBetaSuffix(mContext.getPackageName()), 0).versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
mszReleaseAPKName = mszAppAPKName + "_" + szReleaseAppVersionName + ".apk";
|
||||
|
||||
// String szReleaseAppVersionName = "";
|
||||
// try {
|
||||
// //LogUtils.d(TAG, String.format("mContext.getPackageName() %s", mContext.getPackageName()));
|
||||
// String szSubBetaSuffix = subBetaSuffix(mContext.getPackageName());
|
||||
// //LogUtils.d(TAG, String.format("szSubBetaSuffix : %s", szSubBetaSuffix));
|
||||
// szReleaseAppVersionName = mContext.getPackageManager().getPackageInfo(szSubBetaSuffix, 0).versionName;
|
||||
// } catch (PackageManager.NameNotFoundException e) {
|
||||
// LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
// }
|
||||
// mszReleaseAPKName = mszAppAPKName + "_" + szReleaseAppVersionName + ".apk";
|
||||
}
|
||||
|
||||
void initView(Context context, AttributeSet attrs) {
|
||||
mAPPInfo = createAppInfo(context, attrs);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public static String subBetaSuffix(String input) {
|
||||
@@ -150,10 +191,13 @@ public class AboutView extends LinearLayout {
|
||||
return;
|
||||
}*/
|
||||
|
||||
if (!AppVersionUtils.isHasNewStageReleaseVersion(mszReleaseAPKName, mszNewestAppPackageName)) {
|
||||
// if (!AppVersionUtils.isHasNewStageReleaseVersion(mszReleaseAPKName, mszNewestAppPackageName)) {
|
||||
// ToastUtils.delayedShow("Current app is the newest.", 5000);
|
||||
// }
|
||||
if (!AppVersionUtils.isHasNewVersion2(mszCurrentAppPackageName, mszNewestAppPackageName)) {
|
||||
ToastUtils.delayedShow("Current app is the newest.", 5000);
|
||||
} else {
|
||||
String szMsg = "Current app is :\n[ " + mszReleaseAPKName
|
||||
String szMsg = "Current app is :\n[ " + mszCurrentAppPackageName
|
||||
+ " ]\nThe last app is :\n[ " + mszNewestAppPackageName
|
||||
+ " ]\nIs download the last app?";
|
||||
YesNoAlertDialog.show(mContext, "Application Update Prompt", szMsg, mIsDownlaodUpdateListener);
|
||||
@@ -168,7 +212,7 @@ public class AboutView extends LinearLayout {
|
||||
// 定义应用调试按钮
|
||||
//
|
||||
Element elementAppMode;
|
||||
if (WinBollApplication.isDebug()) {
|
||||
if (GlobalApplication.isDebuging()) {
|
||||
elementAppMode = new Element(mContext.getString(R.string.app_normal), R.drawable.ic_winboll);
|
||||
elementAppMode.setOnClickListener(mAppNormalOnClickListener);
|
||||
} else {
|
||||
@@ -200,7 +244,7 @@ public class AboutView extends LinearLayout {
|
||||
//.addItem(versionElement)
|
||||
//.addItem(adsElement)
|
||||
//.addGroup("Connect with us")
|
||||
.addEmail("ZhanGSKen@QQ.COM")
|
||||
.addEmail("ZhanGSKen@AliYun.Com")
|
||||
.addWebsite(mszHomePage)
|
||||
.addItem(elementAppMode)
|
||||
.addItem(elementGitWeb)
|
||||
@@ -234,7 +278,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);
|
||||
WinBollApplication.setIsDebug(true);
|
||||
GlobalApplication.setIsDebuging(context, true);
|
||||
DebugBean.saveBean(context, new DebugBean(true));
|
||||
|
||||
WinBollActivityManager.getInstance(context).finishAll();
|
||||
@@ -246,7 +290,7 @@ public class AboutView extends LinearLayout {
|
||||
Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
|
||||
if (intent != null) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
WinBollApplication.setIsDebug(false);
|
||||
GlobalApplication.setIsDebuging(context, false);
|
||||
DebugBean.saveBean(context, new DebugBean(false));
|
||||
|
||||
WinBollActivityManager.getInstance(context).finishAll();
|
||||
@@ -272,7 +316,7 @@ public class AboutView extends LinearLayout {
|
||||
String szUrl = mszWinBollServerHost + "/studio/details.php?app=" + mszAppAPKFolderName;
|
||||
// 构建包含认证信息的请求
|
||||
String credential = "";
|
||||
if (WinBollApplication.isDebug()) {
|
||||
if (GlobalApplication.isDebuging()) {
|
||||
credential = Credentials.basic(metDevUserName.getText().toString(), metDevUserPassword.getText().toString());
|
||||
PrefUtils.saveString(mContext, "metDevUserName", metDevUserName.getText().toString());
|
||||
PrefUtils.saveString(mContext, "metDevUserPassword", metDevUserPassword.getText().toString());
|
||||
|
@@ -1,25 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/activityaboutToolbar1"/>
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/activityaboutToolbar1"/>
|
||||
|
||||
<cc.winboll.studio.libapputils.view.AboutView
|
||||
app:app_name= "APP"
|
||||
app:app_apkfoldername="APP"
|
||||
app:app_apkname="APP"
|
||||
app:app_gitname="APP"
|
||||
app:appdescription="WinBoll.CC 网站客户端。"
|
||||
app:appicon="@drawable/ic_winboll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/activityaboutAboutView1"/>
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0"
|
||||
android:id="@+id/activityaboutLinearLayout1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@@ -8,8 +8,8 @@
|
||||
app:cardElevation="4dp"
|
||||
app:cardCornerRadius="4dp"
|
||||
android:id="@+id/listviewauthinfoCardView1"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp">
|
||||
android:layout_marginLeft="0dp"
|
||||
android:layout_marginRight="5dp">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
@@ -19,6 +19,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:id="@+id/viewlogtagTextView1"/>
|
||||
|
||||
<CheckBox
|
||||
|
@@ -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"/>
|
||||
|
@@ -5,6 +5,9 @@
|
||||
<attr name="app_apkfoldername" format="string" />
|
||||
<attr name="app_apkname" format="string" />
|
||||
<attr name="app_gitname" format="string" />
|
||||
<attr name="app_gitowner" 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>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="lib_name">library</string>
|
||||
<string name="lib_name">libapputils</string>
|
||||
<string name="app_normal">Click here is switch to Normal APP</string>
|
||||
<string name="app_debug">Click here is switch to APP DEBUG</string>
|
||||
<string name="gitea_home">GITEA HOME</string>
|
||||
|
Reference in New Issue
Block a user