运维功能进行分组显示
parent
32adff37c5
commit
33be977e56
@ -0,0 +1,212 @@
|
||||
package com.xypower.mpmaster;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import com.dev.devapi.api.SysApi;
|
||||
import com.xypower.mpmaster.sms.UpdateSysConfigUtil;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
public class DashboardActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_dashboard);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
findViewById(R.id.btnEnableCam3V3).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SysApi.setCam3V3Enable(true);
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.btnDisableCam3V3).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SysApi.setCam3V3Enable(false);
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.btnTurnOtgOn).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SysApi.setOtgState(true);
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.btnTurnOtgOff).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SysApi.setOtgState(false);
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.nrsec).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SysApi.setSpiPowerOn(true);
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.btnTurnAppOn).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// SysApi.enableApp(v.getContext(), "abcd1234");
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
findViewById(R.id.btnTurn485On).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SysApi.setRS485Enable(true);
|
||||
SysApi.set12VEnable(true);
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.btnTurn485Off).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SysApi.set12VEnable(false);
|
||||
SysApi.setRS485Enable(false);
|
||||
}
|
||||
});
|
||||
|
||||
Switch sw = (Switch) findViewById(R.id.btn485ReadMode);
|
||||
sw.setChecked(true);
|
||||
findViewById(R.id.btn485ReadMode).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Switch sw = (Switch) view;
|
||||
if (sw.isChecked()) {
|
||||
SysApi.set485ReadMode();
|
||||
} else {
|
||||
SysApi.set485WriteMode();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
findViewById(R.id.sendsms).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// boolean gpsEnabled = LocationUtil.isGpsEnabled(MainActivity.this);
|
||||
// System.out.printf("g" + gpsEnabled);
|
||||
// LocationUtil.register(MainActivity.this, 0, 0, new LocationUtil.OnLocationChangeListener() {
|
||||
// @Override
|
||||
// public void getLastKnownLocation(Location location) {
|
||||
// Log.e("xyh", "onLocationChanged: " + location.getLatitude());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onLocationChanged(Location location) {
|
||||
// //位置信息变化时触发
|
||||
// Log.e("xyh", "定位方式:" + location.getProvider());
|
||||
// Log.e("xyh", "纬度:" + location.getLatitude());
|
||||
// Log.e("xyh", "经度:" + location.getLongitude());
|
||||
// Log.e("xyh", "海拔:" + location.getAltitude());
|
||||
// Log.e("xyh", "时间:" + location.getTime());
|
||||
// Log.e("xyh", "国家:" + LocationUtil.getCountryName(MainActivity.this, location.getLatitude(), location.getLongitude()));
|
||||
// Log.e("xyh", "获取地理位置:" + LocationUtil.getAddress(MainActivity.this, location.getLatitude(), location.getLongitude()));
|
||||
// Log.e("xyh", "所在地:" + LocationUtil.getLocality(MainActivity.this, location.getLatitude(), location.getLongitude()));
|
||||
// Log.e("xyh", "所在街道:" + LocationUtil.getStreet(MainActivity.this, location.getLatitude(), location.getLongitude()));
|
||||
// LocationUtil.unregister();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
// System.out.println("dfsad");
|
||||
// }
|
||||
// });
|
||||
|
||||
// SysApi.reboot(MainActivity.this);
|
||||
|
||||
// DownloadUtils downloadUtils = new DownloadUtils(getApplicationContext(), "http://180.166.218.222:40101/upgrades/20240509_upd_663c857dbfcf7.apk", "test.apk");
|
||||
|
||||
// ActivityManager manager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
|
||||
// manager.restartPackage(context.getPackageName());
|
||||
// String ACTION_UPDATE_CONFIGS = "com.xypower.mpapp.ACT_UPD_CFG";
|
||||
// Intent intent = new Intent();
|
||||
// intent.setAction(ACTION_UPDATE_CONFIGS);
|
||||
// intent.putExtra("restart", 1);
|
||||
// // PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
|
||||
// sendBroadcast(intent);
|
||||
//// LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
|
||||
//// localBroadcastManager.sendBroadcast(intent);
|
||||
|
||||
|
||||
// boolean photoOrVideo;
|
||||
// photoOrVideo = true;
|
||||
// List<Long> schedules = new ArrayList<>();
|
||||
// long ts = System.currentTimeMillis() / 1000;
|
||||
// long val = 0;
|
||||
// val |= ((long) 1 << 16);
|
||||
// val |= ((long) 255 << 8);
|
||||
// val |= photoOrVideo ? 0L : 1L;
|
||||
//
|
||||
// schedules.add(Long.valueOf(val));
|
||||
//
|
||||
// Intent intent1 = new Intent();
|
||||
// intent1.setAction(ACTION_TAKE_PHOTO);
|
||||
// int cnt = schedules.size();
|
||||
// intent1.putExtra(EXTRA_PARAM_SCHEDULES, cnt);
|
||||
// for (int idx = 0; idx < cnt; idx++) {
|
||||
// intent1.putExtra(EXTRA_PARAM_SCHEDULE + idx, schedules.get(idx).longValue());
|
||||
// }
|
||||
// intent1.putExtra(EXTRA_PARAM_TIME, 0);
|
||||
// intent1.putExtra(EXTRA_PARAM_TAKING_TIME, ts);
|
||||
// sendBroadcast(intent1);
|
||||
|
||||
|
||||
// UpdateSysConfigUtil.getScheduless(1);
|
||||
byte[] bytes = {1, 1, 2, 0, 0, 0, 23, 59};
|
||||
String photoSchedules = UpdateSysConfigUtil.getPhotoSchedules(1);
|
||||
|
||||
byte[] decode = Base64.getDecoder().decode(photoSchedules);
|
||||
System.out.println(decode);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
// HotspotManager.enableHotspot(getApplicationContext(), false);
|
||||
// SysApi.openHotSpot(getApplicationContext());
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
//当点击不同的menu item 是执行不同的操作
|
||||
switch (id) {
|
||||
case android.R.id.home:
|
||||
{
|
||||
finish();
|
||||
return false;
|
||||
}
|
||||
// break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".DashboardActivity">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnEnableCam3V3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="Cam3V3 On"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDisableCam3V3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:text="Cam3V3 Off"
|
||||
app:layout_constraintStart_toEndOf="@+id/btnEnableCam3V3"
|
||||
app:layout_constraintTop_toTopOf="@+id/btnEnableCam3V3" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnTurnOtgOn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="OTG On"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btnEnableCam3V3" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnTurnOtgOff"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:text="OTG Off"
|
||||
app:layout_constraintStart_toEndOf="@+id/btnTurnOtgOn"
|
||||
app:layout_constraintTop_toTopOf="@+id/btnTurnOtgOn" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnTurnAppOn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="APP On"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btnTurnOtgOn" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnTurn485On"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="485 On"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btnTurnAppOn" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnTurn485Off"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:text="485 Off"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@+id/btnTurn485On"
|
||||
app:layout_constraintTop_toTopOf="@+id/btnTurn485On" />
|
||||
|
||||
|
||||
<Switch
|
||||
android:id="@+id/btn485ReadMode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="485Read"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@+id/btnTurn485Off"
|
||||
app:layout_constraintTop_toTopOf="@+id/btnTurn485On" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/sendsms"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:text="gps"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btnTurn485On" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/nrsec"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:text="NRSEC"
|
||||
app:layout_constraintStart_toEndOf="@+id/sendsms"
|
||||
app:layout_constraintTop_toTopOf="@+id/sendsms" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.xypower.mpmaster.MainActivity">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_dashboard"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/btn_dashboard"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_reboot_mp"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/btn_reboot_mp"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_reboot_mpmst"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/btn_reboot_mpmst"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
@ -1,5 +1,7 @@
|
||||
<resources>
|
||||
<string name="app_name">运维APP</string>
|
||||
<string name="text_name_notification">Notification Name</string>
|
||||
|
||||
<string name="btn_dashboard">操作区</string>
|
||||
<string name="btn_reboot_mp">重启MpAPP</string>
|
||||
<string name="btn_reboot_mpmst">重启运维APP</string>
|
||||
</resources>
|
Loading…
Reference in New Issue