add default profile name for unnamed or missing improted profiles

This commit is contained in:
nnngrach 2021-02-02 04:02:43 +03:00
parent 9f58fdff95
commit 56e8f85c04
3 changed files with 16 additions and 3 deletions

View file

@ -26,6 +26,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
public class ProfileSettingsItem extends OsmandSettingsItem {
@ -124,7 +125,7 @@ public class ProfileSettingsItem extends OsmandSettingsItem {
if (Algorithms.isEmpty(modeBean.userProfileName)) {
ApplicationMode appMode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null);
if (appMode != null) {
modeBean.userProfileName = app.getString(appMode.getNameKeyResource());
modeBean.userProfileName = appMode.toHumanString();
}
}
int number = 0;

View file

@ -33,6 +33,7 @@ import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean;
import net.osmand.util.Algorithms;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import java.io.File;
@ -91,7 +92,11 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter<RecyclerView
String profileName = modeBean.userProfileName;
if (Algorithms.isEmpty(profileName)) {
ApplicationMode appMode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null);
profileName = app.getString(appMode.getNameKeyResource());
try {
profileName = app.getString(appMode.getNameKeyResource());
} catch (Exception e) {
profileName = StringUtils.capitalize(modeBean.stringKey);
}
}
itemHolder.title.setText(profileName);
String routingProfile = "";

View file

@ -61,6 +61,7 @@ import net.osmand.plus.settings.fragments.ExportSettingsAdapter.OnItemSelectedLi
import net.osmand.util.Algorithms;
import net.osmand.view.ThreeStateCheckbox;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import java.io.File;
@ -279,7 +280,13 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment {
String profileName = modeBean.userProfileName;
if (Algorithms.isEmpty(profileName)) {
ApplicationMode appMode = ApplicationMode.valueOfStringKey(modeBean.stringKey, null);
profileName = appMode.toHumanString();
if (appMode != null) {
profileName = appMode.toHumanString();
} else {
String defaultProfileName = StringUtils.capitalize(modeBean.stringKey);
profileName = defaultProfileName;
modeBean.userProfileName = defaultProfileName;
}
}
builder.setTitle(profileName);