Add "Reload" button; close keyboard on Done click

This commit is contained in:
Alexander Sytnyk 2017-06-27 11:55:19 +03:00
parent 7d161bc769
commit 10fea91f14
3 changed files with 95 additions and 5 deletions

View file

@ -20,8 +20,7 @@
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_margin="16dp"
tools:src="@drawable/ic_action_gabout_dark" />
<android.support.v7.widget.SwitchCompat
@ -42,14 +41,77 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_toEndOf="@+id/toggle_row_icon"
android:layout_toLeftOf="@id/toggle_row_toggle"
android:layout_toRightOf="@+id/toggle_row_icon"
android:layout_toStartOf="@id/toggle_row_toggle"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="Some title text" />
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_marginTop="12dp"
android:layout_toEndOf="@+id/toggle_row_icon"
android:layout_toRightOf="@+id/toggle_row_icon"
android:background="?attr/dashboard_divider" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:minHeight="60dp">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/mapillary_filters_tile_cache_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_margin="16dp"
tools:src="@drawable/ic_layer_top_dark" />
<Button
android:id="@+id/button_reload_tile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="?attr/selectableItemBackground"
android:text="@string/shared_string_reload"
android:textColor="?attr/color_dialog_buttons" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_toEndOf="@+id/mapillary_filters_tile_cache_icon"
android:layout_toLeftOf="@id/button_reload_tile"
android:layout_toRightOf="@+id/mapillary_filters_tile_cache_icon"
android:layout_toStartOf="@id/button_reload_tile"
android:minHeight="60dp"
android:orientation="vertical"
android:paddingBottom="12dp"
android:paddingTop="10dp">
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/mapillary_menu_title_tile_cache"
android:textAppearance="@style/TextAppearance.ListItemTitle" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:maxLines="2"
android:text="@string/mapillary_menu_descr_tile_cache"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size" />
</LinearLayout>
</RelativeLayout>
<LinearLayout xmlns:osmand="http://schemas.android.com/apk/res-auto"
@ -95,7 +157,6 @@
android:text="@string/mapillary_menu_filter_description"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size" />
</LinearLayout>
<View

View file

@ -9,6 +9,9 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="shared_string_reload">Reload</string>
<string name="mapillary_menu_descr_tile_cache">Reload tiles if you want see latest data.</string>
<string name="mapillary_menu_title_tile_cache">Tile cache</string>
<string name="wrong_user_name">Wrong user name!</string>
<string name="shared_string_to">To</string>
<string name="mapillary_menu_date_from">From</string>

View file

@ -2,6 +2,7 @@ package net.osmand.plus.mapillary;
import android.app.DatePickerDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
@ -10,14 +11,18 @@ import android.support.v7.widget.AppCompatTextView;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
@ -86,9 +91,19 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
});
final Button reloadTile = (Button) view.findViewById(R.id.button_reload_tile);
reloadTile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
final int colorRes = nightMode ? R.color.color_white : R.color.icon_color;
((AppCompatImageView) view.findViewById(R.id.mapillary_filters_user_icon)).setImageDrawable(getIcon(R.drawable.ic_action_user, colorRes));
((AppCompatImageView) view.findViewById(R.id.mapillary_filters_date_icon)).setImageDrawable(getIcon(R.drawable.ic_action_data, colorRes));
((AppCompatImageView) view.findViewById(R.id.mapillary_filters_tile_cache_icon)).setImageDrawable(getIcon(R.drawable.ic_layer_top_dark, colorRes));
final DelayAutoCompleteTextView textView = (DelayAutoCompleteTextView) view.findViewById(R.id.auto_complete_text_view);
@ -98,6 +113,17 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
textView.setText(selectedUsername);
textView.setSelection(selectedUsername.length());
}
textView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == EditorInfo.IME_ACTION_DONE) {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(textView.getWindowToken(), 0);
return true;
}
return false;
}
});
textView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {