Skip to content

Commit

Permalink
Giphy integration
Browse files Browse the repository at this point in the history
// FREEBIE
  • Loading branch information
moxie0 committed Oct 18, 2016
1 parent 8e9e384 commit 69d0242
Show file tree
Hide file tree
Showing 58 changed files with 1,644 additions and 15 deletions.
5 changes: 5 additions & 0 deletions AndroidManifest.xml
Expand Up @@ -266,6 +266,11 @@
android:windowSoftInputMode="stateHidden"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>

<activity android:name=".giph.ui.GiphyActivity"
android:theme="@style/TextSecure.LightNoActionBar"
android:windowSoftInputMode="stateHidden"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>

<activity android:name=".PassphraseChangeActivity"
android:label="@string/AndroidManifest__change_passphrase"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Expand Up @@ -172,6 +172,8 @@ android {

buildConfigField "long", "BUILD_TIMESTAMP", getLastCommitTimestamp() + "L"
buildConfigField "String", "TEXTSECURE_URL", "\"https://textsecure-service.whispersystems.org\""
buildConfigField "String", "GIPHY_PROXY_HOST", "\"giphy-proxy-production.whispersystems.org\""
buildConfigField "int", "GIPHY_PROXY_PORT", "80"
buildConfigField "String", "USER_AGENT", "\"OWA\""
buildConfigField "String", "REDPHONE_MASTER_URL", "\"https://redphone-master.whispersystems.org\""
buildConfigField "String", "REDPHONE_RELAY_HOST", "\"relay.whispersystems.org\""
Expand Down
4 changes: 4 additions & 0 deletions proguard-appcompat-v7.pro
Expand Up @@ -7,3 +7,7 @@
-keep public class * extends android.support.v4.view.ActionProvider {
public <init>(android.content.Context);
}

-keepattributes *Annotation*
-keep public class * extends android.support.design.widget.CoordinatorLayout.Behavior { *; }
-keep public class * extends android.support.design.widget.ViewOffsetBehavior { *; }
Binary file added res/drawable-hdpi/ic_dashboard_white_24dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/ic_gif_white_36dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/ic_view_stream_white_24dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/poweredby_giphy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/ic_dashboard_white_24dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/ic_gif_white_36dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/ic_view_stream_white_24dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/poweredby_giphy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ic_dashboard_white_24dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ic_gif_white_36dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ic_view_stream_white_24dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/poweredby_giphy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xxhdpi/ic_dashboard_white_24dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xxhdpi/ic_gif_white_36dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xxhdpi/ic_view_stream_white_24dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xxhdpi/poweredby_giphy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xxxhdpi/ic_dashboard_white_24dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xxxhdpi/ic_gif_white_36dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xxxhdpi/ic_view_stream_white_24dp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xxxhdpi/poweredby_giphy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions res/layout/attachment_type_selector.xml
Expand Up @@ -169,6 +169,21 @@
android:gravity="center"
android:orientation="vertical">

<org.thoughtcrime.securesms.components.CircleColorImageView
android:id="@+id/giphy_button"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/ic_gif_white_36dp"
android:scaleType="center"
android:elevation="4dp"
app:circleColor="@color/cyan_400"/>

<TextView android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AttachmentTypeLabel"
android:text="GIF"/>

</LinearLayout>

<LinearLayout android:layout_width="match_parent"
Expand Down
52 changes: 52 additions & 0 deletions res/layout/giphy_activity.xml
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">

<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/giphy_logo"
android:orientation="vertical">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="?attr/actionBarStyle"
android:background="?attr/colorPrimary">

<org.thoughtcrime.securesms.giph.ui.GiphyActivityToolbar
android:id="@+id/giphy_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="?attr/colorPrimary"
android:theme="?attr/actionBarStyle"
app:layout_scrollFlags="scroll|enterAlways"/>

<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal"/>

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
android:id="@+id/giphy_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

</android.support.design.widget.CoordinatorLayout>

<ImageView android:id="@+id/giphy_logo"
android:src="@drawable/poweredby_giphy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:padding="10dp"
android:background="@color/black"/>

</RelativeLayout>
86 changes: 86 additions & 0 deletions res/layout/giphy_activity_toolbar.xml
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<ImageView android:id="@+id/action_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:clickable="true"
android:background="@drawable/circle_touch_highlight_background"
android:src="@drawable/ic_search_white_24dp" />

<LinearLayout android:id="@+id/toggle_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<EditText android:id="@+id/search_view"
android:layout_height="wrap_content"
android:layout_width="0px"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:hint="@string/giphy_activity_toolbar__search_gifs_and_stickers"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textCursorDrawable="@null"
android:maxLines="1"
android:imeOptions="actionSearch"
android:background="@android:color/transparent"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"/>

<ImageView android:id="@+id/search_clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:clickable="true"
android:focusable="true"
android:visibility="invisible"
android:background="@drawable/circle_touch_highlight_background"
android:src="@drawable/ic_clear_white_24dp" />

<org.thoughtcrime.securesms.components.AnimatingToggle
android:id="@+id/button_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:gravity="center">

<ImageView android:id="@+id/view_grid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:clickable="true"
android:visibility="visible"
android:focusable="true"
android:background="@drawable/circle_touch_highlight_background"
android:src="@drawable/ic_dashboard_white_24dp" />

<ImageView android:id="@+id/view_stream"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:visibility="gone"
android:clickable="true"
android:focusable="true"
android:background="@drawable/circle_touch_highlight_background"
android:src="@drawable/ic_view_stream_white_24dp" />

</org.thoughtcrime.securesms.components.AnimatingToggle>

</LinearLayout>

</LinearLayout>

</merge>
27 changes: 27 additions & 0 deletions res/layout/giphy_fragment.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:id="@+id/giphy_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>

<ProgressBar android:id="@+id/loading_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="visible"
android:indeterminate="true"/>

<TextView android:id="@+id/no_results"
android:text="@string/giphy_fragment__no_results_found"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_gravity="center"/>

</FrameLayout>
22 changes: 22 additions & 0 deletions res/layout/giphy_thumbnail.xml
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools">

<org.thoughtcrime.securesms.giph.ui.AspectRatioImageView
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY" />

<ProgressBar android:id="@+id/gif_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:visibility="gone"
tools:visibility="visible"
android:layout_gravity="center"
android:gravity="center"/>

</FrameLayout>
15 changes: 15 additions & 0 deletions res/values/strings.xml
Expand Up @@ -269,6 +269,14 @@
<string name="GcmRefreshJob_Permanent_Signal_communication_failure">Permanent Signal communication failure!</string>
<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>


<!-- GiphyActivity -->
<string name="GiphyActivity_error_while_retrieving_full_resolution_gif">Error while retrieving full resolution GiF...</string>

<!-- GiphyFragmentPageAdapter -->
<string name="GiphyFragmentPagerAdapter_gifs">GIFs</string>
<string name="GiphyFragmentPagerAdapter_stickers">Stickers</string>

<!-- GroupCreateActivity -->
<string name="GroupCreateActivity_actionbar_title">New group</string>
<string name="GroupCreateActivity_actionbar_update_title">Update group</string>
Expand Down Expand Up @@ -751,6 +759,13 @@

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

<!-- giphy_activity -->
<string name="giphy_activity_toolbar__search_gifs_and_stickers">Search GIFs and stickers</string>

<!-- giphy_fragment -->
<string name="giphy_fragment__no_results_found">No results found.</string>


<!-- log_submit_activity -->
<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>
<string name="log_submit_activity__thanks">Thanks for your help!</string>
Expand Down
9 changes: 6 additions & 3 deletions src/org/thoughtcrime/securesms/ConversationActivity.java
Expand Up @@ -92,14 +92,11 @@
import org.thoughtcrime.securesms.database.DraftDatabase.Draft;
import org.thoughtcrime.securesms.database.DraftDatabase.Drafts;
import org.thoughtcrime.securesms.database.GroupDatabase;
import org.thoughtcrime.securesms.database.MessagingDatabase;
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
import org.thoughtcrime.securesms.database.MmsSmsColumns.Types;
import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.RecipientsPreferences;
import org.thoughtcrime.securesms.database.ThreadDatabase;
import org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob;
import org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob;
import org.thoughtcrime.securesms.mms.AttachmentManager;
import org.thoughtcrime.securesms.mms.AttachmentManager.MediaType;
import org.thoughtcrime.securesms.mms.AttachmentTypeSelectorAdapter;
Expand Down Expand Up @@ -187,6 +184,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
private static final int TAKE_PHOTO = 6;
private static final int ADD_CONTACT = 7;
private static final int PICK_LOCATION = 8;
private static final int PICK_GIF = 9;

private MasterSecret masterSecret;
protected ComposeText composeText;
Expand Down Expand Up @@ -371,6 +369,9 @@ public void onActivityResult(final int reqCode, int resultCode, Intent data) {
SignalPlace place = new SignalPlace(PlacePicker.getPlace(data, this));
attachmentManager.setLocation(masterSecret, place, getCurrentMediaConstraints());
break;
case PICK_GIF:
setMedia(data.getData(), MediaType.GIF);
break;
}
}

