Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorАлександр Зацепин <az@mapswithme.com>2017-06-20 21:03:24 +0300
committerYuri Gorshenin <mipt.vi002@gmail.com>2017-07-05 16:41:38 +0300
commita594f77fae88e2c73ef479552b70daa60f717d7f (patch)
treef31545ea4d201fedbb2892c0c57e410df0385edc
parentca0bb787e642a7d52057603850baf80dec98abd9 (diff)
[android] Added base structures for UGC
-rw-r--r--android/AndroidManifest.xml2
-rw-r--r--android/src/com/mapswithme/maps/ugc/UGC.java16
-rw-r--r--android/src/com/mapswithme/maps/ugc/UGCEditorActivity.java51
-rw-r--r--android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java8
-rw-r--r--android/src/com/mapswithme/maps/ugc/UgcAverageRatingController.java56
-rw-r--r--android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java18
6 files changed, 149 insertions, 2 deletions
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml
index 6e16c326a1..745fd626a4 100644
--- a/android/AndroidManifest.xml
+++ b/android/AndroidManifest.xml
@@ -345,6 +345,8 @@
<activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>
+ <activity android:name=".ugc.UGCEditorActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
+
<receiver
android:name="com.mapswithme.maps.background.ConnectivityChangedReceiver"
android:enabled="true"
diff --git a/android/src/com/mapswithme/maps/ugc/UGC.java b/android/src/com/mapswithme/maps/ugc/UGC.java
index f6f7d9d59d..26de7af139 100644
--- a/android/src/com/mapswithme/maps/ugc/UGC.java
+++ b/android/src/com/mapswithme/maps/ugc/UGC.java
@@ -1,10 +1,13 @@
package com.mapswithme.maps.ugc;
+import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.mapswithme.util.concurrency.UiThread;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -12,6 +15,17 @@ import java.util.List;
public class UGC
{
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({ RATING_HORRIBLE, RATING_BAD, RATING_NORMAL, RATING_GOOD, RATING_EXCELLENT })
+
+ public @interface UGCRating
+ {}
+
+ public static final int RATING_HORRIBLE = 1;
+ public static final int RATING_BAD = 2;
+ public static final int RATING_NORMAL = 3;
+ public static final int RATING_GOOD = 4;
+ public static final int RATING_EXCELLENT = 5;
@NonNull
private final Rating[] mRatings;
@@ -62,7 +76,6 @@ public class UGC
mListener.onUGCReviewsObtained(reviews);
}
}, 500);
-
}
public static void setListener(@Nullable UGCListener listener)
@@ -130,6 +143,7 @@ public class UGC
public interface UGCListener
{
void onUGCReviewsObtained(@NonNull List<Review> reviews);
+
void onUGCRatingsObtained(@NonNull List<Rating> ratings);
}
}
diff --git a/android/src/com/mapswithme/maps/ugc/UGCEditorActivity.java b/android/src/com/mapswithme/maps/ugc/UGCEditorActivity.java
new file mode 100644
index 0000000000..5d6b43f239
--- /dev/null
+++ b/android/src/com/mapswithme/maps/ugc/UGCEditorActivity.java
@@ -0,0 +1,51 @@
+package com.mapswithme.maps.ugc;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.support.annotation.NonNull;
+import android.support.annotation.StyleRes;
+import android.support.v4.app.Fragment;
+
+import com.mapswithme.maps.R;
+import com.mapswithme.maps.base.BaseMwmFragmentActivity;
+import com.mapswithme.util.ThemeUtils;
+
+public class UGCEditorActivity extends BaseMwmFragmentActivity
+{
+ private static final String EXTRA_FEATURE_INDEX = "extra_feature_index";
+ private static final String EXTRA_RATING = "extra_rating";
+
+ public static void start(@NonNull Activity activity, int featureIndex, @UGC.UGCRating int rating)
+ {
+ final Intent i = new Intent(activity, UGCEditorActivity.class);
+ i.putExtra(EXTRA_FEATURE_INDEX, featureIndex);
+ i.putExtra(EXTRA_RATING, rating);
+ activity.startActivity(i);
+ activity.overridePendingTransition(R.anim.search_fade_in, R.anim.search_fade_out);
+ }
+
+ @Override
+ @StyleRes
+ public int getThemeResourceId(@NonNull String theme)
+ {
+ return ThemeUtils.getCardBgThemeResourceId(theme);
+ }
+
+ @Override
+ protected Class<? extends Fragment> getFragmentClass()
+ {
+ return UGCEditorFragment.class;
+ }
+
+ @Override
+ protected boolean useTransparentStatusBar()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean useColorStatusBar()
+ {
+ return true;
+ }
+}
diff --git a/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java b/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java
new file mode 100644
index 0000000000..76c97b2225
--- /dev/null
+++ b/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java
@@ -0,0 +1,8 @@
+package com.mapswithme.maps.ugc;
+
+import com.mapswithme.maps.base.BaseMwmFragment;
+
+
+public class UGCEditorFragment extends BaseMwmFragment
+{
+}
diff --git a/android/src/com/mapswithme/maps/ugc/UgcAverageRatingController.java b/android/src/com/mapswithme/maps/ugc/UgcAverageRatingController.java
new file mode 100644
index 0000000000..b96bb8c8ab
--- /dev/null
+++ b/android/src/com/mapswithme/maps/ugc/UgcAverageRatingController.java
@@ -0,0 +1,56 @@
+package com.mapswithme.maps.ugc;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.view.View;
+
+import com.mapswithme.maps.R;
+
+public class UgcAverageRatingController implements View.OnClickListener
+{
+ @Nullable
+ private final OnUgcRatingChangedListener mListener;
+
+ public UgcAverageRatingController(@NonNull View view, @Nullable OnUgcRatingChangedListener listener)
+ {
+ mListener = listener;
+ view.findViewById(R.id.iv__horrible).setOnClickListener(this);
+ view.findViewById(R.id.iv__bad).setOnClickListener(this);
+ view.findViewById(R.id.iv__normal).setOnClickListener(this);
+ view.findViewById(R.id.iv__good).setOnClickListener(this);
+ view.findViewById(R.id.iv__excellent).setOnClickListener(this);
+
+ }
+
+ @Override
+ public void onClick(View v)
+ {
+ if (mListener == null)
+ return;
+
+ switch (v.getId()){
+ case R.id.iv__horrible:
+ mListener.onRatingChanged(UGC.RATING_HORRIBLE);
+ break;
+ case R.id.iv__bad:
+ mListener.onRatingChanged(UGC.RATING_BAD);
+ break;
+ case R.id.iv__normal:
+ mListener.onRatingChanged(UGC.RATING_NORMAL);
+ break;
+ case R.id.good:
+ mListener.onRatingChanged(UGC.RATING_GOOD);
+ break;
+ case R.id.excellent:
+ mListener.onRatingChanged(UGC.RATING_EXCELLENT);
+ break;
+ default:
+ throw new AssertionError("Unknown rating view!");
+ }
+ }
+
+ public interface OnUgcRatingChangedListener
+ {
+ void onRatingChanged(@UGC.UGCRating int rating);
+ }
+}
diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
index fc44f53b6c..e0b493d6ee 100644
--- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
+++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java
@@ -70,7 +70,9 @@ import com.mapswithme.maps.viator.Viator;
import com.mapswithme.maps.viator.ViatorAdapter;
import com.mapswithme.maps.viator.ViatorProduct;
import com.mapswithme.maps.ugc.UGC;
+import com.mapswithme.maps.ugc.UGCEditorActivity;
import com.mapswithme.maps.ugc.UGCReviewAdapter;
+import com.mapswithme.maps.ugc.UgcAverageRatingController;
import com.mapswithme.maps.widget.ArrowView;
import com.mapswithme.maps.widget.BaseShadowController;
import com.mapswithme.maps.widget.LineCountTextView;
@@ -119,7 +121,8 @@ public class PlacePageView extends RelativeLayout
BannerController.BannerListener,
Viator.ViatorListener,
ViatorAdapter.ItemSelectedListener
- UGC.UGCListener
+ UGC.UGCListener,
+ UgcAverageRatingController.OnUgcRatingChangedListener
{
private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
private static final String TAG = PlacePageView.class.getSimpleName();
@@ -194,6 +197,9 @@ public class PlacePageView extends RelativeLayout
private View mUgcMoreReviews;
@Nullable
+ UgcAverageRatingController mUgcController;
+
+ @Nullable
BannerController mBannerController;
@Nullable
@@ -277,6 +283,15 @@ public class PlacePageView extends RelativeLayout
}
+ @Override
+ public void onRatingChanged(@UGC.UGCRating int rating)
+ {
+ if (mMapObject == null)
+ return;
+
+ UGCEditorActivity.start(getActivity(), mMapObject.getFeatureIndex(), rating);
+ }
+
public enum State
{
HIDDEN,
@@ -638,6 +653,7 @@ public class PlacePageView extends RelativeLayout
{
mUgcView = findViewById(R.id.ll__pp_ugc);
mUgcRating = findViewById(R.id.ll__pp_ugc_rating);
+ mUgcController = new UgcAverageRatingController(mUgcRating, this);
mUgcMoreReviews = findViewById(R.id.tv__pp_ugc_reviews_more);
RecyclerView rvHotelReview = (RecyclerView) findViewById(R.id.rv__pp_ugc_reviews);
rvHotelReview.setLayoutManager(new LinearLayoutManager(getContext()));