forked from organicmaps/organicmaps
[android] UI for localized names.
This commit is contained in:
parent
9c980d3d9b
commit
911ad5b75a
4 changed files with 144 additions and 42 deletions
|
@ -22,8 +22,8 @@
|
|||
style="@style/MwmWidget.Editor.MetadataBlock.Clickable"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/editor_height_field"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:minHeight="@dimen/editor_height_field"
|
||||
android:padding="@dimen/margin_half_plus">
|
||||
|
||||
<ImageView
|
||||
|
@ -74,43 +74,7 @@
|
|||
android:id="@+id/cv__name"
|
||||
style="@style/MwmWidget.Editor.CardView">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/margin_base"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingEnd="@dimen/margin_base"
|
||||
android:paddingLeft="@dimen/margin_base"
|
||||
android:paddingRight="@dimen/margin_base"
|
||||
android:paddingStart="@dimen/margin_base">
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/input"
|
||||
style="@style/MwmWidget.Editor.FieldLayout.EditText"
|
||||
android:hint="@string/editor_edit_place_name_hint"
|
||||
android:singleLine="true"/>
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name_multilang"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/height_block_base"
|
||||
android:background="?clickableBackground"
|
||||
android:drawableEnd="@drawable/ic_arrow_down"
|
||||
android:drawableRight="@drawable/ic_arrow_down"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/add_language"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body3"/>
|
||||
|
||||
</LinearLayout>
|
||||
<include layout="@layout/item_localized_name"/>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
|
|
56
android/res/layout/item_localized_name.xml
Normal file
56
android/res/layout/item_localized_name.xml
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/margin_base"
|
||||
android:animateLayoutChanges="true"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingEnd="@dimen/margin_base"
|
||||
android:paddingLeft="@dimen/margin_base"
|
||||
android:paddingRight="@dimen/margin_base"
|
||||
android:paddingStart="@dimen/margin_base">
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/input"
|
||||
style="@style/MwmWidget.Editor.FieldLayout.EditText"
|
||||
android:hint="@string/editor_edit_place_name_hint"
|
||||
android:singleLine="true"/>
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/show_langs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/height_block_base"
|
||||
android:background="?clickableBackground"
|
||||
android:fontFamily="@string/robotoMedium"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/other_languages"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body3"
|
||||
tools:drawableRight="@drawable/ic_expand_more"
|
||||
tools:ignore="UnusedAttribute"/>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/names"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/add_langs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/height_block_base"
|
||||
android:background="?clickableBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/add_language"
|
||||
android:textAppearance="@style/MwmTextAppearance.Button"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -6,6 +6,7 @@ import android.support.annotation.NonNull;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -23,6 +24,7 @@ import com.mapswithme.maps.editor.data.Timetable;
|
|||
import com.mapswithme.util.InputUtils;
|
||||
import com.mapswithme.util.StringUtils;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import org.solovyev.android.views.llm.LinearLayoutManager;
|
||||
|
||||
public class EditorFragment extends BaseMwmFragment implements View.OnClickListener
|
||||
{
|
||||
|
@ -31,7 +33,9 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
|
|||
private View mCardAddress;
|
||||
private View mCardMetadata;
|
||||
private EditText mName;
|
||||
private TextView mLocalizedNames;
|
||||
private RecyclerView mLocalizedNames;
|
||||
private View mLocalizedAdd;
|
||||
private View mLocalizedShow;
|
||||
private TextView mStreet;
|
||||
private EditText mHouseNumber;
|
||||
private EditText mZipcode;
|
||||
|
@ -69,8 +73,6 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
|
|||
initViews(view);
|
||||
|
||||
mCategory.setText(Editor.nativeGetCategory());
|
||||
// TODO(yunikkk): Add multilanguages support.
|
||||
UiUtils.hide(mLocalizedNames);
|
||||
mName.setText(Editor.nativeGetDefaultName());
|
||||
mStreet.setText(Editor.nativeGetStreet());
|
||||
mHouseNumber.setText(Editor.nativeGetHouseNumber());
|
||||
|
@ -200,7 +202,11 @@ public class EditorFragment extends BaseMwmFragment implements View.OnClickListe
|
|||
mCardAddress = view.findViewById(R.id.cv__address);
|
||||
mCardMetadata = view.findViewById(R.id.cv__metadata);
|
||||
mName = findInput(mCardName);
|
||||
mLocalizedNames = (TextView) view.findViewById(R.id.name_multilang);
|
||||
mLocalizedAdd = view.findViewById(R.id.add_langs);
|
||||
mLocalizedShow = view.findViewById(R.id.show_langs);
|
||||
mLocalizedNames = (RecyclerView) view.findViewById(R.id.names);
|
||||
mLocalizedNames.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
mLocalizedNames.setAdapter(new MultilanguageAdapter(Editor.nativeGetLocalizedNames()));
|
||||
// Address
|
||||
view.findViewById(R.id.block_street).setOnClickListener(this);
|
||||
mStreet = (TextView) view.findViewById(R.id.street);
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package com.mapswithme.maps.editor;
|
||||
|
||||
import android.support.v7.util.SortedList;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.util.SortedListAdapterCallback;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.editor.data.LocalizedName;
|
||||
|
||||
public class MultilanguageAdapter extends RecyclerView.Adapter<MultilanguageAdapter.Holder>
|
||||
{
|
||||
private SortedList<LocalizedName> mNames;
|
||||
|
||||
MultilanguageAdapter(LocalizedName[] names)
|
||||
{
|
||||
mNames = new SortedList<>(LocalizedName.class,
|
||||
new SortedListAdapterCallback<LocalizedName>(this)
|
||||
{
|
||||
@Override
|
||||
public int compare(LocalizedName o1, LocalizedName o2)
|
||||
{
|
||||
return o1.lang.compareTo(o2.lang);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(LocalizedName oldItem, LocalizedName newItem)
|
||||
{
|
||||
return oldItem.name.equals(newItem.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areItemsTheSame(LocalizedName item1, LocalizedName item2)
|
||||
{
|
||||
return item1.code == item2.code;
|
||||
}
|
||||
},
|
||||
names.length);
|
||||
|
||||
mNames.addAll(names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Holder onCreateViewHolder(ViewGroup parent, int viewType)
|
||||
{
|
||||
final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_localized_name, parent, false);
|
||||
return new Holder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(Holder holder, int position)
|
||||
{
|
||||
LocalizedName name = mNames.get(position);
|
||||
holder.input.setText(name.name);
|
||||
holder.input.setHint(name.lang);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount()
|
||||
{
|
||||
return mNames.size();
|
||||
}
|
||||
|
||||
public static class Holder extends RecyclerView.ViewHolder
|
||||
{
|
||||
EditText input;
|
||||
|
||||
public Holder(View itemView)
|
||||
{
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue