Skip to content

Commit

Permalink
Merge pull request #17 from TheAndroidMaster/develop
Browse files Browse the repository at this point in the history
Version 0.0.5
  • Loading branch information
fennifith authored May 6, 2018
2 parents 976ac90 + bb6080d commit 4dce43f
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ As long as your pull request doesn't break the app in any way or conflict with a

## Branches

I don't use branches because I'm lazy. If you want to make a new branch, feel free to do so, just be aware that I will completely ignore it and push my changes to master anyway, because I'm special.
I am using the `develop` branch for all changes that will not be immediately available on bintray. Most PRs should be made to the `develop` branch. The only reason that a PR should be made to `master` is when there is a typo/inconsistency in the README or a similar issue is present. If you make a PR to `master` that changes something other than a .md file, I will stare at my screen and make ugly whale noises for approximately 10 minutes before politely asking you to change the branch. Thank you.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This is just sample data. It is not real. Though Jahir is lazy, so that part is
The Gradle dependency is available through jCenter, which is used by default in Android Studio. To add the dependency to your project, copy this line into the dependencies section of your app's build.gradle file.

```gradle
compile 'me.jfenn:attribouter:0.0.4'
compile 'me.jfenn:attribouter:0.0.5'
```

#### Starting an Activity
Expand Down Expand Up @@ -65,6 +65,7 @@ Link tags can exist inside of the `<appInfo>`, `<contributor>`, or `<project>` t
|url|String|The url of the link.|
|icon|String (URL) / Drawable Resource|The icon to display next to the link.|
|priority|Integer|Defines how the links should be sorted - the highest priority appears first in the list, and/or is opened when the whole item is clicked.|
|hidden|Boolean|Whether to hide the link. This is useful for removing automatically generated links that you do not want to display (example: removing the 'playStore' link generated by `<appInfo>` using the package name if your app is not published on the play store).|

Auto-generated links for the `<appInfo>` tag are as follows:

Expand Down
9 changes: 8 additions & 1 deletion app/src/main/res/xml/about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
name="Documentation"
icon="https://jfenn.me/favicon.ico"
url="https://jfenn.me/about/?Attribouter" />
<link
hidden="true"
id="github" />
</appInfo>
<text text="@string/html" />
<!-- <text> elements can be added anywhere directly within the <about> tag -->
Expand Down Expand Up @@ -39,7 +42,11 @@
<contributor
login="jahirfiquitiva"
position="3"
task="^Lazy Slacker" />
task="^Lazy Slacker">
<link
hidden="true"
id="website" />
</contributor>
<!-- For Jahir, the task "Lazy Slacker" will override the default task "Contributor" even after the github data is fetched (starting with the "^"
character is what tells the library to do this) -->
<contributor
Expand Down
6 changes: 3 additions & 3 deletions attribouter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'me.jfenn'
PUBLISH_ARTIFACT_ID = 'attribouter'
PUBLISH_VERSION = '0.0.4'
PUBLISH_VERSION = '0.0.5'
}

