Fix several possible errors
This commit is contained in:
parent
ca69159332
commit
06c43fdef6
5 changed files with 59 additions and 40 deletions
|
@ -248,6 +248,8 @@ public class ImportHelper {
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
//
|
//
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
if (is != null) try {
|
if (is != null) try {
|
||||||
is.close();
|
is.close();
|
||||||
|
@ -314,6 +316,8 @@ public class ImportHelper {
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
//
|
//
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
if (is != null) try {
|
if (is != null) try {
|
||||||
is.close();
|
is.close();
|
||||||
|
@ -410,7 +414,7 @@ public class ImportHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error(e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (is != null) {
|
if (is != null) {
|
||||||
|
@ -463,6 +467,8 @@ public class ImportHelper {
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
//
|
//
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
if (is != null) try {
|
if (is != null) try {
|
||||||
is.close();
|
is.close();
|
||||||
|
@ -549,7 +555,10 @@ public class ImportHelper {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
error = e.getMessage();
|
error = e.getMessage();
|
||||||
} finally {
|
} catch (SecurityException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
error = e.getMessage();
|
||||||
|
} finally {
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
try {
|
try {
|
||||||
in.close();
|
in.close();
|
||||||
|
@ -918,6 +927,8 @@ public class ImportHelper {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
if (is != null) try {
|
if (is != null) try {
|
||||||
is.close();
|
is.close();
|
||||||
|
|
|
@ -35,7 +35,6 @@ import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.LocalIndexHelper;
|
import net.osmand.plus.activities.LocalIndexHelper;
|
||||||
|
@ -50,6 +49,7 @@ import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseListener;
|
||||||
import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseTaskType;
|
import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseTaskType;
|
||||||
import net.osmand.plus.inapp.InAppPurchases.InAppSubscription;
|
import net.osmand.plus.inapp.InAppPurchases.InAppSubscription;
|
||||||
import net.osmand.plus.resources.IncrementalChangesManager;
|
import net.osmand.plus.resources.IncrementalChangesManager;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -82,6 +82,8 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
return lhs.getName().compareTo(rhs.getName());
|
return lhs.getName().compareTo(rhs.getName());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
private View subscriptionHeader;
|
private View subscriptionHeader;
|
||||||
private ExpandableListView listView;
|
private ExpandableListView listView;
|
||||||
private LocalIndexesAdapter adapter;
|
private LocalIndexesAdapter adapter;
|
||||||
|
@ -109,6 +111,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
|
app = getMyApplication();
|
||||||
if (getActivity() instanceof OsmLiveActivity) {
|
if (getActivity() instanceof OsmLiveActivity) {
|
||||||
showSettingsOnly = ((OsmLiveActivity) getActivity()).isShowSettingOnly();
|
showSettingsOnly = ((OsmLiveActivity) getActivity()).isShowSettingOnly();
|
||||||
}
|
}
|
||||||
|
@ -120,7 +123,6 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
View view = inflater.inflate(R.layout.fragment_live_updates, container, false);
|
View view = inflater.inflate(R.layout.fragment_live_updates, container, false);
|
||||||
listView = (ExpandableListView) view.findViewById(android.R.id.list);
|
listView = (ExpandableListView) view.findViewById(android.R.id.list);
|
||||||
|
|
||||||
final OsmandApplication app = getMyApplication();
|
|
||||||
boolean nightMode = !app.getSettings().isLightContent();
|
boolean nightMode = !app.getSettings().isLightContent();
|
||||||
final SwipeRefreshLayout swipeRefresh = view.findViewById(R.id.swipe_refresh);
|
final SwipeRefreshLayout swipeRefresh = view.findViewById(R.id.swipe_refresh);
|
||||||
int swipeColor = ContextCompat.getColor(app, nightMode ? R.color.osmand_orange_dark : R.color.osmand_orange);
|
int swipeColor = ContextCompat.getColor(app, nightMode ? R.color.osmand_orange_dark : R.color.osmand_orange);
|
||||||
|
@ -141,7 +143,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
listView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
|
listView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||||
if (!processing && InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication())) {
|
if (!processing && InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
|
||||||
final FragmentManager fragmentManager = getChildFragmentManager();
|
final FragmentManager fragmentManager = getChildFragmentManager();
|
||||||
LiveUpdatesSettingsDialogFragment
|
LiveUpdatesSettingsDialogFragment
|
||||||
.createInstance(adapter.getChild(groupPosition, childPosition).getFileName())
|
.createInstance(adapter.getChild(groupPosition, childPosition).getFileName())
|
||||||
|
@ -155,7 +157,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
|
|
||||||
progressBar = (ProgressBar) view.findViewById(R.id.progress);
|
progressBar = (ProgressBar) view.findViewById(R.id.progress);
|
||||||
|
|
||||||
if (!Version.isDeveloperVersion(getMyApplication())) {
|
if (!Version.isDeveloperVersion(app)) {
|
||||||
subscriptionHeader = inflater.inflate(R.layout.live_updates_header, listView, false);
|
subscriptionHeader = inflater.inflate(R.layout.live_updates_header, listView, false);
|
||||||
updateSubscriptionHeader();
|
updateSubscriptionHeader();
|
||||||
listView.addHeaderView(subscriptionHeader, "subscriptionHeader", false);
|
listView.addHeaderView(subscriptionHeader, "subscriptionHeader", false);
|
||||||
|
@ -172,22 +174,22 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
if (getActivity() instanceof OsmLiveActivity && subscriptionHeader != null) {
|
if (getActivity() instanceof OsmLiveActivity && subscriptionHeader != null) {
|
||||||
View subscriptionBanner = subscriptionHeader.findViewById(R.id.subscription_banner);
|
View subscriptionBanner = subscriptionHeader.findViewById(R.id.subscription_banner);
|
||||||
View subscriptionInfo = subscriptionHeader.findViewById(R.id.subscription_info);
|
View subscriptionInfo = subscriptionHeader.findViewById(R.id.subscription_info);
|
||||||
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication())) {
|
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
|
||||||
ImageView statusIcon = (ImageView) subscriptionHeader.findViewById(R.id.statusIcon);
|
ImageView statusIcon = (ImageView) subscriptionHeader.findViewById(R.id.statusIcon);
|
||||||
TextView statusTextView = (TextView) subscriptionHeader.findViewById(R.id.statusTextView);
|
TextView statusTextView = (TextView) subscriptionHeader.findViewById(R.id.statusTextView);
|
||||||
TextView regionNameHeaderTextView = (TextView) subscriptionHeader.findViewById(R.id.regionHeaderTextView);
|
TextView regionNameHeaderTextView = (TextView) subscriptionHeader.findViewById(R.id.regionHeaderTextView);
|
||||||
TextView regionNameTextView = (TextView) subscriptionHeader.findViewById(R.id.regionTextView);
|
TextView regionNameTextView = (TextView) subscriptionHeader.findViewById(R.id.regionTextView);
|
||||||
statusTextView.setText(getString(R.string.osm_live_active));
|
statusTextView.setText(getString(R.string.osm_live_active));
|
||||||
statusIcon.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_done));
|
statusIcon.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_done));
|
||||||
|
|
||||||
regionNameHeaderTextView.setText(R.string.osm_live_support_region);
|
regionNameHeaderTextView.setText(R.string.osm_live_support_region);
|
||||||
String countryName = getSettings().BILLING_USER_COUNTRY.get();
|
String countryName = app.getSettings().BILLING_USER_COUNTRY.get();
|
||||||
InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper();
|
InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper();
|
||||||
if (purchaseHelper != null) {
|
if (purchaseHelper != null) {
|
||||||
InAppSubscription monthlyPurchased = purchaseHelper.getPurchasedMonthlyLiveUpdates();
|
InAppSubscription monthlyPurchased = purchaseHelper.getPurchasedMonthlyLiveUpdates();
|
||||||
if (monthlyPurchased != null && monthlyPurchased.isDonationSupported()) {
|
if (monthlyPurchased != null && monthlyPurchased.isDonationSupported()) {
|
||||||
if (Algorithms.isEmpty(countryName)) {
|
if (Algorithms.isEmpty(countryName)) {
|
||||||
if (getSettings().BILLING_USER_COUNTRY_DOWNLOAD_NAME.get().equals(OsmandSettings.BILLING_USER_DONATION_NONE_PARAMETER)) {
|
if (app.getSettings().BILLING_USER_COUNTRY_DOWNLOAD_NAME.get().equals(OsmandSettings.BILLING_USER_DONATION_NONE_PARAMETER)) {
|
||||||
regionNameHeaderTextView.setText(R.string.default_buttons_support);
|
regionNameHeaderTextView.setText(R.string.default_buttons_support);
|
||||||
countryName = getString(R.string.osmand_team);
|
countryName = getString(R.string.osmand_team);
|
||||||
} else {
|
} else {
|
||||||
|
@ -277,10 +279,8 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyLiveUpdatesChanged() {
|
public void notifyLiveUpdatesChanged() {
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null && adapter != null) {
|
||||||
if (adapter != null && getMyApplication() != null) {
|
adapter.notifyLiveUpdatesChanged();
|
||||||
adapter.notifyLiveUpdatesChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
|
|
||||||
public void add(LocalIndexInfo info) {
|
public void add(LocalIndexInfo info) {
|
||||||
OsmandSettings.CommonPreference<Boolean> preference = preferenceLiveUpdatesOn(
|
OsmandSettings.CommonPreference<Boolean> preference = preferenceLiveUpdatesOn(
|
||||||
info.getFileName(), getSettings());
|
info.getFileName(), app.getSettings());
|
||||||
if (preference.get()) {
|
if (preference.get()) {
|
||||||
dataShouldUpdate.add(info);
|
dataShouldUpdate.add(info);
|
||||||
} else {
|
} else {
|
||||||
|
@ -325,7 +325,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
Set<LocalIndexInfo> changedSet = new HashSet<>();
|
Set<LocalIndexInfo> changedSet = new HashSet<>();
|
||||||
for (LocalIndexInfo localIndexInfo : dataShouldUpdate) {
|
for (LocalIndexInfo localIndexInfo : dataShouldUpdate) {
|
||||||
OsmandSettings.CommonPreference<Boolean> preference =
|
OsmandSettings.CommonPreference<Boolean> preference =
|
||||||
preferenceLiveUpdatesOn(localIndexInfo.getFileName(), getSettings());
|
preferenceLiveUpdatesOn(localIndexInfo.getFileName(), app.getSettings());
|
||||||
if (!preference.get()) {
|
if (!preference.get()) {
|
||||||
changedSet.add(localIndexInfo);
|
changedSet.add(localIndexInfo);
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
changedSet.clear();
|
changedSet.clear();
|
||||||
for (LocalIndexInfo localIndexInfo : dataShouldNotUpdate) {
|
for (LocalIndexInfo localIndexInfo : dataShouldNotUpdate) {
|
||||||
OsmandSettings.CommonPreference<Boolean> preference =
|
OsmandSettings.CommonPreference<Boolean> preference =
|
||||||
preferenceLiveUpdatesOn(localIndexInfo.getFileName(), getSettings());
|
preferenceLiveUpdatesOn(localIndexInfo.getFileName(), app.getSettings());
|
||||||
if (preference.get()) {
|
if (preference.get()) {
|
||||||
changedSet.add(localIndexInfo);
|
changedSet.add(localIndexInfo);
|
||||||
}
|
}
|
||||||
|
@ -410,11 +410,11 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication())) {
|
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
|
||||||
switchOnLiveUpdates(settings);
|
switchOnLiveUpdates(settings);
|
||||||
} else {
|
} else {
|
||||||
liveUpdatesSwitch.setChecked(false);
|
liveUpdatesSwitch.setChecked(false);
|
||||||
getMyApplication().showToastMessage(getString(R.string.osm_live_ask_for_purchase));
|
app.showToastMessage(getString(R.string.osm_live_ask_for_purchase));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
settings.IS_LIVE_UPDATES_ON.set(false);
|
settings.IS_LIVE_UPDATES_ON.set(false);
|
||||||
|
@ -447,16 +447,16 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
private void showUpdateDialog() {
|
private void showUpdateDialog() {
|
||||||
if(dataShouldUpdate.size() > 0) {
|
if(dataShouldUpdate.size() > 0) {
|
||||||
if (dataShouldUpdate.size() == 1) {
|
if (dataShouldUpdate.size() == 1) {
|
||||||
runLiveUpdate(getMyApplication(), dataShouldUpdate.get(0).getFileName(), false);
|
runLiveUpdate(app, dataShouldUpdate.get(0).getFileName(), false);
|
||||||
} else {
|
} else {
|
||||||
Builder bld = new AlertDialog.Builder(getActivity());
|
Builder bld = new AlertDialog.Builder(ctx);
|
||||||
bld.setMessage(R.string.update_all_maps_now);
|
bld.setMessage(R.string.update_all_maps_now);
|
||||||
bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
for (LocalIndexInfo li : dataShouldUpdate) {
|
for (LocalIndexInfo li : dataShouldUpdate) {
|
||||||
runLiveUpdate(getMyApplication(), li.getFileName(), false);
|
runLiveUpdate(app, li.getFileName(), false);
|
||||||
}
|
}
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@ -468,17 +468,15 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableLiveUpdates(boolean enable) {
|
private void enableLiveUpdates(boolean enable) {
|
||||||
AlarmManager alarmMgr = (AlarmManager) getActivity()
|
AlarmManager alarmMgr = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE);
|
||||||
.getSystemService(Context.ALARM_SERVICE);
|
|
||||||
for (LocalIndexInfo li : dataShouldUpdate) {
|
for (LocalIndexInfo li : dataShouldUpdate) {
|
||||||
String fileName = li.getFileName();
|
String fileName = li.getFileName();
|
||||||
PendingIntent alarmIntent = getPendingIntent(getActivity(),
|
PendingIntent alarmIntent = getPendingIntent(ctx, fileName);
|
||||||
fileName);
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
final OsmandSettings.CommonPreference<Integer> updateFrequencyPreference =
|
final OsmandSettings.CommonPreference<Integer> updateFrequencyPreference =
|
||||||
preferenceUpdateFrequency(fileName, getSettings());
|
preferenceUpdateFrequency(fileName, app.getSettings());
|
||||||
final OsmandSettings.CommonPreference<Integer> timeOfDayPreference =
|
final OsmandSettings.CommonPreference<Integer> timeOfDayPreference =
|
||||||
preferenceTimeOfDayToUpdate(fileName, getSettings());
|
preferenceTimeOfDayToUpdate(fileName, app.getSettings());
|
||||||
UpdateFrequency updateFrequency = UpdateFrequency.values()[updateFrequencyPreference.get()];
|
UpdateFrequency updateFrequency = UpdateFrequency.values()[updateFrequencyPreference.get()];
|
||||||
TimeOfDay timeOfDayToUpdate = TimeOfDay.values()[timeOfDayPreference.get()];
|
TimeOfDay timeOfDayToUpdate = TimeOfDay.values()[timeOfDayPreference.get()];
|
||||||
setAlarmForPendingIntent(alarmIntent, alarmMgr, updateFrequency, timeOfDayToUpdate);
|
setAlarmForPendingIntent(alarmIntent, alarmMgr, updateFrequency, timeOfDayToUpdate);
|
||||||
|
@ -713,8 +711,8 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGetItems() {
|
public void onGetItems() {
|
||||||
if (!InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication())) {
|
if (!InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
|
||||||
getSettings().IS_LIVE_UPDATES_ON.set(false);
|
app.getSettings().IS_LIVE_UPDATES_ON.set(false);
|
||||||
adapter.enableLiveUpdates(false);
|
adapter.enableLiveUpdates(false);
|
||||||
}
|
}
|
||||||
disableProgress();
|
disableProgress();
|
||||||
|
|
|
@ -559,7 +559,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
if (getActivity() instanceof MapActivity) {
|
if (getActivity() instanceof MapActivity) {
|
||||||
((MapActivity) getActivity()).getMapView().refreshMap(true);
|
((MapActivity) getActivity()).getMapView().refreshMap(true);
|
||||||
}
|
}
|
||||||
dismiss();
|
dismissAllowingStateLoss();
|
||||||
} else {
|
} else {
|
||||||
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||||
mOpenstreetmapUtil = plugin.getPoiModificationLocalUtil();
|
mOpenstreetmapUtil = plugin.getPoiModificationLocalUtil();
|
||||||
|
|
|
@ -10,7 +10,7 @@ import net.osmand.plus.settings.bottomsheets.VehicleSizeAssets;
|
||||||
public class SizePreference extends DialogPreference {
|
public class SizePreference extends DialogPreference {
|
||||||
|
|
||||||
private String[] entries;
|
private String[] entries;
|
||||||
private Object[] entryValues;
|
private String[] entryValues;
|
||||||
private String description;
|
private String description;
|
||||||
private VehicleSizeAssets assets;
|
private VehicleSizeAssets assets;
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ public class SizePreference extends DialogPreference {
|
||||||
this.entries = entries;
|
this.entries = entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getEntryValues() {
|
public String[] getEntryValues() {
|
||||||
return entryValues;
|
return entryValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEntryValues(Object[] entryValues) {
|
public void setEntryValues(String[] entryValues) {
|
||||||
this.entryValues = entryValues;
|
this.entryValues = entryValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,11 @@ public class SizePreference extends DialogPreference {
|
||||||
String[] entries = getEntries();
|
String[] entries = getEntries();
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (int i = 0; i < entries.length; i++) {
|
||||||
if (entries[i].equals(item)) {
|
if (entries[i].equals(item)) {
|
||||||
return Float.parseFloat(getEntryValues()[i].toString());
|
try {
|
||||||
|
return Float.parseFloat(entryValues[i]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
@ -77,12 +81,18 @@ public class SizePreference extends DialogPreference {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
|
String summary = "-";
|
||||||
String persistedString = getValue();
|
String persistedString = getValue();
|
||||||
if (!persistedString.equals(defaultValue)) {
|
if (!persistedString.equals(defaultValue)) {
|
||||||
persistedString = String.valueOf(Float.parseFloat(persistedString) + 0.01f);
|
try {
|
||||||
return String.format(getContext().getString(R.string.ltr_or_rtl_combine_via_space), persistedString, getContext().getString(assets.getMetricShortRes()));
|
persistedString = String.valueOf(Float.parseFloat(persistedString) + 0.01f);
|
||||||
|
summary = String.format(getContext().getString(R.string.ltr_or_rtl_combine_via_space),
|
||||||
|
persistedString, getContext().getString(assets.getMetricShortRes()));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
summary = "-";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "-";
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
|
|
|
@ -236,9 +236,9 @@ public class SRTMPlugin extends OsmandPlugin {
|
||||||
if (contourLinesProp != null) {
|
if (contourLinesProp != null) {
|
||||||
final OsmandSettings.CommonPreference<String> pref = app.getSettings().getCustomRenderProperty(contourLinesProp.getAttrName());
|
final OsmandSettings.CommonPreference<String> pref = app.getSettings().getCustomRenderProperty(contourLinesProp.getAttrName());
|
||||||
if (!Algorithms.isEmpty(pref.get())) {
|
if (!Algorithms.isEmpty(pref.get())) {
|
||||||
contourLinesEnabled = !pref.get().equals(CONTOUR_LINES_DISABLED_VALUE);
|
contourLinesEnabled = !CONTOUR_LINES_DISABLED_VALUE.equals(pref.get());
|
||||||
} else {
|
} else {
|
||||||
contourLinesEnabled = !contourLinesProp.getDefaultValueDescription().equals(CONTOUR_LINES_DISABLED_VALUE);
|
contourLinesEnabled = !CONTOUR_LINES_DISABLED_VALUE.equals(contourLinesProp.getDefaultValueDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return contourLinesEnabled;
|
return contourLinesEnabled;
|
||||||
|
|
Loading…
Reference in a new issue