Skip to content

Commit 69d0242

Browse files
committed
Giphy integration
// FREEBIE
1 parent 8e9e384 commit 69d0242

File tree

58 files changed

+1644
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1644
-15
lines changed

AndroidManifest.xml

+5
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@
266266
android:windowSoftInputMode="stateHidden"
267267
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
268268

269+
<activity android:name=".giph.ui.GiphyActivity"
270+
android:theme="@style/TextSecure.LightNoActionBar"
271+
android:windowSoftInputMode="stateHidden"
272+
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
273+
269274
<activity android:name=".PassphraseChangeActivity"
270275
android:label="@string/AndroidManifest__change_passphrase"
271276
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>

build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ android {
172172

173173
buildConfigField "long", "BUILD_TIMESTAMP", getLastCommitTimestamp() + "L"
174174
buildConfigField "String", "TEXTSECURE_URL", "\"https://textsecure-service.whispersystems.org\""
175+
buildConfigField "String", "GIPHY_PROXY_HOST", "\"giphy-proxy-production.whispersystems.org\""
176+
buildConfigField "int", "GIPHY_PROXY_PORT", "80"
175177
buildConfigField "String", "USER_AGENT", "\"OWA\""
176178
buildConfigField "String", "REDPHONE_MASTER_URL", "\"https://redphone-master.whispersystems.org\""
177179
buildConfigField "String", "REDPHONE_RELAY_HOST", "\"relay.whispersystems.org\""

proguard-appcompat-v7.pro

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@
77
-keep public class * extends android.support.v4.view.ActionProvider {
88
public <init>(android.content.Context);
99
}
10+
11+
-keepattributes *Annotation*
12+
-keep public class * extends android.support.design.widget.CoordinatorLayout.Behavior { *; }
13+
-keep public class * extends android.support.design.widget.ViewOffsetBehavior { *; }
130 Bytes
Loading
243 Bytes
Loading
105 Bytes
Loading

res/drawable-hdpi/poweredby_giphy.png

4.03 KB
Loading
94 Bytes
Loading
196 Bytes
Loading
82 Bytes
Loading

res/drawable-mdpi/poweredby_giphy.png

2.42 KB
Loading
104 Bytes
Loading
213 Bytes
Loading
92 Bytes
Loading
5.44 KB
Loading
109 Bytes
Loading
312 Bytes
Loading
94 Bytes
Loading
8.62 KB
Loading
110 Bytes
Loading
308 Bytes
Loading
Loading
6.47 KB
Loading

res/layout/attachment_type_selector.xml

+15
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,21 @@
169169
android:gravity="center"
170170
android:orientation="vertical">
171171

172+
<org.thoughtcrime.securesms.components.CircleColorImageView
173+
android:id="@+id/giphy_button"
174+
android:layout_width="60dp"
175+
android:layout_height="60dp"
176+
android:src="@drawable/ic_gif_white_36dp"
177+
android:scaleType="center"
178+
android:elevation="4dp"
179+
app:circleColor="@color/cyan_400"/>
180+
181+
<TextView android:layout_marginTop="10dp"
182+
android:layout_width="wrap_content"
183+
android:layout_height="wrap_content"
184+
style="@style/AttachmentTypeLabel"
185+
android:text="GIF"/>
186+
172187
</LinearLayout>
173188

174189
<LinearLayout android:layout_width="match_parent"

res/layout/giphy_activity.xml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:layout_height="match_parent"
5+
android:layout_width="match_parent"
6+
android:orientation="vertical">
7+
8+
<android.support.design.widget.CoordinatorLayout
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent"
11+
android:layout_above="@+id/giphy_logo"
12+
android:orientation="vertical">
13+
14+
<android.support.design.widget.AppBarLayout
15+
android:layout_width="match_parent"
16+
android:layout_height="wrap_content"
17+
android:theme="?attr/actionBarStyle"
18+
android:background="?attr/colorPrimary">
19+
20+
<org.thoughtcrime.securesms.giph.ui.GiphyActivityToolbar
21+
android:id="@+id/giphy_toolbar"
22+
android:layout_height="wrap_content"
23+
android:layout_width="match_parent"
24+
android:background="?attr/colorPrimary"
25+
android:theme="?attr/actionBarStyle"
26+
app:layout_scrollFlags="scroll|enterAlways"/>
27+
28+
<android.support.design.widget.TabLayout
29+
android:id="@+id/tab_layout"
30+
android:layout_width="match_parent"
31+
android:layout_height="wrap_content"
32+
android:scrollbars="horizontal"/>
33+
34+
</android.support.design.widget.AppBarLayout>
35+
36+
<android.support.v4.view.ViewPager
37+
android:id="@+id/giphy_pager"
38+
android:layout_width="match_parent"
39+
android:layout_height="match_parent"
40+
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
41+
42+
</android.support.design.widget.CoordinatorLayout>
43+
44+
<ImageView android:id="@+id/giphy_logo"
45+
android:src="@drawable/poweredby_giphy"
46+
android:layout_width="match_parent"
47+
android:layout_height="wrap_content"
48+
android:layout_alignParentBottom="true"
49+
android:padding="10dp"
50+
android:background="@color/black"/>
51+
52+
</RelativeLayout>

res/layout/giphy_activity_toolbar.xml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<merge xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<LinearLayout android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:orientation="horizontal">
7+
8+
<ImageView android:id="@+id/action_icon"
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content"
11+
android:layout_gravity="center_vertical"
12+
android:gravity="center_vertical"
13+
android:clickable="true"
14+
android:background="@drawable/circle_touch_highlight_background"
15+
android:src="@drawable/ic_search_white_24dp" />
16+
17+
<LinearLayout android:id="@+id/toggle_container"
18+
android:layout_width="match_parent"
19+
android:layout_height="match_parent"
20+
android:orientation="horizontal">
21+
22+
<EditText android:id="@+id/search_view"
23+
android:layout_height="wrap_content"
24+
android:layout_width="0px"
25+
android:layout_weight="1"
26+
android:layout_marginLeft="5dp"
27+
android:layout_marginStart="5dp"
28+
android:hint="@string/giphy_activity_toolbar__search_gifs_and_stickers"
29+
android:textColor="@color/white"
30+
android:textColorHint="@color/white"
31+
android:textCursorDrawable="@null"
32+
android:maxLines="1"
33+
android:imeOptions="actionSearch"
34+
android:background="@android:color/transparent"
35+
android:layout_gravity="center_vertical"
36+
android:gravity="center_vertical"/>
37+
38+
<ImageView android:id="@+id/search_clear"
39+
android:layout_width="wrap_content"
40+
android:layout_height="wrap_content"
41+
android:layout_gravity="center_vertical"
42+
android:gravity="center_vertical"
43+
android:clickable="true"
44+
android:focusable="true"
45+
android:visibility="invisible"
46+
android:background="@drawable/circle_touch_highlight_background"
47+
android:src="@drawable/ic_clear_white_24dp" />
48+
49+
<org.thoughtcrime.securesms.components.AnimatingToggle
50+
android:id="@+id/button_toggle"
51+
android:layout_width="wrap_content"
52+
android:layout_height="wrap_content"
53+
android:layout_gravity="center"
54+
android:paddingLeft="10dp"
55+
android:paddingRight="10dp"
56+
android:gravity="center">
57+
58+
<ImageView android:id="@+id/view_grid"
59+
android:layout_width="wrap_content"
60+
android:layout_height="wrap_content"
61+
android:layout_gravity="center_vertical"
62+
android:gravity="center_vertical"
63+
android:clickable="true"
64+
android:visibility="visible"
65+
android:focusable="true"
66+
android:background="@drawable/circle_touch_highlight_background"
67+
android:src="@drawable/ic_dashboard_white_24dp" />
68+
69+
<ImageView android:id="@+id/view_stream"
70+
android:layout_width="wrap_content"
71+
android:layout_height="wrap_content"
72+
android:layout_gravity="center_vertical"
73+
android:gravity="center_vertical"
74+
android:visibility="gone"
75+
android:clickable="true"
76+
android:focusable="true"
77+
android:background="@drawable/circle_touch_highlight_background"
78+
android:src="@drawable/ic_view_stream_white_24dp" />
79+
80+
</org.thoughtcrime.securesms.components.AnimatingToggle>
81+
82+
</LinearLayout>
83+
84+
</LinearLayout>
85+
86+
</merge>

res/layout/giphy_fragment.xml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent">
5+
6+
<android.support.v7.widget.RecyclerView
7+
android:id="@+id/giphy_list"
8+
android:layout_width="match_parent"
9+
android:layout_height="match_parent"
10+
android:scrollbars="vertical"/>
11+
12+
<ProgressBar android:id="@+id/loading_progress"
13+
android:layout_width="wrap_content"
14+
android:layout_height="wrap_content"
15+
android:layout_gravity="center"
16+
android:visibility="visible"
17+
android:indeterminate="true"/>
18+
19+
<TextView android:id="@+id/no_results"
20+
android:text="@string/giphy_fragment__no_results_found"
21+
android:gravity="center"
22+
android:layout_width="match_parent"
23+
android:layout_height="wrap_content"
24+
android:visibility="gone"
25+
android:layout_gravity="center"/>
26+
27+
</FrameLayout>

res/layout/giphy_thumbnail.xml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="wrap_content"
5+
xmlns:tools="http://schemas.android.com/tools">
6+
7+
<org.thoughtcrime.securesms.giph.ui.AspectRatioImageView
8+
android:id="@+id/thumbnail"
9+
android:layout_width="match_parent"
10+
android:layout_height="wrap_content"
11+
android:scaleType="fitXY" />
12+
13+
<ProgressBar android:id="@+id/gif_progress"
14+
android:layout_width="wrap_content"
15+
android:layout_height="wrap_content"
16+
android:indeterminate="true"
17+
android:visibility="gone"
18+
tools:visibility="visible"
19+
android:layout_gravity="center"
20+
android:gravity="center"/>
21+
22+
</FrameLayout>

res/values/strings.xml

+15
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,14 @@
269269
<string name="GcmRefreshJob_Permanent_Signal_communication_failure">Permanent Signal communication failure!</string>
270270
<string name="GcmRefreshJob_Signal_was_unable_to_register_with_Google_Play_Services">Signal was unable to register with Google Play Services. Signal messages and calls have been disabled, please try re-registering in Settings &gt; Advanced.</string>
271271

272+
273+
<!-- GiphyActivity -->
274+
<string name="GiphyActivity_error_while_retrieving_full_resolution_gif">Error while retrieving full resolution GiF...</string>
275+
276+
<!-- GiphyFragmentPageAdapter -->
277+
<string name="GiphyFragmentPagerAdapter_gifs">GIFs</string>
278+
<string name="GiphyFragmentPagerAdapter_stickers">Stickers</string>
279+
272280
<!-- GroupCreateActivity -->
273281
<string name="GroupCreateActivity_actionbar_title">New group</string>
274282
<string name="GroupCreateActivity_actionbar_update_title">Update group</string>
@@ -751,6 +759,13 @@
751759

752760
<string name="expiration_weeks_abbreviated">%dw</string>
753761

762+
<!-- giphy_activity -->
763+
<string name="giphy_activity_toolbar__search_gifs_and_stickers">Search GIFs and stickers</string>
764+
765+
<!-- giphy_fragment -->
766+
<string name="giphy_fragment__no_results_found">No results found.</string>
767+
768+
754769
<!-- log_submit_activity -->
755770
<string name="log_submit_activity__log_fetch_failed">Could not read the log on your device. You can still use ADB to get a debug log instead.</string>
756771
<string name="log_submit_activity__thanks">Thanks for your help!</string>

src/org/thoughtcrime/securesms/ConversationActivity.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,11 @@
9292
import org.thoughtcrime.securesms.database.DraftDatabase.Draft;
9393
import org.thoughtcrime.securesms.database.DraftDatabase.Drafts;
9494
import org.thoughtcrime.securesms.database.GroupDatabase;
95-
import org.thoughtcrime.securesms.database.MessagingDatabase;
9695
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
97-
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
9896
import org.thoughtcrime.securesms.database.MmsSmsColumns.Types;
9997
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
10098
import org.thoughtcrime.securesms.database.ThreadDatabase;
10199
import org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob;
102-
import org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob;
103100
import org.thoughtcrime.securesms.mms.AttachmentManager;
104101
import org.thoughtcrime.securesms.mms.AttachmentManager.MediaType;
105102
import org.thoughtcrime.securesms.mms.AttachmentTypeSelectorAdapter;
@@ -187,6 +184,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
187184
private static final int TAKE_PHOTO = 6;
188185
private static final int ADD_CONTACT = 7;
189186
private static final int PICK_LOCATION = 8;
187+
private static final int PICK_GIF = 9;
190188

191189
private MasterSecret masterSecret;
192190
protected ComposeText composeText;
@@ -371,6 +369,9 @@ public void onActivityResult(final int reqCode, int resultCode, Intent data) {
371369
SignalPlace place = new SignalPlace(PlacePicker.getPlace(data, this));
372370
attachmentManager.setLocation(masterSecret, place, getCurrentMediaConstraints());
373371
break;
372+
case PICK_GIF:
373+
setMedia(data.getData(), MediaType.GIF);
374+
break;
374375
}
375376
}
376377

@@ -1118,6 +1119,8 @@ private void addAttachment(int type) {
11181119
AttachmentManager.selectLocation(this, PICK_LOCATION); break;
11191120
case AttachmentTypeSelectorAdapter.TAKE_PHOTO:
11201121
attachmentManager.capturePhoto(this, TAKE_PHOTO); break;
1122+
case AttachmentTypeSelector.ADD_GIF:
1123+
AttachmentManager.selectGif(this, PICK_GIF); break;
11211124
}
11221125
}
11231126

src/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class AttachmentTypeSelector extends PopupWindow {
3434
public static final int ADD_CONTACT_INFO = 4;
3535
public static final int TAKE_PHOTO = 5;
3636
public static final int ADD_LOCATION = 6;
37+
public static final int ADD_GIF = 7;
3738

3839
private static final int ANIMATION_DURATION = 300;
3940

@@ -45,6 +46,7 @@ public class AttachmentTypeSelector extends PopupWindow {
4546
private final @NonNull ImageView contactButton;
4647
private final @NonNull ImageView cameraButton;
4748
private final @NonNull ImageView locationButton;
49+
private final @NonNull ImageView gifButton;
4850
private final @NonNull ImageView closeButton;
4951

5052
private @Nullable View currentAnchor;
@@ -62,15 +64,17 @@ public AttachmentTypeSelector(@NonNull Context context, @Nullable AttachmentClic
6264
this.videoButton = ViewUtil.findById(layout, R.id.video_button);
6365
this.contactButton = ViewUtil.findById(layout, R.id.contact_button);
6466
this.cameraButton = ViewUtil.findById(layout, R.id.camera_button);
65-
this.closeButton = ViewUtil.findById(layout, R.id.close_button);
6667
this.locationButton = ViewUtil.findById(layout, R.id.location_button);
68+
this.gifButton = ViewUtil.findById(layout, R.id.giphy_button);
69+
this.closeButton = ViewUtil.findById(layout, R.id.close_button);
6770

6871
this.imageButton.setOnClickListener(new PropagatingClickListener(ADD_IMAGE));
6972
this.audioButton.setOnClickListener(new PropagatingClickListener(ADD_SOUND));
7073
this.videoButton.setOnClickListener(new PropagatingClickListener(ADD_VIDEO));
7174
this.contactButton.setOnClickListener(new PropagatingClickListener(ADD_CONTACT_INFO));
7275
this.cameraButton.setOnClickListener(new PropagatingClickListener(TAKE_PHOTO));
7376
this.locationButton.setOnClickListener(new PropagatingClickListener(ADD_LOCATION));
77+
this.gifButton.setOnClickListener(new PropagatingClickListener(ADD_GIF));
7478
this.closeButton.setOnClickListener(new CloseClickListener());
7579

7680
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
@@ -112,6 +116,7 @@ public void onGlobalLayout() {
112116
animateButtonIn(audioButton, ANIMATION_DURATION / 3);
113117
animateButtonIn(locationButton, ANIMATION_DURATION / 3);
114118
animateButtonIn(videoButton, ANIMATION_DURATION / 4);
119+
animateButtonIn(gifButton, ANIMATION_DURATION / 4);
115120
animateButtonIn(contactButton, 0);
116121
animateButtonIn(closeButton, 0);
117122
}

0 commit comments

Comments
 (0)