Selected Profile UI fixes and tweaks
This commit is contained in:
parent
7e98dd6d6e
commit
5a41dbb962
6 changed files with 180 additions and 39 deletions
17
OsmAnd/res/drawable/btn_round_profile_blue.xml
Normal file
17
OsmAnd/res/drawable/btn_round_profile_blue.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape android:shape="rectangle">
|
||||
<solid android:color="@color/map_widget_blue_pressed" />
|
||||
<corners android:radius="@dimen/map_button_rect_rad" />
|
||||
</shape></item>
|
||||
<item android:state_enabled="false"><shape android:shape="rectangle">
|
||||
<solid android:color="@color/searchbar_tab_inactive_light" />
|
||||
<corners android:radius="@dimen/map_button_rect_rad" />
|
||||
</shape></item>
|
||||
<item><shape android:shape="rectangle">
|
||||
<solid android:color="@color/active_buttons_and_links_light" />
|
||||
<corners android:radius="@dimen/map_button_rect_rad" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
16
OsmAnd/res/drawable/btn_round_profile_gray.xml
Normal file
16
OsmAnd/res/drawable/btn_round_profile_gray.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"><shape android:shape="rectangle">
|
||||
<solid android:color="@color/profile_button_gray_pressed" />
|
||||
<corners android:radius="@dimen/map_button_rect_rad" />
|
||||
</shape></item>
|
||||
<item android:state_enabled="false"><shape android:shape="rectangle">
|
||||
<solid android:color="@color/searchbar_tab_inactive_light" />
|
||||
<corners android:radius="@dimen/map_button_rect_rad" />
|
||||
</shape></item>
|
||||
<item><shape android:shape="rectangle">
|
||||
<solid android:color="@color/profile_button_gray" />
|
||||
<corners android:radius="@dimen/map_button_rect_rad" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
|
@ -13,6 +13,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:layout_marginBottom="@dimen/setting_profile_item_height">
|
||||
|
||||
<LinearLayout
|
||||
|
@ -64,7 +66,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
android:text="Base Profile"/>
|
||||
|
||||
<TextView
|
||||
|
@ -73,7 +74,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textSize="16sp"
|
||||
android:textSize="18sp"
|
||||
android:textColor="?attr/main_font_color_basic"
|
||||
tools:text="Item additional desription"/>
|
||||
|
||||
|
@ -137,7 +138,7 @@
|
|||
<net.osmand.plus.widgets.OsmandTextFieldBoxes
|
||||
android:id="@+id/profile_name_otfb"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="60dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/list_content_padding"
|
||||
android:layout_marginBottom="@dimen/list_content_padding"
|
||||
|
@ -160,8 +161,8 @@
|
|||
|
||||
<LinearLayout
|
||||
android:id="@+id/profile_icon_layout"
|
||||
android:layout_width="68dp"
|
||||
android:layout_height="68dp"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:clickable="true"
|
||||
|
@ -174,7 +175,8 @@
|
|||
android:id="@+id/select_icon_btn_txt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="8dp"
|
||||
android:textSize="12sp"
|
||||
android:paddingBottom="2dp"
|
||||
android:text="Icon"/>
|
||||
|
||||
<ImageView
|
||||
|
@ -198,7 +200,7 @@
|
|||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/list_content_padding"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
|
@ -216,7 +218,7 @@
|
|||
<net.osmand.plus.widgets.OsmandTextFieldBoxes
|
||||
android:id="@+id/navigation_type_otfb"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="60dp"
|
||||
|
||||
app:labelText="Navigation Type">
|
||||
|
||||
|
@ -228,7 +230,7 @@
|
|||
android:drawableRight="@drawable/ic_action_arrow_drop_down"
|
||||
android:focusable="false"
|
||||
android:maxLines="1"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
|
||||
tools:text="Car"/>
|
||||
|
||||
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
|
||||
|
@ -245,7 +247,7 @@
|
|||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/list_content_padding"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
|
@ -314,6 +316,7 @@
|
|||
android:id="@+id/map_config_btn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="65dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
@ -356,12 +359,13 @@
|
|||
android:layout_height="1dp"
|
||||
android:layout_marginStart="64dp"
|
||||
android:layout_marginLeft="64dp"
|
||||
android:background="?android:attr/listDivider"/>
|
||||
android:background="@color/divider_light"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/screen_config_btn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
@ -405,7 +409,7 @@
|
|||
android:layout_height="1dp"
|
||||
android:layout_marginStart="64dp"
|
||||
android:layout_marginLeft="64dp"
|
||||
android:background="?android:attr/listDivider"
|
||||
android:background="@color/divider_light"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -413,6 +417,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:gravity="center_vertical"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
|
@ -421,7 +426,7 @@
|
|||
android:layout_height="24dp"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:src="@drawable/ic_action_start_navigation"
|
||||
android:src="@drawable/ic_action_gdirections_dark"
|
||||
android:tint="?attr/primary_icon_color"/>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -456,7 +461,48 @@
|
|||
<include layout="@layout/list_shadow_footer"/>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttons_layout_sv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone">
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel_button_sv"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/list_content_padding"
|
||||
android:layout_marginBottom="@dimen/list_content_padding"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:layout_marginRight="8dp"
|
||||
android:background="@drawable/btn_round_profile_gray"
|
||||
android:text="@string/shared_string_cancel"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@color/map_widget_blue"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/save_profile_btn_sv"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/list_content_padding"
|
||||
android:layout_marginBottom="@dimen/list_content_padding"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:background="@drawable/btn_round_profile_blue"
|
||||
android:text="@string/shared_string_save"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@color/color_white"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -473,7 +519,7 @@
|
|||
<Button
|
||||
android:id="@+id/cancel_button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="42dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/list_content_padding"
|
||||
android:layout_marginBottom="@dimen/list_content_padding"
|
||||
|
@ -481,7 +527,7 @@
|
|||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:layout_marginRight="8dp"
|
||||
android:background="@drawable/btn_right_round"
|
||||
android:background="@drawable/btn_round_profile_gray"
|
||||
android:text="@string/shared_string_cancel"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@color/map_widget_blue"/>
|
||||
|
@ -489,7 +535,7 @@
|
|||
<Button
|
||||
android:id="@+id/save_profile_btn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="42dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/list_content_padding"
|
||||
android:layout_marginBottom="@dimen/list_content_padding"
|
||||
|
@ -497,7 +543,7 @@
|
|||
android:layout_marginEnd="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:background="@drawable/btn_round_blue"
|
||||
android:background="@drawable/btn_round_profile_blue"
|
||||
android:text="@string/shared_string_save"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@color/color_white"/>
|
||||
|
|
|
@ -481,6 +481,7 @@
|
|||
<color name="active_buttons_and_links_trans_light">#66237bff</color>
|
||||
<color name="active_buttons_and_links_trans_dark">#66d28521</color>
|
||||
<color name="settings_divider">#dcdcdc</color>
|
||||
|
||||
<color name="profile_button_gray">#EFEFEF</color>
|
||||
<color name="profile_button_gray_pressed">#ababab</color>
|
||||
|
||||
</resources>
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.profiles;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
|
@ -7,6 +8,8 @@ import android.support.v4.view.MenuItemCompat;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package net.osmand.plus.profiles;
|
||||
|
||||
import static net.osmand.plus.activities.SettingsBaseActivity.getRoutingStringPropertyDescription;
|
||||
import static net.osmand.plus.activities.SettingsNavigationActivity.INTENT_SKIP_DIALOG;
|
||||
import static net.osmand.plus.profiles.ProfileBottomSheetDialogFragment.TYPE_APP_PROFILE;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
|
@ -23,12 +25,15 @@ import android.view.View.OnClickListener;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
import android.view.ViewTreeObserver.OnScrollChangedListener;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
|
@ -92,6 +97,11 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
|||
private ImageView baseModeIcon;
|
||||
private TextView baseModeTitle;
|
||||
private ScrollView scrollContainer;
|
||||
private LinearLayout buttonsLayoutSV;
|
||||
private Button cancelBtnSV;
|
||||
private Button saveButtonSV;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
|
@ -133,6 +143,9 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
|||
baseModeIcon = view.findViewById(R.id.mode_icon);
|
||||
baseModeTitle = view.findViewById(R.id.mode_title);
|
||||
scrollContainer = view.findViewById(R.id.scroll_view_container);
|
||||
buttonsLayoutSV = view.findViewById(R.id.buttons_layout_sv);
|
||||
cancelBtnSV = view.findViewById(R.id.save_profile_btn_sv);
|
||||
saveButtonSV = view.findViewById(R.id.cancel_button_sv);
|
||||
|
||||
profileNameEt.setFocusable(true);
|
||||
profileNameEt.setSelectAllOnFocus(true);
|
||||
|
@ -247,9 +260,16 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
|||
((EditProfileActivity) getActivity()).getSupportActionBar().setElevation(5.0f);
|
||||
}
|
||||
|
||||
profileIcon.setImageDrawable(app.getUIUtilities().getIcon(startIconId,
|
||||
isNightMode ? R.color.active_buttons_and_links_dark
|
||||
: R.color.active_buttons_and_links_light));
|
||||
int iconColor;
|
||||
if (!isUserProfile) {
|
||||
iconColor = R.color.icon_color;
|
||||
} else {
|
||||
iconColor = isNightMode
|
||||
? R.color.active_buttons_and_links_dark
|
||||
: R.color.active_buttons_and_links_light;
|
||||
}
|
||||
|
||||
profileIcon.setImageDrawable(app.getUIUtilities().getIcon(startIconId, iconColor));
|
||||
|
||||
profileTypeDialogListener = new ProfileTypeDialogListener() {
|
||||
@Override
|
||||
|
@ -336,7 +356,6 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
|||
.add(iconSelectDialog, "select_icon")
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -398,6 +417,15 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
});
|
||||
|
||||
cancelBtnSV.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (getActivity() != null) {
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
saveButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -407,11 +435,21 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
});
|
||||
|
||||
saveButtonSV.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (saveNewProfile()) {
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
int marginShow = 66;
|
||||
int marginHide = 2;
|
||||
|
||||
float d = getResources().getDisplayMetrics().density;
|
||||
Rect r = new Rect();
|
||||
view.getWindowVisibleDisplayFrame(r);
|
||||
|
@ -419,20 +457,35 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
|||
int keypadHeight = screenHeight - r.bottom;
|
||||
if (keypadHeight > screenHeight * 0.15) {
|
||||
buttonsLayout.setVisibility(View.GONE);
|
||||
buttonsLayoutSV.setVisibility(View.VISIBLE);
|
||||
setMargins(scrollContainer, 0, 0, 0, (int) (marginHide * d));
|
||||
} else {
|
||||
buttonsLayoutSV.setVisibility(View.GONE);
|
||||
buttonsLayout.setVisibility(View.VISIBLE);
|
||||
setMargins(scrollContainer, 0, 0, 0, (int) (marginShow * d));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
if (!isUserProfile && !isNew) {
|
||||
profileNameEt.setFocusable(false);
|
||||
navTypeEt.setFocusable(false);
|
||||
}
|
||||
|
||||
return view;
|
||||
if (isNew) {
|
||||
profileNameEt.requestFocus();
|
||||
} else {
|
||||
scrollContainer.requestFocus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void activateMode(ApplicationMode mode) {
|
||||
|
@ -573,23 +626,28 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
|||
|
||||
void onDeleteProfileClick() {
|
||||
if (getActivity() != null) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
|
||||
bld.setTitle("Delete Profile");
|
||||
bld.setMessage(String
|
||||
.format("Are you sure you want to delete %s profile", profile.userProfileTitle));
|
||||
bld.setPositiveButton(R.string.shared_string_delete,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ApplicationMode
|
||||
.deleteCustomMode(profile.getUserProfileTitle(), getMyApplication());
|
||||
if (getActivity() != null) {
|
||||
getActivity().onBackPressed();
|
||||
if (isUserProfile) {
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
|
||||
bld.setTitle("Delete Profile");
|
||||
bld.setMessage(String
|
||||
.format("Are you sure you want to delete %s profile", profile.userProfileTitle));
|
||||
bld.setPositiveButton(R.string.shared_string_delete,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ApplicationMode
|
||||
.deleteCustomMode(profile.getUserProfileTitle(), getMyApplication());
|
||||
if (getActivity() != null) {
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
bld.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||
bld.show();
|
||||
});
|
||||
bld.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||
bld.show();
|
||||
} else {
|
||||
Toast.makeText(getActivity(), "You cannot delete OsmAnd base profiles", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue