Commit 1212e6be authored by chenyuling's avatar chenyuling

"更换UI"

parent da66d469
Pipeline #1619 canceled with stages
......@@ -20,7 +20,7 @@ android {
minSdk 24
targetSdk 32
versionCode 1
versionName "1.0.0"
versionName "1.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
......@@ -9,7 +9,6 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 安装APK权限,需要在程序中动态申请,并且不同于外部存储读写权限申请 -->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<application
android:name=".uis.MyApplication"
android:allowBackup="true"
......@@ -23,14 +22,44 @@
android:supportsRtl="true"
android:theme="@style/Theme.StatInfo"
android:usesCleartextTraffic="true"
tools:targetApi="31">
tools:targetApi="31" >
<activity
android:name=".uis.news.SettingActivity"
android:configChanges="keyboardHidden|orientation"
android:exported="false"
android:windowSoftInputMode="adjustPan" >
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".uis.MainActivity"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!--
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
-->
</intent-filter>
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<meta-data
android:name="design_width_in_dp"
android:value="960" />
<meta-data
android:name="design_height_in_dp"
android:value="540" /> <!-- fileprovider名称在安装时传递给系统安装程序 -->
<!--<provider
<!--
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileProvider"
android:exported="false"
......@@ -38,46 +67,37 @@
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/autoupdate" />
</provider>-->
</provider>
-->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<activity
android:name=".uis.MainActivity"
android:name=".uis.MainOldActivity"
android:configChanges="keyboardHidden|orientation"
android:exported="true"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!--<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />-->
</intent-filter>
android:exported="false"
android:windowSoftInputMode="adjustPan" >
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".uis.GroupActivity"
android:exported="false">
android:exported="false" >
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".uis.FlashActivity"
android:exported="false">
android:exported="false" >
<meta-data
android:name="android.app.lib_name"
android:value="" />
......
package com.srthinker.statinfo.constant;
import com.srthinker.statinfo.util.common.FileUtil;
public class Const {
public static final String DEVICE_TYPE = "RC500";
public static final String SN_PATH = "/sdcard/devicesn/deviceSn.txt";
public static final String DEVICE_SN = FileUtil.readTextFromFile(SN_PATH);
}
......@@ -235,13 +235,15 @@ public class ApiQuest {
mgrHashMap.clear();
}
public void queryPersons(QueryPersonCallback callback){
public boolean queryPersons(QueryPersonCallback callback){
if (enterMgrHashMap.size()>0){
ApiManager oneEnterMgr = enterMgrHashMap.get(oneEnterIp);
if (oneEnterMgr != null) {
oneEnterMgr.queryPersons();
oneEnterMgr.setOnQueryPersonsCallback(callback);
return true;
}
}
return false;
}
}
......@@ -55,7 +55,6 @@ import com.srthinker.statinfo.presenter.RealTimeClock;
import com.srthinker.statinfo.presenter.StatSize;
import com.srthinker.statinfo.uis.fragment.ConfigDlgFragment;
import com.srthinker.statinfo.update.MDownloadCallBack;
import com.srthinker.statinfo.update.NetworkViewModel;
import com.srthinker.statinfo.update.UpdateInfo;
import com.srthinker.statinfo.util.common.ClickUtil;
import com.srthinker.statinfo.util.common.FileUtil;
......@@ -74,7 +73,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
public class MainActivity extends BaseActivity implements OnTimeUpdateListener, MDownloadCallBack, UpperDownloadCallback, NetworkIPMonitor.OnIPChangeCallback, ConfigCallback, QueryPersonCallback, UpperDevicesCallback {
public class MainOldActivity extends BaseActivity implements OnTimeUpdateListener, MDownloadCallBack, UpperDownloadCallback, NetworkIPMonitor.OnIPChangeCallback, ConfigCallback, QueryPersonCallback, UpperDevicesCallback {
private static final String TAG = "MainActivity";
private com.srthinker.statinfo.databinding.ActivityMainBinding mBinding;
......@@ -204,10 +203,10 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
}
private void detectUpgrade() {
NetworkViewModel networkViewModel = new NetworkViewModel();
/*NetworkViewModel networkViewModel = new NetworkViewModel();
networkViewModel.init(this,this);
networkViewModel.setDownloadCallback(this);
networkViewModel.getLastestVersion(deviceSn,DEVICE_TYPE);
networkViewModel.getLastestVersion(deviceSn,DEVICE_TYPE);*/
}
private void checkAllPermission() {
......@@ -341,7 +340,7 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
ThreadPool.getInstance().getThreadPoolExecutor().execute(() -> {
boolean restricted = Utils.isRootPermissionRestricted();
if (!restricted){
Utils.clientInstall(installPath,MainActivity.this,".uis.MainActivity");
Utils.clientInstall(installPath, MainOldActivity.this,".uis.MainActivity");
}else{
Utils.installApp(getApplicationContext(),new File(installPath));
}
......@@ -533,7 +532,7 @@ public class MainActivity extends BaseActivity implements OnTimeUpdateListener,
runOnUiThread(()->{
ClickUtil.enableClick(mBinding.btnGroupDetail);
});
Intent intent = new Intent(MainActivity.this, GroupActivity.class);
Intent intent = new Intent(MainOldActivity.this, GroupActivity.class);
startActivity(intent);
});
......
......@@ -16,6 +16,7 @@ import java.util.concurrent.TimeUnit
abstract class BaseViewModel : ViewModel() {
lateinit var mContext: Context
//lateinit var mActivity: MainActivity
lateinit var mActivity: MainActivity
......@@ -34,6 +35,11 @@ abstract class BaseViewModel : ViewModel() {
)
/*open fun init(context: Context, mainActivity: MainActivity) {
mContext = context
mActivity = mainActivity
}*/
open fun init(context: Context, mainActivity: MainActivity) {
mContext = context
mActivity = mainActivity
......
......@@ -29,6 +29,11 @@ class NetworkViewModel : BaseViewModel(),
private val thirdUrl = "http://139.9.78.104:8080/"
private val TAG = "lwl-DownloadViewModel"
/*override fun init(context: Context, mainActivity: MainActivity) {
super.init(context, mainActivity)
initData()
}*/
override fun init(context: Context, mainActivity: MainActivity) {
super.init(context, mainActivity)
initData()
......
......@@ -49,6 +49,11 @@ public class SharedUtil {
mEditor.commit(); // 提交编辑器中的修改
}
public void writeShared(String key,boolean value){
mEditor.putBoolean(key,value);
mEditor.commit();
}
public void writeShared(int key, Object obj){
writeShared(String.valueOf(key),obj);
}
......@@ -97,6 +102,10 @@ public class SharedUtil {
return mShared.getInt(key, defaultValue);
}
public boolean readShared(String key,boolean defaultValue){
return mShared.getBoolean(key,defaultValue);
}
//将String转化回对象
public <T extends Object> T readSharedObject(String key,Class<T> clazz,String defaultValue){
String readString = readShared(key, defaultValue);
......
......@@ -12,6 +12,7 @@ import android.provider.Settings;
import android.text.InputType;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.Toast;
......@@ -91,6 +92,21 @@ public class Utils {
return dm.density; // 返回屏幕的像素密度数值
}
//根据高度和行数设置字体大小
public static float calculateTextSize(Context ctx,int line){
int screenHeight = getScreenHeight(ctx);
if (line>0) {
int lineHeight = screenHeight / line;
TypedValue typedValue = new TypedValue();
typedValue.density = (int) ctx.getResources().getDisplayMetrics().density;
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, lineHeight, ctx.getResources().getDisplayMetrics());
}else{
return 0;
}
}
public static void installApp(Context pContext, File pFile){
if (null == pFile)
return;
......
......@@ -8,7 +8,7 @@
android:focusableInTouchMode="true"
android:orientation="vertical"
android:background="@color/bg_070A2E"
tools:context=".uis.MainActivity">
tools:context=".uis.MainOldActivity">
<RelativeLayout
android:layout_width="939.59dp"
......
......@@ -11,4 +11,5 @@
<dimen name="text_15">15sp</dimen>
<dimen name="text_11">11sp</dimen>
<dimen name="dlg_margin">10dp</dimen>
<dimen name="display_text">95sp</dimen>
</resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment