complex button / import layouts
This commit is contained in:
parent
03dcb4facd
commit
a4d31c18d5
9 changed files with 406 additions and 306 deletions
|
@ -4,7 +4,6 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:minHeight="@dimen/dialog_button_ex_height">
|
android:minHeight="@dimen/dialog_button_ex_height">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -21,7 +20,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/content_padding_small"
|
android:layout_marginStart="@dimen/content_padding_small"
|
||||||
android:layout_marginLeft="@dimen/content_padding_small"
|
android:layout_marginLeft="@dimen/content_padding_small"
|
||||||
tools:src="@drawable/ic_action_explore" />
|
tools:src="@drawable/ic_action_keep_both" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -36,7 +35,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textColor="?android:textColorPrimary"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
tools:text="Main text" />
|
tools:text="Main text" />
|
||||||
|
@ -47,7 +45,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:textColor="?android:textColorSecondary"
|
|
||||||
android:textSize="@dimen/default_sub_text_size"
|
android:textSize="@dimen/default_sub_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
tools:text="Long subtext about two lines" />
|
tools:text="Long subtext about two lines" />
|
||||||
|
|
|
@ -62,29 +62,37 @@
|
||||||
android:id="@+id/buttons_container"
|
android:id="@+id/buttons_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dialog_button_ex_height"
|
android:layout_height="@dimen/dialog_button_ex_height"
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:background="?attr/bg_color"
|
android:background="?attr/bg_color"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingLeft="@dimen/content_padding"
|
android:paddingLeft="@dimen/content_padding"
|
||||||
android:paddingRight="@dimen/content_padding">
|
android:paddingTop="@dimen/content_padding_small"
|
||||||
|
android:paddingRight="@dimen/content_padding"
|
||||||
|
android:paddingBottom="@dimen/content_padding_small">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/select_all_button"
|
android:id="@+id/select_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/dlg_btn_stroked_dark"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:gravity="start"
|
android:ellipsize="end"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
android:paddingLeft="@dimen/content_padding_small"
|
android:paddingLeft="@dimen/content_padding_small"
|
||||||
|
android:paddingTop="@dimen/content_padding_half"
|
||||||
android:paddingRight="@dimen/content_padding_small"
|
android:paddingRight="@dimen/content_padding_small"
|
||||||
|
android:paddingBottom="@dimen/content_padding_half"
|
||||||
|
android:text="@string/shared_string_select_all"
|
||||||
|
android:textColor="?attr/active_color_basic"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
tools:text="Replace all" />
|
tools:text="Select all" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
@ -93,17 +101,24 @@
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1"
|
||||||
|
android:background="?attr/dlg_btn_primary">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/continue_button"
|
android:id="@+id/continue_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/dlg_btn_primary"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:gravity="end"
|
android:ellipsize="end"
|
||||||
|
android:gravity="end|center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
android:paddingLeft="@dimen/content_padding_small"
|
android:paddingLeft="@dimen/content_padding_small"
|
||||||
|
android:paddingTop="@dimen/content_padding_half"
|
||||||
android:paddingRight="@dimen/content_padding_small"
|
android:paddingRight="@dimen/content_padding_small"
|
||||||
|
android:paddingBottom="@dimen/content_padding_half"
|
||||||
|
android:text="@string/shared_string_continue"
|
||||||
|
android:textColor="?attr/dlg_btn_primary_text"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
tools:text="Continue" />
|
tools:text="Continue" />
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/activity_background_basic"
|
android:background="?attr/activity_background_basic"
|
||||||
|
@ -62,19 +61,42 @@
|
||||||
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"
|
||||||
android:padding="16dp">
|
android:padding="@dimen/content_padding">
|
||||||
|
|
||||||
<include
|
<FrameLayout
|
||||||
android:id="@+id/keep_both"
|
|
||||||
layout="@layout/button_with_icon_and_subtext" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/content_padding_small" />
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/content_padding_half"
|
||||||
|
android:background="?attr/dlg_btn_secondary">
|
||||||
|
|
||||||
<include
|
<net.osmand.view.ComplexButton
|
||||||
android:id="@+id/replace_all"
|
android:id="@+id/keep_both_btn"
|
||||||
layout="@layout/button_with_icon_and_subtext" />
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
osmand:setSubText="@string/keep_both_desc"
|
||||||
|
osmand:setSubTextColor="?android:textColorSecondary"
|
||||||
|
osmand:setText="@string/keep_both"
|
||||||
|
osmand:setTextColor="?attr/active_color_basic" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/dlg_btn_primary">
|
||||||
|
|
||||||
|
<net.osmand.view.ComplexButton
|
||||||
|
android:id="@+id/replace_all_btn"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
osmand:setSubText="@string/replace_all_desc"
|
||||||
|
osmand:setSubTextColor="?android:textColorTertiaryInverse"
|
||||||
|
osmand:setText="@string/replace_all"
|
||||||
|
osmand:setTextColor="?attr/dlg_btn_primary_text" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,15 @@
|
||||||
<attr name="typeface" format="string|reference"/>
|
<attr name="typeface" format="string|reference"/>
|
||||||
<attr name="textAllCapsCompat" format="reference|boolean" />
|
<attr name="textAllCapsCompat" format="reference|boolean" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
|
<declare-styleable name="ComplexButton">
|
||||||
|
<attr name="setText" format="string" />
|
||||||
|
<attr name="setTextColor" format="color" />
|
||||||
|
<attr name="setSubText" format="string" />
|
||||||
|
<attr name="setSubTextColor" format="color" />
|
||||||
|
<attr name="setIcon" format="reference" />
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
<!--<declare-styleable name="ButtonEx" parent="TextViewEx" />
|
<!--<declare-styleable name="ButtonEx" parent="TextViewEx" />
|
||||||
<declare-styleable name="SwitchEx" parent="ButtonEx" />-->
|
<declare-styleable name="SwitchEx" parent="ButtonEx" />-->
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -11,6 +11,13 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="replace_all_desc">Current items will be replaced with items from the file</string>
|
||||||
|
<string name="replace_all">Replace all</string>
|
||||||
|
<string name="keep_both">Keep both</string>
|
||||||
|
<string name="keep_both_desc">Imported items will be added with prexif</string>
|
||||||
|
<string name="import_duplicates_description">OsmAnd already has elements with the same names as those imported.\n\nSelect an action.</string>
|
||||||
|
<string name="import_duplicates_title">Some items already exist</string>
|
||||||
|
<string name="select_data_to_import">Select the data to be imported.</string>
|
||||||
<string name="routing_profile_direct_to">Direct-to-point</string>
|
<string name="routing_profile_direct_to">Direct-to-point</string>
|
||||||
<string name="clear_recorded_data">Clear recorded data</string>
|
<string name="clear_recorded_data">Clear recorded data</string>
|
||||||
<string name="release_3_6">
|
<string name="release_3_6">
|
||||||
|
@ -27,9 +34,6 @@
|
||||||
• Added correct transliteration into the map of Japan\n\n
|
• Added correct transliteration into the map of Japan\n\n
|
||||||
• Added Antarctica map\n\n
|
• Added Antarctica map\n\n
|
||||||
</string>
|
</string>
|
||||||
<string name="import_duplicates_description">OsmAnd already has elements with the same names as those imported.\n\nSelect an action.</string>
|
|
||||||
<string name="import_duplicates_title">Some items already exist</string>
|
|
||||||
<string name="select_data_to_import">Select the data to be imported.</string>
|
|
||||||
<string name="copy_coordinates">Copy coordinates</string>
|
<string name="copy_coordinates">Copy coordinates</string>
|
||||||
<string name="reset_to_default_category_button_promo">Reset to default will reset sort order to the default state after installation.</string>
|
<string name="reset_to_default_category_button_promo">Reset to default will reset sort order to the default state after installation.</string>
|
||||||
<string name="use_system_screen_timeout">Use system screen timeout</string>
|
<string name="use_system_screen_timeout">Use system screen timeout</string>
|
||||||
|
|
|
@ -50,6 +50,8 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||||
|
import net.osmand.plus.settings.ImportDuplicatesFragment;
|
||||||
|
import net.osmand.plus.settings.ImportSettingsFragment;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.router.RoutingConfiguration;
|
import net.osmand.router.RoutingConfiguration;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
|
@ -4,21 +4,25 @@ import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.SettingsHelper.SettingsItem;
|
||||||
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
||||||
|
import net.osmand.view.ComplexButton;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment {
|
public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment implements View.OnClickListener {
|
||||||
|
|
||||||
public static final String TAG = ImportSettingsFragment.class.getSimpleName();
|
public static final String TAG = ImportSettingsFragment.class.getSimpleName();
|
||||||
|
|
||||||
private FrameLayout replaceAllBtn;
|
private RecyclerView list;
|
||||||
|
|
||||||
public static void showInstance(@NonNull FragmentManager fm) {
|
public static void showInstance(@NonNull FragmentManager fm) {
|
||||||
ImportDuplicatesFragment fragment = new ImportDuplicatesFragment();
|
ImportDuplicatesFragment fragment = new ImportDuplicatesFragment();
|
||||||
|
@ -30,10 +34,48 @@ public class ImportDuplicatesFragment extends BaseOsmAndDialogFragment {
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
View root = inflater.inflate(R.layout.fragment_import_duplicates, container, false);
|
View root = inflater.inflate(R.layout.fragment_import_duplicates, container, false);
|
||||||
setupToolbar((Toolbar) root.findViewById(R.id.toolbar));
|
setupToolbar((Toolbar) root.findViewById(R.id.toolbar));
|
||||||
replaceAllBtn = root.findViewById(R.id.replace_all);
|
ComplexButton replaceAllBtn = root.findViewById(R.id.replace_all_btn);
|
||||||
|
ComplexButton keepBothBtn = root.findViewById(R.id.keep_both_btn);
|
||||||
|
keepBothBtn.setIcon(getPaintedContentIcon(R.drawable.ic_action_keep_both,
|
||||||
|
getSettings().isLightContent()
|
||||||
|
? getResources().getColor(R.color.icon_color_active_light)
|
||||||
|
: getResources().getColor(R.color.icon_color_active_dark))
|
||||||
|
);
|
||||||
|
replaceAllBtn.setIcon(getPaintedContentIcon(R.drawable.ic_action_replace,
|
||||||
|
getSettings().isLightContent()
|
||||||
|
? getResources().getColor(R.color.active_buttons_and_links_text_light)
|
||||||
|
: getResources().getColor(R.color.active_buttons_and_links_text_dark))
|
||||||
|
);
|
||||||
|
keepBothBtn.setOnClickListener(this);
|
||||||
|
replaceAllBtn.setOnClickListener(this);
|
||||||
|
list = root.findViewById(R.id.list);
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
switch (view.getId()) {
|
||||||
|
case R.id.keep_both_btn: {
|
||||||
|
keepBothItems();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case R.id.replace_all_btn: {
|
||||||
|
replaceAllItems();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void keepBothItems() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void replaceAllItems() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void importItems(List<SettingsItem> list) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,87 +1 @@
|
||||||
package net.osmand.plus.settings;
|
package net.osmand.plus.settings;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnGroupClickListener;
import android.widget.ExpandableListView.OnChildClickListener;
import net.osmand.plus.R;
import net.osmand.plus.SettingsHelper.SettingsItem;
import net.osmand.plus.base.BaseOsmAndDialogFragment;
import net.osmand.plus.widgets.TextViewEx;
import java.util.List;
public class ImportSettingsFragment extends BaseOsmAndDialogFragment
implements OnChildClickListener, OnGroupClickListener, View.OnClickListener {
public static final String TAG = ImportSettingsFragment.class.getSimpleName();
private boolean allSelected;
private ExpandableListView listView;
private TextViewEx selectBtn;
private TextViewEx continueBtn;
private List<SettingsItem> settingsItems;
public static void showInstance(@NonNull FragmentManager fm, @NonNull List<SettingsItem> settingsItems) {
ImportSettingsFragment fragment = new ImportSettingsFragment();
fragment.setSettingsItems(settingsItems);
fragment.show(fm, TAG);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_import, container, false);
setupToolbar((Toolbar) root.findViewById(R.id.toolbar));
continueBtn = root.findViewById(R.id.continue_button);
selectBtn = root.findViewById(R.id.select_button);
listView = root.findViewById(android.R.id.list);
continueBtn.setOnClickListener(this);
selectBtn.setOnClickListener(this);
return root;
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.select_button: {
allSelected = !allSelected;
selectBtn.setText(allSelected ? R.string.shared_string_deselect_all : R.string.shared_string_select_all);
selectDeselectAll();
break;
}
case R.id.continue_button: {
importItems();
break;
}
}
}
private void selectDeselectAll() {
if (allSelected) {
} else {
}
}
private void importItems() {
}
private boolean checkDuplicates() {
return false;
}
@Override
public boolean onChildClick(ExpandableListView expandableListView, View view, int i, int i1, long l) {
return false;
}
@Override
public boolean onGroupClick(ExpandableListView expandableListView, View view, int i, long l) {
return false;
}
public void setSettingsItems(List<SettingsItem> settingsItems) {
this.settingsItems = settingsItems;
}
private void setupToolbar(Toolbar toolbar) {
toolbar.setNavigationIcon(getPaintedContentIcon(R.drawable.headline_close_button,
getSettings().isLightContent()
? getResources().getColor(R.color.active_buttons_and_links_text_light)
: getResources().getColor(R.color.active_buttons_and_links_text_dark)));
toolbar.setNavigationContentDescription(R.string.shared_string_close);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
}
}
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ExpandableListView;
|
|
||||||
import android.widget.ExpandableListView.OnGroupClickListener;
|
|
||||||
import android.widget.ExpandableListView.OnChildClickListener;
|
|
||||||
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.SettingsHelper.SettingsItem;
|
|
||||||
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ImportSettingsFragment extends BaseOsmAndDialogFragment
|
|
||||||
implements OnChildClickListener, OnGroupClickListener, View.OnClickListener {
|
|
||||||
|
|
||||||
public static final String TAG = ImportSettingsFragment.class.getSimpleName();
|
|
||||||
|
|
||||||
private ExpandableListView listView;
|
|
||||||
|
|
||||||
private Button selectAllBtn;
|
|
||||||
|
|
||||||
private Button continueBtn;
|
|
||||||
|
|
||||||
private List<SettingsItem> settingsItems;
|
|
||||||
|
|
||||||
public static void showInstance(@NonNull FragmentManager fm, @NonNull List<SettingsItem> settingsItems) {
|
|
||||||
ImportSettingsFragment fragment = new ImportSettingsFragment();
|
|
||||||
fragment.setSettingsItems(settingsItems);
|
|
||||||
fragment.show(fm, TAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
||||||
View root = inflater.inflate(R.layout.fragment_import, container, false);
|
|
||||||
setupToolbar((Toolbar) root.findViewById(R.id.toolbar));
|
|
||||||
listView = root.findViewById(android.R.id.list);
|
|
||||||
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onChildClick(ExpandableListView expandableListView, View view, int i, int i1, long l) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onGroupClick(ExpandableListView expandableListView, View view, int i, long l) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSettingsItems(List<SettingsItem> settingsItems) {
|
|
||||||
this.settingsItems = settingsItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupToolbar(Toolbar toolbar) {
|
|
||||||
toolbar.setNavigationIcon(getPaintedContentIcon(R.drawable.headline_close_button,
|
|
||||||
getSettings().isLightContent()
|
|
||||||
? getResources().getColor(R.color.active_buttons_and_links_text_light)
|
|
||||||
: getResources().getColor(R.color.active_buttons_and_links_text_dark)));
|
|
||||||
toolbar.setNavigationContentDescription(R.string.shared_string_close);
|
|
||||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isNightMode() {
|
|
||||||
return getSettings().isLightContent();
|
|
||||||
}
|
|
||||||
}
|
|
95
OsmAnd/src/net/osmand/view/ComplexButton.java
Normal file
95
OsmAnd/src/net/osmand/view/ComplexButton.java
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
package net.osmand.view;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
|
|
||||||
|
public class ComplexButton extends FrameLayout {
|
||||||
|
|
||||||
|
private TextViewEx textTv;
|
||||||
|
private TextViewEx subTextTv;
|
||||||
|
private ImageView iconIv;
|
||||||
|
|
||||||
|
public ComplexButton(@NonNull Context context) {
|
||||||
|
super(context);
|
||||||
|
inflateView();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComplexButton(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
inflateView();
|
||||||
|
initView(attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComplexButton(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
inflateView();
|
||||||
|
initView(attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void inflateView() {
|
||||||
|
View view = LayoutInflater.from(getContext()).inflate(R.layout.button_with_icon_and_subtext, this);
|
||||||
|
textTv = view.findViewById(R.id.text);
|
||||||
|
subTextTv = view.findViewById(R.id.sub_text);
|
||||||
|
iconIv = view.findViewById(R.id.icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView(@Nullable AttributeSet attrs) {
|
||||||
|
TypedArray a = getContext().getTheme().obtainStyledAttributes(
|
||||||
|
attrs,
|
||||||
|
R.styleable.ComplexButton,
|
||||||
|
0, 0);
|
||||||
|
try {
|
||||||
|
textTv.setText(a.getString(R.styleable.ComplexButton_setText));
|
||||||
|
textTv.setTextColor(a.getColor(R.styleable.ComplexButton_setTextColor, Color.WHITE));
|
||||||
|
subTextTv.setText(a.getString(R.styleable.ComplexButton_setSubText));
|
||||||
|
subTextTv.setTextColor(a.getColor(R.styleable.ComplexButton_setSubTextColor, Color.WHITE));
|
||||||
|
iconIv.setImageResource(a.getResourceId(R.styleable.ComplexButton_setIcon, 0));
|
||||||
|
} finally {
|
||||||
|
a.recycle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
textTv.setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(int textRes) {
|
||||||
|
textTv.setText(textRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextColor(int color) {
|
||||||
|
textTv.setTextColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubText(String subText) {
|
||||||
|
subTextTv.setText(subText);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubText(int subTextRes) {
|
||||||
|
subTextTv.setText(subTextRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubTextColor(int color) {
|
||||||
|
subTextTv.setTextColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIcon(int iconRes) {
|
||||||
|
iconIv.setImageResource(iconRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIcon(Drawable drawable) {
|
||||||
|
iconIv.setImageDrawable(drawable);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue