use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.
the class SearchAddressFragment method attachListeners.
private void attachListeners() {
countryButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(createIntent(SearchRegionByNameActivity.class));
}
});
cityButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(createIntent(SearchCityByNameActivity.class));
}
});
streetButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(createIntent(SearchStreetByNameActivity.class));
}
});
buildingButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (radioBuilding) {
startActivity(createIntent(SearchBuildingByNameActivity.class));
} else {
startActivity(createIntent(SearchStreet2ByNameActivity.class));
}
}
});
OsmandApplication app = getApplication();
Drawable icon = getApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_remove_dark);
((ImageView) findViewById(R.id.ResetBuilding)).setBackgroundDrawable(icon);
findViewById(R.id.ResetBuilding).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
building = null;
searchPoint = null;
osmandSettings.setLastSearchedBuilding("", null);
// also empties Point, REMOVES intersecting street
updateUI();
}
});
((ImageView) findViewById(R.id.ResetStreet)).setBackgroundDrawable(icon);
findViewById(R.id.ResetStreet).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
street = null;
street2 = null;
building = null;
searchPoint = null;
osmandSettings.setLastSearchedStreet("", null);
// also empties Building, (Intersecting Street), Point
updateUI();
}
});
((ImageView) findViewById(R.id.ResetCity)).setBackgroundDrawable(icon);
findViewById(R.id.ResetCity).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
postcode = null;
city = null;
street = null;
street2 = null;
building = null;
searchPoint = null;
osmandSettings.setLastSearchedCity(-1L, "", null);
// also empties Street, (Intersecting Street), Building, Point, REMOVES Postcode
updateUI();
}
});
((ImageView) findViewById(R.id.ResetCountry)).setBackgroundDrawable(icon);
findViewById(R.id.ResetCountry).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
region = null;
postcode = null;
city = null;
street = null;
street2 = null;
building = null;
searchPoint = null;
osmandSettings.setLastSearchedRegion("", null);
// also empties City, Postcode, Street, (Interseting street), Building, Point
updateUI();
}
});
((RadioGroup) findViewById(R.id.RadioGroup)).setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
SearchAddressFragment.this.radioBuilding = checkedId == R.id.RadioBuilding;
if (radioBuilding) {
SearchAddressFragment.this.street2 = null;
} else {
SearchAddressFragment.this.building = null;
}
updateBuildingSection();
}
});
}
use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.
the class SearchPOIActivity method savePoiFilter.
public void savePoiFilter() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.edit_filter_save_as_menu_item);
final EditText editText = new EditText(this);
if (filter.isStandardFilter()) {
editText.setText((filter.getName() + " " + searchFilter.getText()).trim());
} else {
editText.setText(filter.getName());
}
LinearLayout ll = new LinearLayout(this);
ll.setPadding(5, 3, 5, 0);
ll.addView(editText, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
builder.setView(ll);
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
PoiUIFilter nFilter = new PoiUIFilter(editText.getText().toString(), null, filter.getAcceptedTypes(), (OsmandApplication) getApplication());
if (searchFilter.getText().toString().length() > 0) {
nFilter.setSavedFilterByName(searchFilter.getText().toString());
}
if (app.getPoiFilters().createPoiFilter(nFilter)) {
Toast.makeText(SearchPOIActivity.this, MessageFormat.format(SearchPOIActivity.this.getText(R.string.edit_filter_create_message).toString(), editText.getText().toString()), Toast.LENGTH_SHORT).show();
}
SearchPOIActivity.this.finish();
}
});
builder.create().show();
}
use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.
the class TrackActivity method getGpxFile.
public List<GpxDisplayGroup> getGpxFile(boolean useDisplayGroups) {
if (gpxFile == null) {
return new ArrayList<>();
}
if (gpxFile.modifiedTime != modifiedTime) {
modifiedTime = gpxFile.modifiedTime;
GpxSelectionHelper selectedGpxHelper = ((OsmandApplication) getApplication()).getSelectedGpxHelper();
displayGroups = selectedGpxHelper.collectDisplayGroups(gpxFile);
originalGroups.clear();
for (GpxDisplayGroup g : displayGroups) {
originalGroups.add(g.cloneInstance());
}
if (file != null) {
SelectedGpxFile sf = selectedGpxHelper.getSelectedFileByPath(gpxFile.path);
if (sf != null && file != null && sf.getDisplayGroups() != null) {
displayGroups = sf.getDisplayGroups();
}
}
}
if (useDisplayGroups) {
return displayGroups;
} else {
return originalGroups;
}
}
use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.
the class ShareDialog method sendQRCode.
public static void sendQRCode(final Activity activity, String encodeType, Bundle encodeData, String strEncodeData) {
Intent intent = new Intent();
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setAction(ZXING_BARCODE_SCANNER_ACTIVITY);
ResolveInfo resolved = activity.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (resolved != null) {
intent.putExtra("ENCODE_TYPE", encodeType);
if (strEncodeData != null) {
intent.putExtra("ENCODE_DATA", strEncodeData);
} else {
intent.putExtra("ENCODE_DATA", encodeData);
}
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
activity.startActivity(intent);
} else {
if (Version.isMarketEnabled((OsmandApplication) activity.getApplication())) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage(activity.getString(R.string.zxing_barcode_scanner_not_found));
builder.setPositiveButton(activity.getString(R.string.shared_string_yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.getUrlWithUtmRef((OsmandApplication) activity.getApplication(), ZXING_BARCODE_SCANNER_COMPONENT)));
try {
activity.startActivity(intent);
} catch (ActivityNotFoundException e) {
}
}
});
builder.setNegativeButton(activity.getString(R.string.shared_string_no), null);
builder.show();
} else {
Toast.makeText(activity, R.string.zxing_barcode_scanner_not_found, Toast.LENGTH_LONG).show();
}
}
}
use of net.osmand.plus.OsmandApplication in project Osmand by osmandapp.
the class SettingsActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings_pref);
PreferenceScreen screen = getPreferenceScreen();
general = (Preference) screen.findPreference("general_settings");
general.setOnPreferenceClickListener(this);
routing = (Preference) screen.findPreference("routing_settings");
routing.setOnPreferenceClickListener(this);
getToolbar().setTitle(Version.getFullVersion(getMyApplication()));
Intent intent = getIntent();
if (intent != null && intent.getIntExtra(INTENT_KEY_SETTINGS_SCREEN, 0) != 0) {
int s = intent.getIntExtra(INTENT_KEY_SETTINGS_SCREEN, 0);
if (s == SCREEN_GENERAL_SETTINGS) {
startActivity(new Intent(this, SettingsGeneralActivity.class));
} else if (s == SCREEN_NAVIGATION_SETTINGS) {
startActivity(new Intent(this, SettingsNavigationActivity.class));
}
}
PreferenceCategory plugins = (PreferenceCategory) screen.findPreference("plugin_settings");
for (OsmandPlugin op : OsmandPlugin.getEnabledPlugins()) {
final Class<? extends Activity> sa = op.getSettingsActivity();
if (sa != null) {
Preference preference = new Preference(this);
preference.setTitle(op.getName());
preference.setKey(op.getId());
preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(SettingsActivity.this, sa));
return false;
}
});
plugins.addPreference(preference);
}
}
}
Aggregations