made repo interaction icons to has bigger clickable area to fix #137

This commit is contained in:
Kosh 2017-03-18 20:01:17 +08:00
parent 7166e5bc81
commit baf552ea09
8 changed files with 170 additions and 220 deletions

View File

@ -7,11 +7,11 @@ import android.view.View;
import com.annimon.stream.Collectors;
import com.annimon.stream.Stream;
import com.fastaccess.data.dao.NameParser;
import com.fastaccess.data.dao.SimpleUrlsModel;
import com.fastaccess.data.dao.model.Event;
import com.fastaccess.data.dao.model.Login;
import com.fastaccess.data.dao.NameParser;
import com.fastaccess.data.dao.model.Repo;
import com.fastaccess.data.dao.SimpleUrlsModel;
import com.fastaccess.data.dao.types.EventsType;
import com.fastaccess.helper.InputHelper;
import com.fastaccess.helper.RxHelper;
@ -107,14 +107,14 @@ class FeedsPresenter extends BasePresenter<FeedsMvp.View> implements FeedsMvp.Pr
RepoPagerView.startRepoPager(v.getContext(), parser);
} else {
if (item.getPayload() != null && item.getPayload().getIssue() != null) {
SchemeParser.launchUri(v.getContext(), Uri.parse(item.getPayload().getIssue().getHtmlUrl()));
SchemeParser.launchUri(v.getContext(), Uri.parse(item.getPayload().getIssue().getHtmlUrl()), true);
} else if (item.getPayload() != null && item.getPayload().getPullRequest() != null) {
SchemeParser.launchUri(v.getContext(), Uri.parse(item.getPayload().getPullRequest().getHtmlUrl()));
SchemeParser.launchUri(v.getContext(), Uri.parse(item.getPayload().getPullRequest().getHtmlUrl()), true);
} else {
Repo repoModel = item.getRepo();
String name = InputHelper.isEmpty(repoModel.getName()) ? repoModel.getFullName() : repoModel.getName();
if (name == null) return;
if (item.getRepo() != null) SchemeParser.launchUri(v.getContext(), Uri.parse(name));
if (item.getRepo() != null) SchemeParser.launchUri(v.getContext(), Uri.parse(name), true);
}
}
}

View File

