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

Feature/standalone emoji picker #60

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.61'
repositories {
mavenCentral()
jcenter()
google()

}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath "com.github.dcendents:android-maven-gradle-plugin:1.3"
classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
mavenCentral()
jcenter()
google()
}

}
Expand Down
12 changes: 6 additions & 6 deletions example/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
compileSdkVersion 28
buildToolsVersion "28.0.3"

defaultConfig {
applicationId "momanii.hani.supernova_emoji"
minSdkVersion 9
targetSdkVersion 25
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
Expand All @@ -19,6 +19,6 @@ android {
}

dependencies {
compile project(':supernova-emoji-library')
//compile 'com.android.support:appcompat-v7:25.3.1'
implementation project(':supernova-emoji-library')
implementation 'com.android.support:appcompat-v7:28.0.0'
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package momanii.hani.supernova_emoji;

import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;

import hani.momanii.supernova_emoji_library.Actions.EmojIconActions;
import hani.momanii.supernova_emoji_library.Helper.EmojiconEditText;
import hani.momanii.supernova_emoji_library.Helper.EmojiconTextView;
import hani.momanii.supernova_emoji_library.actions.EmojIconActions;
import hani.momanii.supernova_emoji_library.helper.EmojiconEditText;
import hani.momanii.supernova_emoji_library.helper.EmojiconPicker;
import hani.momanii.supernova_emoji_library.helper.EmojiconTextView;

public class MainActivity extends AppCompatActivity {

Expand All @@ -29,6 +33,7 @@ protected void onCreate(Bundle savedInstanceState) {

rootView = findViewById(R.id.root_view);
emojiButton = (ImageView) findViewById(R.id.emoji_btn);
Button dialog_trigger = (Button) findViewById(R.id.dialog_trigger);
submitButton = (ImageView) findViewById(R.id.submit_btn);
mCheckBox = (CheckBox) findViewById(R.id.use_system_default);
emojiconEditText = (EmojiconEditText) findViewById(R.id.emojicon_edit_text);
Expand Down Expand Up @@ -63,6 +68,22 @@ public void onClick(View v) {
textView.setText(newText);
}
});

dialog_trigger.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
EmojiconPicker picker = new EmojiconPicker();
picker.create(v.getContext(), true);
picker.setOnEmojiSelectedListener(new EmojiconPicker.OnSelectedListener() {
@Override
public void onSelected(@NonNull View view, @NonNull String emoji) {
textView.setText(emoji);
}
});
picker.show(v);

}
});
}


Expand Down
50 changes: 29 additions & 21 deletions example/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:emojicon="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="momanii.hani.supernova_emoji.MainActivity">
xmlns:emojicon="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="momanii.hani.supernova_emoji.MainActivity">

<ImageView
android:id="@+id/emoji_btn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:padding="4dp"
android:src="@mipmap/smiley"
/>
android:src="@mipmap/smiley" />

<ImageView
android:id="@+id/submit_btn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:padding="4dp"
android:src="@android:drawable/ic_menu_send"
/>
android:src="@android:drawable/ic_menu_send" />

<hani.momanii.supernova_emoji_library.Helper.EmojiconEditText
<hani.momanii.supernova_emoji_library.helper.EmojiconEditText
android:id="@+id/emojicon_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -38,17 +36,17 @@
android:layout_toRightOf="@id/emoji_btn"
android:imeOptions="actionSend"
android:inputType="text"
emojicon:emojiconSize="28sp"/>
emojicon:emojiconSize="28sp" />


<hani.momanii.supernova_emoji_library.Helper.EmojiconEditText
<hani.momanii.supernova_emoji_library.helper.EmojiconEditText
android:id="@+id/emojicon_edit_text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/emojicon_edit_text"
android:imeOptions="actionSend"
android:inputType="text"
emojicon:emojiconSize="28sp"/>
emojicon:emojiconSize="28sp" />


<CheckBox
Expand All @@ -58,9 +56,19 @@
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true"
android:checked="false"
android:text="Use System Default?"/>
android:text="Use System Default?" />


<Button
android:id="@+id/dialog_trigger"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/use_system_default"
android:layout_centerHorizontal="true"
android:layout_marginTop="8dp"
android:text="Trigger dialog" />

<hani.momanii.supernova_emoji_library.Helper.EmojiconTextView
<hani.momanii.supernova_emoji_library.helper.EmojiconTextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -71,5 +79,5 @@
android:text="Hello Emojis !"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="#000000"
emojicon:emojiconAlignment="bottom"/>
emojicon:emojiconAlignment="bottom" />
</RelativeLayout>
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Sun Apr 02 22:46:20 EEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip

