version:3.6
fix:去点腾讯推送 update:去掉系统节点
This commit is contained in:
@@ -59,18 +59,11 @@ public class ControlActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.iv_back)
|
||||
ImageView iv_back;
|
||||
|
||||
@BindView(R.id.tv_wifi)
|
||||
TextView tv_wifi;
|
||||
@BindView(R.id.tv_wifi_ssid)
|
||||
TextView tv_wifi_ssid;
|
||||
@BindView(R.id.tv_bt)
|
||||
TextView tv_bt;
|
||||
@BindView(R.id.tv_bt_ssid)
|
||||
TextView tv_bt_ssid;
|
||||
|
||||
// @BindView(R.id.tv_font_size)
|
||||
// TextView tv_font_size;
|
||||
@BindView(R.id.seekBar)
|
||||
RulerSeekBar seekBar;
|
||||
@BindView(R.id.seekbar_brightness)
|
||||
@@ -80,21 +73,14 @@ public class ControlActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.tv_sound)
|
||||
TextView tv_sound;
|
||||
|
||||
@BindView(R.id.tv_battery)
|
||||
TextView tv_battery;
|
||||
@BindView(R.id.tv_electricity)
|
||||
TextView tv_electricity;
|
||||
@BindView(R.id.tv_flashlight)
|
||||
TextView tv_flashlight;
|
||||
@BindView(R.id.tv_flashlight_switch)
|
||||
TextView tv_flashlight_switch;
|
||||
|
||||
@BindView(R.id.tv_brightness)
|
||||
TextView tv_brightness;
|
||||
@BindView(R.id.tv_location)
|
||||
TextView tv_location;
|
||||
|
||||
@BindView(R.id.cl_wifi)
|
||||
ConstraintLayout cl_wifi;
|
||||
@BindView(R.id.cl_bt)
|
||||
@@ -153,6 +139,12 @@ public class ControlActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
});
|
||||
cl_battery.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,15 +156,15 @@ public class ControlActivity extends BaseActivity {
|
||||
cl_wifi.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
|
||||
startActivity(new Intent(ControlActivity.this, WiFiManagerActivity.class));
|
||||
startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
|
||||
// startActivity(new Intent(ControlActivity.this, WiFiManagerActivity.class));
|
||||
}
|
||||
});
|
||||
if (isWifiEnabled()) {
|
||||
tv_wifi_ssid.setText(getConnectWifiSsid());
|
||||
// tv_wifi_ssid.setText(getConnectWifiSsid());
|
||||
cl_wifi.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
} else {
|
||||
tv_wifi_ssid.setText("未连接");
|
||||
// tv_wifi_ssid.setText("未连接");
|
||||
cl_wifi.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
}
|
||||
}
|
||||
@@ -205,8 +197,6 @@ public class ControlActivity extends BaseActivity {
|
||||
filter.addAction(WifiManager.RSSI_CHANGED_ACTION);
|
||||
filter.addAction(WifiManager.NETWORK_IDS_CHANGED_ACTION);
|
||||
filter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
|
||||
filter.addAction(WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION);
|
||||
filter.addAction(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION);
|
||||
filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
|
||||
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
registerReceiver(mWifiReceiver, filter);
|
||||
@@ -226,14 +216,14 @@ public class ControlActivity extends BaseActivity {
|
||||
NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
|
||||
if (info.getState().equals(NetworkInfo.State.DISCONNECTED)) {
|
||||
Log.e(TAG, "wifi断开");
|
||||
tv_wifi_ssid.setText("未连接");
|
||||
// tv_wifi_ssid.setText("未连接");
|
||||
cl_wifi.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
} else if (info.getState().equals(NetworkInfo.State.CONNECTED)) {
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
//获取当前wifi名称
|
||||
String newSSID = wifiInfo.getSSID();
|
||||
tv_wifi_ssid.setText(newSSID.replaceAll("\"", ""));
|
||||
// tv_wifi_ssid.setText(getConnectWifiSsid());
|
||||
cl_wifi.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
}
|
||||
break;
|
||||
@@ -242,7 +232,7 @@ public class ControlActivity extends BaseActivity {
|
||||
int wifistate = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED);
|
||||
if (wifistate == WifiManager.WIFI_STATE_DISABLED) {
|
||||
Log.e(TAG, "系统关闭wifi");
|
||||
tv_wifi_ssid.setText("关");
|
||||
// tv_wifi_ssid.setText("关");
|
||||
cl_wifi.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
} else if (wifistate == WifiManager.WIFI_STATE_ENABLED) {
|
||||
Log.e(TAG, "系统开启wifi");
|
||||
@@ -271,17 +261,17 @@ public class ControlActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private String getConnectWifiSsid() {
|
||||
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
// //去掉带引号的字符串方法一
|
||||
// String wifiInfo1 = wifiInfo.getSSID();
|
||||
// if (wifiInfo1.contains("\"")) {
|
||||
// wifiInfo1 = wifiInfo1.substring(1, wifiInfo1.length() - 1);
|
||||
// }
|
||||
//去掉带引号的字符串方法二
|
||||
String wifiSSID = wifiInfo.getSSID();
|
||||
String wifiInfo1 = wifiSSID.replaceAll("\"", "");
|
||||
return wifiInfo1;
|
||||
// WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
|
||||
// WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
//// //去掉带引号的字符串方法一
|
||||
//// String wifiInfo1 = wifiInfo.getSSID();
|
||||
//// if (wifiInfo1.contains("\"")) {
|
||||
//// wifiInfo1 = wifiInfo1.substring(1, wifiInfo1.length() - 1);
|
||||
//// }
|
||||
////去掉带引号的字符串方法二
|
||||
// String wifiSSID = wifiInfo.getSSID();
|
||||
// String wifiInfo1 = wifiSSID.replaceAll("\"", "");
|
||||
return RemoteManager.getInstance().getConnectWifiSsid();
|
||||
}
|
||||
|
||||
private BluetoothAdapter bluetoothAdapter;
|
||||
@@ -289,16 +279,16 @@ public class ControlActivity extends BaseActivity {
|
||||
private void getBluetooth() {
|
||||
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (bluetoothAdapter.isEnabled()) {
|
||||
if (isConnected()) {
|
||||
cl_bt.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
tv_bt_ssid.setText(getBluetoothDeviceName());
|
||||
} else {
|
||||
cl_bt.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
tv_bt_ssid.setText("未连接");
|
||||
}
|
||||
// if (isConnected()) {
|
||||
// cl_bt.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
// tv_bt_ssid.setText(getBluetoothDeviceName());
|
||||
// } else {
|
||||
// cl_bt.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
// tv_bt_ssid.setText("未连接");
|
||||
// }
|
||||
} else {
|
||||
cl_bt.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
tv_bt_ssid.setText("已关闭");
|
||||
// tv_bt_ssid.setText("已关闭");
|
||||
}
|
||||
getConnectedDevicesV1();
|
||||
cl_bt.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -309,31 +299,31 @@ public class ControlActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
Set<BluetoothDevice> bondedDevices = bluetoothAdapter.getBondedDevices();
|
||||
List<BluetoothDevice> deviceList = bondedDevices.stream().filter(new Predicate<BluetoothDevice>() {
|
||||
@Override
|
||||
public boolean test(BluetoothDevice bluetoothDevice) {
|
||||
return bluetoothDevice.isConnected();
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
return deviceList.size() > 0;
|
||||
}
|
||||
// public boolean isConnected() {
|
||||
// Set<BluetoothDevice> bondedDevices = bluetoothAdapter.getBondedDevices();
|
||||
// List<BluetoothDevice> deviceList = bondedDevices.stream().filter(new Predicate<BluetoothDevice>() {
|
||||
// @Override
|
||||
// public boolean test(BluetoothDevice bluetoothDevice) {
|
||||
// return bluetoothDevice.isConnected();
|
||||
// }
|
||||
// }).collect(Collectors.toList());
|
||||
// return deviceList.size() > 0;
|
||||
// }
|
||||
|
||||
public String getBluetoothDeviceName() {
|
||||
Set<BluetoothDevice> bondedDevices = bluetoothAdapter.getBondedDevices();
|
||||
List<BluetoothDevice> deviceList = bondedDevices.stream().filter(new Predicate<BluetoothDevice>() {
|
||||
@Override
|
||||
public boolean test(BluetoothDevice bluetoothDevice) {
|
||||
return bluetoothDevice.isConnected();
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
if (deviceList.size() == 0) {
|
||||
return "未连接";
|
||||
} else {
|
||||
return deviceList.get(0).getName();
|
||||
}
|
||||
}
|
||||
// public String getBluetoothDeviceName() {
|
||||
// Set<BluetoothDevice> bondedDevices = bluetoothAdapter.getBondedDevices();
|
||||
// List<BluetoothDevice> deviceList = bondedDevices.stream().filter(new Predicate<BluetoothDevice>() {
|
||||
// @Override
|
||||
// public boolean test(BluetoothDevice bluetoothDevice) {
|
||||
// return bluetoothDevice.isConnected();
|
||||
// }
|
||||
// }).collect(Collectors.toList());
|
||||
// if (deviceList.size() == 0) {
|
||||
// return "未连接";
|
||||
// } else {
|
||||
// return deviceList.get(0).getName();
|
||||
// }
|
||||
// }
|
||||
|
||||
//TODO 根据mac地址判断是否已连接(这里参数可以直接用BluetoothDevice对象)
|
||||
//但这么写其实更通用。
|
||||
@@ -437,30 +427,30 @@ public class ControlActivity extends BaseActivity {
|
||||
int blueState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, 0);
|
||||
switch (blueState) {
|
||||
case BluetoothAdapter.STATE_TURNING_ON:
|
||||
tv_bt_ssid.setText("正在打开");
|
||||
// tv_bt_ssid.setText("正在打开");
|
||||
cl_bt.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
break;
|
||||
case BluetoothAdapter.STATE_ON:
|
||||
tv_bt_ssid.setText("已打开");
|
||||
// tv_bt_ssid.setText("已打开");
|
||||
cl_bt.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
break;
|
||||
case BluetoothAdapter.STATE_TURNING_OFF:
|
||||
tv_bt_ssid.setText("正在关闭");
|
||||
// tv_bt_ssid.setText("正在关闭");
|
||||
cl_bt.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
break;
|
||||
case BluetoothAdapter.STATE_OFF:
|
||||
tv_bt_ssid.setText("已关闭");
|
||||
// tv_bt_ssid.setText("已关闭");
|
||||
cl_bt.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
break;
|
||||
case BluetoothDevice.ACTION_ACL_CONNECTED:
|
||||
tv_bt_ssid.setText(getBluetoothDeviceName());
|
||||
// tv_bt_ssid.setText(getBluetoothDeviceName());
|
||||
cl_bt.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
break;
|
||||
case BluetoothDevice.ACTION_ACL_DISCONNECTED:
|
||||
tv_bt_ssid.setText("未连接");
|
||||
// tv_bt_ssid.setText("未连接");
|
||||
cl_bt.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
break;
|
||||
default:
|
||||
@@ -471,7 +461,7 @@ public class ControlActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void getBattery() {
|
||||
tv_electricity.setText(getBatteryCapacity() + "%");
|
||||
// tv_electricity.setText(getBatteryCapacity() + "%");
|
||||
if (isBatteryCharging()) {
|
||||
cl_battery.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
} else {
|
||||
@@ -523,7 +513,7 @@ public class ControlActivity extends BaseActivity {
|
||||
filter.addAction(Intent.ACTION_POWER_CONNECTED);
|
||||
filter.addAction(Intent.ACTION_POWER_DISCONNECTED);
|
||||
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||
filter.addAction(Intent.ACTION_BATTERY_LEVEL_CHANGED);
|
||||
// filter.addAction(Intent.ACTION_BATTERY_LEVEL_CHANGED);
|
||||
filter.addAction(Intent.ACTION_BATTERY_LOW);
|
||||
filter.addAction(Intent.ACTION_BATTERY_OKAY);
|
||||
registerReceiver(mBatteryReceiver, filter);
|
||||
@@ -546,9 +536,9 @@ public class ControlActivity extends BaseActivity {
|
||||
case Intent.ACTION_POWER_DISCONNECTED:
|
||||
cl_battery.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
break;
|
||||
case Intent.ACTION_BATTERY_LEVEL_CHANGED:
|
||||
tv_electricity.setText(getBatteryCapacity() + "%");
|
||||
break;
|
||||
// case Intent.ACTION_BATTERY_LEVEL_CHANGED:
|
||||
// tv_electricity.setText(getBatteryCapacity() + "%");
|
||||
// break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
@@ -707,9 +697,9 @@ public class ControlActivity extends BaseActivity {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isFlashlightEnabled() {
|
||||
return Settings.Secure.getInt(crv, Settings.Secure.FLASHLIGHT_ENABLED, 0) == 1;
|
||||
}
|
||||
// private boolean isFlashlightEnabled() {
|
||||
// return Settings.Secure.getInt(crv, Settings.Secure.FLASHLIGHT_ENABLED, 0) == 1;
|
||||
// }
|
||||
|
||||
private void getFontSize() {
|
||||
float fontScale = Settings.System.getFloat(crv, Settings.System.FONT_SCALE, 0.0f);
|
||||
@@ -775,7 +765,7 @@ public class ControlActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
||||
Log.e(TAG, "onProgressChanged: i = " + i);
|
||||
Settings.System.putInt(crv, Settings.System.SCREEN_BRIGHTNESS, i);
|
||||
RemoteManager.getInstance().putSystemInt(Settings.System.SCREEN_BRIGHTNESS, i);
|
||||
int gamma = BrightnessUtils.convertLinearToGamma(i, 1, 255);
|
||||
Log.e(TAG, "onProgressChanged: gamma = " + gamma);
|
||||
long percentage = Math.round((((double) gamma / 65535) * 100f));
|
||||
|
||||
Reference in New Issue
Block a user