Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jrvansuita authored Feb 21, 2017
2 parents 7de7e8d + 76f9935 commit 038b1a8
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void loadAbout() {
.addChangeLogAction((Intent) null)
.addRemoveAdsAction((Intent) null)
.addDonateAction((Intent) null)
.setWrapScrollView(true)
.build());
}

Expand Down
7 changes: 3 additions & 4 deletions app/src/main/res/layout/sample_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@
android:text="@string/custom_theme" />
</LinearLayout>

<ScrollView
<FrameLayout
android:id="@+id/about"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="outsideInset">
android:layout_height="match_parent">

</ScrollView>
</FrameLayout>

</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class AboutBuilder {
private int linksColumnsCount = 5;
private int actionsColumnsCount = 2;

private boolean wrapScrollView = false;

private List<Item> links = new ArrayList();
private List<Item> actions = new ArrayList();

Expand Down Expand Up @@ -230,6 +232,11 @@ public AboutBuilder setShowDivider(boolean showDivider) {
return this;
}

public AboutBuilder setWrapScrollView(boolean wrapScrollView) {
this.wrapScrollView = wrapScrollView;
return this;
}

public AboutBuilder addLink(Bitmap icon, String label, View.OnClickListener onClickListener) {
links.add(new Item(icon, label, onClickListener));
return this;
Expand Down Expand Up @@ -570,6 +577,10 @@ public AboutBuilder addAction(Drawable icon, String label, String url) {
return addAction(icon, label, Uri.parse(url));
}

public AboutBuilder addFiveStarsAction(int appId) {
return addFiveStarsAction(context.getString(appId));
}

public AboutBuilder addFiveStarsAction(String appId) {
return addAction(R.mipmap.star, R.string.rate_five_stars, util.openPlayStoreAppPage(appId));
}
Expand All @@ -578,6 +589,11 @@ public AboutBuilder addFiveStarsAction() {
return addFiveStarsAction(BuildConfig.APPLICATION_ID);
}

public AboutBuilder addUpdateAction(int appId) {
return addUpdateAction(context.getString(appId));
}


public AboutBuilder addUpdateAction(String appId) {
return addAction(R.mipmap.update, R.string.update_app, util.openPlayStoreAppPage(appId));
}
Expand All @@ -586,10 +602,18 @@ public AboutBuilder addUpdateAction() {
return addUpdateAction(BuildConfig.APPLICATION_ID);
}

public AboutBuilder addMoreFromMeAction(int userName) {
return addMoreFromMeAction(context.getString(userName));
}

public AboutBuilder addMoreFromMeAction(String userName) {
return addAction(R.mipmap.google_play_store, R.string.more_apps, util.openPlayStoreAppsList(userName));
}

public AboutBuilder addShareAction(int subject, int message) {
return addShareAction(context.getString(subject), context.getString(message));
}

public AboutBuilder addShareAction(String subject, String message) {
return addAction(R.mipmap.share, R.string.share_app, util.shareThisApp(subject, message));
}
Expand All @@ -602,14 +626,27 @@ public AboutBuilder addShareAction(int subject) {
return addShareAction(context.getString(subject));
}

public AboutBuilder addFeedbackAction(int email, int subject, int text) {
return addFeedbackAction(context.getString(email), context.getString(subject), context.getString(text));
}

public AboutBuilder addFeedbackAction(String email, String subject, String text) {
return addAction(R.mipmap.feedback, R.string.feedback_app, util.sendEmail(email, subject, text));
}

public AboutBuilder addFeedbackAction(int email, int subject) {
return addFeedbackAction(context.getString(email), context.getString(subject));
}

public AboutBuilder addFeedbackAction(String email, String subject) {
return addFeedbackAction(email, subject, null);
}

public AboutBuilder addFeedbackAction(int email) {
return addFeedbackAction(context.getString(email));
}


public AboutBuilder addFeedbackAction(String email) {
return addFeedbackAction(email, null);
}
Expand Down Expand Up @@ -655,6 +692,7 @@ public AboutBuilder addDonateAction(Intent intent) {
return addDonateAction(util.clickIntent(intent));
}


public String getName() {
return name;
}
Expand Down Expand Up @@ -739,6 +777,10 @@ public boolean isLinksAnimated() {
return linksAnimated;
}

public boolean isWrapScrollView() {
return wrapScrollView;
}

public List<Item> getLinks() {
return links;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;

import com.vansuita.library.Icon;
Expand Down Expand Up @@ -63,15 +64,27 @@ public AboutView(Context context, AttributeSet attrs) {

public AboutView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);

init();
bind();
}

private void init() {
setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
private void init(boolean wrapScrollView) {
layoutInflater = LayoutInflater.from(getContext());
layoutInflater.inflate(R.layout.about, this);

ViewGroup holder = this;
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

if (wrapScrollView) {
lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
ScrollView scrollView = new ScrollView(getContext());
scrollView.setLayoutParams(lp);
addView(scrollView);
holder = new FrameLayout(getContext());
holder.setLayoutParams(lp);
scrollView.addView(holder);
}

setLayoutParams(lp);

layoutInflater.inflate(R.layout.about, holder);
}

private void bind() {
Expand All @@ -91,6 +104,8 @@ private void bind() {
}

public void build(AboutBuilder bundle) {
init(bundle.isWrapScrollView());
bind();

tvName.setText(bundle.getName());
VisibleUtil.handle(tvName, bundle.getName());
Expand Down

0 comments on commit 038b1a8

Please sign in to comment.