add colors and refactored some code
This commit is contained in:
parent
d63198e2d5
commit
431c2aee23
6 changed files with 45 additions and 39 deletions
|
@ -71,12 +71,12 @@
|
|||
android:id="@+id/bottom_row_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
android:background="?attr/wikivoyage_bottom_bar_divider_color" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/wikivoyage_bg_color"
|
||||
android:background="?attr/wikivoyage_bottom_bar_color"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
|
@ -107,7 +107,7 @@
|
|||
android:id="@+id/bottom_buttons_divider"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/dashboard_divider"
|
||||
android:background="?attr/wikivoyage_bottom_bar_divider_color"
|
||||
android:visibility="visible" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
|
|
|
@ -69,6 +69,8 @@
|
|||
<attr name="wikivoyage_card_bg_color" format="reference"/>
|
||||
<attr name="wikivoyage_card_divider_color" format="reference"/>
|
||||
<attr name="wikivoyage_app_bar_color" format="reference"/>
|
||||
<attr name="wikivoyage_bottom_bar_color" format="reference"/>
|
||||
<attr name="wikivoyage_bottom_bar_divider_color" format="reference"/>
|
||||
<attr name="wikivoyage_app_bar_text_color" format="reference"/>
|
||||
<attr name="wikivoyage_active_color" format="reference"/>
|
||||
</declare-styleable>
|
||||
|
|
|
@ -146,7 +146,7 @@
|
|||
<color name="status_bar_wikivoyage_dark">#101112</color>
|
||||
<color name="status_bar_wikivoyage_article_light">#f2f2f2</color>
|
||||
<color name="status_bar_wikivoyage_article_dark">#222526</color>
|
||||
<color name="bottom_bar_wikivoyage_article_light">#f5f5f5</color>
|
||||
<color name="bottom_bar_wikivoyage_light">#f5f5f5</color>
|
||||
|
||||
|
||||
<color name="color_transparent">#0000</color>
|
||||
|
@ -394,7 +394,9 @@
|
|||
<color name="wikivoyage_card_bg_light">#ffffff</color>
|
||||
<color name="wikivoyage_card_bg_dark">#222526</color>
|
||||
<color name="wikivoyage_card_divider_light">#f0f0f0</color>
|
||||
<color name="wikivoyage_bottom_bar_divider_light">#e3e3e3</color>
|
||||
<color name="wikivoyage_card_divider_dark">#2d3133</color>
|
||||
<color name="wikivoyage_bottom_bar_divider_dark">#2d3133</color>
|
||||
<color name="wikivoyage_active_light">#237bff</color>
|
||||
<color name="wikivoyage_active_dark">#d28521</color>
|
||||
<color name="wikivoyage_app_bar_light">#f2f2f2</color>
|
||||
|
|
|
@ -201,6 +201,8 @@
|
|||
<item name="wikivoyage_card_bg_color">@color/wikivoyage_card_bg_light</item>
|
||||
<item name="wikivoyage_card_divider_color">@color/wikivoyage_card_divider_light</item>
|
||||
<item name="wikivoyage_app_bar_color">@color/wikivoyage_app_bar_light</item>
|
||||
<item name="wikivoyage_bottom_bar_color">@color/bottom_bar_wikivoyage_light</item>
|
||||
<item name="wikivoyage_bottom_bar_divider_color">@color/wikivoyage_bottom_bar_divider_light</item>
|
||||
<item name="wikivoyage_app_bar_text_color">@color/wikivoyage_app_bar_text_light</item>
|
||||
<item name="wikivoyage_active_color">@color/wikivoyage_active_light</item>
|
||||
</style>
|
||||
|
@ -392,6 +394,8 @@
|
|||
<item name="wikivoyage_card_bg_color">@color/wikivoyage_card_bg_dark</item>
|
||||
<item name="wikivoyage_card_divider_color">@color/wikivoyage_card_divider_dark</item>
|
||||
<item name="wikivoyage_app_bar_color">@color/wikivoyage_app_bar_dark</item>
|
||||
<item name="wikivoyage_bottom_bar_color">@color/status_bar_wikivoyage_article_dark</item>
|
||||
<item name="wikivoyage_bottom_bar_divider_color">@color/wikivoyage_bottom_bar_divider_dark</item>
|
||||
<item name="wikivoyage_app_bar_text_color">@color/wikivoyage_app_bar_text_dark</item>
|
||||
<item name="wikivoyage_active_color">@color/wikivoyage_active_dark</item>
|
||||
</style>
|
||||
|
|
|
@ -24,9 +24,9 @@ import net.osmand.IndexConstants;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.widgets.TextViewEx;
|
||||
import net.osmand.plus.wikivoyage.data.WikivoyageArticle;
|
||||
import net.osmand.plus.wikivoyage.data.WikivoyageArticleContentsFragment;
|
||||
import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.plus.wikivoyage.data.WikivoyageArticleContentsBottomSheetDialogFragment;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -90,32 +90,26 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
}
|
||||
});
|
||||
|
||||
final View buttonBar = mainView.findViewById(R.id.bottom_bar);
|
||||
|
||||
buttonBar.setBackgroundColor(getResolvedColor(nightMode ? R.color.status_bar_wikivoyage_article_dark : R.color.bottom_bar_wikivoyage_article_light));
|
||||
|
||||
TextViewEx contentsButton = (TextViewEx) mainView.findViewById(R.id.contents_button);
|
||||
TextViewEx saveButton = (TextViewEx) mainView.findViewById(R.id.save_button);
|
||||
|
||||
saveButton.setCompoundDrawablesWithIntrinsicBounds(null,
|
||||
null, getIcon(R.drawable.ic_action_read_later, nightMode ?
|
||||
R.color.wikivoyage_active_dark : R.color.ctx_menu_bottom_buttons_text_color_light), null);
|
||||
saveButton.setCompoundDrawablesWithIntrinsicBounds(
|
||||
null, null, getActiveIcon(R.drawable.ic_action_read_later), null);
|
||||
|
||||
contentsButton.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_list_header,
|
||||
nightMode ? R.color.wikivoyage_active_dark : R.color.ctx_menu_bottom_buttons_text_color_light),
|
||||
null, null, null);
|
||||
contentsButton.setCompoundDrawablesWithIntrinsicBounds(
|
||||
getActiveIcon(R.drawable.ic_action_list_header), null, null, null);
|
||||
|
||||
contentsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FragmentManager fm = getActivity().getSupportFragmentManager();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(WikivoyageArticleContentsBottomSheetDialogFragment.CONTENTS_JSON, contentsJson);
|
||||
WikivoyageArticleContentsBottomSheetDialogFragment fragment = new WikivoyageArticleContentsBottomSheetDialogFragment();
|
||||
args.putString(WikivoyageArticleContentsFragment.CONTENTS_JSON_KEY, contentsJson);
|
||||
WikivoyageArticleContentsFragment fragment = new WikivoyageArticleContentsFragment();
|
||||
fragment.setUsedOnMap(false);
|
||||
fragment.setArguments(args);
|
||||
fragment.setTargetFragment(WikivoyageArticleDialogFragment.this, 0);
|
||||
fragment.show(fm, WikivoyageArticleContentsBottomSheetDialogFragment.TAG);
|
||||
fragment.show(fm, WikivoyageArticleContentsFragment.TAG);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -138,9 +132,9 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 0) {
|
||||
String link = data.getStringExtra(WikivoyageArticleContentsBottomSheetDialogFragment.CONTENTS_LINK);
|
||||
moveAnchor(link);
|
||||
if (requestCode == WikivoyageArticleContentsFragment.REQUEST_LINK_CODE) {
|
||||
String link = data.getStringExtra(WikivoyageArticleContentsFragment.CONTENTS_LINK_KEY);
|
||||
moveToAnchor(link);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +195,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
contentWebView.loadDataWithBaseURL(getBaseUrl(), createHtmlContent(article), "text/html", "UTF-8", null);
|
||||
}
|
||||
|
||||
public void moveAnchor(String id) {
|
||||
public void moveToAnchor(String id) {
|
||||
contentWebView.loadUrl("javascript:scrollAnchor(\"" + id + "\")");
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@ package net.osmand.plus.wikivoyage.data;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -24,12 +26,12 @@ import java.util.ArrayList;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||
|
||||
public final static String TAG = "WikivoyageArticleContentsBottomSheetDialogFragment";
|
||||
public final static String CONTENTS_JSON = "contents_json";
|
||||
public final static String CONTENTS_LINK = "contents_link";
|
||||
public class WikivoyageArticleContentsFragment extends MenuBottomSheetDialogFragment {
|
||||
|
||||
public final static String TAG = "WikivoyageArticleContentsFragment";
|
||||
public final static String CONTENTS_JSON_KEY = "contents_json";
|
||||
public final static String CONTENTS_LINK_KEY = "contents_link";
|
||||
public final static int REQUEST_LINK_CODE = 0;
|
||||
|
||||
private LinkedHashMap<String, String> map;
|
||||
private String link;
|
||||
|
@ -39,7 +41,7 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott
|
|||
Bundle args = getArguments();
|
||||
String contentsJson;
|
||||
if (args != null) {
|
||||
contentsJson = args.getString(CONTENTS_JSON);
|
||||
contentsJson = args.getString(CONTENTS_JSON_KEY);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -58,8 +60,7 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott
|
|||
ExpandableListAdapter listAdapter = new ExpandableListAdapter(getContext(), listDataHeader, listDataChild);
|
||||
|
||||
expListView.setAdapter(listAdapter);
|
||||
expListView.setChildDivider(getResources().getDrawable(R.color.color_transparent));
|
||||
|
||||
expListView.setChildDivider(ContextCompat.getDrawable(getContext(), R.color.color_transparent));
|
||||
expListView.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT));
|
||||
|
@ -101,13 +102,13 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott
|
|||
items.add(favoritesItem);
|
||||
}
|
||||
|
||||
private void sendResult(int REQUEST_CODE) {
|
||||
private void sendResult(int requestLinkCode) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(CONTENTS_LINK, link);
|
||||
intent.putExtra(CONTENTS_LINK_KEY, link);
|
||||
Fragment fragment = getTargetFragment();
|
||||
if (fragment != null) {
|
||||
fragment.onActivityResult(
|
||||
getTargetRequestCode(), REQUEST_CODE, intent);
|
||||
getTargetRequestCode(), requestLinkCode, intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,12 +122,19 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott
|
|||
private Context context;
|
||||
private List<String> listDataHeader;
|
||||
private LinkedHashMap<String, List<String>> listDataChild;
|
||||
private Drawable itemGroupIcon;
|
||||
private Drawable itemChildIcon;
|
||||
|
||||
public ExpandableListAdapter(Context context, List<String> listDataHeader,
|
||||
LinkedHashMap<String, List<String>> listChildData) {
|
||||
this.context = context;
|
||||
this.listDataHeader = listDataHeader;
|
||||
this.listDataChild = listChildData;
|
||||
|
||||
itemGroupIcon = getIcon(R.drawable.ic_action_contents,
|
||||
isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light);
|
||||
itemChildIcon = getIcon(R.drawable.ic_action_list_bullet,
|
||||
isNightMode() ? R.color.route_info_unchecked_mode_icon_color : R.color.ctx_menu_nearby_routes_text_color_dark);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -151,9 +159,7 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott
|
|||
TextView txtListChild = (TextView) convertView.findViewById(R.id.item_label);
|
||||
txtListChild.setText(childText);
|
||||
txtListChild.setTextColor(getResolvedColor(isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light));
|
||||
txtListChild.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_list_bullet,
|
||||
isNightMode() ? R.color.route_info_unchecked_mode_icon_color : R.color.ctx_menu_nearby_routes_text_color_dark),
|
||||
null, null, null);
|
||||
txtListChild.setCompoundDrawablesWithIntrinsicBounds(itemChildIcon, null, null, null);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
@ -194,9 +200,7 @@ public class WikivoyageArticleContentsBottomSheetDialogFragment extends MenuBott
|
|||
TextView lblListHeader = (TextView) convertView.findViewById(R.id.item_label);
|
||||
lblListHeader.setText(headerTitle);
|
||||
lblListHeader.setTextColor(getResolvedColor(isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light));
|
||||
lblListHeader.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_contents,
|
||||
isNightMode() ? R.color.wikivoyage_active_dark : R.color.wikivoyage_active_light),
|
||||
null, null, null);
|
||||
lblListHeader.setCompoundDrawablesWithIntrinsicBounds(itemGroupIcon, null, null, null);
|
||||
|
||||
return convertView;
|
||||
}
|
Loading…
Reference in a new issue