-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7627fb
commit f236088
Showing
83 changed files
with
1,309 additions
and
749 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
uikit/src/main/java/com/cometchat/pro/uikit/ComposeBox/CometChatEditText.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.cometchat.pro.uikit.ComposeBox; | ||
|
||
import android.content.ContentResolver; | ||
import android.content.Context; | ||
import android.os.Bundle; | ||
import android.util.AttributeSet; | ||
import android.util.Log; | ||
import android.view.inputmethod.EditorInfo; | ||
import android.view.inputmethod.InputConnection; | ||
import android.view.inputmethod.InputContentInfo; | ||
|
||
import androidx.appcompat.widget.AppCompatEditText; | ||
import androidx.core.os.BuildCompat; | ||
import androidx.core.view.inputmethod.EditorInfoCompat; | ||
import androidx.core.view.inputmethod.InputConnectionCompat; | ||
import androidx.core.view.inputmethod.InputContentInfoCompat; | ||
|
||
import com.cometchat.pro.constants.CometChatConstants; | ||
import com.cometchat.pro.core.CometChat; | ||
import com.cometchat.pro.exceptions.CometChatException; | ||
import com.cometchat.pro.models.MediaMessage; | ||
|
||
import java.io.File; | ||
|
||
import utils.MediaUtils; | ||
import utils.Utils; | ||
|
||
public class CometChatEditText extends AppCompatEditText { | ||
|
||
private static final String TAG = "CometChatEditText"; | ||
|
||
public OnEditTextMediaListener onEditTextMediaListener; | ||
|
||
public CometChatEditText(Context context) { | ||
super(context); | ||
} | ||
|
||
public CometChatEditText(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public CometChatEditText(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
} | ||
|
||
@Override | ||
public InputConnection onCreateInputConnection(EditorInfo outAttrs) { | ||
final InputConnection ic = super.onCreateInputConnection(outAttrs); | ||
EditorInfoCompat.setContentMimeTypes(outAttrs, | ||
new String [] {"image/png","image/gif"}); | ||
|
||
|
||
final InputConnectionCompat.OnCommitContentListener callback = | ||
new InputConnectionCompat.OnCommitContentListener() { | ||
@Override | ||
public boolean onCommitContent(InputContentInfoCompat inputContentInfo, | ||
int flags, Bundle opts) { | ||
// read and display inputContentInfo asynchronously | ||
if (BuildCompat.isAtLeastNMR1() && (flags & | ||
InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) { | ||
try { | ||
inputContentInfo.requestPermission(); | ||
} | ||
catch (Exception e) { | ||
return false; // return false if failed | ||
} | ||
} | ||
ContentResolver cr = getContext().getContentResolver(); | ||
String mimeType = cr.getType(inputContentInfo.getLinkUri()); | ||
|
||
Log.e(TAG, "onCommitContent: "+inputContentInfo.getLinkUri().getPath() | ||
+"\n"+inputContentInfo.getContentUri()+"\n"+ | ||
mimeType); | ||
onEditTextMediaListener.OnMediaSelected(inputContentInfo); | ||
// read and display inputContentInfo asynchronously. | ||
// call inputContentInfo.releasePermission() as needed. | ||
|
||
return true; // return true if succeeded | ||
} | ||
}; | ||
return InputConnectionCompat.createWrapper(ic, outAttrs, callback); | ||
} | ||
|
||
public void setMediaSelected(OnEditTextMediaListener onEditTextMediaListener) { | ||
this.onEditTextMediaListener = onEditTextMediaListener; | ||
} | ||
|
||
public interface OnEditTextMediaListener { | ||
void OnMediaSelected(InputContentInfoCompat i); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.