Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bunch of library fixes #43

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.2.3'

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -33,7 +33,7 @@ task clean(type: Delete) {
}

ext {
supportLibVersion = "24.1.1"
supportLibVersion = "25.0.1"
testRunnerVersion = "0.5"
espressoVersion = "2.2.2"
}
4 changes: 2 additions & 2 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion '24.0.1'
buildToolsVersion '25.0.2'

defaultConfig {
applicationId "it.snipsnap.slyce_messaging_example"
minSdkVersion 16
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ protected void onCreate(Bundle savedInstanceState) {
hasLoadedMore = false;

slyceMessagingFragment = (SlyceMessagingFragment) getFragmentManager().findFragmentById(R.id.fragment_for_slyce_messaging);
slyceMessagingFragment.setDefaultAvatarUrl("https://scontent-lga3-1.xx.fbcdn.net/v/t1.0-9/10989174_799389040149643_722795835011402620_n.jpg?oh=bff552835c414974cc446043ac3c70ca&oe=580717A5");
slyceMessagingFragment.setDefaultDisplayName("Matthew Page");
//slyceMessagingFragment.setDefaultAvatarUrl("https://scontent-lga3-1.xx.fbcdn.net/v/t1.0-9/10989174_799389040149643_722795835011402620_n.jpg?oh=bff552835c414974cc446043ac3c70ca&oe=580717A5");
//slyceMessagingFragment.setDefaultDisplayName("Matthew Page");
slyceMessagingFragment.setDefaultUserId("uhtnaeohnuoenhaeuonthhntouaetnheuontheuo");
slyceMessagingFragment.setDefaultUserInitials("MP");

slyceMessagingFragment.setOnSendMessageListener(new UserSendsMessageListener() {
@Override
Expand Down Expand Up @@ -143,6 +144,7 @@ public String onOptionSelected(int optionSelected) {
} catch (InterruptedException e) {
e.printStackTrace();
}

ScheduledExecutorService scheduleTaskExecutor = Executors.newScheduledThreadPool(1);
scheduleTaskExecutor.scheduleAtFixedRate(new Runnable() {
@Override
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon May 16 10:54:06 EDT 2016
#Mon Jan 30 15:28:34 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
4 changes: 2 additions & 2 deletions local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Thu Aug 04 11:57:49 EDT 2016
ndk.dir=sdk.dir=/usr/local/android-sdk-linux
#Mon Jan 30 15:15:23 CET 2017
sdk.dir=C\:\\androidsdk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not commit changes to this file, it is set for CI to run successfully.

13 changes: 6 additions & 7 deletions slyce-messaging/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ ext {

android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
buildToolsVersion "25.0.2"

defaultConfig {
minSdkVersion 16
minSdkVersion 15
targetSdkVersion 24
versionCode 102
versionName "4.0"
versionCode 103
versionName "4.1"
multiDexEnabled true
generatedDensities = []

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -85,9 +84,9 @@ dependencies {
compile "com.android.support:support-v13:$rootProject.ext.supportLibVersion"

// Image
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.makeramen:roundedimageview:2.3.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.commonsware.cwac:cam2:0.6.2'
compile 'com.commonsware.cwac:cam2:0.7.3'
compile 'com.github.bumptech.glide:glide:3.7.0'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.Manifest;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.TypedArray;
Expand All @@ -25,6 +26,7 @@
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.commonsware.cwac.cam2.CameraActivity;
import com.commonsware.cwac.cam2.ZoomStyle;
Expand All @@ -49,11 +51,14 @@
import it.slyce.messaging.message.messageItem.MessageRecyclerAdapter;
import it.slyce.messaging.utils.CustomSettings;
import it.slyce.messaging.utils.DateUtils;
import it.slyce.messaging.utils.KeyboardOpenedRecyclerViewScrollToBottomController;
import it.slyce.messaging.utils.Refresher;
import it.slyce.messaging.utils.ScrollUtils;
import it.slyce.messaging.utils.asyncTasks.AddNewMessageTask;
import it.slyce.messaging.utils.asyncTasks.ReplaceMessagesTask;
import it.slyce.messaging.view.ViewUtils;
import it.slyce.messaging.view.inputToolbar.SlyceMessagingInputToolbar;
import it.slyce.messaging.view.inputToolbar.TakePictureSlyceMessagingInputToolbar;

/**
* Created by John C. Hunchar on 1/12/16.
Expand All @@ -78,17 +83,28 @@ public class SlyceMessagingFragment extends Fragment implements OnClickListener
private String defaultAvatarUrl;
private String defaultDisplayName;
private String defaultUserId;
private String defaultInitials;
private int startHereWhenUpdate;
private long recentUpdatedTime;
private boolean moreMessagesExist;

public void setPictureButtonVisible(final boolean bool) {
private SlyceMessagingInputToolbar inputToolbar = new TakePictureSlyceMessagingInputToolbar(this);
private LinearLayout inputToolbarLayout;

ScheduledExecutorService scheduleTaskExecutor;


public EditText getInputEditText() {
return mEntryField;
}

public void setInputToolbarVisible(final boolean bool) {
if (getActivity() != null)
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
ImageView imageView = (ImageView) rootView.findViewById(R.id.slyce_messaging_image_view_snap);
imageView.setVisibility(bool ? View.VISIBLE : View.GONE);
View inputToolbar = rootView.findViewById(R.id.slyce_messaging_leftInputToolbar);
inputToolbar.setVisibility(bool ? View.VISIBLE : View.GONE);
}
});
}
Expand Down Expand Up @@ -134,6 +150,10 @@ public void setDefaultDisplayName(String defaultDisplayName) {
this.defaultDisplayName = defaultDisplayName;
}

public void setDefaultUserInitials(String defaultUserInitials){
this.defaultInitials = defaultUserInitials;
}

public void setDefaultUserId(String defaultUserId) {
this.defaultUserId = defaultUserId;
}
Expand Down Expand Up @@ -179,12 +199,12 @@ public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bun
// Setup views
mEntryField = (EditText) rootView.findViewById(R.id.slyce_messaging_edit_text_entry_field);
ImageView mSendButton = (ImageView) rootView.findViewById(R.id.slyce_messaging_image_view_send);
ImageView mSnapButton = (ImageView) rootView.findViewById(R.id.slyce_messaging_image_view_snap);
mRecyclerView = (RecyclerView) rootView.findViewById(R.id.slyce_messaging_recycler_view);

// Add interfaces
mSendButton.setOnClickListener(this);
mSnapButton.setOnClickListener(this);
inputToolbarLayout = (LinearLayout)rootView.findViewById(R.id.slyce_messaging_leftInputToolbar);
buildInputToolbarLayout();

// Init variables for recycler view
mMessages = new ArrayList<>();
Expand Down Expand Up @@ -217,6 +237,7 @@ public boolean onTouch(View v, MotionEvent event) {
}
}
);
mRecyclerView.getViewTreeObserver().addOnGlobalLayoutListener(new KeyboardOpenedRecyclerViewScrollToBottomController(mRecyclerView));

startUpdateTimestampsThread();
startHereWhenUpdate = 0;
Expand All @@ -237,7 +258,7 @@ public boolean onTouch(View v, MotionEvent event) {
}

private void startUpdateTimestampsThread() {
ScheduledExecutorService scheduleTaskExecutor = Executors.newScheduledThreadPool(1);
scheduleTaskExecutor = Executors.newScheduledThreadPool(1);
scheduleTaskExecutor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
Expand Down Expand Up @@ -353,44 +374,41 @@ public void run() {
}
}

private File file;
private Uri outputFileUri;
public void setInputToolbar(SlyceMessagingInputToolbar inputToolbar) {
this.inputToolbar=inputToolbar;
}

public SlyceMessagingInputToolbar getInputToolbar(){
return this.inputToolbar;
}

private void buildInputToolbarLayout() {
inputToolbarLayout.removeAllViews();
getInputToolbar().inflateInputToolbarViews(this.getActivity(), inputToolbarLayout);
inputToolbarLayout.requestLayout();
}

@Override
public void onClick(View v) {
if (v.getId() == R.id.slyce_messaging_image_view_send) {
sendUserTextMessage();
} else if (v.getId() == R.id.slyce_messaging_image_view_snap) {
mEntryField.setText("");
final File mediaStorageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
final File root = new File(mediaStorageDir, "SlyceMessaging");
root.mkdirs();
final String fname = "img_" + System.currentTimeMillis() + ".jpg";
file = new File(root, fname);
outputFileUri = Uri.fromFile(file);
Intent takePhotoIntent = new CameraActivity.IntentBuilder(getActivity().getApplicationContext())
.skipConfirm()
.to(this.file)
.zoomStyle(ZoomStyle.SEEKBAR)
.updateMediaStore()
.build();
Intent pickPhotoIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickPhotoIntent.setType("image/*");
Intent chooserIntent = Intent.createChooser(pickPhotoIntent, "Take a photo or select one from your device");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] {takePhotoIntent});
try {
startActivityForResult(chooserIntent, 1);
} catch (RuntimeException exception) {
Log.d("debug", exception.getMessage());
exception.printStackTrace();
}
} else {
getInputToolbar().onInputToolbarViewClicked(this, v);
}
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 232 || (data == null && this.file.exists())) {

SlyceMessagingInputToolbar inputToolbar = getInputToolbar();

if (! (inputToolbar instanceof TakePictureSlyceMessagingInputToolbar) )
return;

TakePictureSlyceMessagingInputToolbar takePictureSlyceMessagingInputToolbar = (TakePictureSlyceMessagingInputToolbar)inputToolbar;

if (requestCode == 232 || (data == null && takePictureSlyceMessagingInputToolbar.getFile().exists())) {
return;
}
try {
Expand All @@ -412,22 +430,25 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
return;
}
if (isCamera || data == null || data.getData() == null) {
selectedImageUri = outputFileUri;
selectedImageUri = takePictureSlyceMessagingInputToolbar.getOutputFile();
} else {
selectedImageUri = data == null ? null : data.getData();
}

MediaMessage message = new MediaMessage();
message.setUrl(selectedImageUri.toString());
message.setDate(System.currentTimeMillis());
message.setDisplayName(this.defaultDisplayName);
message.setInitials(this.defaultInitials);
message.setSource(MessageSource.LOCAL_USER);
message.setAvatarUrl(this.defaultAvatarUrl);
message.setUserId(this.defaultUserId);
addNewMessage(message);
addMessageOnUserSendMessage(message);

ScrollUtils.scrollToBottomAfterDelay(mRecyclerView, mRecyclerAdapter);
if (listener != null)
listener.onUserSendsMediaMessage(selectedImageUri);
}
}
} catch (RuntimeException exception) {
Log.d("debug", exception.getMessage());
exception.printStackTrace();
Expand All @@ -446,12 +467,25 @@ private void sendUserTextMessage() {
message.setAvatarUrl(defaultAvatarUrl);
message.setSource(MessageSource.LOCAL_USER);
message.setDisplayName(defaultDisplayName);
message.setInitials(defaultInitials);
message.setText(text);
message.setUserId(defaultUserId);
addNewMessage(message);
addMessageOnUserSendMessage(message);

ScrollUtils.scrollToBottomAfterDelay(mRecyclerView, mRecyclerAdapter);
if (listener != null)
listener.onUserSendsTextMessage(message.getText());
}

protected void addMessageOnUserSendMessage(Message message){
addNewMessage(message);
}

@Override
public void onDestroy() {
super.onDestroy();

if (scheduleTaskExecutor != null)
scheduleTaskExecutor.shutdown();
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package it.slyce.messaging.message.messageItem;

import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;

import java.util.List;

Expand All @@ -16,6 +19,7 @@
import it.slyce.messaging.message.messageItem.general.generalText.MessageGeneralTextViewHolder;
import it.slyce.messaging.message.messageItem.spinner.SpinnerViewHolder;
import it.slyce.messaging.utils.CustomSettings;
import it.slyce.messaging.utils.ViewHideKeyboardUtils;

/**
* Created by John C. Hunchar on 5/12/16.
Expand Down Expand Up @@ -82,11 +86,18 @@ public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
}

@Override
public void onBindViewHolder(MessageViewHolder messageViewHolder, int position) {
public void onBindViewHolder(final MessageViewHolder messageViewHolder, int position) {
if (messageViewHolder == null) {
return;
}

messageViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ViewHideKeyboardUtils.RequestKeyboardHide(view);
}
});

// Build the item
MessageItem messageItem = getMessageItemByPosition(position);
if (messageItem != null) {
Expand Down
Loading