diff --git a/OsmAnd/res/drawable/fab_extended_blue_idle.xml b/OsmAnd/res/drawable/fab_extended_blue_idle.xml deleted file mode 100644 index 38d7efd49e..0000000000 --- a/OsmAnd/res/drawable/fab_extended_blue_idle.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/OsmAnd/res/drawable/fab_extended_blue_pressed.xml b/OsmAnd/res/drawable/fab_extended_blue_pressed.xml deleted file mode 100644 index fecb5efccc..0000000000 --- a/OsmAnd/res/drawable/fab_extended_blue_pressed.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/OsmAnd/res/drawable/fab_extended_drawable.xml b/OsmAnd/res/drawable/fab_extended_drawable.xml index 9d90401dba..b4e52993b4 100644 --- a/OsmAnd/res/drawable/fab_extended_drawable.xml +++ b/OsmAnd/res/drawable/fab_extended_drawable.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/OsmAnd/res/layout/activity_profile_settings.xml b/OsmAnd/res/layout/activity_profile_settings.xml deleted file mode 100644 index 0e850d0149..0000000000 --- a/OsmAnd/res/layout/activity_profile_settings.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/layout/profile_list_item.xml b/OsmAnd/res/layout/profile_list_item.xml index d193c7b16c..b6da74edbb 100644 --- a/OsmAnd/res/layout/profile_list_item.xml +++ b/OsmAnd/res/layout/profile_list_item.xml @@ -32,7 +32,7 @@ android:layout_height="match_parent" android:gravity="center" android:orientation="vertical" - android:layout_weight="4"> + android:layout_weight="5"> - + android:orientation="horizontal" + android:gravity="center_vertical"> + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/profiles/ProfileMenuAdapter.java b/OsmAnd/src/net/osmand/plus/profiles/ProfileMenuAdapter.java index 9a1a3c5705..6c188b2c24 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/ProfileMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/profiles/ProfileMenuAdapter.java @@ -14,7 +14,8 @@ import java.util.List; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.profiles.ProfileMenuAdapter.ProfileViewHolder; -import net.osmand.plus.profiles.SettingsProfileActivity.ProfileItem; +import net.osmand.plus.profiles.SettingsProfileFragment.ProfileItem; + public class ProfileMenuAdapter extends RecyclerView.Adapter { @@ -47,10 +48,12 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter public void onBindViewHolder(@NonNull ProfileViewHolder holder, int position) { ProfileItem item = items.get(position); holder.title.setText(item.getTitle()); - holder.descr.setText(item.getDescr()); + holder.title.setTextColor(app.getResources().getColor(isNightMode(app) ? R.color.main_font_dark : R.color.main_font_light)); + holder.descr.setText(String.format("Type: %s", item.getDescr())); Drawable drawable = app.getUIUtilities().getThemedIcon(item.getIconRes()); holder.icon.setImageDrawable(drawable); - holder.aSwitch.setChecked(item.getState()); + holder.icon.setImageDrawable(app.getUIUtilities().getIcon(item.getIconRes(), isNightMode(app) ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light)); + holder.aSwitch.setChecked(item.isSelected()); holder.aSwitch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -70,6 +73,10 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter return items.size(); } + private static boolean isNightMode(OsmandApplication ctx) { + return !ctx.getSettings().isLightContent(); + } + class ProfileViewHolder extends RecyclerView.ViewHolder { TextView title, descr; SwitchCompat aSwitch; diff --git a/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileActivity.java b/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileActivity.java index 0ed2c31532..4417572672 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileActivity.java +++ b/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileActivity.java @@ -42,49 +42,5 @@ public class SettingsProfileActivity extends OsmandActionBarActivity { super.onResume(); } - public class ProfileItem { - private int iconRes; - private String title; - private String descr; - private boolean state; - public ProfileItem(int iconRes, String title, String descr, boolean state) { - this.iconRes = iconRes; - this.title = title; - this.descr = descr; - this.state = state; - } - - public int getIconRes() { - return iconRes; - } - - public void setIconRes(int iconRes) { - this.iconRes = iconRes; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescr() { - return descr; - } - - public void setDescr(String descr) { - this.descr = descr; - } - - public boolean getState() { - return state; - } - - public void setState(boolean state) { - this.state = state; - } - } } diff --git a/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java b/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java index 65f8dbfe8c..949bb03ab4 100644 --- a/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java +++ b/OsmAnd/src/net/osmand/plus/profiles/SettingsProfileFragment.java @@ -3,13 +3,17 @@ package net.osmand.plus.profiles; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.support.v7.widget.AppCompatButton; +import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.widget.LinearLayout; +import java.util.ArrayList; +import java.util.List; import net.osmand.PlatformUtil; +import net.osmand.plus.ApplicationMode; import net.osmand.plus.R; import net.osmand.plus.base.BaseOsmAndFragment; import org.apache.commons.logging.Log; @@ -20,14 +24,40 @@ public class SettingsProfileFragment extends BaseOsmAndFragment { private ProfileMenuAdapter adapter; private RecyclerView recyclerView; - private AppCompatButton btn; + private LinearLayout btn; + + private List allDefaultModes; + private List selectedDefaultModes; + private List profilesList; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + profilesList = new ArrayList<>(); + allDefaultModes = ApplicationMode.allPossibleValues(); + allDefaultModes.remove(ApplicationMode.DEFAULT); + selectedDefaultModes = new ArrayList<>(ApplicationMode.values(getMyApplication())); + selectedDefaultModes.remove(ApplicationMode.DEFAULT); + for (ApplicationMode am : allDefaultModes) { + ProfileItem profileItem = new ProfileItem( + am.getSmallIconDark(), + am.toHumanStringCtx(getMyApplication().getApplicationContext()), + am.toHumanStringCtx(getMyApplication().getApplicationContext()), + true); + if (selectedDefaultModes.contains(am)) { + profileItem.setSelected(true); + } + profilesList.add(profileItem); + } + + + } @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.profiles_list_fragment, container, false); - recyclerView = view.findViewById(R.id.profiles_list); btn = view.findViewById(R.id.add_profile_btn); btn.setOnClickListener(new OnClickListener() { @@ -36,7 +66,66 @@ public class SettingsProfileFragment extends BaseOsmAndFragment { //todo add new profile; } }); + adapter = new ProfileMenuAdapter(profilesList, getMyApplication()); + recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + recyclerView.setAdapter(adapter); + return view; } + + public class ProfileItem { + private int iconRes; + private String title; + private String descr; + private boolean isSelected; + private boolean isAppDefault; + + public ProfileItem(int iconRes, String title, String descr, boolean isAppDefault) { + this.iconRes = iconRes; + this.title = title; + this.descr = descr; + this.isAppDefault = isAppDefault; + } + + public int getIconRes() { + return iconRes; + } + + public void setIconRes(int iconRes) { + this.iconRes = iconRes; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescr() { + return descr; + } + + public void setDescr(String descr) { + this.descr = descr; + } + + public boolean isSelected() { + return isSelected; + } + + public void setSelected(boolean isSelected) { + this.isSelected = isSelected; + } + + public boolean isAppDefault() { + return isAppDefault; + } + + public void setAppDefault(boolean appDefault) { + isAppDefault = appDefault; + } + } } diff --git a/README.md b/README.md index 903f32387d..8dd1a35992 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Functionality * Add POIs and directly upload them to OSM (or later if offline) * Optional trip recording also in background mode (while device is in sleep mode) -OsmAnd is open source and actively being developed. Everyone can contribute to the application by reporting bugs, [improving translations](https://hosted.weblate.org/projects/osmand/), or coding new features. The project is in a lively state of continuous improvement by all these forms of developer and user interaction. The project progress also relies on financial contributions to fund the development, coding, and testing of new functionality. By buying OsmAnd+ and subscribing to OsmAnd Live you help the application to be even more awesome! It is also possible to make a general donation, see http://osmand.net/help-online#buy_app. +OsmAnd is open source and actively being developed. Everyone can contribute to the application by reporting bugs, [improving translations](https://hosted.weblate.org/projects/osmand/), or coding new features. The project is in a lively selected of continuous improvement by all these forms of developer and user interaction. The project progress also relies on financial contributions to fund the development, coding, and testing of new functionality. By buying OsmAnd+ and subscribing to OsmAnd Live you help the application to be even more awesome! It is also possible to make a general donation, see http://osmand.net/help-online#buy_app. #### Approximate map coverage and quality: