Add Facebook sharing from thanks page

This commit is contained in:
Christopher Wright
2015-09-09 18:18:26 -04:00
parent a9d7a4addc
commit 0dad28e51d
17 changed files with 99 additions and 18 deletions

View File

@@ -69,11 +69,17 @@
android:name=".ui.activities.TwoFactorActivity"
android:theme="@style/Login" />
<activity android:name="com.facebook.FacebookActivity"
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name" />
<provider
android:authorities="com.facebook.app.FacebookContentProvider10153359799336694"
android:name="com.facebook.FacebookContentProvider"
android:exported="true"/>
<activity android:name="net.hockeyapp.android.UpdateActivity" />
</application>

View File

@@ -3,6 +3,7 @@ package com.kickstarter;
import android.app.Application;
import android.content.Context;
import com.facebook.FacebookSdk;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;
@@ -49,6 +50,8 @@ public class KsrApplication extends Application {
component().inject(this);
CookieHandler.setDefault(cookieManager);
FacebookSdk.sdkInitialize(this);
}
public ApplicationComponent component() {

View File

@@ -22,6 +22,7 @@ import rx.subjects.PublishSubject;
public class ThanksPresenter extends Presenter<ThanksActivity> {
private final PublishSubject<Void> doneClick = PublishSubject.create();
private final PublishSubject<Void> facebookClick = PublishSubject.create();
private final PublishSubject<Void> shareClick = PublishSubject.create();
private final PublishSubject<Void> twitterClick = PublishSubject.create();
@@ -41,6 +42,10 @@ public class ThanksPresenter extends Presenter<ThanksActivity> {
.observeOn(AndroidSchedulers.mainThread())
.subscribe(vp -> vp.first.show(vp.second)));
addSubscription(RxUtils.takeWhen(viewAndProject, facebookClick)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(vp -> vp.first.startFacebookShareIntent(vp.second)));
addSubscription(RxUtils.takeWhen(viewAndProject, shareClick)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(vp -> vp.first.startShareIntent(vp.second)));
@@ -72,6 +77,10 @@ public class ThanksPresenter extends Presenter<ThanksActivity> {
doneClick.onNext(null);
}
public void takeFacebookClick() {
facebookClick.onNext(null);
}
public void takeShareClick() {
shareClick.onNext(null);
}

View File

@@ -25,8 +25,6 @@ public class LoginToutActivity extends BaseActivity<LoginToutPresenter> {
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(this.getApplicationContext());
setContentView(R.layout.login_tout_layout);
ButterKnife.bind(this);

View File

@@ -3,6 +3,7 @@ package com.kickstarter.ui.activities;
import android.content.Intent;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.widget.LinearLayoutManager;
@@ -12,6 +13,9 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.facebook.CallbackManager;
import com.facebook.share.model.ShareLinkContent;
import com.facebook.share.widget.ShareDialog;
import com.kickstarter.R;
import com.kickstarter.libs.BaseActivity;
import com.kickstarter.libs.RequiresPresenter;
@@ -32,7 +36,9 @@ public class ThanksActivity extends BaseActivity<ThanksPresenter> {
@Bind(R.id.recommended_projects_recycler_view) RecyclerView recommendedProjectsRecyclerView;
@Bind(R.id.woohoo_background) ImageView woohooBackgroundImageView;
CallbackManager facebookCallbackManager;
ProjectCardMiniAdapter projectCardMiniAdapter;
ShareDialog shareDialog;
@Override
protected void onCreate(final Bundle savedInstanceState) {
@@ -41,6 +47,9 @@ public class ThanksActivity extends BaseActivity<ThanksPresenter> {
setContentView(R.layout.thanks_layout);
ButterKnife.bind(this);
facebookCallbackManager = CallbackManager.Factory.create(); // TODO: Use this to track Facebook shares
shareDialog = new ShareDialog(this);
final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
recommendedProjectsRecyclerView.setLayoutManager(layoutManager);
@@ -67,11 +76,28 @@ public class ThanksActivity extends BaseActivity<ThanksPresenter> {
presenter.takeShareClick();
}
@OnClick(R.id.facebook_button)
public void onFacebookButtonClick(final View view) {
presenter.takeFacebookClick();
}
@OnClick(R.id.twitter_button)
public void onTwitterButtonClick(final View view) {
presenter.takeTwitterClick();
}
public void startFacebookShareIntent(final Project project) {
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentTitle(project.name())
.setContentDescription(shareString(project))
.setContentUrl(Uri.parse(project.secureWebProjectUrl()))
.build();
shareDialog.show(content);
}
}
public void startShareIntent(final Project project) {
final Intent intent = new Intent(android.content.Intent.ACTION_SEND)
.setType("text/plain")

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1012 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true">
<shape>
<solid android:color="@color/facebook_blue"/>
<corners android:radius="@dimen/button_corner_radius"/>
</shape>
</item>
<item android:state_pressed="true">
<shape>
<solid android:color="@color/facebook_blue"/>
<corners android:radius="@dimen/button_corner_radius"/>
</shape>
</item>
<item>
<shape>
<solid android:color="@color/facebook_blue"/>
<corners android:radius="@dimen/button_corner_radius"/>
</shape>
</item>
</selector>

View File

@@ -61,20 +61,28 @@
<Button
android:id="@+id/facebook_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/grid_5"
android:layout_marginLeft="@dimen/keyline_1_half"
android:layout_weight="1"
android:layout_marginRight="@dimen/keyline_1_half"
android:text="Facebook Stub" />
android:paddingRight="@dimen/grid_3"
android:background="@drawable/button_facebook"
android:drawableLeft="@drawable/ic_social_facebook"
android:drawableStart="@drawable/ic_social_facebook"
android:text="@string/Share"
android:textAllCaps="false"
android:textAppearance="@style/TextAppearance.AppCompat.Button"
android:textColor="@color/white" />
<Button
android:id="@+id/twitter_button"
android:layout_width="match_parent"
android:layout_height="@dimen/grid_5"
android:layout_marginLeft="@dimen/keyline_1_half"
android:layout_marginRight="3dp"
android:layout_weight="1"
android:paddingLeft="@dimen/grid_1"
android:paddingRight="@dimen/grid_2"
android:background="@drawable/button_twitter_blue"
android:background="@drawable/button_twitter"
android:drawableLeft="@drawable/ic_social_twitter"
android:drawableStart="@drawable/ic_social_twitter"
android:text="@string/Tweet"
@@ -86,6 +94,7 @@
<Button
android:id="@+id/share_button"
android:layout_marginLeft="4dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onShareClick"

View File

@@ -57,5 +57,6 @@
<color name="blue_darken_10">#0087E6</color>
<!-- Third-party colors -->
<color name="facebook_blue">#3b5998</color>
<color name="twitter_blue">#00aced</color>
</resources>

View File

@@ -2,7 +2,9 @@
<string name="app_name">Kickstarter</string>
<!-- Settings -->
<!-- TODO: Switch app_id in different environments. The app_id here is the Kickstarter app in development mode. -->
<!-- TODO: Switch app_id in different environments. The app_id here is the Kickstarter app in development mode.
The app id is also replicated for FacebookContentProvider in AndroidManifest.xml -->
<string name="facebook_app_id">10153359799336694</string>
<string name="hockey_app_id">ecdab725861a76c38d60b5ae44dbe9f2</string>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="512px" height="512px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
<path d="M288,192v-38.1c0-17.2,3.8-25.9,30.5-25.9H352V64h-55.9c-68.5,0-91.1,31.4-91.1,85.3V192h-45v64h45v192h83V256h56.4l7.6-64
H288z"/>
</svg>

After

Width:  |  Height:  |  Size: 630 B

View File

@@ -1,14 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!-- Generator: Adobe Illustrator 16.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="-49 141 512 512" style="enable-background:new -49 141 512 512;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;}
</style>
<path class="st0" d="M443,250.5c-17.4,7.7-36,12.9-55.6,15.3c20-12,35.4-31,42.6-53.6c-18.7,11.1-39.4,19.2-61.5,23.5
c-17.7-18.9-42.9-30.7-70.7-30.7c-53.5,0-96.8,43.4-96.8,96.9c0,7.6,0.8,15,2.5,22.1C123,320,51.6,281.4,3.9,222.7
c-8.3,14.3-13.1,31-13.1,48.7C-9.2,305,8,334.7,34,352.1c-16-0.4-31-4.8-44-12.1c0,0.4,0,0.8,0,1.2c0,47,33.4,86.1,77.7,95
width="512px" height="512px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
<path d="M492,109.5c-17.4,7.7-36,12.9-55.6,15.3c20-12,35.4-31,42.6-53.6c-18.7,11.1-39.4,19.2-61.5,23.5
C399.8,75.8,374.6,64,346.8,64c-53.5,0-96.8,43.4-96.8,96.9c0,7.6,0.8,15,2.5,22.1c-80.5-4-151.9-42.6-199.6-101.3
c-8.3,14.3-13.1,31-13.1,48.7c0,33.6,17.2,63.3,43.2,80.7C67,210.7,52,206.3,39,199c0,0.4,0,0.8,0,1.2c0,47,33.4,86.1,77.7,95
c-8.1,2.2-16.7,3.4-25.5,3.4c-6.2,0-12.3-0.6-18.2-1.8c12.3,38.5,48.1,66.5,90.5,67.3c-33.1,26-74.9,41.5-120.3,41.5
c-7.8,0-15.5-0.5-23.1-1.4C13.8,573,64.7,589,119.3,589C297.6,589,395,441.3,395,313.2c0-4.2-0.1-8.4-0.3-12.5
C413.6,287,430,270,443,250.5z"/>
c-7.8,0-15.5-0.5-23.1-1.4C62.8,432,113.7,448,168.3,448C346.6,448,444,300.3,444,172.2c0-4.2-0.1-8.4-0.3-12.5
C462.6,146,479,129,492,109.5z"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB