version:
fix: update:优化控制页面
This commit is contained in:
@@ -40,6 +40,7 @@ import com.uiuios.aios.view.RulerSeekBar;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -66,7 +67,7 @@ public class ControlActivity extends AppCompatActivity {
|
||||
@BindView(R.id.tv_bt_ssid)
|
||||
TextView tv_bt_ssid;
|
||||
|
||||
// @BindView(R.id.tv_font_size)
|
||||
// @BindView(R.id.tv_font_size)
|
||||
// TextView tv_font_size;
|
||||
@BindView(R.id.seekBar)
|
||||
RulerSeekBar seekBar;
|
||||
@@ -538,53 +539,136 @@ public class ControlActivity extends AppCompatActivity {
|
||||
private boolean flashing = false;
|
||||
private CameraManager cameraManager;
|
||||
|
||||
private void getFlashlight() {
|
||||
if (isFlashlightAvailable()) {
|
||||
tv_flashlight_switch.setText("关");
|
||||
cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
} else {
|
||||
tv_flashlight_switch.setText("不可用");
|
||||
cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
return;
|
||||
}
|
||||
// if (isFlashlightEnabled()) {
|
||||
// tv_flashlight_switch.setText("开");
|
||||
// cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
// } else {
|
||||
// private void getFlashlight() {
|
||||
// if (isFlashlightAvailable()) {
|
||||
// tv_flashlight_switch.setText("关");
|
||||
// cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
// } else {
|
||||
// tv_flashlight_switch.setText("不可用");
|
||||
// cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
// return;
|
||||
// }
|
||||
//// if (isFlashlightEnabled()) {
|
||||
//// tv_flashlight_switch.setText("开");
|
||||
//// cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
//// } else {
|
||||
//// tv_flashlight_switch.setText("关");
|
||||
//// cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
//// }
|
||||
//
|
||||
// cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
|
||||
//
|
||||
// cl_flashlight.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// if (flashing) {
|
||||
// try {
|
||||
// String CameraId = cameraManager.getCameraIdList()[0];
|
||||
// cameraManager.setTorchMode(CameraId, false);
|
||||
// } catch (CameraAccessException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// flashing = false;
|
||||
// tv_flashlight_switch.setText("关");
|
||||
// cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
// } else {
|
||||
// try {
|
||||
// String CameraId = cameraManager.getCameraIdList()[0];
|
||||
// cameraManager.setTorchMode(CameraId, true);
|
||||
// } catch (CameraAccessException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// tv_flashlight_switch.setText("开");
|
||||
// cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
// flashing = true;
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
|
||||
BroadcastReceiver mTimeUpdateReceiver;
|
||||
|
||||
cl_flashlight.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (flashing) {
|
||||
try {
|
||||
String CameraId = cameraManager.getCameraIdList()[0];
|
||||
cameraManager.setTorchMode(CameraId, false);
|
||||
} catch (CameraAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
flashing = false;
|
||||
tv_flashlight_switch.setText("关");
|
||||
cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
} else {
|
||||
try {
|
||||
String CameraId = cameraManager.getCameraIdList()[0];
|
||||
cameraManager.setTorchMode(CameraId, true);
|
||||
} catch (CameraAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
tv_flashlight_switch.setText("开");
|
||||
cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
flashing = true;
|
||||
}
|
||||
class TimeUpdateReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent == null) return;
|
||||
String action = intent.getAction();
|
||||
if (action == null || action.isEmpty()) return;
|
||||
|
||||
if (action.equals(Intent.ACTION_TIME_TICK)) {
|
||||
//系统每1分钟发送一次广播
|
||||
updateTimeUi();
|
||||
} else if (action.equals(Intent.ACTION_TIME_CHANGED)) {
|
||||
//系统手动更改时间发送广播
|
||||
updateTimeUi();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTimeUi() {
|
||||
long time = System.currentTimeMillis();
|
||||
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm");
|
||||
String timeText = timeFormat.format(time);
|
||||
tv_flashlight.setText(timeText);
|
||||
SimpleDateFormat format = new SimpleDateFormat("MM月dd日");
|
||||
String dataText = format.format(time);
|
||||
tv_flashlight_switch.setText(dataText);
|
||||
}
|
||||
|
||||
private void getFlashlight() {
|
||||
if (mTimeUpdateReceiver == null) {
|
||||
mTimeUpdateReceiver = new TimeUpdateReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(Intent.ACTION_TIME_TICK);
|
||||
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||
registerReceiver(mTimeUpdateReceiver, filter);
|
||||
updateTimeUi();
|
||||
// if (isFlashlightAvailable()) {
|
||||
// tv_flashlight_switch.setText("关");
|
||||
// cl_flashlight.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
// } else {
|
||||
// tv_flashlight_switch.setText("不可用");
|
||||
// cl_flashlight.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
// return;
|
||||
// }
|
||||
//// if (isFlashlightEnabled()) {
|
||||
//// tv_flashlight_switch.setText("开");
|
||||
//// cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
//// } else {
|
||||
//// tv_flashlight_switch.setText("关");
|
||||
//// cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
//// }
|
||||
//
|
||||
// cameraManager = (CameraManager) mContext.getSystemService(Context.CAMERA_SERVICE);
|
||||
//
|
||||
// cl_flashlight.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// if (flashing) {
|
||||
// try {
|
||||
// String CameraId = cameraManager.getCameraIdList()[0];
|
||||
// cameraManager.setTorchMode(CameraId, false);
|
||||
// } catch (CameraAccessException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// flashing = false;
|
||||
// tv_flashlight_switch.setText("关");
|
||||
// cl_flashlight.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
// } else {
|
||||
// try {
|
||||
// String CameraId = cameraManager.getCameraIdList()[0];
|
||||
// cameraManager.setTorchMode(CameraId, true);
|
||||
// } catch (CameraAccessException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// tv_flashlight_switch.setText("开");
|
||||
// cl_flashlight.setBackground(mContext.getDrawable(R.drawable.control_background_item));
|
||||
// flashing = true;
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private boolean isFlashlightAvailable() {
|
||||
return getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
|
||||
@@ -763,5 +847,6 @@ public class ControlActivity extends AppCompatActivity {
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mWifiReceiver != null) unregisterReceiver(mWifiReceiver);
|
||||
if (mTimeUpdateReceiver != null) unregisterReceiver(mTimeUpdateReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class AmapManager {
|
||||
private LocationClientOption mOption;
|
||||
private BDLocation mLocation;
|
||||
private CacheHelper mCacheHelper;
|
||||
private MMKV mmkv = MMKV.defaultMMKV();
|
||||
|
||||
private static final String AMAPLOCATION_JSON_KEY = "MAPLOCATION_JSON_STRING";
|
||||
public static final String LONGITUDE_KEY = "map_longitude_key";
|
||||
@@ -74,7 +75,7 @@ public class AmapManager {
|
||||
|
||||
public BDLocation getNowMapLocation() {
|
||||
if (mLocation == null) {
|
||||
String aMapLocationjson = mCacheHelper.getAsString(AMAPLOCATION_JSON_KEY);
|
||||
String aMapLocationjson = mmkv.decodeString(AMAPLOCATION_JSON_KEY);
|
||||
if (TextUtils.isEmpty(aMapLocationjson)) {
|
||||
return null;
|
||||
}
|
||||
@@ -147,7 +148,7 @@ public class AmapManager {
|
||||
case BDLocation.TypeGpsLocation:// GPS定位结果
|
||||
case BDLocation.TypeNetWorkLocation:// 网络定位结果
|
||||
case BDLocation.TypeOffLineLocation:// 离线定位结果
|
||||
mCacheHelper.put(AMAPLOCATION_JSON_KEY, GsonUtils.toJsonString(location));
|
||||
mmkv.encode(AMAPLOCATION_JSON_KEY, GsonUtils.toJsonString(location));
|
||||
Log.e(TAG, "onLocationChanged: " + "定位成功");
|
||||
Log.e(TAG, "onLocationChanged: longitude = " + location.getLongitude());
|
||||
Log.e(TAG, "onLocationChanged: latitude = " + location.getLatitude());
|
||||
|
||||
@@ -37,7 +37,7 @@ public class RulerSeekBar extends androidx.appcompat.widget.AppCompatSeekBar {
|
||||
*/
|
||||
private boolean isShowTopOfThumb = true;
|
||||
|
||||
private int radius = 8;
|
||||
private int radius = 12;
|
||||
|
||||
public RulerSeekBar(Context context) {
|
||||
super(context);
|
||||
@@ -60,7 +60,7 @@ public class RulerSeekBar extends androidx.appcompat.widget.AppCompatSeekBar {
|
||||
private void init() {
|
||||
//创建绘制刻度线的画笔
|
||||
mRulerPaint = new Paint();
|
||||
mRulerPaint.setColor(mRulerColor);
|
||||
mRulerPaint.setColor(Color.parseColor("#d0cccc"));
|
||||
mRulerPaint.setAntiAlias(true);
|
||||
|
||||
//Api21及以上调用,去掉滑块后面的背景
|
||||
|
||||
Reference in New Issue
Block a user