diff --git a/OsmAnd/res/layout/dialog_live_updates_item_settings.xml b/OsmAnd/res/layout/dialog_live_updates_item_settings.xml index a101670cdd..6d2aaaac9f 100644 --- a/OsmAnd/res/layout/dialog_live_updates_item_settings.xml +++ b/OsmAnd/res/layout/dialog_live_updates_item_settings.xml @@ -34,6 +34,7 @@ android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" android:gravity="center" android:textColor="@color/color_white" android:textSize="12sp" @@ -44,7 +45,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom" - android:layout_marginTop="8dp" android:layout_marginBottom="8dp" android:gravity="center" android:textColor="@color/color_white" diff --git a/OsmAnd/res/layout/fragment_reports.xml b/OsmAnd/res/layout/fragment_reports.xml index 94dee37462..6dfe5545e3 100644 --- a/OsmAnd/res/layout/fragment_reports.xml +++ b/OsmAnd/res/layout/fragment_reports.xml @@ -14,100 +14,141 @@ - + android:orientation="vertical"> - + - + + + + + + + - - + android:background="?attr/selectableItemBackground" + android:gravity="center_vertical" + android:minHeight="60dp" + android:clickable="true" + android:orientation="horizontal"> - + - + android:layout_weight="1" + android:layout_marginRight="16dp" + android:orientation="vertical"> + + + + + + + + + - - + android:gravity="center_vertical" + android:minHeight="60dp" + android:background="?attr/selectableItemBackground" + android:orientation="horizontal"> - + + + android:layout_marginRight="16dp" + android:orientation="vertical"> + + + + + - - - + android:gravity="center_vertical" + android:minHeight="60dp" + android:background="?attr/selectableItemBackground" + android:orientation="horizontal"> - + + + android:layout_marginRight="16dp" + android:orientation="vertical"> - - + - + + - - - - - - - + android:gravity="center_vertical" + android:minHeight="60dp" + android:orientation="horizontal"> - + + + android:layout_marginRight="16dp" + android:orientation="vertical"> + + + + + - - + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/layout/fragment_simple_list.xml b/OsmAnd/res/layout/fragment_simple_list.xml index 95e228a960..cc1b98b264 100644 --- a/OsmAnd/res/layout/fragment_simple_list.xml +++ b/OsmAnd/res/layout/fragment_simple_list.xml @@ -30,12 +30,6 @@ app:typeface="@string/font_roboto_regular"/> - + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java index b186a23a38..2cf6587ca2 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java @@ -22,7 +22,6 @@ import net.osmand.PlatformUtil; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; -import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.download.AbstractDownloadActivity; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.liveupdates.LiveUpdatesHelper.TimeOfDay; @@ -41,6 +40,7 @@ import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceDownloadViaWiFi; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceForLocalIndex; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck; +import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLiveUpdatesOn; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceTimeOfDayToUpdate; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceUpdateFrequency; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.runLiveUpdate; @@ -78,7 +78,15 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment { String lastCheckString = formatDateTime(getActivity(), lastCheck != DEFAULT_LAST_CHECK ? lastCheck : timestamp); lastMapChangeTextView.setText(getString(R.string.last_map_change, lastUpdateDate)); - lastUpdateTextView.setText(getString(R.string.last_update, lastCheckString)); + + + OsmandSettings.CommonPreference preference = preferenceLiveUpdatesOn(localIndexInfo, + getSettings()); + if (preference.get()) { + lastUpdateTextView.setText(getString(R.string.last_update, lastCheckString)); + } else { + lastUpdateTextView.setVisibility(View.GONE); + } final OsmandSettings.CommonPreference liveUpdatePreference = preferenceForLocalIndex(localIndexInfo, getSettings()); @@ -98,7 +106,7 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment { for (int i = 0; i < timeOfDays.length; i++) { timeOfDaysStrings[i] = getString(timeOfDays[i].getLocalizedId()); } - updateTimesOfDaySpinner.setAdapter(new ArrayAdapter(getActivity(), + updateTimesOfDaySpinner.setAdapter(new ArrayAdapter<>(getActivity(), R.layout.action_spinner_item, timeOfDaysStrings)); updateTimesOfDaySpinner.setSelection(timeOfDayPreference.get()); @@ -109,7 +117,7 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment { } refreshTimeOfDayLayout(UpdateFrequency.values()[updateFrequencyPreference.get()], updateTimesOfDayLayout); - updateFrequencySpinner.setAdapter(new ArrayAdapter(getActivity(), + updateFrequencySpinner.setAdapter(new ArrayAdapter<>(getActivity(), R.layout.action_spinner_item, updateFrequenciesStrings)); updateFrequencySpinner.setSelection(updateFrequencyPreference.get()); updateFrequencySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java index 95f1200550..91dd4693b0 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java @@ -11,6 +11,7 @@ import android.support.annotation.AttrRes; import android.support.annotation.ColorInt; import android.util.TypedValue; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -24,6 +25,7 @@ import android.widget.TextView; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; +import net.osmand.AndroidUtils; import net.osmand.PlatformUtil; import net.osmand.osm.io.NetworkUtils; import net.osmand.plus.R; @@ -55,7 +57,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect private TextView donationsTextView; private TextView recipientsTextView; - private Spinner montReportsSpinner; + private Spinner monthReportsSpinner; private MonthsForReportsAdapter monthsForReportsAdapter; private CountrySelectionFragment countrySelectionFragment = new CountrySelectionFragment(); @@ -82,10 +84,26 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_reports, container, false); - montReportsSpinner = (Spinner) view.findViewById(R.id.montReportsSpinner); + monthReportsSpinner = (Spinner) view.findViewById(R.id.monthReportsSpinner); + final View monthButton = view.findViewById(R.id.monthButton); + monthReportsSpinner.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + event.offsetLocation(AndroidUtils.dpToPx(getActivity(), 48f), 0); + monthButton.onTouchEvent(event); + return true; + } + }); monthsForReportsAdapter = new MonthsForReportsAdapter(getActivity()); - montReportsSpinner.setAdapter(monthsForReportsAdapter); - + monthReportsSpinner.setAdapter(monthsForReportsAdapter); + + monthButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + monthReportsSpinner.performClick(); + } + }); + view.findViewById(R.id.show_all).setOnClickListener(new OnClickListener() { @Override @@ -105,7 +123,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View v) { - int monthItemPosition = montReportsSpinner.getSelectedItemPosition(); + int monthItemPosition = monthReportsSpinner.getSelectedItemPosition(); String monthUrlString = monthsForReportsAdapter.getQueryString(monthItemPosition); String countryUrlString = selectedCountryItem.getDownloadName(); if (countryUrlString.length() > 0) { @@ -128,8 +146,10 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect countryNameTextView.setText(selectedCountryItem.getLocalName()); setThemedDrawable(view, R.id.calendarImageView, R.drawable.ic_action_data); + setThemedDrawable(view, R.id.monthDropDownIcon, R.drawable.ic_action_arrow_drop_down); setThemedDrawable(view, R.id.regionIconImageView, R.drawable.ic_world_globe_dark); - + setThemedDrawable(view, R.id.countryDropDownIcon, R.drawable.ic_action_arrow_drop_down); + numberOfContributorsIcon = (ImageView) view.findViewById(R.id.numberOfContributorsIcon); numberOfEditsIcon = (ImageView) view.findViewById(R.id.numberOfEditsIcon); numberOfRecipientsIcon = (ImageView) view.findViewById(R.id.numberOfRecipientsIcon); @@ -167,7 +187,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect } }; - montReportsSpinner.setOnItemSelectedListener(onItemSelectedListener); + monthReportsSpinner.setOnItemSelectedListener(onItemSelectedListener); inactiveColor = getColorFromAttr(R.attr.plugin_details_install_header_bg); textColorPrimary = getColorFromAttr(android.R.attr.textColorPrimary); @@ -177,7 +197,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect } public void requestAndUpdateUi() { - int monthItemPosition = montReportsSpinner.getSelectedItemPosition(); + int monthItemPosition = monthReportsSpinner.getSelectedItemPosition(); String monthUrlString = monthsForReportsAdapter.getQueryString(monthItemPosition); String countryUrlString = selectedCountryItem.getDownloadName(); @@ -260,7 +280,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect private static class MonthsForReportsAdapter extends ArrayAdapter { private static final SimpleDateFormat queryFormat = new SimpleDateFormat("yyyy-MM", Locale.US); @SuppressLint("SimpleDateFormat") - private static final SimpleDateFormat humanFormat = new SimpleDateFormat("MMMM yyyy"); + private static final SimpleDateFormat humanFormat = new SimpleDateFormat("LLLL yyyy"); ArrayList queryString = new ArrayList<>(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 644c246c9b..95660d7748 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -32,6 +32,7 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.view.WindowManager; import android.view.inputmethod.EditorInfo; import android.widget.AdapterView; @@ -165,18 +166,40 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { final TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tab_layout); tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); + // tabLayout.setupWithViewPager(viewPager); // Hack due to bug in design support library v22.2.1 // https://code.google.com/p/android/issues/detail?id=180462 // TODO remove in new version - if (ViewCompat.isLaidOut(tabLayout)) { - tabLayout.setupWithViewPager(viewPager); + if (Build.VERSION.SDK_INT >= 11) { + if (ViewCompat.isLaidOut(tabLayout)) { + tabLayout.setupWithViewPager(viewPager); + } else { + tabLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { + @Override + public void onLayoutChange(View v, int left, int top, int right, int bottom, + int oldLeft, int oldTop, int oldRight, int oldBottom) { + tabLayout.setupWithViewPager(viewPager); + tabLayout.removeOnLayoutChangeListener(this); + } + }); + } } else { - tabLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { + ViewTreeObserver vto = view.getViewTreeObserver(); + vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override - public void onLayoutChange(View v, int left, int top, int right, int bottom, - int oldLeft, int oldTop, int oldRight, int oldBottom) { - tabLayout.setupWithViewPager(viewPager); - tabLayout.removeOnLayoutChangeListener(this); + public void onGlobalLayout() { + + ViewTreeObserver obs = view.getViewTreeObserver(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + obs.removeOnGlobalLayoutListener(this); + } else { + obs.removeGlobalOnLayoutListener(this); + } + + if (getActivity() != null) { + tabLayout.setupWithViewPager(viewPager); + } } }); } @@ -346,9 +369,9 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { } else { new SaveWithAdvancedTagsDialogFragment().show(getChildFragmentManager(), "dialog"); } - } else if(editPoiData.getPoiCategory() == getMyApplication().getPoiTypes().getOtherPoiCategory()) { + } else if (editPoiData.getPoiCategory() == getMyApplication().getPoiTypes().getOtherPoiCategory()) { poiTypeEditText.setError(getResources().getString(R.string.please_specify_poi_type)); - } else if(editPoiData.getPoiTypeDefined() == null) { + } else if (editPoiData.getPoiTypeDefined() == null) { poiTypeEditText.setError(getResources().getString(R.string.please_specify_poi_type_only_from_list)); } else { save(); @@ -372,7 +395,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { node.putTag(editPoiData.getPoiCategory().getDefaultTag(), tag.getValue()); } - if(offlineEdit && !Algorithms.isEmpty(tag.getValue())) { + if (offlineEdit && !Algorithms.isEmpty(tag.getValue())) { node.putTag(tag.getKey(), tag.getValue()); } } else if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue())) { @@ -460,7 +483,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { @Override protected void onPostExecute(Node result) { progress.dismiss(); - if(postExecute != null) { + if (postExecute != null) { postExecute.processResult(result); } } @@ -476,9 +499,9 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { private void setAdapterForPoiTypeEditText() { final Map subCategories = new LinkedHashMap<>(); PoiCategory ct = editPoiData.getPoiCategory(); - if(ct != null) { + if (ct != null) { for (PoiType s : ct.getPoiTypes()) { - if(!s.isReference() && !s.isNotEditableOsm() && s.getBaseLangType() == null) { + if (!s.isReference() && !s.isNotEditableOsm() && s.getBaseLangType() == null) { addMapEntryAdapter(subCategories, s.getTranslation(), s); addMapEntryAdapter(subCategories, s.getKeyName().replace('_', ' '), s); } @@ -663,11 +686,11 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { deleteNode(n, c, closeChangeSet); } - + }); builder.create().show(); } - + private void deleteNode(final Node n, final String c, final boolean closeChangeSet) { final boolean isLocalEdit = openstreetmapUtil instanceof OpenstreetmapLocalUtil; commitNode(OsmPoint.Action.DELETE, n, openstreetmapUtil.getEntityInfo(n.getId()), c, closeChangeSet, @@ -727,7 +750,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { .setNegativeButton(R.string.shared_string_cancel, null); return builder.create(); } - } + } private TextView.OnEditorActionListener mOnEditorActionListener = new TextView.OnEditorActionListener() {