kopia lustrzana https://github.com/sh123/codec2_talkie
rodzic
09b38e65f7
commit
50450ac0af
|
@ -8,8 +8,11 @@ import android.graphics.Color;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
|
@ -57,6 +60,7 @@ public class MapActivity extends AppCompatActivity {
|
|||
private AprsSymbolTable _aprsSymbolTable;
|
||||
|
||||
private String _mySymbolCode;
|
||||
private boolean _rotateMap = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -84,7 +88,16 @@ public class MapActivity extends AppCompatActivity {
|
|||
_mapController.zoomTo(5.0);
|
||||
|
||||
// compass
|
||||
_compassOverlay = new CompassOverlay(context, new InternalCompassOrientationProvider(context), _map);
|
||||
InternalCompassOrientationProvider compassOrientationProvider = new InternalCompassOrientationProvider(context) {
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent sensorEvent) {
|
||||
if (_rotateMap) {
|
||||
_map.setMapOrientation(-sensorEvent.values[0]);
|
||||
}
|
||||
super.onSensorChanged(sensorEvent);
|
||||
}
|
||||
};
|
||||
_compassOverlay = new CompassOverlay(context, compassOrientationProvider, _map);
|
||||
_compassOverlay.enableCompass();
|
||||
_map.getOverlays().add(_compassOverlay);
|
||||
|
||||
|
@ -209,6 +222,16 @@ public class MapActivity extends AppCompatActivity {
|
|||
} else if (itemId == R.id.map_menu_clear_cache) {
|
||||
_map.getTileProvider().clearTileCache();
|
||||
return true;
|
||||
} else if (itemId == R.id.map_menu_rotate_map) {
|
||||
if (item.isChecked()) {
|
||||
item.setChecked(false);
|
||||
_rotateMap = false;
|
||||
_map.setMapOrientation(0);
|
||||
} else {
|
||||
item.setChecked(true);
|
||||
_rotateMap = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/map_menu_rotate_map"
|
||||
android:title="@string/map_menu_rotate_map"
|
||||
android:checkable="true"
|
||||
android:checked="false"/>
|
||||
<item
|
||||
android:id="@+id/map_menu_clear_cache"
|
||||
android:title="@string/map_menu_clear_cache_title" />
|
||||
|
|
|
@ -363,4 +363,5 @@
|
|||
<string name="log_view_menu_clear_7d">Older than 7 days</string>
|
||||
<string name="log_view_menu_clear_all">Clear all</string>
|
||||
<string name="log_item_activity_delete_hours_title">This will remove everything older than %d hours. Are you sure?</string>
|
||||
<string name="map_menu_rotate_map">Rotate map with compass</string>
|
||||
</resources>
|
Ładowanie…
Reference in New Issue