Icons color.
Prevent editing of base app profiles
This commit is contained in:
madwasp79 2019-05-07 13:19:06 +03:00
parent adc45b7783
commit 1bcd7f7bf6
5 changed files with 93 additions and 73 deletions

View file

@ -12,13 +12,12 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingStart="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding_small" android:paddingEnd="@dimen/content_padding_small"
android:paddingLeft="@dimen/content_padding" android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding_small" android:paddingRight="@dimen/content_padding_small"
android:paddingStart="@dimen/content_padding"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal">
>
<ImageView <ImageView
@ -27,17 +26,17 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_coordinates_latitude" tools:tint="?attr/primary_icon_color"
android:tint="?attr/primary_icon_color"/> tools:src="@drawable/ic_action_coordinates_latitude"/>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:layout_weight="1"
android:layout_marginEnd="@dimen/content_padding" android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding" android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1" android:gravity="center_vertical"
android:gravity="center_vertical"> android:orientation="vertical">
<TextView <TextView
@ -46,8 +45,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textColor="?attr/main_font_color_basic"
android:textAppearance="@style/TextAppearance.ListItemTitle" android:textAppearance="@style/TextAppearance.ListItemTitle"
android:textColor="?attr/main_font_color_basic"
tools:text="Item Title"/> tools:text="Item Title"/>
<TextView <TextView

View file

@ -24,9 +24,11 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/bg_color" android:background="?attr/bg_color"
android:orientation="vertical" android:orientation="vertical">
> <FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -89,6 +91,13 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<FrameLayout
android:id="@+id/click_block_layout"
android:clickable="false"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -81,6 +81,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
private View screenConfigBtn; private View screenConfigBtn;
private View navConfigBtn; private View navConfigBtn;
private LinearLayout buttonsLayout; private LinearLayout buttonsLayout;
private FrameLayout clickBlockLayout;
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
@ -117,6 +118,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
screenConfigBtn = view.findViewById(R.id.screen_config_btn); screenConfigBtn = view.findViewById(R.id.screen_config_btn);
navConfigBtn = view.findViewById(R.id.nav_settings_btn); navConfigBtn = view.findViewById(R.id.nav_settings_btn);
buttonsLayout = view.findViewById(R.id.buttons_layout); buttonsLayout = view.findViewById(R.id.buttons_layout);
clickBlockLayout = view.findViewById(R.id.click_block_layout);
profileNameEt.setFocusable(true); profileNameEt.setFocusable(true);
profileNameEt.setSelectAllOnFocus(true); profileNameEt.setSelectAllOnFocus(true);
@ -143,6 +145,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
title = profile.getUserProfileTitle(); title = profile.getUserProfileTitle();
profileNameEt.setText(title); profileNameEt.setText(title);
startIconId = profile.iconId; startIconId = profile.iconId;
} else if (isNew) { } else if (isNew) {
isDataChanged = true; isDataChanged = true;
title = String title = String
@ -155,6 +158,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
title = getResources().getString(profile.getKey()); title = getResources().getString(profile.getKey());
profileNameEt.setText(profile.getKey()); profileNameEt.setText(profile.getKey());
startIconId = profile.getIconId(); startIconId = profile.getIconId();
clickBlockLayout.setClickable(true);
} }
profile.setUserProfileTitle(title); profile.setUserProfileTitle(title);
@ -254,6 +258,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
selectNavTypeBtn.setOnClickListener(new View.OnClickListener() { selectNavTypeBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if(isNew || isUserProfile) {
final ProfileBottomSheetDialogFragment fragment = new ProfileBottomSheetDialogFragment(); final ProfileBottomSheetDialogFragment fragment = new ProfileBottomSheetDialogFragment();
fragment.setProfileTypeListener(profileTypeDialogListener); fragment.setProfileTypeListener(profileTypeDialogListener);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
@ -269,7 +274,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
navTypeEt.setTextIsSelectable(false); navTypeEt.setTextIsSelectable(false);
navTypeEt.clearFocus(); navTypeEt.clearFocus();
navTypeEt.requestFocus(ExtendedEditText.FOCUS_UP); navTypeEt.requestFocus(ExtendedEditText.FOCUS_UP);
}
} }
}); });
@ -348,10 +353,9 @@ public class EditProfileFragment extends BaseOsmAndFragment {
saveButton.setOnClickListener(new OnClickListener() { saveButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
saveNewProfile(); if (saveNewProfile()) {
// if (saveNewProfile()) { getActivity().onBackPressed();
// getActivity().onBackPressed(); }
// }
} }
}); });
@ -370,6 +374,11 @@ public class EditProfileFragment extends BaseOsmAndFragment {
} }
}); });
if (!isUserProfile && !isNew) {
profileNameEt.setFocusable(false);
navTypeEt.setFocusable(false);
}
return view; return view;
} }
@ -472,6 +481,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
if (getSettings() != null) { if (getSettings() != null) {
getSettings().AVAILABLE_APP_MODES.set(vls.toString()); getSettings().AVAILABLE_APP_MODES.set(vls.toString());
} }
isDataChanged = false;
return true; return true;
} }

View file

@ -60,10 +60,12 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
final ApplicationMode item = items.get(position); final ApplicationMode item = items.get(position);
if (item.getParent() != null) { if (item.getParent() != null) {
holder.title.setText(item.getUserProfileName()); holder.title.setText(item.getUserProfileName());
holder.descr.setText(String.format("Type: %s", Algorithms.capitalizeFirstLetterAndLowercase(item.getParent().getStringKey().replace("_", " ")))); holder.descr.setText(String.format("Type: %s",
Algorithms.capitalizeFirstLetterAndLowercase(item.getParent().getStringKey().replace("_", " "))));
} else { } else {
holder.title.setText(app.getResources().getString(item.getStringResource())); holder.title.setText(app.getResources().getString(item.getStringResource()));
holder.descr.setText(String.format("Base Profile, type: %s", Algorithms.capitalizeFirstLetterAndLowercase(item.getStringKey().replace("_", " ")))); holder.descr.setText(String.format("Base Profile, type: %s",
Algorithms.capitalizeFirstLetterAndLowercase(item.getStringKey().replace("_", " "))));
} }
holder.title.setTextColor(app.getResources().getColor(isNightMode(app) holder.title.setTextColor(app.getResources().getColor(isNightMode(app)
@ -80,16 +82,16 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
} }
}); });
if (item.getParent() != null) { // if (item.getParent() != null) {
holder.profileOptions.setOnClickListener(new OnClickListener() { holder.profileOptions.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
listener.editProfile(item); listener.editProfile(item);
} }
}); });
} else { // } else {
holder.profileOptions.setVisibility(View.INVISIBLE); // holder.profileOptions.setVisibility(View.INVISIBLE);
} // }
} }

View file

@ -86,7 +86,7 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
Intent intent = new Intent(getActivity(), EditProfileActivity.class); Intent intent = new Intent(getActivity(), EditProfileActivity.class);
intent.putExtra("stringKey", item.getStringKey()); intent.putExtra("stringKey", item.getStringKey());
intent.putExtra("isNew", false); intent.putExtra("isNew", false);
if (!item.getUserProfileName().isEmpty()) { if (item.getUserProfileName() != null && !item.getUserProfileName().isEmpty()) {
intent.putExtra("isUserProfile", true); intent.putExtra("isUserProfile", true);
} }
startActivity(intent); startActivity(intent);