fixed show images dialog
This commit is contained in:
parent
eb56fd75a6
commit
012d19e79f
5 changed files with 104 additions and 53 deletions
|
@ -7,6 +7,17 @@
|
||||||
android:background="?attr/bottom_menu_view_bg"
|
android:background="?attr/bottom_menu_view_bg"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/scroll_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/scrollable_items_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -44,10 +55,13 @@
|
||||||
android:paddingEnd="@dimen/list_content_padding"
|
android:paddingEnd="@dimen/list_content_padding"
|
||||||
android:text="@string/wikivoyage_download_pics_descr"
|
android:text="@string/wikivoyage_download_pics_descr"
|
||||||
android:textSize="16sp"/>
|
android:textSize="16sp"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/bottom_sheet_descr_height"
|
||||||
android:paddingLeft="@dimen/list_header_padding"
|
android:paddingLeft="@dimen/list_header_padding"
|
||||||
android:paddingStart="@dimen/list_header_padding"
|
android:paddingStart="@dimen/list_header_padding"
|
||||||
android:paddingRight="@dimen/list_header_padding"
|
android:paddingRight="@dimen/list_header_padding"
|
||||||
|
@ -82,32 +96,6 @@
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginEnd="@dimen/bottom_sheet_content_margin_small"
|
|
||||||
android:layout_marginRight="@dimen/bottom_sheet_content_margin_small"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="?attr/wikivoyage_secondary_btn_bg">
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/button_wifi"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/wikivoyage_card_button_height"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="?attr/selectableItemBackgroundBorderless"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:gravity="center"
|
|
||||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:text="@string/shared_string_only_with_wifi"
|
|
||||||
android:textColor="?attr/wikivoyage_active_color"
|
|
||||||
android:textSize="@dimen/text_button_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:ignore="UnusedAttribute" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -115,7 +103,7 @@
|
||||||
android:background="?attr/wikivoyage_primary_btn_bg">
|
android:background="?attr/wikivoyage_primary_btn_bg">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/button_yes"
|
android:id="@+id/button_download"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/wikivoyage_card_button_height"
|
android:layout_height="@dimen/wikivoyage_card_button_height"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
@ -124,11 +112,11 @@
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:text="@string/shared_string_do"
|
|
||||||
android:textColor="?attr/wikivoyage_primary_btn_text_color"
|
android:textColor="?attr/wikivoyage_primary_btn_text_color"
|
||||||
android:textSize="@dimen/text_button_text_size"
|
android:textSize="@dimen/text_button_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
tools:ignore="UnusedAttribute" />
|
tools:ignore="UnusedAttribute"
|
||||||
|
tools:text="@string/shared_string_do" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="?attr/bg_color"
|
android:background="?attr/bg_color"
|
||||||
|
android:visibility="gone"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -140,13 +140,13 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
listView.setAdapter(listAdapter);
|
|
||||||
View headerView = inflater.inflate(R.layout.menu_obj_selection_header, listView, false);
|
View headerView = inflater.inflate(R.layout.menu_obj_selection_header, listView, false);
|
||||||
if (!menu.isLandscapeLayout()) {
|
if (!menu.isLandscapeLayout()) {
|
||||||
AndroidUtils.setBackground(getContext(), headerView, !menu.isLight(), R.color.ctx_menu_bg_light, R.color.ctx_menu_bg_dark);
|
AndroidUtils.setBackground(getContext(), headerView, !menu.isLight(), R.color.ctx_menu_bg_light, R.color.ctx_menu_bg_dark);
|
||||||
}
|
}
|
||||||
headerView.setOnClickListener(null);
|
headerView.setOnClickListener(null);
|
||||||
listView.addHeaderView(headerView);
|
listView.addHeaderView(headerView);
|
||||||
|
listView.setAdapter(listAdapter);
|
||||||
|
|
||||||
view.findViewById(R.id.divider).setBackgroundColor(ContextCompat.getColor(getContext(), menu.isLight()
|
view.findViewById(R.id.divider).setBackgroundColor(ContextCompat.getColor(getContext(), menu.isLight()
|
||||||
? R.color.multi_selection_menu_divider_light : R.color.multi_selection_menu_divider_dark));
|
? R.color.multi_selection_menu_divider_light : R.color.multi_selection_menu_divider_dark));
|
||||||
|
|
|
@ -1,15 +1,23 @@
|
||||||
package net.osmand.plus.wikivoyage;
|
package net.osmand.plus.wikivoyage;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
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.view.ViewTreeObserver;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings.WikivoyageShowImages;
|
import net.osmand.plus.OsmandSettings.WikivoyageShowImages;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
|
||||||
public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragment {
|
public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
|
@ -32,7 +40,10 @@ public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragm
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view.findViewById(R.id.button_wifi).setOnClickListener(new View.OnClickListener() {
|
TextView buttonDownload = view.findViewById(R.id.button_download);
|
||||||
|
if (getMyApplication().getSettings().isWifiConnected()) {
|
||||||
|
buttonDownload.setText(R.string.shared_string_do);
|
||||||
|
buttonDownload.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
|
@ -43,7 +54,9 @@ public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragm
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view.findViewById(R.id.button_yes).setOnClickListener(new View.OnClickListener() {
|
} else {
|
||||||
|
buttonDownload.setText(R.string.shared_string_only_with_wifi);
|
||||||
|
buttonDownload.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
|
@ -54,6 +67,9 @@ public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragm
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setupHeight(view);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -64,4 +80,50 @@ public class WikivoyageShowPicturesDialogFragment extends BottomSheetDialogFragm
|
||||||
fragment.onActivityResult(getTargetRequestCode(), SHOW_PICTURES_CHANGED_REQUEST_CODE, null);
|
fragment.onActivityResult(getTargetRequestCode(), SHOW_PICTURES_CHANGED_REQUEST_CODE, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
if (!AndroidUiHelper.isOrientationPortrait(getActivity())) {
|
||||||
|
final Activity activity = getActivity();
|
||||||
|
final Window window = getDialog().getWindow();
|
||||||
|
if (activity != null && window != null) {
|
||||||
|
WindowManager.LayoutParams params = window.getAttributes();
|
||||||
|
params.width = activity.getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
||||||
|
window.setAttributes(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setupHeight(final View mainView) {
|
||||||
|
final Activity activity = getActivity();
|
||||||
|
if (activity != null) {
|
||||||
|
final int screenHeight = AndroidUtils.getScreenHeight(activity);
|
||||||
|
final int statusBarHeight = AndroidUtils.getStatusBarHeight(activity);
|
||||||
|
final int contentHeight = getContentHeight(screenHeight - statusBarHeight - AndroidUtils.getNavBarHeight(activity));
|
||||||
|
|
||||||
|
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
final View contentView = mainView.findViewById(R.id.scroll_view);
|
||||||
|
if (contentView.getHeight() > contentHeight) {
|
||||||
|
contentView.getLayoutParams().height = contentHeight;
|
||||||
|
contentView.requestLayout();
|
||||||
|
}
|
||||||
|
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
|
obs.removeOnGlobalLayoutListener(this);
|
||||||
|
} else {
|
||||||
|
obs.removeGlobalOnLayoutListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getContentHeight(int availableScreenHeight) {
|
||||||
|
return availableScreenHeight
|
||||||
|
- AndroidUtils.dpToPx(getContext(), 1) // divider height
|
||||||
|
- getResources().getDimensionPixelSize(R.dimen.bottom_sheet_descr_height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,7 +263,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
OsmandSettings settings = getMyApplication().getSettings();
|
OsmandSettings settings = getMyApplication().getSettings();
|
||||||
if (!settings.WIKIVOYAGE_SHOW_IMAGES_ASKED.get()) {
|
// if (!settings.WIKIVOYAGE_SHOW_IMAGES_ASKED.get()) {
|
||||||
FragmentActivity activity = getActivity();
|
FragmentActivity activity = getActivity();
|
||||||
FragmentManager fm = getFragmentManager();
|
FragmentManager fm = getFragmentManager();
|
||||||
if (activity != null && fm != null) {
|
if (activity != null && fm != null) {
|
||||||
|
@ -272,7 +272,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
fragment.show(fm, WikivoyageShowPicturesDialogFragment.TAG);
|
fragment.show(fm, WikivoyageShowPicturesDialogFragment.TAG);
|
||||||
settings.WIKIVOYAGE_SHOW_IMAGES_ASKED.set(true);
|
settings.WIKIVOYAGE_SHOW_IMAGES_ASKED.set(true);
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue