forked from organicmaps/organicmaps
[android] Implemented writing UGC review UI
This commit is contained in:
parent
cf324e4bbb
commit
208fe1926a
6 changed files with 90 additions and 78 deletions
|
@ -364,7 +364,15 @@
|
|||
|
||||
<activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>
|
||||
|
||||
<activity android:name=".ugc.UGCEditorActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
|
||||
<activity
|
||||
android:name=".ugc.UGCEditorActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:parentActivityName=".MwmActivity">
|
||||
<!-- The meta-data element is needed for versions lower than 4.1 -->
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.mapswithme.maps.MwmActivity"/>
|
||||
</activity>
|
||||
|
||||
<receiver
|
||||
android:name="com.mapswithme.maps.background.ConnectivityChangedReceiver"
|
||||
|
|
|
@ -1,58 +1,66 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:background="?cardBackground"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/MwmWidget.ToolbarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/rv__ratings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:listitem="@layout/item_ugc_rating"/>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="@dimen/margin_base"
|
||||
android:layout_marginRight="@dimen/margin_base"
|
||||
android:background="?dividerHorizontal"/>
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:theme="@style/MwmWidget.ToolbarTheme">
|
||||
<ImageView
|
||||
android:id="@+id/send"
|
||||
android:layout_width="?actionBarSize"
|
||||
android:layout_height="?actionBarSize"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_done"/>
|
||||
</android.support.v7.widget.Toolbar>
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<LinearLayout
|
||||
android:padding="@dimen/margin_base"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="@dimen/margin_half"
|
||||
android:background="?cardBackground"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/ratings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body1.Secondary"
|
||||
android:text="What is the best food in Sorochani?"
|
||||
/>
|
||||
tools:listitem="@layout/item_ugc_rating"/>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/divider_height"
|
||||
android:background="?dividerHorizontal"/>
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/input_layout"
|
||||
android:layout_marginTop="@dimen/margin_base"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<EditText
|
||||
android:id="@+id/review"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/rating_user_review_min_height"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body1"
|
||||
android:gravity="top"
|
||||
android:maxLength="400"
|
||||
android:paddingLeft="@dimen/margin_base"
|
||||
android:paddingStart="@dimen/margin_base"
|
||||
android:paddingRight="@dimen/margin_base"
|
||||
android:paddingEnd="@dimen/margin_base"
|
||||
android:paddingBottom="@dimen/margin_base"
|
||||
android:textColorHint="?android:textColorSecondary"
|
||||
android:inputType="textCapSentences"
|
||||
android:hint="What's good or bad here?"/>
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
</LinearLayout>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?dividerHorizontal"/>
|
||||
<EditText
|
||||
android:id="@+id/et_review"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="152dp"
|
||||
android:gravity="top"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLength="400"
|
||||
android:paddingLeft="@dimen/margin_base"
|
||||
android:paddingStart="@dimen/margin_base"
|
||||
android:paddingEnd="@dimen/margin_base"
|
||||
android:paddingRight="@dimen/margin_base"
|
||||
android:hint="Write a review, if possible in English"/>
|
||||
<Button
|
||||
android:id="@+id/submit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/MwmWidget.Button.Start"
|
||||
android:text="Submit"
|
||||
android:textAllCaps="true"/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -2,12 +2,7 @@
|
|||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:paddingLeft="@dimen/margin_base"
|
||||
android:paddingStart="@dimen/margin_base"
|
||||
android:paddingRight="@dimen/margin_base"
|
||||
android:paddingEnd="@dimen/margin_base"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="14dp"
|
||||
android:padding="@dimen/margin_base"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
|
@ -17,8 +12,7 @@
|
|||
android:textAppearance="@style/MwmTextAppearance.Body1"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:paddingBottom="@dimen/margin_quarter_plus"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@+id/rb__rate"
|
||||
android:layout_toStartOf="@+id/rb__rate"
|
||||
tools:text="Service"/>
|
||||
|
|
|
@ -215,4 +215,7 @@
|
|||
<dimen name="rating_view_height">40dp</dimen>
|
||||
<dimen name="rating_view_height_small">20dp</dimen>
|
||||
<dimen name="rating_view_background_radius">20dp</dimen>
|
||||
<dimen name="rating_user_review_min_height">152dp</dimen>
|
||||
|
||||
<dimen name="divider_height">1dp</dimen>
|
||||
</resources>
|
||||
|
|
|
@ -2,16 +2,14 @@ package com.mapswithme.maps.ugc;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StyleRes;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import com.mapswithme.maps.base.BaseToolbarActivity;
|
||||
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
|
||||
import com.mapswithme.util.ThemeUtils;
|
||||
|
||||
public class UGCEditorActivity extends BaseToolbarActivity
|
||||
public class UGCEditorActivity extends BaseMwmFragmentActivity
|
||||
{
|
||||
private static final String EXTRA_FEATURE_INDEX = "extra_feature_index";
|
||||
static final String EXTRA_UGC = "extra_ugc";
|
||||
|
@ -29,13 +27,6 @@ public class UGCEditorActivity extends BaseToolbarActivity
|
|||
activity.startActivity(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
getToolbar().setTitle(getIntent().getStringExtra(EXTRA_TITLE));
|
||||
}
|
||||
|
||||
@Override
|
||||
@StyleRes
|
||||
public int getThemeResourceId(@NonNull String theme)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.mapswithme.maps.ugc;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
@ -10,12 +11,12 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmFragment;
|
||||
import com.mapswithme.maps.base.BaseMwmToolbarFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class UGCEditorFragment extends BaseMwmFragment
|
||||
public class UGCEditorFragment extends BaseMwmToolbarFragment
|
||||
{
|
||||
@NonNull
|
||||
private final UGCRatingAdapter mUGCRatingAdapter = new UGCRatingAdapter();
|
||||
|
@ -25,22 +26,30 @@ public class UGCEditorFragment extends BaseMwmFragment
|
|||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
View root = inflater.inflate(R.layout.fragment_ugc_editor, container, false);
|
||||
RecyclerView rvRatingView = (RecyclerView) root.findViewById(R.id.rv__ratings);
|
||||
RecyclerView rvRatingView = (RecyclerView) root.findViewById(R.id.ratings);
|
||||
rvRatingView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
rvRatingView.getLayoutManager().setAutoMeasureEnabled(true);
|
||||
rvRatingView.setNestedScrollingEnabled(false);
|
||||
rvRatingView.setHasFixedSize(false);
|
||||
rvRatingView.setAdapter(mUGCRatingAdapter);
|
||||
|
||||
//TODO: use parcelable instead of seriliazable
|
||||
UGC ugc = (UGC) getActivity().getIntent().getSerializableExtra(UGCEditorActivity.EXTRA_UGC);
|
||||
//TODO: use parcelable instead of serializable
|
||||
Intent intent = getActivity().getIntent();
|
||||
UGC ugc = (UGC) intent.getSerializableExtra(UGCEditorActivity.EXTRA_UGC);
|
||||
List<UGC.Rating> avgRatings = new ArrayList<>(ugc.getRatings());
|
||||
for (UGC.Rating rating: avgRatings)
|
||||
rating.setValue(getActivity().getIntent().getIntExtra(UGCEditorActivity.EXTRA_AVG_RATING, 3));
|
||||
mUGCRatingAdapter.setItems(avgRatings);
|
||||
|
||||
View submit = root.findViewById(R.id.submit);
|
||||
submit.setOnClickListener(new View.OnClickListener()
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
View save = mToolbarController.findViewById(R.id.send);
|
||||
save.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
|
@ -48,8 +57,7 @@ public class UGCEditorFragment extends BaseMwmFragment
|
|||
getActivity().finish();
|
||||
}
|
||||
});
|
||||
return root;
|
||||
|
||||
|
||||
Intent intent = getActivity().getIntent();
|
||||
mToolbarController.setTitle(intent.getStringExtra(UGCEditorActivity.EXTRA_TITLE));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue