changed appbar,statusbar and refactored WikipediaDialogFragment
This commit is contained in:
parent
94e53b8ecb
commit
7cbba3d625
2 changed files with 89 additions and 102 deletions
|
@ -9,79 +9,54 @@
|
||||||
android:background="?attr/wikivoyage_bg_color"
|
android:background="?attr/wikivoyage_bg_color"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<android.support.design.widget.AppBarLayout
|
|
||||||
android:id="@+id/app_bar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
osmand:layout_scrollFlags="scroll|enterAlways"
|
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/toolbar_height"
|
||||||
osmand:contentInsetLeft="0dp"
|
android:background="?attr/wikivoyage_app_bar_color"
|
||||||
osmand:contentInsetStart="0dp"
|
android:gravity="center_vertical"
|
||||||
osmand:contentInsetRight="0dp"
|
android:minHeight="@dimen/toolbar_height"
|
||||||
osmand:contentInsetEnd="0dp">
|
osmand:contentInsetLeft="54dp"
|
||||||
|
osmand:contentInsetStart="54dp">
|
||||||
<LinearLayout
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
android:layout_height="match_parent">
|
||||||
android:gravity="center_vertical">
|
|
||||||
|
|
||||||
<ImageButton
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/back_button"
|
android:id="@+id/title_text_view"
|
||||||
style="@style/Widget.AppCompat.ActionButton"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
tools:src="@drawable/ic_arrow_back"
|
|
||||||
android:contentDescription="@string/shared_string_back" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_height="match_parent"/>
|
android:ellipsize="end"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textSize="@dimen/dialog_header_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/select_language_text_view"
|
android:id="@+id/select_language_text_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginBottom="@dimen/content_padding_small"
|
android:layout_marginBottom="@dimen/content_padding_small"
|
||||||
android:layout_marginTop="@dimen/content_padding_small"
|
|
||||||
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
|
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
|
||||||
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||||
tools:background="?attr/ctx_menu_controller_bg"
|
android:layout_marginTop="@dimen/content_padding_small"
|
||||||
|
android:drawablePadding="@dimen/context_menu_padding_margin_small"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
android:padding="@dimen/context_menu_padding_margin_tiny"
|
android:padding="@dimen/context_menu_padding_margin_tiny"
|
||||||
android:textAllCaps="true"
|
android:textSize="@dimen/text_button_text_size"
|
||||||
tools:textColor="?attr/ctx_menu_controller_text_color"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
tools:text="RU"/>
|
tools:background="@drawable/wikipedia_select_lang_bg_dark_n"
|
||||||
|
tools:drawableLeft="@drawable/ic_action_map_language"
|
||||||
</LinearLayout>
|
tools:ignore="UnusedAttribute"
|
||||||
|
tools:text="En"
|
||||||
<TextView
|
tools:textColor="?attr/wikivoyage_active_color" />
|
||||||
android:id="@+id/title_text_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingLeft="@dimen/content_padding"
|
|
||||||
android:paddingRight="@dimen/content_padding"
|
|
||||||
android:paddingTop="@dimen/list_header_padding"
|
|
||||||
android:paddingBottom="@dimen/list_header_padding"
|
|
||||||
android:textSize="@dimen/map_button_text_size"
|
|
||||||
tools:text="Title"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</android.support.v7.widget.Toolbar>
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
</android.support.design.widget.AppBarLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -6,24 +6,26 @@ import android.content.Context;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.ColorInt;
|
||||||
|
import android.support.annotation.ColorRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.customtabs.CustomTabsIntent;
|
import android.support.customtabs.CustomTabsIntent;
|
||||||
import android.support.design.widget.AppBarLayout;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.PopupMenu;
|
import android.support.v7.widget.PopupMenu;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.Window;
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
@ -31,6 +33,7 @@ import net.osmand.IndexConstants;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
||||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
@ -41,7 +44,7 @@ import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
|
||||||
public class WikipediaDialogFragment extends DialogFragment {
|
public class WikipediaDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
|
|
||||||
public static final String TAG = "WikipediaDialogFragment";
|
public static final String TAG = "WikipediaDialogFragment";
|
||||||
|
|
||||||
|
@ -52,8 +55,10 @@ public class WikipediaDialogFragment extends DialogFragment {
|
||||||
"</head>";
|
"</head>";
|
||||||
private static final String FOOTER_INNER = "</body></html>";
|
private static final String FOOTER_INNER = "</body></html>";
|
||||||
|
|
||||||
private View mainView;
|
|
||||||
private WebView contentWebView;
|
private WebView contentWebView;
|
||||||
|
private TextView articleToolbarText;
|
||||||
|
private TextView readFullArticleButton;
|
||||||
|
private TextView selectLanguageTextView;
|
||||||
|
|
||||||
private boolean darkMode;
|
private boolean darkMode;
|
||||||
private Amenity amenity;
|
private Amenity amenity;
|
||||||
|
@ -79,9 +84,16 @@ public class WikipediaDialogFragment extends DialogFragment {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
Dialog dialog = new Dialog(getContext(), getTheme());
|
int themeId = darkMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme_LightStatusBar;
|
||||||
if (!getMyApplication().getSettings().DO_NOT_USE_ANIMATIONS.get()) {
|
Dialog dialog = new Dialog(getContext(), themeId);
|
||||||
dialog.getWindow().getAttributes().windowAnimations = R.style.Animations_Alpha;
|
if (!getSettings().DO_NOT_USE_ANIMATIONS.get()) {
|
||||||
|
Window window = dialog.getWindow();
|
||||||
|
if (window != null) {
|
||||||
|
window.getAttributes().windowAnimations = R.style.Animations_Alpha;
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
window.setStatusBarColor(getResolvedColor(getStatusBarColor()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
@ -90,32 +102,17 @@ public class WikipediaDialogFragment extends DialogFragment {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
mainView = inflater.inflate(R.layout.wikipedia_dialog_fragment, container, false);
|
View mainView = inflater.inflate(R.layout.wikipedia_dialog_fragment, container, false);
|
||||||
|
|
||||||
mainView.setBackgroundColor(ContextCompat.getColor(getContext(), darkMode ? R.color.ctx_menu_bottom_view_bg_dark : R.color.ctx_menu_bottom_view_bg_light));
|
setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar));
|
||||||
|
|
||||||
AppBarLayout appBarLayout = (AppBarLayout) mainView.findViewById(R.id.app_bar);
|
articleToolbarText = (TextView) mainView.findViewById(R.id.title_text_view);
|
||||||
appBarLayout.setBackgroundColor(ContextCompat.getColor(getContext(), darkMode ? R.color.ctx_menu_buttons_bg_dark: R.color.ctx_menu_buttons_bg_light));
|
|
||||||
|
|
||||||
int toolbarTextColor = ContextCompat.getColor(getContext(), R.color.dashboard_subheader_text_light);
|
|
||||||
|
|
||||||
ImageButton backButton = (ImageButton) mainView.findViewById(R.id.back_button);
|
|
||||||
backButton.setImageDrawable(getMyApplication().getIconsCache().getPaintedIcon(R.drawable.ic_arrow_back, toolbarTextColor));
|
|
||||||
backButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
TextView titleTextView = (TextView) mainView.findViewById(R.id.title_text_view);
|
|
||||||
titleTextView.setTextColor(toolbarTextColor);
|
|
||||||
|
|
||||||
ColorStateList buttonColorStateList = AndroidUtils.createPressedColorStateList(getContext(), darkMode,
|
ColorStateList buttonColorStateList = AndroidUtils.createPressedColorStateList(getContext(), darkMode,
|
||||||
R.color.ctx_menu_controller_button_text_color_light_n, R.color.ctx_menu_controller_button_text_color_light_p,
|
R.color.ctx_menu_controller_button_text_color_light_n, R.color.ctx_menu_controller_button_text_color_light_p,
|
||||||
R.color.ctx_menu_controller_button_text_color_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p);
|
R.color.ctx_menu_controller_button_text_color_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p);
|
||||||
|
|
||||||
final TextView readFullArticleButton = (TextView) mainView.findViewById(R.id.read_full_article);
|
readFullArticleButton = (TextView) mainView.findViewById(R.id.read_full_article);
|
||||||
|
|
||||||
readFullArticleButton.setBackgroundResource(darkMode ? R.drawable.bt_round_long_night : R.drawable.bt_round_long_day);
|
readFullArticleButton.setBackgroundResource(darkMode ? R.drawable.bt_round_long_night : R.drawable.bt_round_long_day);
|
||||||
readFullArticleButton.setTextColor(buttonColorStateList);
|
readFullArticleButton.setTextColor(buttonColorStateList);
|
||||||
|
@ -125,7 +122,7 @@ public class WikipediaDialogFragment extends DialogFragment {
|
||||||
readFullArticleButton.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_world_globe_dark), null, null, null);
|
readFullArticleButton.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_world_globe_dark), null, null, null);
|
||||||
readFullArticleButton.setCompoundDrawablePadding((int) getResources().getDimension(R.dimen.content_padding_small));
|
readFullArticleButton.setCompoundDrawablePadding((int) getResources().getDimension(R.dimen.content_padding_small));
|
||||||
|
|
||||||
final TextView selectLanguageTextView = mainView.findViewById(R.id.select_language_text_view);
|
selectLanguageTextView = mainView.findViewById(R.id.select_language_text_view);
|
||||||
selectLanguageTextView.setTextColor(buttonColorStateList);
|
selectLanguageTextView.setTextColor(buttonColorStateList);
|
||||||
selectLanguageTextView.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_map_language), null, null, null);
|
selectLanguageTextView.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_map_language), null, null, null);
|
||||||
selectLanguageTextView.setCompoundDrawablePadding((int) getResources().getDimension(R.dimen.context_menu_padding_margin_small));
|
selectLanguageTextView.setCompoundDrawablePadding((int) getResources().getDimension(R.dimen.context_menu_padding_margin_small));
|
||||||
|
@ -186,9 +183,8 @@ public class WikipediaDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
final String langSelected = lng;
|
final String langSelected = lng;
|
||||||
final String title = amenity.getName(langSelected);
|
final String title = amenity.getName(langSelected);
|
||||||
((TextView) mainView.findViewById(R.id.title_text_view)).setText(title);
|
articleToolbarText.setText(title);
|
||||||
|
readFullArticleButton.setOnClickListener(new View.OnClickListener() {
|
||||||
mainView.findViewById(R.id.read_full_article).setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
String article = "https://" + langSelected.toLowerCase() + ".wikipedia.org/wiki/" + title.replace(' ', '_');
|
String article = "https://" + langSelected.toLowerCase() + ".wikipedia.org/wiki/" + title.replace(' ', '_');
|
||||||
|
@ -196,7 +192,6 @@ public class WikipediaDialogFragment extends DialogFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final TextView selectLanguageTextView = mainView.findViewById(R.id.select_language_text_view);
|
|
||||||
selectLanguageTextView.setText(langSelected);
|
selectLanguageTextView.setText(langSelected);
|
||||||
selectLanguageTextView.setOnClickListener(new View.OnClickListener() {
|
selectLanguageTextView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -260,11 +255,7 @@ public class WikipediaDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
private Drawable getIcon(int resId) {
|
private Drawable getIcon(int resId) {
|
||||||
int colorId = darkMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n;
|
int colorId = darkMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n;
|
||||||
return getMyApplication().getIconsCache().getIcon(resId, colorId);
|
return getIcon(resId, colorId);
|
||||||
}
|
|
||||||
|
|
||||||
private OsmandApplication getMyApplication() {
|
|
||||||
return (OsmandApplication) getActivity().getApplication();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean showInstance(AppCompatActivity activity, Amenity amenity, String lang) {
|
public static boolean showInstance(AppCompatActivity activity, Amenity amenity, String lang) {
|
||||||
|
@ -289,4 +280,25 @@ public class WikipediaDialogFragment extends DialogFragment {
|
||||||
public static boolean showInstance(AppCompatActivity activity, Amenity amenity) {
|
public static boolean showInstance(AppCompatActivity activity, Amenity amenity) {
|
||||||
return showInstance(activity, amenity, null);
|
return showInstance(activity, amenity, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setupToolbar(Toolbar toolbar) {
|
||||||
|
toolbar.setNavigationIcon(getIcon(R.drawable.ic_arrow_back, R.color.icon_color));
|
||||||
|
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
|
||||||
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorRes
|
||||||
|
protected int getStatusBarColor() {
|
||||||
|
return darkMode ? R.color.status_bar_wikivoyage_article_dark : R.color.status_bar_wikivoyage_article_light;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
protected int getResolvedColor(@ColorRes int colorId) {
|
||||||
|
return ContextCompat.getColor(getContext(), colorId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue