mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-10 22:34:15 +01:00
Cleanups and bundled emoji font
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
b9d96fe882
commit
2592e8bbaf
@ -82,6 +82,8 @@ dependencies {
|
|||||||
implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
|
implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
|
||||||
implementation "com.android.support:design:${supportLibraryVersion}"
|
implementation "com.android.support:design:${supportLibraryVersion}"
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
|
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
|
||||||
|
implementation "com.android.support:support-emoji-bundled:${supportLibraryVersion}"
|
||||||
|
|
||||||
implementation "android.arch.lifecycle:extensions:1.1.1"
|
implementation "android.arch.lifecycle:extensions:1.1.1"
|
||||||
|
|
||||||
implementation 'com.android.support:multidex:1.0.3'
|
implementation 'com.android.support:multidex:1.0.3'
|
||||||
|
@ -24,6 +24,8 @@ import android.annotation.SuppressLint;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.text.emoji.EmojiCompat;
|
||||||
|
import android.support.text.emoji.bundled.BundledEmojiCompatConfig;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -90,6 +92,8 @@ public final class MainActivity extends AppCompatActivity implements ActionBarPr
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
EmojiCompat.Config config = new BundledEmojiCompatConfig(this);
|
||||||
|
EmojiCompat.init(config);
|
||||||
|
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import android.content.Context;
|
|||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.nextcloud.talk.R;
|
import com.nextcloud.talk.R;
|
||||||
|
|
||||||
@ -38,6 +39,8 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public final class EmojiDetection {
|
public final class EmojiDetection {
|
||||||
|
|
||||||
|
private static final String TAG = "EmojiDetection";
|
||||||
|
|
||||||
private static Pattern regexPattern;
|
private static Pattern regexPattern;
|
||||||
|
|
||||||
public static boolean isMessageWithSingleEmoticonOnly(@NonNull final Context context,
|
public static boolean isMessageWithSingleEmoticonOnly(@NonNull final Context context,
|
||||||
@ -45,9 +48,8 @@ public final class EmojiDetection {
|
|||||||
|
|
||||||
int startPosition = -1;
|
int startPosition = -1;
|
||||||
int endPosition = -1;
|
int endPosition = -1;
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(text)) {
|
if (!TextUtils.isEmpty(text)) {
|
||||||
|
|
||||||
|
|
||||||
final Matcher matcher = getRegex(context).matcher(text);
|
final Matcher matcher = getRegex(context).matcher(text);
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
if (startPosition == -1 && endPosition == -1) {
|
if (startPosition == -1 && endPosition == -1) {
|
||||||
@ -76,7 +78,7 @@ public final class EmojiDetection {
|
|||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private static String readTextFile(@NonNull Context context, int rowResource) {
|
private static String readTextFile(@NonNull Context context, int rowResource) {
|
||||||
InputStream inputStream = context.getResources().openRawResource(rowResource); // getting json
|
InputStream inputStream = context.getResources().openRawResource(rowResource);
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
|
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
@ -84,16 +86,16 @@ public final class EmojiDetection {
|
|||||||
String sCurrentLine;
|
String sCurrentLine;
|
||||||
while ((sCurrentLine = br.readLine()) != null) builder.append(sCurrentLine);
|
while ((sCurrentLine = br.readLine()) != null) builder.append(sCurrentLine);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Log.e(TAG, e.getLocalizedMessage());
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
br.close();
|
br.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
Log.e(TAG, e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user