complex button / import layouts

This commit is contained in:
veliymolfar 2020-02-12 18:54:25 +02:00
parent 03dcb4facd
commit a4d31c18d5
9 changed files with 406 additions and 306 deletions

View file

@ -1,59 +1,56 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout 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" 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
android:id="@+id/button_container" android:id="@+id/button_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:id="@+id/icon" android:id="@+id/icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
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"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/content_padding_small" android:layout_margin="@dimen/content_padding_small"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/text" android:id="@+id/text"
android:layout_width="match_parent" android:layout_width="match_parent"
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" />
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/sub_text" android:id="@+id/sub_text"
android:layout_width="match_parent" android:layout_width="match_parent"
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" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>

View file

@ -1,115 +1,130 @@
<?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" 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"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
android:orientation="vertical"> android:orientation="vertical">
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height" android:layout_height="@dimen/toolbar_height"
android:minHeight="@dimen/toolbar_height" /> android:minHeight="@dimen/toolbar_height" />
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/title" android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="@dimen/content_padding" android:paddingStart="@dimen/content_padding"
android:paddingTop="@dimen/list_header_settings_top_margin" android:paddingTop="@dimen/list_header_settings_top_margin"
android:paddingEnd="@dimen/content_padding" android:paddingEnd="@dimen/content_padding"
android:paddingBottom="@dimen/list_header_settings_top_margin" android:paddingBottom="@dimen/list_header_settings_top_margin"
android:text="@string/shared_string_import" android:text="@string/shared_string_import"
android:textColor="?attr/app_bar_primary_item_color" android:textColor="?attr/app_bar_primary_item_color"
android:textSize="@dimen/dialog_header_text_size" android:textSize="@dimen/dialog_header_text_size"
osmand:typeface="@string/font_roboto_medium" /> osmand:typeface="@string/font_roboto_medium" />
</LinearLayout> </LinearLayout>
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/description" android:id="@+id/description"
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:paddingStart="@dimen/content_padding" android:paddingStart="@dimen/content_padding"
android:paddingTop="@dimen/list_header_settings_top_margin" android:paddingTop="@dimen/list_header_settings_top_margin"
android:paddingEnd="@dimen/content_padding" android:paddingEnd="@dimen/content_padding"
android:paddingBottom="@dimen/list_header_settings_top_margin" android:paddingBottom="@dimen/list_header_settings_top_margin"
android:text="@string/select_data_to_import" android:text="@string/select_data_to_import"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" /> osmand:typeface="@string/font_roboto_medium" />
<include layout="@layout/list_item_divider" /> <include layout="@layout/list_item_divider" />
<ExpandableListView <ExpandableListView
android:id="@android:id/list" android:id="@android:id/list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:background="?attr/expandable_list_background" android:background="?attr/expandable_list_background"
android:groupIndicator="@android:color/transparent" /> android:groupIndicator="@android:color/transparent" />
<LinearLayout <LinearLayout
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:paddingTop="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding"> 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:paddingLeft="@dimen/content_padding_small" android:gravity="start|center_vertical"
android:paddingRight="@dimen/content_padding_small" android:maxLines="1"
android:textSize="@dimen/default_desc_text_size" android:paddingLeft="@dimen/content_padding_small"
osmand:typeface="@string/font_roboto_medium" android:paddingTop="@dimen/content_padding_half"
tools:text="Replace all" /> android:paddingRight="@dimen/content_padding_small"
</FrameLayout> 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"
osmand:typeface="@string/font_roboto_medium"
tools:text="Select all" />
<View </FrameLayout>
android:layout_width="@dimen/content_padding"
android:layout_height="match_parent" />
<FrameLayout <View
android:layout_width="0dp" android:layout_width="@dimen/content_padding"
android:layout_height="wrap_content" android:layout_height="match_parent" />
android:layout_weight="1">
<net.osmand.plus.widgets.TextViewEx <FrameLayout
android:id="@+id/continue_button" android:layout_width="0dp"
android:layout_width="match_parent" android:layout_height="match_parent"
android:layout_height="match_parent" android:layout_weight="1"
android:background="?attr/dlg_btn_primary" android:background="?attr/dlg_btn_primary">
android:gravity="end"
android:paddingLeft="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding_small"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Continue" />
</FrameLayout> <net.osmand.plus.widgets.TextViewEx
android:id="@+id/continue_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:ellipsize="end"
android:gravity="end|center_vertical"
android:maxLines="1"
android:paddingLeft="@dimen/content_padding_small"
android:paddingTop="@dimen/content_padding_half"
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"
osmand:typeface="@string/font_roboto_medium"
tools:text="Continue" />
</LinearLayout> </FrameLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -1,81 +1,103 @@
<?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" android:orientation="vertical">
android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
android:orientation="vertical"> android:orientation="vertical">
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height" android:layout_height="@dimen/toolbar_height"
android:minHeight="@dimen/toolbar_height" /> android:minHeight="@dimen/toolbar_height" />
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/title" android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="@dimen/content_padding" android:paddingStart="@dimen/content_padding"
android:paddingTop="@dimen/list_header_settings_top_margin" android:paddingTop="@dimen/list_header_settings_top_margin"
android:paddingEnd="@dimen/content_padding" android:paddingEnd="@dimen/content_padding"
android:paddingBottom="@dimen/list_header_settings_top_margin" android:paddingBottom="@dimen/list_header_settings_top_margin"
android:text="@string/import_duplicates_title" android:text="@string/import_duplicates_title"
android:textColor="?attr/app_bar_primary_item_color" android:textColor="?attr/app_bar_primary_item_color"
android:textSize="@dimen/dialog_header_text_size" android:textSize="@dimen/dialog_header_text_size"
osmand:typeface="@string/font_roboto_medium" /> osmand:typeface="@string/font_roboto_medium" />
</LinearLayout> </LinearLayout>
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/description" android:id="@+id/description"
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:paddingStart="@dimen/content_padding" android:paddingStart="@dimen/content_padding"
android:paddingTop="@dimen/list_header_settings_top_margin" android:paddingTop="@dimen/list_header_settings_top_margin"
android:paddingEnd="@dimen/content_padding" android:paddingEnd="@dimen/content_padding"
android:paddingBottom="@dimen/list_header_settings_top_margin" android:paddingBottom="@dimen/list_header_settings_top_margin"
android:text="@string/import_duplicates_description" android:text="@string/import_duplicates_description"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" /> osmand:typeface="@string/font_roboto_medium" />
<include layout="@layout/list_item_divider" /> <include layout="@layout/list_item_divider" />
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@android:id/list" android:id="@android:id/list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:background="?attr/list_background_color" /> android:background="?attr/list_background_color" />
<LinearLayout <LinearLayout
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"
android:padding="16dp"> android:padding="@dimen/content_padding">
<include <FrameLayout
android:id="@+id/keep_both" android:layout_width="match_parent"
layout="@layout/button_with_icon_and_subtext" /> android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/content_padding_half"
android:background="?attr/dlg_btn_secondary">
<View <net.osmand.view.ComplexButton
android:layout_width="match_parent" android:id="@+id/keep_both_btn"
android:layout_height="@dimen/content_padding_small" /> 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" />
<include </FrameLayout>
android:id="@+id/replace_all"
layout="@layout/button_with_icon_and_subtext" />
</LinearLayout> <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> </LinearLayout>

View file

@ -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="ButtonEx" parent="TextViewEx" />
<declare-styleable name="SwitchEx" parent="ButtonEx" />--> <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="SwitchEx" parent="ButtonEx" />-->
</resources> </resources>

View file

@ -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>

View file

@ -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;

View file

@ -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) {
} }

View file

@ -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();
}
}

View 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);
}
}