version:7.1
fix: update:更新圆角,修复修改字体大小报错
This commit is contained in:
@@ -8,6 +8,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
@@ -28,6 +29,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
@@ -35,6 +37,7 @@ import com.baidu.location.BDAbstractLocationListener;
|
||||
import com.baidu.location.BDLocation;
|
||||
import com.baidu.location.LocationClient;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.disklrucache.CacheHelper;
|
||||
import com.uiui.aios.manager.AmapManager;
|
||||
import com.uiui.aios.utils.BrightnessUtils;
|
||||
import com.uiui.aios.view.RulerSeekBar;
|
||||
@@ -112,7 +115,7 @@ public class ControlFragment extends Fragment {
|
||||
private View rootView;
|
||||
private Context mContext;
|
||||
private ContentResolver mCRv;
|
||||
|
||||
private CacheHelper mCacheHelper;
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
@@ -154,6 +157,11 @@ public class ControlFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
@@ -161,6 +169,7 @@ public class ControlFragment extends Fragment {
|
||||
rootView = inflater.inflate(R.layout.fragment_control, container, false);
|
||||
mContext = rootView.getContext();
|
||||
mCRv = mContext.getContentResolver();
|
||||
mCacheHelper = new CacheHelper(mContext);
|
||||
ButterKnife.bind(this, rootView);
|
||||
initView();
|
||||
initData();
|
||||
@@ -171,7 +180,7 @@ public class ControlFragment extends Fragment {
|
||||
tv_wifi_ssid.requestFocus();
|
||||
|
||||
getWifi();
|
||||
registerReceivers();
|
||||
registerWiFiReceiver();
|
||||
getBluetooth();
|
||||
registerBluetoothReceiver();
|
||||
getBattery();
|
||||
@@ -217,10 +226,6 @@ public class ControlFragment extends Fragment {
|
||||
|
||||
private WifiReceiver mWifiReceiver;
|
||||
|
||||
private void registerReceivers() {
|
||||
registerWiFiReceiver();
|
||||
}
|
||||
|
||||
private void registerWiFiReceiver() {
|
||||
if (mWifiReceiver == null) {
|
||||
mWifiReceiver = new WifiReceiver();
|
||||
@@ -238,7 +243,7 @@ public class ControlFragment extends Fragment {
|
||||
mContext.registerReceiver(mWifiReceiver, filter);
|
||||
}
|
||||
|
||||
public class WifiReceiver extends BroadcastReceiver {
|
||||
class WifiReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "wifiReceiver";
|
||||
|
||||
@Override
|
||||
@@ -279,6 +284,12 @@ public class ControlFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
setBrightness();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前连接WIFI的SSID
|
||||
*/
|
||||
@@ -452,7 +463,7 @@ public class ControlFragment extends Fragment {
|
||||
mContext.registerReceiver(this.bleListenerReceiver, intentFilter);
|
||||
}
|
||||
|
||||
public class BluetoothMonitorReceiver extends BroadcastReceiver {
|
||||
class BluetoothMonitorReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
@@ -556,7 +567,7 @@ public class ControlFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
public class BatteryReceiver extends BroadcastReceiver {
|
||||
class BatteryReceiver extends BroadcastReceiver {
|
||||
public static final String TAG = "BatteryReceiver";
|
||||
|
||||
@Override
|
||||
@@ -564,7 +575,7 @@ public class ControlFragment extends Fragment {
|
||||
// 获取广播事件
|
||||
String action = intent.getAction();
|
||||
if (TextUtils.isEmpty(action)) return;
|
||||
Log.e(TAG, "onReceive: " + action);
|
||||
// Log.e(TAG, "onReceive: " + action);
|
||||
switch (action) {
|
||||
case Intent.ACTION_POWER_CONNECTED:
|
||||
cl_battery.setBackground(mContext.getDrawable(R.drawable.control_background_item));
|
||||
@@ -705,10 +716,10 @@ public class ControlFragment extends Fragment {
|
||||
String font_size;
|
||||
int index = Arrays.binarySearch(mValues, fontScale);
|
||||
Log.e(TAG, "getFontSize: index: " + index);
|
||||
if (index == -1) {
|
||||
font_size = "默认";
|
||||
} else {
|
||||
if (index >= 0) {
|
||||
font_size = mEntries.get(index);
|
||||
} else {
|
||||
font_size = "默认";
|
||||
}
|
||||
// tv_font_size.setText(font_size);
|
||||
seekBar.setProgress(index);
|
||||
@@ -740,17 +751,11 @@ public class ControlFragment extends Fragment {
|
||||
private LocationClient locationClient;
|
||||
|
||||
private void getLocation() {
|
||||
BDLocation bdLocation = AmapManager.getInstance().getNowMapLocation();
|
||||
if (bdLocation != null) {
|
||||
if (bdLocation.getLocType() == BDLocation.TypeGpsLocation // GPS定位结果
|
||||
|| bdLocation.getLocType() == BDLocation.TypeNetWorkLocation // 网络定位结果
|
||||
|| bdLocation.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果
|
||||
tv_location.setText(bdLocation.getAddrStr());
|
||||
} else {
|
||||
tv_location.setText("未知");
|
||||
}
|
||||
String addr = mCacheHelper.getAsString(AmapManager.ADDRESS_KEY);
|
||||
if (TextUtils.isEmpty(addr)) {
|
||||
tv_location.setText("未知");
|
||||
} else {
|
||||
tv_location.setText("定位失败");
|
||||
tv_location.setText(addr);
|
||||
}
|
||||
startLocation();
|
||||
cl_location.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -786,25 +791,19 @@ public class ControlFragment extends Fragment {
|
||||
|
||||
private void getBrightness() {
|
||||
seekbar_brightness.setMax(255);
|
||||
//亮度
|
||||
int brightness = Settings.System.getInt(mCRv, Settings.System.SCREEN_BRIGHTNESS, 1);
|
||||
seekbar_brightness.setProgress(brightness);
|
||||
Log.e(TAG, "getBrightness: brightness = " + brightness);
|
||||
int gamma = BrightnessUtils.convertLinearToGamma(brightness, 1, 255);
|
||||
Log.e(TAG, "getBrightness: gamma = " + gamma);
|
||||
long percentage = Math.round((((double) gamma / 65535) * 100f));
|
||||
tv_brightness.setText(percentage + "%");
|
||||
Log.e(TAG, "getBrightness: percentage = " + percentage);
|
||||
setBrightness();
|
||||
seekbar_brightness.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
||||
Log.e(TAG, "onProgressChanged: i = " + i);
|
||||
Settings.System.putInt(mCRv, Settings.System.SCREEN_BRIGHTNESS, i);
|
||||
int gamma = BrightnessUtils.convertLinearToGamma(i, 1, 255);
|
||||
int gamma = BrightnessUtils.convertLinearToGamma(i, 0, 255);
|
||||
Log.e(TAG, "onProgressChanged: gamma = " + gamma);
|
||||
int linear = BrightnessUtils.convertGammaToLinear(gamma, 0, 255);
|
||||
Log.e(TAG, "onProgressChanged: linear = " + linear);
|
||||
long percentage = Math.round((((double) gamma / 65535) * 100f));
|
||||
Log.e(TAG, "onProgressChanged: percentage = " + percentage);
|
||||
tv_brightness.setText(percentage + "%");
|
||||
// tv_brightness.setText(percentage + "%");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -819,6 +818,18 @@ public class ControlFragment extends Fragment {
|
||||
});
|
||||
}
|
||||
|
||||
private void setBrightness() {
|
||||
//亮度
|
||||
int brightness = Settings.System.getInt(mCRv, Settings.System.SCREEN_BRIGHTNESS, 0);
|
||||
seekbar_brightness.setProgress(brightness);
|
||||
Log.e(TAG, "getBrightness: brightness = " + brightness);
|
||||
int gamma = BrightnessUtils.convertLinearToGamma(brightness, 0, 255);
|
||||
Log.e(TAG, "getBrightness: gamma = " + gamma);
|
||||
long percentage = Math.round((((double) gamma / 65535) * 100f));
|
||||
// tv_brightness.setText(percentage + "%");
|
||||
Log.e(TAG, "getBrightness: percentage = " + percentage);
|
||||
}
|
||||
|
||||
private AudioManager mAudioManager;
|
||||
|
||||
private void getSound() {
|
||||
|
||||
Reference in New Issue
Block a user