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:
authorSergey Magidovich <mgsergio@mapswithme.com>2016-06-22 17:38:43 +0300
committerVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-06-24 16:02:12 +0300
commit4f4fad3f51f8c97e7e644d7b8cfd3d4fcd4b48f8 (patch)
tree2a2b7d45697b977323a04c61b0b7a753c069bb14 /android
parent742e141d8a34860d40c47f1d7f505c087fac404d (diff)
Add BottomSheet with refresh and logout.
Diffstat (limited to 'android')
-rw-r--r--android/res/drawable-hdpi/ic_leaderboard.pngbin0 -> 283 bytes
-rw-r--r--android/res/drawable-hdpi/ic_more.pngbin0 -> 101 bytes
-rw-r--r--android/res/drawable-ldpi/ic_leadreboard.pngbin0 -> 185 bytes
-rw-r--r--android/res/drawable-ldpi/ic_more.pngbin0 -> 108 bytes
-rw-r--r--android/res/drawable-mdpi/ic_leaderboard.pngbin0 -> 215 bytes
-rw-r--r--android/res/drawable-mdpi/ic_more.pngbin0 -> 88 bytes
-rw-r--r--android/res/drawable-xhdpi/ic_leaderboard.pngbin0 -> 341 bytes
-rw-r--r--android/res/drawable-xhdpi/ic_more.pngbin0 -> 115 bytes
-rw-r--r--android/res/drawable-xxhdpi/ic_leaderboard.pngbin0 -> 496 bytes
-rw-r--r--android/res/drawable-xxhdpi/ic_more.pngbin0 -> 150 bytes
-rw-r--r--android/res/layout/fragment_auth_editor.xml6
-rw-r--r--android/src/com/mapswithme/maps/editor/ProfileFragment.java78
12 files changed, 71 insertions, 13 deletions
diff --git a/android/res/drawable-hdpi/ic_leaderboard.png b/android/res/drawable-hdpi/ic_leaderboard.png
new file mode 100644
index 0000000000..c5a6bd193e
--- /dev/null
+++ b/android/res/drawable-hdpi/ic_leaderboard.png
Binary files differ
diff --git a/android/res/drawable-hdpi/ic_more.png b/android/res/drawable-hdpi/ic_more.png
new file mode 100644
index 0000000000..3f97515006
--- /dev/null
+++ b/android/res/drawable-hdpi/ic_more.png
Binary files differ
diff --git a/android/res/drawable-ldpi/ic_leadreboard.png b/android/res/drawable-ldpi/ic_leadreboard.png
new file mode 100644
index 0000000000..477f80abef
--- /dev/null
+++ b/android/res/drawable-ldpi/ic_leadreboard.png
Binary files differ
diff --git a/android/res/drawable-ldpi/ic_more.png b/android/res/drawable-ldpi/ic_more.png
new file mode 100644
index 0000000000..fde57e5936
--- /dev/null
+++ b/android/res/drawable-ldpi/ic_more.png
Binary files differ
diff --git a/android/res/drawable-mdpi/ic_leaderboard.png b/android/res/drawable-mdpi/ic_leaderboard.png
new file mode 100644
index 0000000000..45e1c59aaf
--- /dev/null
+++ b/android/res/drawable-mdpi/ic_leaderboard.png
Binary files differ
diff --git a/android/res/drawable-mdpi/ic_more.png b/android/res/drawable-mdpi/ic_more.png
new file mode 100644
index 0000000000..d9b0267b77
--- /dev/null
+++ b/android/res/drawable-mdpi/ic_more.png
Binary files differ
diff --git a/android/res/drawable-xhdpi/ic_leaderboard.png b/android/res/drawable-xhdpi/ic_leaderboard.png
new file mode 100644
index 0000000000..576258ac53
--- /dev/null
+++ b/android/res/drawable-xhdpi/ic_leaderboard.png
Binary files differ
diff --git a/android/res/drawable-xhdpi/ic_more.png b/android/res/drawable-xhdpi/ic_more.png
new file mode 100644
index 0000000000..fed3172552
--- /dev/null
+++ b/android/res/drawable-xhdpi/ic_more.png
Binary files differ
diff --git a/android/res/drawable-xxhdpi/ic_leaderboard.png b/android/res/drawable-xxhdpi/ic_leaderboard.png
new file mode 100644
index 0000000000..ebd5db9a95
--- /dev/null
+++ b/android/res/drawable-xxhdpi/ic_leaderboard.png
Binary files differ
diff --git a/android/res/drawable-xxhdpi/ic_more.png b/android/res/drawable-xxhdpi/ic_more.png
new file mode 100644
index 0000000000..9b2b5f8c71
--- /dev/null
+++ b/android/res/drawable-xxhdpi/ic_more.png
Binary files differ
diff --git a/android/res/layout/fragment_auth_editor.xml b/android/res/layout/fragment_auth_editor.xml
index b67fbd9fd9..670add2329 100644
--- a/android/res/layout/fragment_auth_editor.xml
+++ b/android/res/layout/fragment_auth_editor.xml
@@ -15,13 +15,13 @@
android:theme="@style/MwmWidget.ToolbarTheme"
tools:ignore="UnusedAttribute">
<ImageView
- android:id="@+id/logout"
+ android:id="@+id/more"
android:layout_width="?actionBarSize"
android:layout_height="?actionBarSize"
android:layout_gravity="end|center_vertical"
android:background="?selectableItemBackgroundBorderless"
android:scaleType="center"
- android:src="@drawable/ic_logout"
+ android:src="@drawable/ic_more"
android:visibility="gone"/>
</android.support.v7.widget.Toolbar>
@@ -225,7 +225,7 @@
android:layout_marginLeft="@dimen/margin_half"
android:layout_marginStart="@dimen/margin_half"
android:scaleType="center"
- android:src="@drawable/ic_device"
+ android:src="@drawable/ic_leaderboard"
android:tint="?iconTint"/>
<LinearLayout
diff --git a/android/src/com/mapswithme/maps/editor/ProfileFragment.java b/android/src/com/mapswithme/maps/editor/ProfileFragment.java
index 55c0ef3230..d0d02c7322 100644
--- a/android/src/com/mapswithme/maps/editor/ProfileFragment.java
+++ b/android/src/com/mapswithme/maps/editor/ProfileFragment.java
@@ -3,16 +3,21 @@ package com.mapswithme.maps.editor;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
+import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
+import android.support.annotation.StringRes;
import android.text.format.DateUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Locale;
import com.mapswithme.maps.R;
import com.mapswithme.maps.editor.data.UserStats;
+import com.mapswithme.util.BottomSheetHelper;
import com.mapswithme.util.Constants;
import com.mapswithme.util.UiUtils;
@@ -23,12 +28,45 @@ public class ProfileFragment extends AuthFragment implements View.OnClickListene
private View mSentBlock;
private TextView mEditsSent;
private TextView mEditsSentDate;
- private View mLogout;
+ private View mMore;
private View mAuthBlock;
private View mRatingBlock;
private TextView mEditorRank;
private TextView mEditorLevelUp;
+ private enum MenuItem
+ {
+ LOGOUT(R.drawable.ic_logout, R.string.logout)
+ {
+ @Override
+ void invoke(ProfileFragment fragment)
+ {
+ OsmOAuth.clearAuthorization();
+ fragment.refreshViews();
+ }
+ },
+
+ REFRESH(R.drawable.ic_update, R.string.refresh)
+ {
+ @Override
+ void invoke(ProfileFragment fragment)
+ {
+ OsmOAuth.nativeUpdateOsmUserStats(OsmOAuth.getUsername(), true /* forceUpdate */);
+ }
+ };
+
+ final @DrawableRes int icon;
+ final @StringRes int title;
+
+ MenuItem(@DrawableRes int icon, @StringRes int title)
+ {
+ this.icon = icon;
+ this.title = title;
+ }
+
+ abstract void invoke(ProfileFragment fragment);
+ }
+
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
@@ -37,13 +75,13 @@ public class ProfileFragment extends AuthFragment implements View.OnClickListene
initViews(view);
refreshViews();
OsmOAuth.setUserStatsListener(this);
- OsmOAuth.nativeUpdateOsmUserStats(OsmOAuth.getUsername(), false /*forceUpdate*/);
+ OsmOAuth.nativeUpdateOsmUserStats(OsmOAuth.getUsername(), false /* forceUpdate */);
}
private void initViews(View view)
{
- mLogout = mToolbarController.findViewById(R.id.logout);
- mLogout.setOnClickListener(this);
+ mMore = mToolbarController.findViewById(R.id.more);
+ mMore.setOnClickListener(this);
View editsBlock = view.findViewById(R.id.block_edits);
UiUtils.show(editsBlock);
mLocalBlock = editsBlock.findViewById(R.id.local_edits);
@@ -64,13 +102,13 @@ public class ProfileFragment extends AuthFragment implements View.OnClickListene
{
if (OsmOAuth.isAuthorized())
{
- UiUtils.show(mLogout, mRatingBlock, mSentBlock);
+ UiUtils.show(mMore, mRatingBlock, mSentBlock);
UiUtils.hide(mAuthBlock);
}
else
{
UiUtils.show(mAuthBlock);
- UiUtils.hide(mLogout, mRatingBlock, mSentBlock);
+ UiUtils.hide(mMore, mRatingBlock, mSentBlock);
}
final long[] stats = Editor.nativeGetStats();
@@ -102,7 +140,7 @@ public class ProfileFragment extends AuthFragment implements View.OnClickListene
editsDate = DateUtils.formatDateTime(getActivity(), uploadSeconds * 1000, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME);
}
mEditsSent.setText(edits);
- mEditsSentDate.setText(String.format(Locale.US, getString(R.string.last_update), editsDate));
+ mEditsSentDate.setText(getString(R.string.last_update, editsDate));
mEditorRank.setText(String.valueOf(rank));
// FIXME show when it will be implemented on server
// mEditorLevelUp.setText(levelFeat);
@@ -113,9 +151,8 @@ public class ProfileFragment extends AuthFragment implements View.OnClickListene
{
switch (v.getId())
{
- case R.id.logout:
- OsmOAuth.clearAuthorization();
- refreshViews();
+ case R.id.more:
+ showBottomSheet();
break;
case R.id.about_osm:
startActivity(new Intent((Intent.ACTION_VIEW), Uri.parse(Constants.Url.OSM_ABOUT)));
@@ -134,4 +171,25 @@ public class ProfileFragment extends AuthFragment implements View.OnClickListene
else
refreshRatings(stats.editsCount, stats.uploadTimestampSeconds, stats.editorRank, stats.levelUp);
}
+
+ private void showBottomSheet()
+ {
+ List<MenuItem> items = new ArrayList<>();
+ items.add(MenuItem.REFRESH);
+ items.add(MenuItem.LOGOUT);
+
+ BottomSheetHelper.Builder bs = BottomSheetHelper.create(getActivity());
+ for (MenuItem item: items)
+ bs.sheet(item.ordinal(), item.icon, item.title);
+
+ bs.listener(new android.view.MenuItem.OnMenuItemClickListener()
+ {
+ @Override
+ public boolean onMenuItemClick(android.view.MenuItem item)
+ {
+ MenuItem.values()[item.getItemId()].invoke(ProfileFragment.this);
+ return false;
+ }
+ }).tint().show();
+ }
}