添加服务启动按钮

This commit is contained in:
ZhanGSKen 2025-03-21 21:21:14 +08:00
parent 395674d302
commit f3577c7e78
3 changed files with 40 additions and 28 deletions

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Fri Mar 21 13:06:16 GMT 2025 #Fri Mar 21 13:19:51 GMT 2025
stageCount=0 stageCount=0
libraryProject= libraryProject=
baseVersion=1.0 baseVersion=1.0
publishVersion=1.0.0 publishVersion=1.0.0
buildCount=365 buildCount=367
baseBetaVersion=1.0.1 baseBetaVersion=1.0.1

View File

@ -33,6 +33,7 @@ import cc.winboll.studio.positions.models.PostionFixModel;
import cc.winboll.studio.positions.utils.LocationFusion; import cc.winboll.studio.positions.utils.LocationFusion;
import cc.winboll.studio.positions.utils.TimeUtils; import cc.winboll.studio.positions.utils.TimeUtils;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Switch;
public class PositionsFragment extends Fragment { public class PositionsFragment extends Fragment {
@ -52,6 +53,8 @@ public class PositionsFragment extends Fragment {
EditText metLockLatitude; EditText metLockLatitude;
EditText metLockLongitude; EditText metLockLongitude;
Switch mswTaskService;
double latitudeWifiLock; double latitudeWifiLock;
double longitudeWifiLock; double longitudeWifiLock;
@ -106,34 +109,21 @@ public class PositionsFragment extends Fragment {
metLockLatitude = viewMain.findViewById(R.id.locklatitude_et); metLockLatitude = viewMain.findViewById(R.id.locklatitude_et);
metLockLongitude = viewMain.findViewById(R.id.locklongitude_et); metLockLongitude = viewMain.findViewById(R.id.locklongitude_et);
metLockLatitude.setEnabled(false);
metLockLongitude.setEnabled(false);
// tvWifiLocation = viewMain.findViewById(R.id.wifi_position_tv); // tvWifiLocation = viewMain.findViewById(R.id.wifi_position_tv);
// tvGPSLocation = viewMain.findViewById(R.id.gps_position_tv); // tvGPSLocation = viewMain.findViewById(R.id.gps_position_tv);
// tvFuseLocation = viewMain.findViewById(R.id.fuse_position_tv); // tvFuseLocation = viewMain.findViewById(R.id.fuse_position_tv);
locationManager = (LocationManager) getActivity().getSystemService(getActivity().LOCATION_SERVICE); locationManager = (LocationManager) getActivity().getSystemService(getActivity().LOCATION_SERVICE);
Button btnLockingPosition = viewMain.findViewById(R.id.locking_position_btn); mswTaskService = viewMain.findViewById(R.id.taskservice_sw);
btnLockingPosition.setOnClickListener(new View.OnClickListener(){ // mswTaskService.setOnClickListener(new View.OnClickListener(){
@Override // @Override
public void onClick(View p1) { // public void onClick(View p1) {
if (!metLockLatitude.getText().toString().trim().equals("") //
&& !metLockLongitude.getText().toString().trim().equals("")) { // }
_LocationPhoneGPSLock = new Location("User_Defined_GPS"); // });
_LocationPhoneGPSLock.setLatitude(Double.parseDouble(metLockLatitude.getText().toString()));
_LocationPhoneGPSLock.setLongitude(Double.parseDouble(metLockLongitude.getText().toString()));
ToastUtils.show("定位手动设定位置");
} else {
Location locationFix = fixGPSLocationFromPostionFixModel(_LocationPhoneGPS);
//_LocationPhoneGPSLock = _LocationTX;
_LocationPhoneGPSLock = locationFix;
ToastUtils.show("定位GPS设定位置");
}
showLockPostionInfo();
//ToastUtils.show(String.format("%s", locationFix.toString()));
TXMSFragment.moveToLocation(_LocationPhoneGPSLock.getLatitude(), _LocationPhoneGPSLock.getLongitude());
}
});
// 请求GPS定位 // 请求GPS定位
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, phoneGPSLocationListener); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, phoneGPSLocationListener);
@ -151,6 +141,25 @@ public class PositionsFragment extends Fragment {
return viewMain; return viewMain;
} }
void moveToCurrentLocation() {
if (!metLockLatitude.getText().toString().trim().equals("")
&& !metLockLongitude.getText().toString().trim().equals("")) {
_LocationPhoneGPSLock = new Location("User_Defined_GPS");
_LocationPhoneGPSLock.setLatitude(Double.parseDouble(metLockLatitude.getText().toString()));
_LocationPhoneGPSLock.setLongitude(Double.parseDouble(metLockLongitude.getText().toString()));
ToastUtils.show("定位手动设定位置");
} else {
Location locationFix = fixGPSLocationFromPostionFixModel(_LocationPhoneGPS);
//_LocationPhoneGPSLock = _LocationTX;
_LocationPhoneGPSLock = locationFix;
ToastUtils.show("定位GPS设定位置");
}
showLockPostionInfo();
//ToastUtils.show(String.format("%s", locationFix.toString()));
TXMSFragment.moveToLocation(_LocationPhoneGPSLock.getLatitude(), _LocationPhoneGPSLock.getLongitude());
}
void showLocationPhoneGPS() { void showLocationPhoneGPS() {
if (_LocationPhoneGPS != null) { if (_LocationPhoneGPS != null) {
@ -356,6 +365,9 @@ public class PositionsFragment extends Fragment {
// LogUtils.d(TAG, szTemp); // LogUtils.d(TAG, szTemp);
showLocationPhoneGPS(); showLocationPhoneGPS();
updatePostionFixModel(); updatePostionFixModel();
if(mswTaskService.isChecked()) {
moveToCurrentLocation();
}
} }
} }

View File

@ -152,11 +152,11 @@
</LinearLayout> </LinearLayout>
<Button <Switch
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="定位" android:text="启用提醒服务"
android:id="@+id/locking_position_btn"/> android:id="@+id/taskservice_sw"/>
</LinearLayout> </LinearLayout>