Skip to content

Commit

Permalink
Fix tracking zoom bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp0002 committed Dec 23, 2023
1 parent 6ed9d76 commit e6af1ba
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'org.osmdroid:osmdroid-android:6.1.16'
implementation 'org.osmdroid:osmdroid-android:6.1.17'
}
13 changes: 3 additions & 10 deletions app/src/main/java/de/raffaelhahn/xadgps_client/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,12 @@
import android.os.Bundle;
import android.os.PersistableBundle;
import android.util.Log;
import android.view.MenuItem;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.navigation.NavigationBarView;

import org.json.JSONArray;
import org.json.JSONObject;
import org.osmdroid.config.Configuration;

import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;

import de.raffaelhahn.xadgps_client.async.AsyncCallback;
import de.raffaelhahn.xadgps_client.async.Constants;
import de.raffaelhahn.xadgps_client.async.GetDeviceListAsync;
import de.raffaelhahn.xadgps_client.services.DeviceListService;

public class MainActivity extends AppCompatActivity {
Expand All @@ -37,6 +28,8 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Configuration.getInstance().setUserAgentValue(getPackageName());

SharedPreferences sharedPreferences = getSharedPreferences(Constants.SP_NAME, MODE_PRIVATE);
if(!sharedPreferences.contains("userId")){
startActivity(new Intent(this, LoginActivity.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import androidx.fragment.app.Fragment;

import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -27,7 +26,6 @@
import org.osmdroid.views.CustomZoomButtonsController;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.Marker;
import org.osmdroid.views.overlay.gestures.RotationGestureOverlay;
import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider;
import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay;

Expand All @@ -36,26 +34,15 @@
import de.raffaelhahn.xadgps_client.async.Constants;
import de.raffaelhahn.xadgps_client.services.DeviceListService;

/**
* A simple {@link Fragment} subclass.
* Use the {@link TrackingFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class TrackingFragment extends Fragment implements DeviceListService.DeviceListUpdateListener {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
public static final String ARG_PARAM_SHOW_DEVICE_ID = "paramShowDeviceId";
private static final int REQUEST_PERMISSIONS_REQUEST_CODE = 1;

// TODO: Rename and change types of parameters
private String paramShowDeviceId;

private MapView map = null;
private MaterialCardView trackingLoadingView = null;
private final int REQUEST_PERMISSIONS_REQUEST_CODE = 1;
private MyLocationNewOverlay mLocationOverlay;

//private RotationGestureOverlay mRotationGestureOverlay;

public TrackingFragment() {
// Required empty public constructor
}
Expand Down Expand Up @@ -207,7 +194,7 @@ public void onDeviceListUpdate(ArrayList<Device> deviceList) {
map.invalidate();
if(paramShowDeviceId != null && paramShowDeviceId.equals(device.id)) {
IMapController mapController = map.getController();
mapController.setZoom(20.0);
mapController.setZoom(map.getZoomLevelDouble());
mapController.setCenter(new GeoPoint(lat, lon));
}
}
Expand Down

0 comments on commit e6af1ba

Please sign in to comment.