Merge pull request #7105 from osmandapp/profiles_fixes

Profiles fixes
This commit is contained in:
vshcherb 2019-06-26 14:32:21 +02:00 committed by GitHub
commit 388b3103cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 8 deletions

View file

@ -215,7 +215,7 @@ public class ApplicationMode {
public ApplicationModeBuilder icon(int iconRes, int iconMapRes, String iconResName) {
try {
applicationMode.iconResName = iconResName;
applicationMode.iconMapRes = iconRes;
applicationMode.iconMapRes = iconMapRes;
applicationMode.iconRes = iconRes;
} catch (Exception e) {

View file

@ -661,7 +661,7 @@ public class PlanRouteFragment extends BaseOsmAndFragment implements OsmAndLocat
if (mapActivity != null) {
final ImageButton appModesBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
appModesBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
appModesBtn.setImageDrawable(getActiveIcon(planRouteContext.getSnappedMode().getIconRes()));
appModesBtn.setImageDrawable(getActiveIcon(planRouteContext.getSnappedMode().getMapIconRes()));
appModesBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View file

@ -805,7 +805,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
ImageButton snapToRoadBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
snapToRoadBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
snapToRoadBtn.setImageDrawable(getActiveIcon(appMode.getIconRes()));
snapToRoadBtn.setImageDrawable(getIcon(appMode.getMapIconRes(), appMode.getIconColorInfo().getColor(nightMode)));
snapToRoadBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View file

@ -96,7 +96,7 @@ public class SnapToRoadBottomSheetDialogFragment extends android.support.design.
ApplicationMode mode = modes.get(i);
View row = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.list_item_icon_and_title, null);
((ImageView) row.findViewById(R.id.icon)).setImageDrawable(
getContentIcon(mode.getIconRes()));
app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
((TextView) row.findViewById(R.id.title)).setText(mode.toHumanString(getContext()));
row.setOnClickListener(onClickListener);
row.setTag(i);

View file

@ -33,6 +33,7 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
@ -165,7 +166,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
saveButtonSV = view.findViewById(R.id.save_profile_btn_sv);
profileNameEt.setFocusable(true);
profileNameEt.setSelectAllOnFocus(true);
profileNameTextBox.getEditText().setSelection(profileNameEt.getText().length());
String title = getResources().getString(R.string.new_profile);
@ -278,6 +279,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
@Override
public void onClick(View v) {
if (isNew || isUserProfile) {
hideKeyboard();
final SelectProfileBottomSheetDialogFragment fragment = new SelectProfileBottomSheetDialogFragment();
Bundle bundle = new Bundle();
if (profile.routingProfileDataObject != null) {
@ -307,6 +309,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
bundle.putString(DIALOG_TYPE, TYPE_ICON);
bundle.putString(SELECTED_ICON, profile.iconStringName);
iconSelectDialog.setArguments(bundle);
hideKeyboard();
if (getActivity() != null) {
getActivity().getSupportFragmentManager().beginTransaction()
.add(iconSelectDialog, "select_icon")
@ -590,7 +593,8 @@ public class EditProfileFragment extends BaseOsmAndFragment {
}
if (profile.userProfileTitle.isEmpty()
|| profile.userProfileTitle.replace(" ", "").length() < 1) {
|| profile.userProfileTitle.replace(" ", "").length() < 1
|| profileNameEt.getText().toString().replace(" ", "").length() < 1) {
showSaveWarningDialog(
getString(R.string.profile_alert_need_profile_name_title),
getString(R.string.profile_alert_need_profile_name_msg),
@ -708,6 +712,16 @@ public class EditProfileFragment extends BaseOsmAndFragment {
}
}
}
private void hideKeyboard() {
View cf = getActivity().getCurrentFocus();
if (cf != null) {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(cf.getWindowToken(), 0);
}
}
}
static List<RoutingProfileDataObject> getRoutingProfiles(OsmandApplication context) {
List<RoutingProfileDataObject> profilesObjects = new ArrayList<>();

View file

@ -128,7 +128,10 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
holder.descr.setVisibility(View.GONE);
holder.switcher.setVisibility(View.GONE);
holder.menuIcon.setVisibility(View.GONE);
holder.title.setTextColor(app.getResources().getColor(selectedIconColorRes));
holder.title.setTextColor(app.getResources().getColor(
isNightMode(app)
? R.color.active_buttons_and_links_dark
: R.color.active_buttons_and_links_light));
holder.title.setText(bottomButtonText);
}
}

View file

@ -796,7 +796,7 @@ public class MapControlsLayer extends OsmandMapLayer {
compassHud.forceHideCompass = forceHideCompass;
compassHud.updateVisibility(!forceHideCompass && shouldShowCompass());
if (layersHud.setIconResId(settings.getApplicationMode().getIconRes())) {
if (layersHud.setIconResId(settings.getApplicationMode().getMapIconRes())) {
layersHud.update(app, isNight);
}
layersHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode()