Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Share button in repositories view #335

Closed
wants to merge 3 commits into from

3 participants

@anupcowkur

Added a small share button in the options menu when viewing repositories.

This will allow users to share the HTML URL of the currently viewed repository with other Android apps (Facebook, Twitter, Google+ etc)

This feature was requested in forkhubs/android#319

@anupcowkur

@MrDomopanda Good idea. Code updated.

@anupcowkur

The travis build keeps failing even though the integration tests run perfectly fine on my machine. I think it is because of a known issue with travis configuration:
https://github.com/travis-ci/travis-worker/issues/56

Here is screenshot of integration tests completing successfully on my mac:
testsuccess

And this is the screenshot of the failed travis build:
travisscreenshot

@sbennett18

My pull requests seem to be having the same issues with Travis.

Also, you should probably also remove the string you added in the first commit and maybe add a subject for the sharing that'll show up in the subject line of whatever app you share with.
Something like:

ShareUtils.create("Repository " + repository.getName(), repository.getHtmlUrl());

would be simple.

@anupcowkur

@MrDomopanda I let the string be. I think it adds a personal touch to the Intent Chooser the users see. I updated the code to add a subject.

@sbennett18

My mistake. I didn't see that you were still using the string. I like it!

@kevinsawicki

Hi, thanks for adding this, I've merged it to master.

I did back out wrapping the intent in a createChooser call since that wasn't used elsewhere in other share actions inside the app and I wanted to keep things consistent.

I am definitely up for revisiting using createChooser for all share activities started in the app but would want to do it across the board instead of just in one activity.

@anupcowkur

@kevinsawicki Cool. Thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 28, 2013
  1. @anupcowkur
Commits on Apr 6, 2013
  1. @anupcowkur
  2. @anupcowkur

    Added subject to Intent

    anupcowkur authored
This page is out of date. Refresh to see the latest.
View
24 app/res/menu/repository_share.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2012 GitHub Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item
+ android:id="@+id/m_share"
+ android:showAsAction="never"
+ android:title="@string/share"/>
+
+</menu>
View
1  app/res/values/strings.xml
@@ -234,6 +234,7 @@
<string name="starring_repository">Starring…</string>
<string name="unstarring_repository">Unstarring…</string>
<string name="navigate_to">Navigate to…</string>
+ <string name="share_repo">Share this Repo!</string>
<!-- Tab titles, should be as short as possible -->
<string name="tab_repositories">repositories</string>
View
15 app/src/main/java/com/github/mobile/ui/repo/RepositoryViewActivity.java
@@ -30,6 +30,7 @@
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import com.github.kevinsawicki.wishlist.ViewUtils;
import com.github.mobile.Intents.Builder;
@@ -47,6 +48,7 @@
import com.github.mobile.util.AvatarLoader;
import com.github.mobile.util.ToastUtils;
import com.google.inject.Inject;
+import com.github.mobile.util.ShareUtils;
import org.eclipse.egit.github.core.Repository;
import org.eclipse.egit.github.core.User;
@@ -125,7 +127,9 @@ protected void onException(Exception e) throws RuntimeException {
@Override
public boolean onCreateOptionsMenu(Menu optionsMenu) {
- getSupportMenuInflater().inflate(menu.repository_star, optionsMenu);
+ MenuInflater inflater = getSupportMenuInflater();
+ inflater.inflate(menu.repository_star, optionsMenu);
+ inflater.inflate(menu.repository_share, optionsMenu);
return super.onCreateOptionsMenu(optionsMenu);
}
@@ -172,6 +176,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
case id.m_star:
starRepository();
return true;
+ case id.m_share:
+ shareRepositoryURL();
+ return true;
case android.R.id.home:
finish();
Intent intent = new Intent(this, HomeActivity.class);
@@ -270,4 +277,10 @@ protected void onSuccess(Boolean watching) throws Exception {
}
}.execute();
}
+
+ private void shareRepositoryURL() {
+ Intent sharingIntent = ShareUtils.create(repository.getName(), repository.getHtmlUrl());
+ startActivity(Intent.createChooser(sharingIntent, getResources()
+ .getText(string.share_repo)));
+ }
}
Something went wrong with that request. Please try again.