20 changes: 14 additions & 6 deletions supernova-emoji-library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
compileSdkVersion 28
buildToolsVersion "28.0.3"

defaultConfig {
minSdkVersion 9
targetSdkVersion 25
minSdkVersion 14
targetSdkVersion 28
}
lintOptions {
abortOnError false
}
}

dependencies {
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}

repositories {
mavenCentral()
}


Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package hani.momanii.supernova_emoji_library.Actions;
package hani.momanii.supernova_emoji_library.actions;

import android.content.Context;
import android.view.KeyEvent;
Expand All @@ -26,9 +26,9 @@
import java.util.Collections;
import java.util.List;

import hani.momanii.supernova_emoji_library.Helper.EmojiconEditText;
import hani.momanii.supernova_emoji_library.Helper.EmojiconGridView;
import hani.momanii.supernova_emoji_library.Helper.EmojiconsPopup;
import hani.momanii.supernova_emoji_library.helper.EmojiconEditText;
import hani.momanii.supernova_emoji_library.helper.EmojiconGridView;
import hani.momanii.supernova_emoji_library.helper.EmojiconsPopup;
import hani.momanii.supernova_emoji_library.R;
import hani.momanii.supernova_emoji_library.emoji.Emojicon;

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



package hani.momanii.supernova_emoji_library.Helper;
package hani.momanii.supernova_emoji_library.helper;

import android.content.Context;
import android.view.View;
Expand Down Expand Up @@ -63,15 +63,15 @@ public View getView(final int position, View convertView, ViewGroup parent) {
v.setTag(holder);
}

Emojicon emoji = getItem(position);
ViewHolder holder = (ViewHolder) v.getTag();
holder.icon.setText(emoji.getEmoji());
holder.icon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
emojiClickListener.onEmojiconClicked(getItem(position));
}
});
Emojicon emoji = getItem(position);
ViewHolder holder = (ViewHolder) v.getTag();
holder.icon.setText(emoji.getEmoji());
holder.icon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
emojiClickListener.onEmojiconClicked(getItem(position));
}
});

return v;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package hani.momanii.supernova_emoji_library.Helper;
package hani.momanii.supernova_emoji_library.helper;

import android.content.Context;
import android.content.res.TypedArray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
* limitations under the License.
*/

package hani.momanii.supernova_emoji_library.Helper;
package hani.momanii.supernova_emoji_library.helper;

import android.app.Activity;
import android.content.Context;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.GridView;
Expand All @@ -33,15 +34,16 @@
*/
public class EmojiconGridView{
public View rootView;
EmojiconsPopup mEmojiconPopup;
@Nullable
OnEmojiconClickedListener mOnEmojiconClickedListener;
EmojiconRecents mRecents;
Emojicon[] mData;
private boolean mUseSystemDefault = false;


public EmojiconGridView(Context context, Emojicon[] emojicons, EmojiconRecents recents, EmojiconsPopup emojiconPopup, boolean useSystemDefault) {
public EmojiconGridView(Context context, Emojicon[] emojicons, EmojiconRecents recents, OnEmojiconClickedListener onEmojiconClickedListener, boolean useSystemDefault) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
mEmojiconPopup = emojiconPopup;
mOnEmojiconClickedListener = onEmojiconClickedListener;
rootView = inflater.inflate(R.layout.emojicon_grid, null);
setRecents(recents);
GridView gridView = (GridView) rootView.findViewById(R.id.Emoji_GridView);
Expand All @@ -56,8 +58,8 @@ public EmojiconGridView(Context context, Emojicon[] emojicons, EmojiconRecents r

@Override
public void onEmojiconClicked(Emojicon emojicon) {
if (mEmojiconPopup.onEmojiconClickedListener != null) {
mEmojiconPopup.onEmojiconClickedListener.onEmojiconClicked(emojicon);
if (mOnEmojiconClickedListener != null) {
mOnEmojiconClickedListener.onEmojiconClicked(emojicon);
}
if (mRecents != null) {
mRecents.addRecentEmoji(rootView.getContext(), emojicon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package hani.momanii.supernova_emoji_library.Helper;
package hani.momanii.supernova_emoji_library.helper;

import android.content.Context;
import android.text.Spannable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package hani.momanii.supernova_emoji_library.Helper;
package hani.momanii.supernova_emoji_library.helper;

import android.content.Context;
import android.content.res.TypedArray;
Expand Down
Loading