Expand Down Expand Up @@ -1118,6 +1119,8 @@ private void addAttachment(int type) {
AttachmentManager.selectLocation(this, PICK_LOCATION); break;
case AttachmentTypeSelectorAdapter.TAKE_PHOTO:
attachmentManager.capturePhoto(this, TAKE_PHOTO); break;
case AttachmentTypeSelector.ADD_GIF:
AttachmentManager.selectGif(this, PICK_GIF); break;
}
}

Expand Down
Expand Up @@ -34,6 +34,7 @@ public class AttachmentTypeSelector extends PopupWindow {
public static final int ADD_CONTACT_INFO = 4;
public static final int TAKE_PHOTO = 5;
public static final int ADD_LOCATION = 6;
public static final int ADD_GIF = 7;

private static final int ANIMATION_DURATION = 300;

Expand All @@ -45,6 +46,7 @@ public class AttachmentTypeSelector extends PopupWindow {
private final @NonNull ImageView contactButton;
private final @NonNull ImageView cameraButton;
private final @NonNull ImageView locationButton;
private final @NonNull ImageView gifButton;
private final @NonNull ImageView closeButton;

private @Nullable View currentAnchor;
Expand All @@ -62,15 +64,17 @@ public AttachmentTypeSelector(@NonNull Context context, @Nullable AttachmentClic
this.videoButton = ViewUtil.findById(layout, R.id.video_button);
this.contactButton = ViewUtil.findById(layout, R.id.contact_button);
this.cameraButton = ViewUtil.findById(layout, R.id.camera_button);
this.closeButton = ViewUtil.findById(layout, R.id.close_button);
this.locationButton = ViewUtil.findById(layout, R.id.location_button);
this.gifButton = ViewUtil.findById(layout, R.id.giphy_button);
this.closeButton = ViewUtil.findById(layout, R.id.close_button);

this.imageButton.setOnClickListener(new PropagatingClickListener(ADD_IMAGE));
this.audioButton.setOnClickListener(new PropagatingClickListener(ADD_SOUND));
this.videoButton.setOnClickListener(new PropagatingClickListener(ADD_VIDEO));
this.contactButton.setOnClickListener(new PropagatingClickListener(ADD_CONTACT_INFO));
this.cameraButton.setOnClickListener(new PropagatingClickListener(TAKE_PHOTO));
this.locationButton.setOnClickListener(new PropagatingClickListener(ADD_LOCATION));
this.gifButton.setOnClickListener(new PropagatingClickListener(ADD_GIF));
this.closeButton.setOnClickListener(new CloseClickListener());

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
Expand Down Expand Up @@ -112,6 +116,7 @@ public void onGlobalLayout() {
animateButtonIn(audioButton, ANIMATION_DURATION / 3);
animateButtonIn(locationButton, ANIMATION_DURATION / 3);
animateButtonIn(videoButton, ANIMATION_DURATION / 4);
animateButtonIn(gifButton, ANIMATION_DURATION / 4);
animateButtonIn(contactButton, 0);
animateButtonIn(closeButton, 0);
}
Expand Down

0 comments on commit 69d0242

Please sign in to comment.