android {
Expand All @@ -12,8 +12,8 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 27
versionCode 4
versionName "0.0.4"
versionCode 5
versionName "0.0.5"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,20 @@ public void bind(Context context, ViewHolder viewHolder) {

if (links.size() > 0) {
Collections.sort(links);

List<InfoData> linksList = new ArrayList<>();
for (LinkInfoData link : links) {
if (!link.isHidden())
linksList.add(link);
}

viewHolder.links.setVisibility(View.VISIBLE);

FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(context);
layoutManager.setFlexDirection(FlexDirection.ROW);
layoutManager.setJustifyContent(JustifyContent.CENTER);
viewHolder.links.setLayoutManager(layoutManager);
viewHolder.links.setAdapter(new InfoAdapter(new ArrayList<InfoData>(links)));
viewHolder.links.setAdapter(new InfoAdapter(linksList));
} else viewHolder.links.setVisibility(View.GONE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void onClick(View view) {
} else {
LinkInfoData importantLink = null;
for (LinkInfoData link : links) {
if (importantLink == null || link.getPriority() > importantLink.getPriority())
if (!link.isHidden() && (importantLink == null || link.getPriority() > importantLink.getPriority()))
importantLink = link;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,20 @@ public void bind(Context context, ViewHolder viewHolder) {

if (links.size() > 0) {
Collections.sort(links);

List<InfoData> linksList = new ArrayList<>();
for (LinkInfoData link : links) {
if (!link.isHidden())
linksList.add(link);
}

viewHolder.links.setVisibility(View.VISIBLE);

FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(context);
layoutManager.setFlexDirection(FlexDirection.ROW);
layoutManager.setJustifyContent(JustifyContent.FLEX_START);
viewHolder.links.setLayoutManager(layoutManager);
viewHolder.links.setAdapter(new InfoAdapter(new ArrayList<InfoData>(links)));
viewHolder.links.setAdapter(new InfoAdapter(linksList));
} else viewHolder.links.setVisibility(View.GONE);

LinkInfoData importantLink = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class EmailLinkInfoData extends LinkInfoData {

public EmailLinkInfoData(@NonNull String address, int priority) {
super("email", "@string/title_attribouter_email", "mailto:" + address, "@drawable/ic_attribouter_email", priority);
super("email", "@string/title_attribouter_email", "mailto:" + address, "@drawable/ic_attribouter_email", false, priority);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public GitHubLinkInfoData(@NonNull String name, int priority) {
}

public GitHubLinkInfoData(@NonNull String item, int priority, boolean isFullUrl) {
super("github", "@string/title_attribouter_github", isFullUrl ? item : "https://github.com/" + item, "@drawable/ic_attribouter_github", priority);
super("github", "@string/title_attribouter_github", isFullUrl ? item : "https://github.com/" + item, "@drawable/ic_attribouter_github", false, priority);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class LicenseLinkInfoData extends LinkInfoData {
private LicenseInfoData license;

public LicenseLinkInfoData(@NonNull LicenseInfoData license, int priority) {
super("license", "@string/title_attribouter_license", null, "@drawable/ic_attribouter_copyright", priority);
super("license", "@string/title_attribouter_license", null, "@drawable/ic_attribouter_copyright", false, priority);
this.license = license;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,29 @@ public class LinkInfoData extends InfoData<LinkInfoData.ViewHolder> implements C
private String url;
@Nullable
private String icon;
private boolean isHidden;
int priority;

public LinkInfoData(XmlResourceParser parser) {
this(parser.getAttributeValue(null, "id"),
parser.getAttributeValue(null, "name"),
parser.getAttributeValue(null, "url"),
parser.getAttributeValue(null, "icon"),
parser.getAttributeBooleanValue(null, "hidden", false),
0);

String priorityString = parser.getAttributeValue(null, "priority");
if (priorityString != null)
priority = Integer.parseInt(priorityString);
}

public LinkInfoData(@Nullable String id, @Nullable String name, @Nullable String url, @Nullable String icon, int priority) {
public LinkInfoData(@Nullable String id, @Nullable String name, @Nullable String url, @Nullable String icon, boolean isHidden, int priority) {
super(R.layout.item_attribouter_link);
this.id = id;
this.name = name;
this.url = url;
this.icon = icon;
this.isHidden = isHidden;
this.priority = priority;
}

Expand All @@ -55,6 +58,8 @@ public LinkInfoData merge(LinkInfoData link) {
url = link.url;
if ((icon == null || !icon.startsWith("^")) && link.icon != null)
icon = link.icon;
if (link.isHidden)
isHidden = true;
if (link.priority != 0)
priority = link.priority;

Expand Down Expand Up @@ -89,6 +94,10 @@ public int getPriority() {
return priority;
}

public boolean isHidden() {
return isHidden;
}

String getUrl() {
return url;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class PlayStoreLinkInfoData extends LinkInfoData {

public PlayStoreLinkInfoData(@Nullable String url, int priority) {
super("playStore", "@string/title_attribouter_rate", url, "@drawable/ic_attribouter_rate", priority);
super("playStore", "@string/title_attribouter_rate", url, "@drawable/ic_attribouter_rate", false, priority);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class WebsiteLinkInfoData extends LinkInfoData {

public WebsiteLinkInfoData(@NonNull String url, int priority) {
super("website", "@string/title_attribouter_website", url, "@drawable/ic_attribouter_link", priority);
super("website", "@string/title_attribouter_website", url, "@drawable/ic_attribouter_link", false, priority);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import me.jfenn.attribouter.R;
import me.jfenn.attribouter.adapters.InfoAdapter;
import me.jfenn.attribouter.data.info.ContributorInfoData;
import me.jfenn.attribouter.data.info.InfoData;
import me.jfenn.attribouter.data.info.link.LinkInfoData;
import me.jfenn.attribouter.utils.ResourceUtils;

public class UserDialog extends AppCompatDialog {
Expand Down Expand Up @@ -52,13 +54,20 @@ protected void onCreate(Bundle savedInstanceState) {
bioView.setText(ResourceUtils.getString(getContext(), contributor.bio));
if (contributor.links.size() > 0) {
Collections.sort(contributor.links);

List<InfoData> linksList = new ArrayList<>();
for (LinkInfoData link : contributor.links) {
if (!link.isHidden())
linksList.add(link);
}

links.setVisibility(View.VISIBLE);

FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(getContext());
layoutManager.setFlexDirection(FlexDirection.ROW);
layoutManager.setJustifyContent(JustifyContent.FLEX_START);
links.setLayoutManager(layoutManager);
links.setAdapter(new InfoAdapter(new ArrayList<InfoData>(contributor.links)));
links.setAdapter(new InfoAdapter(linksList));
} else links.setVisibility(View.GONE);
}
}

0 comments on commit 4dce43f

Please sign in to comment.