use of org.osmdroid.config.IConfigurationProvider in project iGap-Android by KianIranian-STDG.
the class FileUtils method clearMapFile.
public void clearMapFile() {
IConfigurationProvider configurationProvider = Configuration.getInstance();
deleteRecursive((configurationProvider.getOsmdroidBasePath()));
}
use of org.osmdroid.config.IConfigurationProvider in project iGap-Android by KianIranian-STDG.
the class FragmentiGapMap method deleteMapFileCash.
public static void deleteMapFileCash() {
try {
IConfigurationProvider configurationProvider = Configuration.getInstance();
FileUtils.deleteRecursive((configurationProvider.getOsmdroidBasePath()));
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.osmdroid.config.IConfigurationProvider in project Conversations by iNPUTmice.
the class LocationActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Context ctx = getApplicationContext();
setTheme(ThemeHelper.find(this));
final PackageManager packageManager = ctx.getPackageManager();
hasLocationFeature = packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION) || packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS) || packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION_NETWORK);
this.locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
this.marker_icon = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.marker);
// screen rotation or if there's no point because it's disabled anyways).
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && savedInstanceState == null) {
requestPermissions(REQUEST_CODE_CREATE);
}
final IConfigurationProvider config = Configuration.getInstance();
config.load(ctx, getPreferences());
config.setUserAgentValue(BuildConfig.APPLICATION_ID + "/" + BuildConfig.VERSION_CODE);
if (QuickConversationsService.isConversations() && getBooleanPreference("use_tor", R.bool.use_tor)) {
config.setHttpProxy(HttpConnectionManager.getProxy());
}
}
use of org.osmdroid.config.IConfigurationProvider in project Conversations by siacs.
the class LocationActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Context ctx = getApplicationContext();
setTheme(ThemeHelper.find(this));
final PackageManager packageManager = ctx.getPackageManager();
hasLocationFeature = packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION) || packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS) || packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION_NETWORK);
this.locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
this.marker_icon = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.marker);
// screen rotation or if there's no point because it's disabled anyways).
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && savedInstanceState == null) {
requestPermissions(REQUEST_CODE_CREATE);
}
final IConfigurationProvider config = Configuration.getInstance();
config.load(ctx, getPreferences());
config.setUserAgentValue(BuildConfig.APPLICATION_ID + "/" + BuildConfig.VERSION_CODE);
if (QuickConversationsService.isConversations() && getBooleanPreference("use_tor", R.bool.use_tor)) {
config.setHttpProxy(HttpConnectionManager.getProxy());
}
}
use of org.osmdroid.config.IConfigurationProvider in project PhoneProfilesPlus by henrichg.
the class LocationGeofenceEditorActivityOSM method onCreate.
@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
GlobalGUIRoutines.setTheme(this, false, false, /*, false*/
false, false, true);
// GlobalGUIRoutines.setLanguage(this);
super.onCreate(savedInstanceState);
IConfigurationProvider osmDroidCobfigurationProvider = org.osmdroid.config.Configuration.getInstance();
osmDroidCobfigurationProvider.load(getApplicationContext(), PreferenceManager.getDefaultSharedPreferences(getApplicationContext()));
osmDroidCobfigurationProvider.setUserAgentValue(BuildConfig.APPLICATION_ID);
osmDroidCobfigurationProvider.setOsmdroidTileCache(getApplicationContext().getExternalFilesDir(null));
osmDroidCobfigurationProvider.setOsmdroidBasePath(getApplicationContext().getExternalFilesDir(null));
setContentView(R.layout.activity_location_geofence_editor_osm);
setTaskDescription(new ActivityManager.TaskDescription(getString(R.string.ppp_app_name)));
if (getSupportActionBar() != null) {
// getSupportActionBar().setHomeButtonEnabled(true);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.location_editor_title);
getSupportActionBar().setElevation(0);
}
// mResultReceiver = new AddressResultReceiver(new Handler(getMainLooper()));
Intent intent = getIntent();
geofenceId = intent.getLongExtra(LocationGeofencePreferenceX.EXTRA_GEOFENCE_ID, 0);
if (geofenceId > 0) {
geofence = DatabaseHandler.getInstance(getApplicationContext()).getGeofence(geofenceId);
mLocation = new Location("LOC");
mLocation.setLatitude(geofence._latitude);
mLocation.setLongitude(geofence._longitude);
}
if (geofence == null) {
geofenceId = 0;
geofence = new Geofence();
int _count = DatabaseHandler.getInstance(getApplicationContext()).getGeofenceCount() + 1;
geofence._name = getString(R.string.event_preferences_location_new_location_name) + "_" + _count;
geofence._radius = 100;
}
mapIsLoading = findViewById(R.id.location_editor_map_loading);
mMap = findViewById(R.id.location_editor_map);
mMap.setTileSource(TileSourceFactory.MAPNIK);
// mMap.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
mMap.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.ALWAYS);
// mMap.setMaxZoomLevel(20d);
mMap.setMultiTouchControls(true);
// mMap.setTilesScaledToDpi(true);
// mMap.getTileProvider().clearTileCache();
boolean isNightMode;
String applicationThene = ApplicationPreferences.applicationTheme(getApplicationContext(), false);
switch(applicationThene) {
case "white":
// noinspection DuplicateBranchesInSwitch
isNightMode = false;
break;
case "dark":
isNightMode = true;
break;
case "night_mode":
int nightModeFlags = getApplicationContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
// if (notificationNightMode) {
switch(nightModeFlags) {
case Configuration.UI_MODE_NIGHT_YES:
isNightMode = true;
// notificationTextColor = "2";
break;
case Configuration.UI_MODE_NIGHT_NO:
// noinspection DuplicateBranchesInSwitch
isNightMode = false;
// notificationTextColor = "1";
break;
case Configuration.UI_MODE_NIGHT_UNDEFINED:
// noinspection DuplicateBranchesInSwitch
isNightMode = false;
break;
default:
isNightMode = false;
}
break;
default:
isNightMode = false;
}
if (isNightMode)
mMap.getOverlayManager().getTilesOverlay().setColorFilter(TilesOverlay.INVERT_COLORS);
else
mMap.getOverlayManager().getTilesOverlay().setColorFilter(null);
// mMap.getOverlayManager().getTilesOverlay().setLoadingBackgroundColor(GlobalGUIRoutines.getThemeDialogBackgroundColor(this));
// mMap.getOverlayManager().getTilesOverlay().setLoadingLineColor(GlobalGUIRoutines.getThemeNormalTextColor(this));
IMapController mapController = mMap.getController();
// mapController.setZoom(15f);
/*
mMap.getOverlayManager().getTilesOverlay().getTileStates().getRunAfters().add(() -> {
if (mMap.getOverlayManager().getTilesOverlay().getTileStates().isDone()) {
PPApplication.logE("LocationGeofenceEditorActivityOSM.getTileStatuses", "map loaded");
if (mapIsLoading.getVisibility() != View.GONE)
mapIsLoading.setVisibility(View.GONE);
if (mMap.getVisibility() != View.VISIBLE) {
mMap.setVisibility(View.VISIBLE);
addressText.setVisibility(View.VISIBLE);
}
}
});
*/
mMap.getOverlays().add(new MapEventsOverlay(new MapEventsReceiver() {
@Override
public boolean singleTapConfirmedHelper(GeoPoint point) {
// PPApplication.logE("LocationGeofenceEditorActivityOSM.singleTapConfirmedHelper", "Map clicked");
if (mLocation == null)
mLocation = new Location("LOC");
mLocation.setLatitude(point.getLatitude());
mLocation.setLongitude(point.getLongitude());
refreshActivity(true, false);
return true;
}
@Override
public boolean longPressHelper(GeoPoint p) {
// Log.e("MapView", "long click");
return false;
}
}));
// radiusLabel = findViewById(R.id.location_pref_dlg_radius_seekbar_label);
TextView radiusLabel = findViewById(R.id.location_pref_dlg_radius_label);
radiusLabel.setText(getString(R.string.event_preferences_location_radius_label) + ":");
radiusValue = findViewById(R.id.location_pref_dlg_radius_value);
TooltipCompat.setTooltipText(radiusValue, getString(R.string.location_pref_dlg_edit_radius_tooltip));
radiusValue.setText(String.valueOf(Math.round(geofence._radius)));
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
dialogBuilder.setTitle(R.string.event_preferences_location_radius_label);
dialogBuilder.setCancelable(true);
dialogBuilder.setPositiveButton(android.R.string.ok, (dialog, which) -> {
boolean persist = true;
BigDecimal number = numberPicker.getEnteredNumber();
if (isSmaller(number) || isBigger(number)) {
/*String errorText = context.getString(R.string.number_picker_min_max_error, String.valueOf(preference.mMin), String.valueOf(preference.mMax));
mNumberPicker.getErrorView().setText(errorText);
mNumberPicker.getErrorView().show();*/
persist = false;
} else if (isSmaller(number)) {
/*String errorText = context.getString(R.string.number_picker_min_error, String.valueOf(preference.mMin));
mNumberPicker.getErrorView().setText(errorText);
mNumberPicker.getErrorView().show();*/
persist = false;
} else if (isBigger(number)) {
/*String errorText = context.getString(R.string.number_picker_max_error, String.valueOf(preference.mMax));
mNumberPicker.getErrorView().setText(errorText);
mNumberPicker.getErrorView().show();*/
persist = false;
}
if (persist) {
geofence._radius = numberPicker.getNumber().floatValue();
radiusValue.setText(String.valueOf(Math.round(geofence._radius)));
updateEditedMarker(true);
}
});
dialogBuilder.setNegativeButton(android.R.string.cancel, null);
LayoutInflater inflater = getLayoutInflater();
@SuppressLint("InflateParams") View layout = inflater.inflate(R.layout.dialog_better_number_preference, null);
dialogBuilder.setView(layout);
numberPicker = layout.findViewById(R.id.better_number_picker);
// Initialize state
numberPicker.setMin(BigDecimal.valueOf(MIN_RADIUS));
numberPicker.setMax(BigDecimal.valueOf(MAX_RADIUS));
numberPicker.setPlusMinusVisibility(View.INVISIBLE);
numberPicker.setDecimalVisibility(View.INVISIBLE);
// mNumberPicker.setLabelText(getContext().getString(R.string.minutes_label_description));
numberPicker.setNumber(Math.round(geofence._radius), null, null);
if (ApplicationPreferences.applicationTheme(this, true).equals("dark"))
numberPicker.setTheme(R.style.BetterPickersDialogFragment);
else
numberPicker.setTheme(R.style.BetterPickersDialogFragment_Light);
valueDialog = dialogBuilder.create();
// valueDialog.setOnShowListener(new DialogInterface.OnShowListener() {
// @Override
// public void onShow(DialogInterface dialog) {
// Button positive = ((AlertDialog)dialog).getButton(DialogInterface.BUTTON_POSITIVE);
// if (positive != null) positive.setAllCaps(false);
// Button negative = ((AlertDialog)dialog).getButton(DialogInterface.BUTTON_NEGATIVE);
// if (negative != null) negative.setAllCaps(false);
// }
// });
radiusValue.setOnClickListener(view -> {
if (!(isFinishing()))
valueDialog.show();
});
/*
// seekBar is logarithmic
SeekBar radiusSeekBar = findViewById(R.id.location_pref_dlg_radius_seekbar);
final float minRadius = 20;
final float maxRadius = 1020;
int value = (int)(Math.sqrt(((geofence._radius - minRadius) / (maxRadius - minRadius)) * 1000.0f * 1000.0f));
radiusSeekBar.setProgress(value);
PPApplication.logE("LocationGeofenceEditorActivityOSM.onCreate", "geofence._radius="+geofence._radius);
PPApplication.logE("LocationGeofenceEditorActivityOSM.onCreate", "seekBar value="+value);
radiusSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
// Approximate an exponential curve with x^2.
geofence._radius = ((progress * progress) / (1000.0f * 1000.0f)) * (maxRadius - minRadius) + minRadius;
updateEditedMarker(false);
//Log.d("LocationGeofenceEditorActivityOSM.onProgressChanged", "radius="+geofence._radius);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
*/
geofenceNameEditText = findViewById(R.id.location_editor_geofence_name);
geofenceNameEditText.setBackgroundTintList(ContextCompat.getColorStateList(this, R.color.highlighted_spinner_all));
geofenceNameEditText.setText(geofence._name);
addressText = findViewById(R.id.location_editor_address_text);
okButton = findViewById(R.id.location_editor_ok);
okButton.setOnClickListener(v -> {
String name = geofenceNameEditText.getText().toString();
if ((!name.isEmpty()) && (mLocation != null)) {
geofence._name = name;
geofence._latitude = mLocation.getLatitude();
geofence._longitude = mLocation.getLongitude();
if (geofenceId > 0) {
DatabaseHandler.getInstance(getApplicationContext()).updateGeofence(geofence);
} else {
DatabaseHandler.getInstance(getApplicationContext()).addGeofence(geofence);
/*synchronized (PPApplication.locationScannerMutex) {
// start location updates
if ((PhoneProfilesService.getInstance() != null) && PhoneProfilesService.isLocationScannerStarted())
PhoneProfilesService.getGeofencesScanner().connectForResolve();
}*/
}
DatabaseHandler.getInstance(getApplicationContext()).checkGeofence(String.valueOf(geofence._id), 1);
Intent returnIntent = new Intent();
returnIntent.putExtra(LocationGeofencePreferenceX.EXTRA_GEOFENCE_ID, geofence._id);
setResult(Activity.RESULT_OK, returnIntent);
finish();
}
});
Button cancelButton = findViewById(R.id.location_editor_cancel);
cancelButton.setOnClickListener(v -> {
Intent returnIntent = new Intent();
setResult(Activity.RESULT_CANCELED, returnIntent);
finish();
});
AppCompatImageButton myLocationButton = findViewById(R.id.location_editor_my_location);
TooltipCompat.setTooltipText(myLocationButton, getString(R.string.location_editor_change_location_dialog_title));
myLocationButton.setOnClickListener(v -> {
AlertDialog changeLocationDialog = new AlertDialog.Builder(this).setTitle(R.string.location_editor_change_location_dialog_title).setCancelable(true).setNegativeButton(android.R.string.cancel, null).setItems(R.array.locationEditorChangeLocationArray, (dialog, which) -> {
IMapController _mapController = mMap.getController();
switch(which) {
case 0:
if (mLocation != null)
_mapController.setCenter(new GeoPoint(mLocation));
break;
case 1:
if (mLastLocation != null)
_mapController.setCenter(new GeoPoint(mLastLocation));
break;
case 2:
// getLastLocation();
if (mLastLocation != null)
mLocation = new Location(mLastLocation);
refreshActivity(true, true);
break;
default:
}
}).create();
// mSelectorDialog.setOnShowListener(new DialogInterface.OnShowListener() {
// @Override
// public void onShow(DialogInterface dialog) {
// Button positive = ((AlertDialog)dialog).getButton(DialogInterface.BUTTON_POSITIVE);
// if (positive != null) positive.setAllCaps(false);
// Button negative = ((AlertDialog)dialog).getButton(DialogInterface.BUTTON_NEGATIVE);
// if (negative != null) negative.setAllCaps(false);
// }
// });
changeLocationDialog.show();
});
addressButton = findViewById(R.id.location_editor_address_btn);
TooltipCompat.setTooltipText(addressButton, getString(R.string.location_editor_rename_with_address_button_tooltip));
addressButton.setOnClickListener(v -> {
AlertDialog renameGeofenceDialog = new AlertDialog.Builder(this).setTitle(R.string.location_editor_rename_with_address_button_tooltip).setCancelable(true).setNegativeButton(android.R.string.cancel, null).setItems(R.array.locationEditorRenameLocationArray, (dialog, which) -> {
if (which == 0) {
getGeofenceAddress();
}
}).create();
// mSelectorDialog.setOnShowListener(new DialogInterface.OnShowListener() {
// @Override
// public void onShow(DialogInterface dialog) {
// Button positive = ((AlertDialog)dialog).getButton(DialogInterface.BUTTON_POSITIVE);
// if (positive != null) positive.setAllCaps(false);
// Button negative = ((AlertDialog)dialog).getButton(DialogInterface.BUTTON_NEGATIVE);
// if (negative != null) negative.setAllCaps(false);
// }
// });
renameGeofenceDialog.show();
});
if (geofence != null)
mapController.setCenter(new GeoPoint(geofence._latitude, geofence._longitude));
}
Aggregations