diff options
author | Alexander Marchuk <trashkalmar@users.noreply.github.com> | 2016-02-05 15:17:34 +0300 |
---|---|---|
committer | Alexander Marchuk <trashkalmar@users.noreply.github.com> | 2016-02-05 15:17:34 +0300 |
commit | 8dfdbc93b73e86207feee3ae2086ac73216ce8ee (patch) | |
tree | adf5249dc4a8c224ca7f94dfe58ac25726549e30 | |
parent | 7422a91556995481bdba4db57b57fcae984f0465 (diff) | |
parent | 8eebdf6327743dff15f1c7d3451ad86f324100ab (diff) |
Merge pull request #1826 from yunikkk/country-suggest-fixandroid-release-561
[android] Country suggest release fixes.
4 files changed, 119 insertions, 123 deletions
diff --git a/android/res/layout-land/fragment_suggest_country_download.xml b/android/res/layout-land/fragment_suggest_country_download.xml index 8fb90341f8..7bebecbaa6 100644 --- a/android/res/layout-land/fragment_suggest_country_download.xml +++ b/android/res/layout-land/fragment_suggest_country_download.xml @@ -1,101 +1,102 @@ <?xml version="1.0" encoding="utf-8"?> <FrameLayout - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="?windowBackgroundForced"> + + <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> - <ScrollView + <LinearLayout + android:id="@+id/ll__select_download" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="wrap_content" + android:gravity="center_horizontal" + android:orientation="vertical" + android:paddingLeft="@dimen/margin_base" + android:paddingRight="@dimen/margin_base" + android:paddingTop="@dimen/margin_half_plus" + tools:ignore="UnusedAttribute"> - <LinearLayout - android:id="@+id/ll__select_download" + <TextView android:layout_width="match_parent" android:layout_height="wrap_content" - android:gravity="center_horizontal" - android:orientation="vertical" - android:paddingLeft="@dimen/margin_base" - android:paddingRight="@dimen/margin_base" - android:paddingTop="@dimen/margin_half_plus" - tools:ignore="UnusedAttribute"> - - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:gravity="center" - android:text="@string/search_without_internet_advertisement" - android:textAppearance="@style/MwmTextAppearance.Body2"/> + android:gravity="center" + android:text="@string/search_without_internet_advertisement" + android:textAppearance="@style/MwmTextAppearance.Body2"/> <LinearLayout - android:id="@+id/ll__location_determined" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:gravity="center_horizontal" - android:orientation="vertical"> + android:id="@+id/ll__location_determined" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_horizontal" + android:orientation="vertical"> <TextView - android:id="@+id/tv__country_name" - android:layout_width="match_parent" - android:layout_height="@dimen/base_block_size" - android:layout_marginTop="@dimen/margin_half" - android:gravity="center" - android:textAppearance="@style/MwmTextAppearance.Title"/> + android:id="@+id/tv__country_name" + android:layout_width="match_parent" + android:layout_height="@dimen/base_block_size" + android:layout_marginTop="@dimen/margin_half" + android:gravity="center" + android:textAppearance="@style/MwmTextAppearance.Title"/> <Button - android:id="@+id/btn__download_map" - style="@style/MwmWidget.Button.Green" - android:layout_width="280dp" - android:layout_height="@dimen/base_block_size" - android:layout_marginTop="@dimen/margin_quarter" - android:text="@string/downloader_download_map" - android:textAllCaps="true" - android:textAppearance="@style/MwmTextAppearance.Body1.Light"/> + android:id="@+id/btn__download_map" + style="@style/MwmWidget.Button.Green" + android:layout_width="280dp" + android:layout_height="@dimen/base_block_size" + android:layout_marginTop="@dimen/margin_quarter" + android:text="@string/downloader_download_map" + android:textAllCaps="true" + android:textAppearance="@style/MwmTextAppearance.Body1.Light"/> <CheckBox - android:id="@+id/chb__routing_too" - android:layout_width="wrap_content" - android:layout_height="@dimen/base_block_size" - android:layout_marginTop="@dimen/margin_quarter" - android:text="@string/search_vehicle_routes" - android:textAppearance="@style/MwmTextAppearance.Body2"/> + android:id="@+id/chb__routing_too" + android:layout_width="wrap_content" + android:layout_height="@dimen/base_block_size" + android:layout_marginTop="@dimen/margin_quarter" + android:text="@string/search_vehicle_routes" + android:textAppearance="@style/MwmTextAppearance.Body2"/> <Button - android:id="@+id/btn__select_other_map" - android:layout_width="280dp" - android:layout_height="@dimen/base_block_size" - android:layout_marginTop="@dimen/margin_base_plus" - android:background="?clickableBackground" - android:text="@string/search_select_other_map" - android:textAllCaps="true" - android:textAppearance="@style/MwmTextAppearance.Body3" - android:textColor="?colorAccent"/> + android:id="@+id/btn__select_other_map" + android:layout_width="280dp" + android:layout_height="@dimen/base_block_size" + android:layout_marginTop="@dimen/margin_base_plus" + android:background="?clickableBackground" + android:text="@string/search_select_other_map" + android:textAllCaps="true" + android:textAppearance="@style/MwmTextAppearance.Body3" + android:textColor="?colorAccent"/> </LinearLayout> <LinearLayout - android:id="@+id/ll__location_unknown" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" - android:visibility="gone"> + android:id="@+id/ll__location_unknown" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="gone"> <TextView - android:layout_width="match_parent" - android:layout_height="@dimen/base_block_size" - android:layout_marginTop="@dimen/margin_half" - android:gravity="center" - android:text="@string/unknown_current_position" - android:textAppearance="@style/MwmTextAppearance.Body3"/> + android:layout_width="match_parent" + android:layout_height="@dimen/base_block_size" + android:layout_marginTop="@dimen/margin_half" + android:gravity="center" + android:text="@string/unknown_current_position" + android:textAppearance="@style/MwmTextAppearance.Body3"/> <Button - android:id="@+id/btn__select_map" - style="@style/MwmWidget.Button.Green" - android:layout_width="280dp" - android:layout_height="@dimen/base_block_size" - android:layout_marginTop="@dimen/margin_half" - android:text="@string/search_select_map" - android:textAllCaps="true" - android:textAppearance="@style/MwmTextAppearance.Body1.Light"/> + android:id="@+id/btn__select_map" + style="@style/MwmWidget.Button.Green" + android:layout_width="280dp" + android:layout_height="@dimen/base_block_size" + android:layout_marginTop="@dimen/margin_half" + android:text="@string/search_select_map" + android:textAllCaps="true" + android:textAppearance="@style/MwmTextAppearance.Body1.Light"/> </LinearLayout> @@ -104,31 +105,31 @@ </ScrollView> <LinearLayout - android:id="@+id/ll__active_download" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="center" - android:gravity="center_horizontal" - android:orientation="vertical" - android:padding="@dimen/margin_double_and_half" - android:visibility="gone"> + android:id="@+id/ll__active_download" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:gravity="center_horizontal" + android:orientation="vertical" + android:padding="@dimen/margin_double_and_half" + android:visibility="gone"> <TextView - android:id="@+id/tv__active_country_name" - android:layout_width="wrap_content" - android:layout_height="@dimen/base_block_size" - android:textAppearance="@style/MwmTextAppearance.Title"/> + android:id="@+id/tv__active_country_name" + android:layout_width="wrap_content" + android:layout_height="@dimen/base_block_size" + android:textAppearance="@style/MwmTextAppearance.Title"/> <com.mapswithme.maps.widget.WheelProgressView - android:id="@+id/wpv__download_progress" - xmlns:wheel="http://schemas.android.com/apk/res-auto" - android:layout_width="@dimen/progress_wheel_height" - android:layout_height="@dimen/progress_wheel_height" - android:layout_marginTop="@dimen/margin_half_plus" - android:background="?clickableBackground" - wheel:wheelProgressColor="@color/base_green" - wheel:wheelSecondaryColor="?dividerHorizontal" - wheel:wheelThickness="@dimen/margin_quarter"/> + xmlns:wheel="http://schemas.android.com/apk/res-auto" + android:id="@+id/wpv__download_progress" + android:layout_width="@dimen/progress_wheel_height" + android:layout_height="@dimen/progress_wheel_height" + android:layout_marginTop="@dimen/margin_half_plus" + android:background="?clickableBackground" + wheel:wheelProgressColor="@color/base_green" + wheel:wheelSecondaryColor="?dividerHorizontal" + wheel:wheelThickness="@dimen/margin_quarter"/> </LinearLayout> </FrameLayout>
\ No newline at end of file diff --git a/android/src/com/mapswithme/country/CountrySuggestFragment.java b/android/src/com/mapswithme/country/CountrySuggestFragment.java index 404b68a419..f35dec1398 100644 --- a/android/src/com/mapswithme/country/CountrySuggestFragment.java +++ b/android/src/com/mapswithme/country/CountrySuggestFragment.java @@ -17,17 +17,14 @@ import com.mapswithme.maps.Framework; import com.mapswithme.maps.MapStorage; import com.mapswithme.maps.R; import com.mapswithme.maps.base.BaseMwmFragment; -import com.mapswithme.maps.base.BaseMwmFragmentActivity; import com.mapswithme.maps.location.LocationHelper; +import com.mapswithme.maps.search.SearchFragment; import com.mapswithme.maps.widget.WheelProgressView; import com.mapswithme.util.StringUtils; import com.mapswithme.util.UiUtils; public class CountrySuggestFragment extends BaseMwmFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener { - public static final String EXTRA_LAT = "Latitude"; - public static final String EXTRA_LON = "Longitude"; - private double mLat; private double mLon; private MapStorage.Index mCurrentLocationCountryIndex; @@ -109,13 +106,10 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl { super.onResume(); - readArguments(); - if (mLat == 0 || mLon == 0) - { - final Location last = LocationHelper.INSTANCE.getLastLocation(); - if (last != null) - setLatLon(last.getLatitude(), last.getLongitude()); - } + final Location last = LocationHelper.INSTANCE.getLastLocation(); + if (last != null) + setLatLon(last.getLatitude(), last.getLongitude()); + refreshViews(); } @@ -139,15 +133,6 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl mTvActiveCountry.setText(name); } - private void readArguments() - { - final Bundle args = getArguments(); - if (args == null) - return; - - setLatLon(args.getDouble(EXTRA_LAT), args.getDouble(EXTRA_LON)); - } - private void initViews(View view) { mLlSelectDownload = (LinearLayout) view.findViewById(R.id.ll__select_download); @@ -238,8 +223,8 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl private void selectMapForDownload() { - final BaseMwmFragmentActivity parent = (BaseMwmFragmentActivity) getActivity(); - parent.replaceFragment(DownloadFragment.class, null, null); + SearchFragment parent = (SearchFragment) getParentFragment(); + parent.showDownloader(); } private void cancelCurrentDownload() diff --git a/android/src/com/mapswithme/maps/search/SearchActivity.java b/android/src/com/mapswithme/maps/search/SearchActivity.java index 7b80454036..083da2cab1 100644 --- a/android/src/com/mapswithme/maps/search/SearchActivity.java +++ b/android/src/com/mapswithme/maps/search/SearchActivity.java @@ -43,9 +43,10 @@ public class SearchActivity extends BaseMwmFragmentActivity implements CustomNav @Override public void onBackPressed() { - final Fragment fragment = getSupportFragmentManager().findFragmentByTag(getFragmentClass().getName()); - if ((fragment == null) || !fragment.isAdded() || - !((OnBackPressListener) fragment).onBackPressed()) - super.onBackPressed(); + for (Fragment f : getSupportFragmentManager().getFragments()) + if ((f instanceof OnBackPressListener) && ((OnBackPressListener)f).onBackPressed()) + return; + + super.onBackPressed(); } } diff --git a/android/src/com/mapswithme/maps/search/SearchFragment.java b/android/src/com/mapswithme/maps/search/SearchFragment.java index e90e4ecc54..a063e7066e 100644 --- a/android/src/com/mapswithme/maps/search/SearchFragment.java +++ b/android/src/com/mapswithme/maps/search/SearchFragment.java @@ -22,10 +22,12 @@ import java.util.List; import com.mapswithme.country.ActiveCountryTree; import com.mapswithme.country.CountrySuggestFragment; +import com.mapswithme.country.DownloadFragment; import com.mapswithme.maps.Framework; import com.mapswithme.maps.MwmActivity; import com.mapswithme.maps.R; import com.mapswithme.maps.base.BaseMwmFragment; +import com.mapswithme.maps.base.BaseMwmFragmentActivity; import com.mapswithme.maps.base.OnBackPressListener; import com.mapswithme.maps.bookmarks.data.MapObject; import com.mapswithme.maps.location.LocationHelper; @@ -118,6 +120,7 @@ public class SearchFragment extends BaseMwmFragment } } + private View mTabFrame; private View mResultsFrame; private View mResultsPlaceholder; @@ -171,7 +174,13 @@ public class SearchFragment extends BaseMwmFragment .commit(); } - protected void updateFrames() + public void showDownloader() + { + UiUtils.hide(mResultsFrame, mResultsPlaceholder, mTabFrame); + ((BaseMwmFragmentActivity) getActivity()).replaceFragment(DownloadFragment.class, null, null); + } + + private void updateFrames() { final boolean active = searchActive(); UiUtils.showIf(active, mResultsFrame); @@ -206,11 +215,11 @@ public class SearchFragment extends BaseMwmFragment readArguments(); ViewGroup root = (ViewGroup) view; - View tabsFrame = root.findViewById(R.id.tab_frame); - ViewPager pager = (ViewPager) tabsFrame.findViewById(R.id.pages); + mTabFrame = root.findViewById(R.id.tab_frame); + ViewPager pager = (ViewPager) mTabFrame.findViewById(R.id.pages); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) - UiUtils.hide(tabsFrame.findViewById(R.id.tabs_divider)); + UiUtils.hide(mTabFrame.findViewById(R.id.tabs_divider)); mToolbarController = new ToolbarController(view); |