Compare commits
11 Commits
aes-v15.0.
...
apputils-v
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8e6b06e366 | ||
![]() |
ae7fb2984a | ||
![]() |
a4d009f8fb | ||
![]() |
5a549e9652 | ||
![]() |
e2d71ae088 | ||
![]() |
506d2619f2 | ||
![]() |
17fa805a7f | ||
![]() |
1dcf8cd007 | ||
![]() |
d86d50212e | ||
![]() |
af2e09c02a | ||
![]() |
de6361b19b |
@@ -50,6 +50,8 @@ android {
|
||||
|
||||
dependencies {
|
||||
api project(':libapputils')
|
||||
api 'cc.winboll.studio:libappbase:1.0.3'
|
||||
|
||||
api 'cc.winboll.studio:libappbase:1.1.0'
|
||||
|
||||
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
|
||||
stageCount=2
|
||||
#Wed Jan 22 21:17:58 HKT 2025
|
||||
stageCount=4
|
||||
libraryProject=libapputils
|
||||
baseVersion=9.2
|
||||
publishVersion=9.2.1
|
||||
publishVersion=9.2.3
|
||||
buildCount=0
|
||||
baseBetaVersion=9.2.2
|
||||
baseBetaVersion=9.2.4
|
||||
|
@@ -5,27 +5,25 @@ package cc.winboll.studio.apputils;
|
||||
* @Date 2024/12/08 15:10:51
|
||||
* @Describe 全局应用类
|
||||
*/
|
||||
import android.app.Application;
|
||||
import android.view.Gravity;
|
||||
import cc.winboll.studio.libapputils.app.WinBollApplication;
|
||||
import cc.winboll.studio.GlobalApplication;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.hjq.toast.style.WhiteToastStyle;
|
||||
import cc.winboll.studio.libapputils.app.WinBollUtils;
|
||||
|
||||
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";
|
||||
|
||||
@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);
|
||||
// 初始化 WinBoll 框架
|
||||
WinBollUtils.getInstance(this).init(this);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@ import cc.winboll.studio.libapputils.app.WinBollActivityManager;
|
||||
import cc.winboll.studio.libapputils.log.LogActivity;
|
||||
import cc.winboll.studio.libapputils.log.LogUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import cc.winboll.studio.libapputils.activities.AboutActivity;
|
||||
import cc.winboll.studio.libapputils.bean.APPInfo;
|
||||
|
||||
final public class MainActivity extends WinBollActivity {
|
||||
|
||||
@@ -50,10 +52,13 @@ final public class MainActivity extends WinBollActivity {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
//WinBollActivityManager.getInstance().printAvtivityListInfo();
|
||||
WinBollActivityManager.getInstance(this).startWinBollActivity(this, LogActivity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,9 +160,32 @@ final public class MainActivity extends WinBollActivity {
|
||||
} 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_about) {
|
||||
openAboutActivity();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
void openAboutActivity() {
|
||||
Intent intent = new Intent(this, AboutActivity.class);
|
||||
APPInfo appInfo = new APPInfo();
|
||||
appInfo.setAppName("APPUtils");
|
||||
appInfo.setAppIcon(cc.winboll.studio.libapputils.R.drawable.ic_winboll);
|
||||
appInfo.setAppDescription("APPUtils Description");
|
||||
appInfo.setAppGitName("APP");
|
||||
appInfo.setAppHomePage("https://www.winboll.cc/studio/details.php?app=APP");
|
||||
appInfo.setAppAPKName("APPUtils");
|
||||
appInfo.setAppAPKFolderName("APPUtils");
|
||||
intent.putExtra(AboutActivity.EXTRA_APPINFO, appInfo);
|
||||
WinBollActivityManager.getInstance(this).startWinBollActivity(this, intent, AboutActivity.class);
|
||||
}
|
||||
|
||||
|
||||
public void onTestAboutActivity(View view) {
|
||||
//ToastUtils.show("onTestAboutActivity");
|
||||
openAboutActivity();
|
||||
}
|
||||
|
||||
public void onTestJavascriptHtmlActivity(View view) {
|
||||
Intent intent = new Intent(this, AssetsHtmlActivity.class);
|
||||
|
@@ -54,6 +54,21 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAllCaps="false"
|
||||
android:text="Test AboutActivity"
|
||||
android:onClick="onTestAboutActivity"/>
|
||||
|
||||
</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.1.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
|
||||
stageCount=2
|
||||
#Wed Jan 22 21:17:58 HKT 2025
|
||||
stageCount=4
|
||||
libraryProject=libapputils
|
||||
baseVersion=9.2
|
||||
publishVersion=9.2.1
|
||||
publishVersion=9.2.3
|
||||
buildCount=0
|
||||
baseBetaVersion=9.2.2
|
||||
baseBetaVersion=9.2.4
|
||||
|
@@ -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,25 +1,31 @@
|
||||
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 应用介绍页
|
||||
*/
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.LinearLayout;
|
||||
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.bean.APPInfo;
|
||||
import cc.winboll.studio.libapputils.view.AboutView;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
|
||||
final public class AboutActivity extends WinBollActivity {
|
||||
|
||||
public static final String TAG = "AboutActivity";
|
||||
public static final String EXTRA_APPINFO = "EXTRA_APPINFO";
|
||||
|
||||
|
||||
APPInfo mAPPInfo;
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
@@ -34,21 +40,19 @@ final public class AboutActivity extends WinBollActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about);
|
||||
|
||||
/*AboutView aboutView = findViewById(R.id.activityaboutAboutView1);
|
||||
aboutView.setOnRequestDevUserInfoAutofillListener(new AboutView.OnRequestDevUserInfoAutofillListener(){
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
});*/
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
mAPPInfo = (APPInfo)intent.getSerializableExtra(EXTRA_APPINFO);
|
||||
}
|
||||
if (mAPPInfo == null) {
|
||||
mAPPInfo = new APPInfo();
|
||||
}
|
||||
|
||||
AboutView aboutView = new AboutView(this, mAPPInfo);
|
||||
LinearLayout llMain = findViewById(R.id.activityaboutLinearLayout1);
|
||||
llMain.addView(aboutView);
|
||||
|
||||
ToastUtils.show(TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,9 +83,8 @@ final public class AboutActivity extends WinBollActivity {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -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 "";
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -6,22 +6,23 @@ 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.GlobalApplication;
|
||||
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";
|
||||
|
||||
Application mApplication;
|
||||
|
||||
public String mInfo = "";
|
||||
|
||||
public MyActivityLifecycleCallbacks(WinBollApplication application) {
|
||||
|
||||
public MyActivityLifecycleCallbacks(Application application) {
|
||||
mApplication = application;
|
||||
}
|
||||
|
||||
void createActivityeInfo(Activity activity) {
|
||||
|
@@ -64,7 +64,7 @@ abstract public class WinBollActivity extends AppCompatActivity {
|
||||
// 传入的Intent action在Activity清单的intent-filter的action节点里有定义
|
||||
if (intent.getAction() != null) {
|
||||
if (intent.getAction().equals(cc.winboll.studio.libapputils.intent.action.DEBUGVIEW)) {
|
||||
WinBollApplication.setIsDebug(true);
|
||||
WinBollUtils.setIsDebug(true);
|
||||
//ToastUtils.show!("WinBollApplication.setIsDebug(true) by action : " + intent.getAction());
|
||||
|
||||
}
|
||||
@@ -356,7 +356,7 @@ abstract public class WinBollActivity extends AppCompatActivity {
|
||||
if (isAddWinBollToolBar()) {
|
||||
getMenuInflater().inflate(R.menu.toolbar_winboll_shared_main, menu);
|
||||
}
|
||||
if (WinBollApplication.isDebug()) {
|
||||
if (WinBollUtils.isDebug()) {
|
||||
getMenuInflater().inflate(R.menu.toolbar_studio_debug, menu);
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
@@ -366,14 +366,21 @@ abstract public class WinBollActivity extends AppCompatActivity {
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
LogUtils.d(TAG, "onOptionsItemSelected");
|
||||
if (item.getItemId() == R.id.item_log) {
|
||||
LogUtils.d(TAG, "item_log not yet.");
|
||||
// LogUtils.d(TAG, "item_log not yet.");
|
||||
// Intent intent = new Intent(this, LogActivity.class);
|
||||
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
// intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
// startActivity(intent);
|
||||
|
||||
//WinBollActivityManager.getInstance().printAvtivityListInfo();
|
||||
//WinBollActivityManager.getInstance(this).startWinBollActivity(this, LogActivity.class);
|
||||
WinBollActivityManager.getInstance(this).startWinBollActivity(this, LogActivity.class);
|
||||
} else if (item.getItemId() == R.id.item_exit) {
|
||||
//ToastUtils.show("item_exit");
|
||||
WinBollActivityManager.getInstance(this).finishAll();
|
||||
} else if (item.getItemId() == R.id.item_info) {
|
||||
WinBollApplication application = (WinBollApplication) getApplication();
|
||||
application.getMyActivityLifecycleCallbacks().showActivityeInfo();
|
||||
LogUtils.d(TAG, "item_info not yet.");
|
||||
//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) {
|
||||
|
@@ -20,17 +20,16 @@ import java.util.Map;
|
||||
public class WinBollActivityManager {
|
||||
|
||||
public static final String TAG = "WinBollActivityManager";
|
||||
public static final String EXTRA_TAG = "EXTRA_TAG";
|
||||
|
||||
Context mContext;
|
||||
static WinBollActivityManager _mWinBollActivityManager;
|
||||
static Map<String, WinBollActivity> _mapActivityList;
|
||||
//static ArrayList<WinBollActivity> _mWinBollActivityList;
|
||||
|
||||
public WinBollActivityManager(Context context) {
|
||||
mContext = context;
|
||||
LogUtils.d(TAG, "WinBollActivityManager()");
|
||||
_mapActivityList = new HashMap<String, WinBollActivity>();
|
||||
//_mWinBollActivityList = new ArrayList<WinBollActivity>();
|
||||
}
|
||||
|
||||
public static synchronized WinBollActivityManager getInstance(Context context) {
|
||||
@@ -42,19 +41,10 @@ public class WinBollActivityManager {
|
||||
return _mWinBollActivityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把Activity添加到管理中
|
||||
*/
|
||||
//
|
||||
// 把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()));
|
||||
} else {
|
||||
@@ -66,7 +56,7 @@ public class WinBollActivityManager {
|
||||
|
||||
//
|
||||
// activity: 为 null 时,
|
||||
// intent.putExtra 函数 "tag" 参数为 tag
|
||||
// intent.putExtra 函数 EXTRA_TAG 参数为 tag
|
||||
// activity: 不为 null 时,
|
||||
// intent.putExtra 函数 "tag" 参数为 activity.getTag()
|
||||
//
|
||||
@@ -84,7 +74,7 @@ public class WinBollActivityManager {
|
||||
//打开多任务窗口 flags
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
intent.putExtra("tag", tag);
|
||||
intent.putExtra(EXTRA_TAG, tag);
|
||||
mContext.startActivity(intent);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
@@ -105,18 +95,18 @@ public class WinBollActivityManager {
|
||||
//打开多任务窗口 flags
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
intent.putExtra("tag", tag);
|
||||
intent.putExtra(EXTRA_TAG, tag);
|
||||
mContext.startActivity(intent);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断 tag绑定的 MyActivity是否存在
|
||||
*/
|
||||
//
|
||||
// 判断 tag绑定的 MyActivity是否存在
|
||||
//
|
||||
public boolean isActive(String tag) {
|
||||
printAvtivityListInfo();
|
||||
//printAvtivityListInfo();
|
||||
WinBollActivity activity = getWinBollActivity(tag);
|
||||
if (activity != null) {
|
||||
LogUtils.d(TAG, "isActive(...) activity != null tag " + tag);
|
||||
@@ -141,21 +131,21 @@ public class WinBollActivityManager {
|
||||
return _mapActivityList.get(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
||||
*/
|
||||
//
|
||||
// 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
||||
//
|
||||
public <T extends WinBollActivity> void resumeActivity(Context context, String tag) {
|
||||
LogUtils.d(TAG, "resumeActivty");
|
||||
T activity = (T)getWinBollActivity(tag);
|
||||
LogUtils.d(TAG, "activity " + activity.getTag());
|
||||
//LogUtils.d(TAG, "activity " + activity.getTag());
|
||||
if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
|
||||
resumeActivity(context, activity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
||||
*/
|
||||
//
|
||||
// 找到tag 绑定的 BaseActivity ,通过 getTaskId() 移动到前台
|
||||
//
|
||||
public <T extends WinBollActivity> void resumeActivity(Context context, T activity) {
|
||||
ActivityManager am = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
//返回启动它的根任务(home 或者 MainActivity)
|
||||
@@ -170,39 +160,39 @@ public class WinBollActivityManager {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 结束所有 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 : _mapActivityList.keySet()) {
|
||||
//System.out.println("Key: " + key + ", Value: " + _mapActivityList.get(key));
|
||||
WinBollActivity activity = _mapActivityList.get(key);
|
||||
//ToastUtils.show("finishAll() activity");
|
||||
if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
|
||||
//ToastUtils.show("activity != null ...");
|
||||
if (WinBollUtils.getInstance(mContext).getWinBollUI_TYPE() == WinBollUtils.WinBollUI_TYPE.Service) {
|
||||
// 结束窗口和最近任务栏, 建议前台服务类应用使用,可以方便用户再次调用 UI 操作。
|
||||
activity.finishAndRemoveTask();
|
||||
//ToastUtils.show("finishAll() activity.finishAndRemoveTask();");
|
||||
} else if (WinBollUtils.getInstance(mContext).getWinBollUI_TYPE() == WinBollUtils.WinBollUI_TYPE.Aplication) {
|
||||
// 结束窗口保留最近任务栏,建议前台服务类应用使用,可以保持应用的系统自觉性。
|
||||
activity.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
|
||||
*/
|
||||
//
|
||||
// 结束指定Activity
|
||||
//
|
||||
public <T extends WinBollActivity> void finish(T activity) {
|
||||
try {
|
||||
if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) {
|
||||
@@ -225,22 +215,6 @@ public class WinBollActivityManager {
|
||||
if (preActivity != null) {
|
||||
resumeActivity(mContext, preActivity);
|
||||
}
|
||||
|
||||
// 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,6 +222,9 @@ public class WinBollActivityManager {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 获取窗口队列中的前一个窗口
|
||||
//
|
||||
WinBollActivity getPreActivity(WinBollActivity activity) {
|
||||
try {
|
||||
boolean bingo = false;
|
||||
@@ -271,12 +248,10 @@ 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());
|
||||
@@ -285,15 +260,9 @@ public class WinBollActivityManager {
|
||||
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() {
|
||||
//LogUtils.d(TAG, "printAvtivityListInfo");
|
||||
if (!_mapActivityList.isEmpty()) {
|
||||
@@ -310,6 +279,4 @@ public class WinBollActivityManager {
|
||||
LogUtils.d(TAG, "The map is empty.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,31 @@
|
||||
package cc.winboll.studio.libapputils.app;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.view.Gravity;
|
||||
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 WinBollApplication extends cc.winboll.studio.libappbase.GlobalApplication {
|
||||
public class WinBollUtils {
|
||||
|
||||
public static final String TAG = "WinBollApplication";
|
||||
public static final String TAG = "WinBollUtils";
|
||||
|
||||
//
|
||||
// 单件结构模块
|
||||
//
|
||||
static volatile WinBollUtils _WinBollUtils;
|
||||
Context mContext;
|
||||
WinBollUtils(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
public static synchronized WinBollUtils getInstance(Context context) {
|
||||
if (_WinBollUtils == null) {
|
||||
_WinBollUtils = new WinBollUtils(context);
|
||||
}
|
||||
return _WinBollUtils;
|
||||
}
|
||||
|
||||
public static enum WinBollUI_TYPE {
|
||||
Aplication, // 退出应用后,保持最近任务栏任务记录主窗口
|
||||
@@ -15,14 +35,14 @@ public class WinBollApplication extends cc.winboll.studio.libappbase.GlobalAppli
|
||||
// 应用类型标志
|
||||
volatile static WinBollUI_TYPE _mWinBollUI_TYPE = WinBollUI_TYPE.Service;
|
||||
|
||||
static volatile WinBollApplication _WinBollApplication = null;
|
||||
//static volatile WinBollApplication _WinBollApplication = null;
|
||||
MyActivityLifecycleCallbacks mMyActivityLifecycleCallbacks;
|
||||
|
||||
// 标记当前应用是否处于调试状态
|
||||
static volatile boolean isDebug = false;
|
||||
|
||||
public static void setIsDebug(boolean isDebug) {
|
||||
WinBollApplication.isDebug = isDebug;
|
||||
WinBollUtils.isDebug = isDebug;
|
||||
}
|
||||
|
||||
public static boolean isDebug() {
|
||||
@@ -47,16 +67,19 @@ public class WinBollApplication extends cc.winboll.studio.libappbase.GlobalAppli
|
||||
return mMyActivityLifecycleCallbacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
_WinBollApplication = this;
|
||||
public void init(Application application) {
|
||||
// 应用环境初始化, 基本调试环境
|
||||
//
|
||||
CrashHandler.init(this);
|
||||
LogUtils.init(this);
|
||||
|
||||
DebugBean debugBean = DebugBean.loadBean(this, DebugBean.class);
|
||||
// 初始化日志模块
|
||||
LogUtils.init(mContext);
|
||||
// 初始化 Toast 框架
|
||||
ToastUtils.init(application);
|
||||
// 设置 Toast 布局样式
|
||||
//ToastUtils.setView(R.layout.view_toast);
|
||||
ToastUtils.setStyle(new WhiteToastStyle());
|
||||
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
|
||||
// 设置应用调试标志
|
||||
DebugBean debugBean = DebugBean.loadBean(mContext, DebugBean.class);
|
||||
if (debugBean == null) {
|
||||
//ToastUtils.show("debugBean == null");
|
||||
setIsDebug(false);
|
||||
@@ -64,11 +87,10 @@ public class WinBollApplication extends cc.winboll.studio.libappbase.GlobalAppli
|
||||
//ToastUtils.show("saveDebugStatus(" + String.valueOf(debugBean.isDebuging()) + ")");
|
||||
setIsDebug(debugBean.isDebuging());
|
||||
}
|
||||
|
||||
// 应用运行状态环境设置
|
||||
// 应用窗口管理模块参数设置
|
||||
//
|
||||
mMyActivityLifecycleCallbacks = new MyActivityLifecycleCallbacks(this);
|
||||
registerActivityLifecycleCallbacks(mMyActivityLifecycleCallbacks);
|
||||
mMyActivityLifecycleCallbacks = new MyActivityLifecycleCallbacks(application);
|
||||
application.registerActivityLifecycleCallbacks(mMyActivityLifecycleCallbacks);
|
||||
// 设置默认 WinBoll 应用 UI 类型
|
||||
setWinBollUI_TYPE(WinBollUI_TYPE.Service);
|
||||
//ToastUtils.show("WinBollUI_TYPE " + getWinBollUI_TYPE());
|
@@ -0,0 +1,107 @@
|
||||
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;
|
||||
// 应用主页
|
||||
String appHomePage;
|
||||
// 应用包名称
|
||||
String appAPKName;
|
||||
// 应用包存储文件夹名称
|
||||
String appAPKFolderName;
|
||||
|
||||
public APPInfo(String appName, int appIcon, String appDescription, String appGitName, String appHomePage, String appAPKName, String appAPKFolderName) {
|
||||
this.appName = appName;
|
||||
this.appIcon = appIcon;
|
||||
this.appDescription = appDescription;
|
||||
this.appGitName = appGitName;
|
||||
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.appHomePage = "https://www.winboll.cc/studio/details.php?app=APP";
|
||||
this.appAPKName = "APP";
|
||||
this.appAPKFolderName = "APP";
|
||||
}
|
||||
|
||||
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,41 @@
|
||||
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.widget.Toolbar;
|
||||
import cc.winboll.studio.libapputils.R;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivity;
|
||||
import cc.winboll.studio.libapputils.app.WinBollUtils;
|
||||
|
||||
public class LogActivity extends WinBollActivity {
|
||||
|
||||
public static final String TAG = "LogActivity";
|
||||
|
||||
LogView mLogView;
|
||||
//ADsView mADsView;
|
||||
|
||||
// @Override
|
||||
// protected boolean isEnableDisplayHomeAsUp() {
|
||||
// return false;
|
||||
// }
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Toolbar initToolBar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnableDisplayHomeAsUp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAddWinBollToolBar() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -32,12 +43,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 (WinBollUtils.isDebug()) { mLogView.start(); }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,21 +53,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.libapputils.app.WinBollUtils;
|
||||
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 (WinBollUtils.isDebug()) {
|
||||
// 初始化日志缓存文件路径
|
||||
_mfLogCacheDir = new File(context.getApplicationContext().getExternalCacheDir(), TAG);
|
||||
if (!_mfLogCacheDir.exists()) {
|
||||
|
@@ -19,7 +19,8 @@ import android.widget.LinearLayout;
|
||||
import cc.winboll.studio.libapputils.R;
|
||||
import cc.winboll.studio.libapputils.app.AppVersionUtils;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivityManager;
|
||||
import cc.winboll.studio.libapputils.app.WinBollApplication;
|
||||
import cc.winboll.studio.libapputils.app.WinBollUtils;
|
||||
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,63 @@ 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.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 = WinBollUtils.isDebug() ? "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 (WinBollApplication.isDebug()) {
|
||||
if (WinBollUtils.isDebug()) {
|
||||
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 +148,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 +184,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 +205,7 @@ public class AboutView extends LinearLayout {
|
||||
// 定义应用调试按钮
|
||||
//
|
||||
Element elementAppMode;
|
||||
if (WinBollApplication.isDebug()) {
|
||||
if (WinBollUtils.isDebug()) {
|
||||
elementAppMode = new Element(mContext.getString(R.string.app_normal), R.drawable.ic_winboll);
|
||||
elementAppMode.setOnClickListener(mAppNormalOnClickListener);
|
||||
} else {
|
||||
@@ -234,7 +271,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);
|
||||
WinBollUtils.setIsDebug(true);
|
||||
DebugBean.saveBean(context, new DebugBean(true));
|
||||
|
||||
WinBollActivityManager.getInstance(context).finishAll();
|
||||
@@ -246,7 +283,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);
|
||||
WinBollUtils.setIsDebug(false);
|
||||
DebugBean.saveBean(context, new DebugBean(false));
|
||||
|
||||
WinBollActivityManager.getInstance(context).finishAll();
|
||||
@@ -272,7 +309,7 @@ public class AboutView extends LinearLayout {
|
||||
String szUrl = mszWinBollServerHost + "/studio/details.php?app=" + mszAppAPKFolderName;
|
||||
// 构建包含认证信息的请求
|
||||
String credential = "";
|
||||
if (WinBollApplication.isDebug()) {
|
||||
if (WinBollUtils.isDebug()) {
|
||||
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
|
||||
|
Reference in New Issue
Block a user