@ -15,6 +15,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
import com.fastaccess.R;
import com.fastaccess.data.dao.NameParser;
@ -33,6 +34,7 @@ import com.fastaccess.ui.modules.repos.code.RepoCodePagerView;
import com.fastaccess.ui.modules.repos.issues.RepoIssuesPagerView;
import com.fastaccess.ui.widgets.AvatarLayout;
import com.fastaccess.ui.widgets.FontTextView;
import com.fastaccess.ui.widgets.ForegroundImageView;
import com.fastaccess.ui.widgets.color.ColorGenerator;
import com.fastaccess.ui.widgets.dialog.MessageDialogView;
@ -66,6 +68,13 @@ public class RepoPagerView extends BaseActivity<RepoPagerMvp.View, RepoPagerPres
@BindView(R.id.fab) FloatingActionButton fab;
@BindView(R.id.language) FontTextView language;
@BindView(R.id.detailsIcon) View detailsIcon;
@BindView(R.id.watchRepoImage) ForegroundImageView watchRepoImage;
@BindView(R.id.starRepoImage) ForegroundImageView starRepoImage;
@BindView(R.id.forkRepoImage) ForegroundImageView forkRepoImage;
@BindView(R.id.licenseLayout) LinearLayout licenseLayout;
@BindView(R.id.watchRepoLayout) LinearLayout watchRepoLayout;
@BindView(R.id.starRepoLayout) LinearLayout starRepoLayout;
@BindView(R.id.forkRepoLayout) LinearLayout forkRepoLayout;
@State @RepoPagerMvp.RepoNavigationType int navType;
@State String login;
@State String repoId;
@ -120,21 +129,21 @@ public class RepoPagerView extends BaseActivity<RepoPagerMvp.View, RepoPagerPres
}
}
@SuppressWarnings("ConstantConditions") @OnClick({R.id.forkRepo, R.id.starRepo, R.id.watchRepo}) void onClick(View view) {
@SuppressWarnings("ConstantConditions") @OnClick({R.id.forkRepoLayout, R.id.starRepoLayout, R.id.watchRepoLayout}) void onClick(View view) {
switch (view.getId()) {
case R.id.forkRepo:
case R.id.forkRepoLayout:
MessageDialogView.newInstance(getString(R.string.fork), getString(R.string.confirm_message),
Bundler.start().put(BundleConstant.EXTRA, true).end())
.show(getSupportFragmentManager(), MessageDialogView.TAG);
break;
case R.id.starRepo:
case R.id.starRepoLayout:
if (getPresenter().login() != null && getPresenter().repoId() != null) {
GithubActionService.startForRepo(this, getPresenter().login(), getPresenter().repoId(),
getPresenter().isStarred() ? GithubActionService.UNSTAR_REPO : GithubActionService.STAR_REPO);
getPresenter().onStar();
}
break;
case R.id.watchRepo:
case R.id.watchRepoLayout:
if (getPresenter().login() != null && getPresenter().repoId() != null) {
GithubActionService.startForRepo(this, getPresenter().login(), getPresenter().repoId(),
getPresenter().isWatched() ? GithubActionService.UNWATCH_REPO : GithubActionService.WATCH_REPO);
@ -227,8 +236,10 @@ public class RepoPagerView extends BaseActivity<RepoPagerMvp.View, RepoPagerPres
title.setText(repoModel.getFullName());
TextViewCompat.setTextAppearance(title, R.style.TextAppearance_AppCompat_Medium);
title.setTextColor(ContextCompat.getColor(this, R.color.primary_text));
license.setVisibility(repoModel.getLicense() != null ? View.VISIBLE : View.GONE);
if (repoModel.getLicense() != null) license.setText(repoModel.getLicense().getSpdxId());
if (!InputHelper.isEmpty(repoModel.getLicense())) {
licenseLayout.setVisibility(View.VISIBLE);
license.setText(repoModel.getLicense().getSpdxId());
}
supportInvalidateOptionsMenu();
if (!PrefGetter.isRepoGuideShowed()) {// the mother of nesting. #dontjudgeme.
new MaterialTapTargetPrompt.Builder(this)
@ -263,30 +274,31 @@ public class RepoPagerView extends BaseActivity<RepoPagerMvp.View, RepoPagerPres
}
@Override public void onRepoWatched(boolean isWatched) {
watchRepo.setTopDrawable(R.drawable.ic_eye, isWatched ? accentColor : blackColor);
watchRepoImage.tintDrawableColor(isWatched ? accentColor : blackColor);
onEnableDisableWatch(true);
}
@Override public void onRepoStarred(boolean isStarred) {
starRepo.setTopDrawable(isStarred ? R.drawable.ic_star_filled : R.drawable.ic_star, isStarred ? accentColor : blackColor);
starRepoImage.setImageResource(isStarred ? R.drawable.ic_star_filled : R.drawable.ic_star);
starRepoImage.tintDrawableColor(isStarred ? accentColor : blackColor);
onEnableDisableStar(true);
}
@Override public void onRepoForked(boolean isForked) {
forkRepo.setTopDrawable(R.drawable.ic_fork, isForked ? accentColor : blackColor);
forkRepoImage.tintDrawableColor(isForked ? accentColor : blackColor);
onEnableDisableFork(true);
}
@Override public void onEnableDisableWatch(boolean isEnabled) {
watchRepo.setEnabled(isEnabled);
watchRepoLayout.setEnabled(isEnabled);
}
@Override public void onEnableDisableStar(boolean isEnabled) {
starRepo.setEnabled(isEnabled);
starRepoLayout.setEnabled(isEnabled);
}
@Override public void onEnableDisableFork(boolean isEnabled) {
forkRepo.setEnabled(isEnabled);
forkRepoLayout.setEnabled(isEnabled);
}
@Override public void onChangeWatchedCount(boolean isWatched) {

View File

@ -22,19 +22,22 @@ public class ForegroundImageView extends AppCompatImageView {
private Drawable foreground;
private Toast toast;
public ForegroundImageView(Context context) {
this(context, null);
}
public ForegroundImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
setOnLongClickListener(view -> {
if (toast != null) toast.cancel();
toast = Toast.makeText(getContext(), getContentDescription(), Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
return true;
});
if (getContentDescription() != null) {
setOnLongClickListener(view -> {
if (toast != null) toast.cancel();
toast = Toast.makeText(getContext(), getContentDescription(), Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
return true;
});
}
}
public ForegroundImageView(Context context, AttributeSet attrs, int defStyleAttr) {
@ -113,6 +116,10 @@ public class ForegroundImageView extends AppCompatImageView {
}
}
public void tintDrawableColor(@ColorInt int colorRes) {
tintDrawableFromColor(colorRes);
}
public void tintDrawable(@ColorRes int colorRes) {
tintDrawableFromColor(ContextCompat.getColor(getContext(), colorRes));
}

View File

@ -21,70 +21,7 @@
android:minHeight="?actionBarSize"
app:theme="@style/ToolbarStyleDark">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal"
android:padding="@dimen/spacing_normal">
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/watchRepo"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:layout_marginEnd="@dimen/spacing_xs_large"
android:background="?selectableItemBackgroundBorderless"
android:drawablePadding="@dimen/spacing_normal"
android:drawableTop="@drawable/ic_eye"
android:gravity="center"
tools:text="100,000"/>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/starRepo"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:layout_marginEnd="@dimen/spacing_xs_large"
android:background="?selectableItemBackgroundBorderless"
android:drawablePadding="@dimen/spacing_normal"
android:drawableTop="@drawable/ic_star"
android:gravity="center"
android:scaleType="centerCrop"
tools:text="100,000"/>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/forkRepo"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:background="?selectableItemBackgroundBorderless"
android:drawablePadding="@dimen/spacing_normal"
android:drawableTop="@drawable/ic_fork"
android:gravity="center"
tools:text="100,000"/>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/license"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:background="?selectableItemBackgroundBorderless"
android:drawablePadding="@dimen/spacing_normal"
android:drawableTop="@drawable/ic_license"
android:layout_marginStart="@dimen/spacing_xs_large"
android:gravity="center"
android:maxLength="6"
android:maxLines="1"
android:visibility="gone"
tools:text="Apache"
tools:visibility="visible"/>
</LinearLayout>
<include layout="@layout/repo_header_icons_layout"/>
</android.support.v7.widget.Toolbar>

View File

@ -21,71 +21,7 @@
android:minHeight="?actionBarSize"
app:theme="@style/ToolbarStyleDark">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal"
android:padding="@dimen/spacing_normal">
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/watchRepo"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:layout_marginEnd="@dimen/spacing_xs_large"
android:background="?selectableItemBackgroundBorderless"
android:drawablePadding="@dimen/spacing_normal"
android:drawableTop="@drawable/ic_eye"
android:gravity="center"
tools:text="100,000"/>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/starRepo"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:layout_marginEnd="@dimen/spacing_xs_large"
android:background="?selectableItemBackgroundBorderless"
android:drawablePadding="@dimen/spacing_normal"
android:drawableTop="@drawable/ic_star"
android:gravity="center"
android:scaleType="centerCrop"
tools:text="100,000"/>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/forkRepo"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:background="?selectableItemBackgroundBorderless"
android:drawablePadding="@dimen/spacing_normal"
android:drawableTop="@drawable/ic_fork"
android:gravity="center"
tools:text="100,000"/>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/license"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:background="?selectableItemBackgroundBorderless"
android:drawablePadding="@dimen/spacing_normal"
android:layout_marginStart="@dimen/spacing_xs_large"
android:drawableTop="@drawable/ic_license"
android:gravity="center"
android:maxLength="6"
android:maxLines="1"
android:visibility="gone"
tools:text="Apache"
tools:visibility="visible"/>
</LinearLayout>
<include layout="@layout/repo_header_icons_layout"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>

View File

@ -3,7 +3,6 @@
android:id="@+id/appbar"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent"
@ -20,70 +19,7 @@
android:minHeight="?actionBarSize"
app:theme="@style/ToolbarStyleDark">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal"
android:padding="@dimen/spacing_normal">
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/watchRepo"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:layout_marginEnd="@dimen/spacing_xs_large"
android:background="?selectableItemBackgroundBorderless"
android:drawablePadding="@dimen/spacing_normal"
android:drawableTop="@drawable/ic_eye"
android:gravity="center"
tools:text="100,000"/>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/starRepo"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:layout_marginEnd="@dimen/spacing_xs_large"
android:background="?selectableItemBackgroundBorderless"
android:drawablePadding="@dimen/spacing_normal"
android:drawableTop="@drawable/ic_star"
android:gravity="center"
android:scaleType="centerCrop"
tools:text="100,000"/>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/forkRepo"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:background="?selectableItemBackgroundBorderless"
android:drawablePadding="@dimen/spacing_normal"
android:drawableTop="@drawable/ic_fork"
android:gravity="center"
tools:text="100,000"/>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/license"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|end"
android:background="?selectableItemBackgroundBorderless"
android:drawablePadding="@dimen/spacing_normal"
android:drawableTop="@drawable/ic_license"
android:layout_marginStart="@dimen/spacing_xs_large"
android:gravity="center"
android:maxLength="6"
android:maxLines="1"
android:visibility="gone"
tools:text="Apache"
tools:visibility="visible"/>
</LinearLayout>
<include layout="@layout/repo_header_icons_layout"/>
</android.support.v7.widget.Toolbar>

View File

@ -0,0 +1,121 @@
<?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:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal"
android:padding="@dimen/spacing_normal"
tools:showIn="@layout/header_title_with_toolbar">
<LinearLayout
android:id="@+id/watchRepoLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/spacing_normal"
android:background="?selectableItemBackgroundBorderless"
android:gravity="center"
android:orientation="vertical">
<com.fastaccess.ui.widgets.ForegroundImageView
android:id="@+id/watchRepoImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/spacing_normal"
android:src="@drawable/ic_eye"/>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/watchRepo"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
tools:text="100,000"/>
</LinearLayout>
<LinearLayout
android:id="@+id/starRepoLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/spacing_normal"
android:background="?selectableItemBackgroundBorderless"
android:gravity="center"
android:orientation="vertical">
<com.fastaccess.ui.widgets.ForegroundImageView
android:id="@+id/starRepoImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/spacing_normal"
android:src="@drawable/ic_star"/>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/starRepo"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
tools:text="100,000"/>
</LinearLayout>
<LinearLayout
android:id="@+id/forkRepoLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless"
android:gravity="center"
android:orientation="vertical">
<com.fastaccess.ui.widgets.ForegroundImageView
android:id="@+id/forkRepoImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/spacing_normal"
android:src="@drawable/ic_fork"/>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/forkRepo"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
tools:text="100,000"/>
</LinearLayout>
<LinearLayout
android:id="@+id/licenseLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_normal"
android:background="?selectableItemBackgroundBorderless"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<com.fastaccess.ui.widgets.ForegroundImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/mal_title_licenses"
android:padding="@dimen/spacing_normal"
android:src="@drawable/ic_license"/>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/license"
style="@style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:maxLength="6"
android:maxLines="1"
tools:text="Apache"/>
</LinearLayout>
</LinearLayout>

View File

@ -47,12 +47,13 @@
android:textColor="@color/primary_text"
tools:text="One must invent the visitor in order to Bliss happens when you follow art so compassionately that whatsoever you are luring is your relativity.praise the sinner of remarkable vision."/>
<ImageView
<com.fastaccess.ui.widgets.ForegroundImageView
android:id="@+id/detailsIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/description"
android:src="@drawable/ic_issues"
android:visibility="gone"
tools:visibility="visible"/>
@ -60,7 +61,7 @@
</LinearLayout>
<LinearLayout
android:layout_width="318dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_micro"
android:orientation="horizontal">