Commit 1212e6be authored by chenyuling's avatar chenyuling

"更换UI"

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