[android] Added toast when network connection not found, added hide mode for more btn, modified sharing text

This commit is contained in:
Dmitry Donskoy 2018-06-21 16:09:47 +03:00 committed by Aleksandr Zatsepin
parent 66ebd4a8ec
commit 798836842e
8 changed files with 38 additions and 11 deletions

View file

@ -11,6 +11,7 @@
android:fontFamily="@string/robotoMedium"
android:text="@string/bookmarks"
tools:targetApi="jelly_bean"
android:background="@color/bookmarks_list_item_bg"
android:paddingEnd="@dimen/margin_base"
android:paddingRight="@dimen/margin_base"
android:paddingStart="@dimen/margin_base"

View file

@ -16,7 +16,6 @@ import android.view.ViewGroup;
import com.mapswithme.maps.R;
import com.mapswithme.maps.widget.PlaceholderView;
import com.mapswithme.maps.widget.recycler.ItemDecoratorFactory;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
@ -83,9 +82,6 @@ public abstract class BaseMwmRecyclerFragment<T extends RecyclerView.Adapter> ex
LinearLayoutManager manager = new LinearLayoutManager(view.getContext());
manager.setSmoothScrollbarEnabled(true);
mRecycler.setLayoutManager(manager);
RecyclerView.ItemDecoration decor = ItemDecoratorFactory
.createDefaultDecorator(getContext(), LinearLayoutManager.VERTICAL);
mRecycler.addItemDecoration(decor);
mAdapter = createAdapter();
mRecycler.setAdapter(mAdapter);

View file

@ -18,6 +18,7 @@ import android.widget.Toast;
import com.mapswithme.maps.R;
import com.mapswithme.maps.auth.BaseWebViewMwmFragment;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
import com.mapswithme.util.ConnectionState;
import com.mapswithme.util.UiUtils;
import java.lang.ref.WeakReference;
@ -179,6 +180,10 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
UiUtils.show(frag.mRetryBtn);
UiUtils.hide(frag.mWebView, frag.mProgressView);
if (ConnectionState.isConnected())
return;
Toast.makeText(frag.getContext(), R.string.common_check_internet_connection_dialog_title, Toast.LENGTH_SHORT)
.show();
}
private void retry()

View file

@ -7,6 +7,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.Menu;
@ -25,6 +26,7 @@ import com.mapswithme.maps.bookmarks.data.BookmarkSharingResult;
import com.mapswithme.maps.bookmarks.data.Track;
import com.mapswithme.maps.widget.placepage.EditBookmarkFragment;
import com.mapswithme.maps.widget.placepage.Sponsored;
import com.mapswithme.maps.widget.recycler.ItemDecoratorFactory;
import com.mapswithme.maps.widget.recycler.RecyclerClickListener;
import com.mapswithme.maps.widget.recycler.RecyclerLongClickListener;
import com.mapswithme.util.BottomSheetHelper;
@ -77,6 +79,14 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
ActionBar bar = ((AppCompatActivity) getActivity()).getSupportActionBar();
if (bar != null)
bar.setTitle(mCategory.getName());
addRecyclerDecor();
}
private void addRecyclerDecor()
{
RecyclerView.ItemDecoration decor = ItemDecoratorFactory
.createDefaultDecorator(getContext(), LinearLayoutManager.VERTICAL);
getRecyclerView().addItemDecoration(decor);
}
@Override

View file

@ -69,8 +69,8 @@ public class CachedBookmarkCategoriesFragment extends BaseBookmarkCategoriesFrag
String deepLink = BookmarkManager.INSTANCE.getCatalogDeeplink(category.getId());
Intent intent = new Intent(Intent.ACTION_SEND)
.setType(TargetUtils.TYPE_TEXT_PLAIN)
.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name))
.putExtra(Intent.EXTRA_TEXT, deepLink);
.putExtra(Intent.EXTRA_SUBJECT, deepLink)
.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_bookmarks_email_body));
startActivity(Intent.createChooser(intent, getString(R.string.share)));
}

View file

@ -441,10 +441,13 @@ public class Holders
{
super(itemView, category);
mDescText = itemView.findViewById(R.id.text);
mMoreBtn = itemView.findViewById(R.id.more_btn);
mMoreBtn.setOnClickListener(this::onMoreBtnClicked);
mTitle = itemView.findViewById(R.id.title);
mAuthor = itemView.findViewById(R.id.author);
mMoreBtn = itemView.findViewById(R.id.more_btn);
boolean isEmptyDesc = TextUtils.isEmpty(category.getDescription());
UiUtils.hideIf(isEmptyDesc, mMoreBtn);
mMoreBtn.setOnClickListener(this::onMoreBtnClicked);
}
private void onMoreBtnClicked(@NonNull View v)

View file

@ -214,6 +214,18 @@ public final class UiUtils
view.setVisibility(condition ? View.VISIBLE : View.GONE);
}
public static void hideIf(boolean condition, View... views)
{
if (condition)
{
hide(views);
}
else
{
show(views);
}
}
public static void showIf(boolean condition, View... views)
{
if (condition)

View file

@ -44,6 +44,7 @@ public enum SharingHelper
private static final String TAG = SharingHelper.class.getSimpleName();
private static final String PREFS_STORAGE = "sharing";
private static final String PREFS_KEY_ITEMS = "items";
private static final String KMZ_MIME_TYPE = "application/vnd.google-earth.kmz";
private final SharedPreferences mPrefs
= MwmApplication.get().getSharedPreferences(PREFS_STORAGE, Context.MODE_PRIVATE);
@ -206,14 +207,13 @@ public enum SharingHelper
}
private static void shareBookmarksCategory(@NonNull Activity context,
@NonNull BookmarkSharingResult result)
@NonNull BookmarkSharingResult result)
{
switch (result.getCode())
{
case BookmarkSharingResult.SUCCESS:
String name = new File(result.getSharingPath()).getName();
shareOutside(new LocalFileShareable(context, result.getSharingPath(),
"application/vnd.google-earth.kmz")
shareOutside(new LocalFileShareable(context, result.getSharingPath(), KMZ_MIME_TYPE)
.setText(context.getString(R.string.share_bookmarks_email_body))
.setSubject(R.string.share_bookmarks_email_subject));
break;