Giter Club home page Giter Club logo

axemojiview's Introduction


AXEmojiView is an advanced Android Library
which adds emoji,sticker,... support to your Android application
DemoAPKReleases

LCoders | AmirHosseinAghajari
picker

Platform API Maven Central Join the chat at https://gitter.im/Aghajari/community

Screenshot

Table of Contents

Changelogs

1.5.2:

1.5.0:

  • New emoji providers!
    • AppleProvider
    • iOSProvider
    • GoogleProvider
    • SamsungProvider
    • FacebookProvider
    • WhatsAppProvider
    • TwitterProvider
    • EmojidexProvider
  • EmojiPediaLoader project for auto updating emojis from emojipedia.org
  • New Variants!
  • Now you can filter some emojis from EmojiManager
  • Now you can disable variants from EmojiManager

Installation

AXEmojiView is available in the mavenCentral(), so you just need to add it as a dependency (Module gradle)

LatestVersion : 1.5.0

Gradle

def emojiViewVersion = "1.5.2"
def emojiViewProvider = "AppleProvider"

implementation "io.github.aghajari:AXEmojiView:$emojiViewVersion"
implementation "io.github.aghajari:AXEmojiView-$emojiViewProvider:$emojiViewVersion"

List of providers:

implementation "io.github.aghajari:AXEmojiView-Microsoft3DProvider:$emojiViewVersion"
implementation "io.github.aghajari:AXEmojiView-AppleProvider:$emojiViewVersion"
implementation "io.github.aghajari:AXEmojiView-iOSProvider:$emojiViewVersion"
implementation "io.github.aghajari:AXEmojiView-GoogleProvider:$emojiViewVersion"
implementation "io.github.aghajari:AXEmojiView-SamsungProvider:$emojiViewVersion"
implementation "io.github.aghajari:AXEmojiView-FacebookProvider:$emojiViewVersion"
implementation "io.github.aghajari:AXEmojiView-WhatsAppProvider:$emojiViewVersion"
implementation "io.github.aghajari:AXEmojiView-TwitterProvider:$emojiViewVersion"
implementation "io.github.aghajari:AXEmojiView-EmojidexProvider:$emojiViewVersion"

Maven

<dependency>
  <groupId>io.github.aghajari</groupId>
  <artifactId>AXEmojiView</artifactId>
  <version>1.5.2</version>
  <type>pom</type>
</dependency>

Microsoft Fluent 3D Emoji

Fluent Emoji are a collection of familiar, friendly, and modern emoji from Microsoft. Reference

Note: This emoji provider doesn't include flags! Why?

Usage

Let's START! 😃

Install Emoji Provider

First step, you should install EmojiView with your EmojiProvider!

AXEmojiManager.install(this,new AXIOSEmojiProvider()); // new ProviderClassName

Note: iOSProvider is almost the same as AppleProvider but has less variants, It's a provider of Telegram emoji set
Note: GoogleProvider includes Emoji-14 new emojis

AppleProvider GoogleProvider Microsoft3DProvider
FacebookProvider WhatsAppProvider SamsungProvider
iOSProvider TwitterProvider EmojidexProvider

Custom Emoji Provider

If you wanna display your own Emojis you can create your own implementation of EmojiProvider and pass it to AXEmojiManager.install.

Basic Usage

Create an AXEmojiEditText in your layout.

<com.aghajari.emojiview.view.AXEmojiEditText
            android:id="@+id/edt"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:hint="enter your message ..." />

Now, you should create a Page. Current pages are :

  • EmojiView
  • SingleEmojiView
  • StickerView

Let's try EmojiView :

AXEmojiEditText edt = findViewById(R.id.edt);

AXEmojiView emojiView = new AXEmojiView(this);
emojiView.setEditText(edt);

And add this page to AXEmojiPopup :

Note: AXEmojiPopup deprecated! Use AXEmojiPopupLayout instead.

AXEmojiPopup emojiPopup = new AXEmojiPopup(emojiView); 

emojiPopup.toggle(); // Toggles visibility of the Popup.
emojiPopup.show(); // Shows the Popup.
emojiPopup.dismiss(); // Dismisses the Popup.
emojiPopup.isShowing(); // Returns true when Popup is showing.

And we are done! 😃 Output :

Back to contents

AXEmojiPopupLayout

you can also create an AXEmojiPopupLayout instead of AXEmojiPopup!

i believe that AXEmojiPopupLayout has better performance, more customizable and it's faster.

  1. create an AXEmojiPopupLayout in your layout.
    <com.aghajari.emojiview.view.AXEmojiPopupLayout
        android:id="@+id/layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"/>
  1. add the created page to AXEmojiPopupLayout :
AXEmojiPopupLayout layout = findViewById(R.id.layout);
layout.initPopupView(emojiView);

layout.toggle(); // Toggles visibility of the Popup.
layout.show(); // Shows the Popup.
layout.dismiss(); // Dismisses the Popup.
layout.hideAndOpenKeyboard(); // Hides the popup
layout.isShowing(); // Returns true when Popup is showing.

Output is just same as the AXEmojiPopup's output!

Back to contents

Single Emoji View

SingleEmojiView is a RecyclerView and all emojis will load in one page (Same As Telegram Inc)

AXSingleEmojiView emojiView = new AXSingleEmojiView(this);
emojiView.setEditText(edt);

Output :

Back to contents

StickerView

StickerView : you have to create your StickerProvider and load all your Stickers (from Url,Res,Bitmap or anything you want!) see example : WhatsAppProvider

AXStickerView stickerView = new AXStickerView(this , "stickers" , new MyStickerProvider());

Result :

Also you can create your custom pages in StickerProvider . see example : ShopStickers

Output :

Back to contents

AXEmojiPager - Use Multiple Pages Together!

you can create an AXEmojiPager and add all your pages (EmojiView,StickerView,...) to the EmojiPager

Enable Footer view in theme settings (if you want) :

AXEmojiManager.getEmojiViewTheme().setFooterEnabled(true);

And Create your EmojiPager :

AXEmojiPager emojiPager = new AXEmojiPager(this);

AXSingleEmojiView singleEmojiView = new AXSingleEmojiView(this);
emojiPager.addPage(singleEmojiView, R.drawable.ic_msg_panel_smiles);

AXStickerView stickerView = new AXStickerView(this, "stickers", new WhatsAppProvider());
emojiPager.addPage(stickerView, R.drawable.ic_msg_panel_stickers);

emojiPager.setSwipeWithFingerEnabled(true);
emojiPager.setEditText(edt);

AXEmojiPopup emojiPopup = new AXEmojiPopup(emojiPager);
//layout.initPopupView(emojiPager);

Add search button to the footer:

emojiPager.setLeftIcon(R.drawable.ic_ab_search);
        
        //Click Listener
        emojiPager.setOnFooterItemClicked(new AXEmojiPager.onFooterItemClicked() {
            @Override
            public void onClick(boolean leftIcon) {
                if (leftIcon) Toast.makeText(EmojiActivity.this,"Search Clicked",Toast.LENGTH_SHORT).show();
            }
        });

Output :

Back to contents

Create Your Custom Pages

Create an AXEmojiBase (ViewGroup) and load your page layout And add your CustomPage to emojiPager

Example: LoadingPage

emojiPager.addPage(new LoadingView(this), R.drawable.msg_round_load_m);

Output :

Back to contents

AXEmojiSearchView

Now you can search for the emoji by text in the default AXEmojiView's database (More than 5800+ words!) or your own db with the AXEmojiSearchView or your own customized view!

Example :

popupLayout.setSearchView(new AXEmojiSearchView(this, emojiPager.getPage(0)));

emojiPager.setOnFooterItemClicked(new AXEmojiPager.OnFooterItemClicked() {
    @Override
    public void onClick(View view, boolean leftIcon) {
        if (leftIcon) layout.showSearchView();
    }
});

Output :

Back to contents

Popup Animation

an smooth popup animation has been enabled for the AXEmojiPopupLayout.

popupLayout.setPopupAnimationEnabled(true);
popupLayout.setPopupAnimationDuration(250);

popupLayout.setSearchViewAnimationEnabled(true);
popupLayout.setSearchViewAnimationDuration(250);

Output :

Back to contents

Customization

Customize theme with AXEmojiTheme.

AXEmojiManager.getEmojiViewTheme().setSelectionColor(0xffFF4081);
AXEmojiManager.getEmojiViewTheme().setFooterSelectedItemColor(0xffFF4081);
AXEmojiManager.getEmojiViewTheme().setFooterBackgroundColor(Color.WHITE);
AXEmojiManager.getEmojiViewTheme().setSelectionColor(Color.TRANSPARENT);
AXEmojiManager.getEmojiViewTheme().setSelectedColor(0xffFF4081);
AXEmojiManager.getEmojiViewTheme().setCategoryColor(Color.WHITE);
AXEmojiManager.getEmojiViewTheme().setAlwaysShowDivider(true);
AXEmojiManager.getEmojiViewTheme().setBackgroundColor(Color.LTGRAY);

AXEmojiManager.getStickerViewTheme().setSelectedColor(0xffFF4081);
AXEmojiManager.getStickerViewTheme().setCategoryColor(Color.WHITE);
AXEmojiManager.getStickerViewTheme().setAlwaysShowDivider(true);
AXEmojiManager.getStickerViewTheme().setBackgroundColor(Color.LTGRAY);

Output :

Back to contents

Custom Footer

// disable default footer
AXEmojiManager.getEmojiViewTheme().setFooterEnabled(false);
AXEmojiManager.getInstance().setBackspaceCategoryEnabled(false);

// add your own footer to the AXEmojiPager
EmojiPager.setCustomFooter(footerView,true);

Output :

Back to contents

DarkMode

  • Style 1
AXEmojiManager.getEmojiViewTheme().setFooterEnabled(true);
AXEmojiManager.getEmojiViewTheme().setSelectionColor(0xff82ADD9);
AXEmojiManager.getEmojiViewTheme().setSelectedColor(0xff82ADD9);
AXEmojiManager.getEmojiViewTheme().setFooterSelectedItemColor(0xff82ADD9);
AXEmojiManager.getEmojiViewTheme().setBackgroundColor(0xFF1E2632);
AXEmojiManager.getEmojiViewTheme().setCategoryColor(0xFF1E2632);
AXEmojiManager.getEmojiViewTheme().setFooterBackgroundColor(0xFF1E2632);
AXEmojiManager.getEmojiViewTheme().setVariantPopupBackgroundColor(0xFF232D3A);
AXEmojiManager.getEmojiViewTheme().setVariantDividerEnabled(false);
AXEmojiManager.getEmojiViewTheme().setDividerColor(0xFF1B242D);
AXEmojiManager.getEmojiViewTheme().setDefaultColor(0xFF677382);
AXEmojiManager.getEmojiViewTheme().setTitleColor(0xFF677382);

AXEmojiManager.getStickerViewTheme().setSelectionColor(0xff82ADD9);
AXEmojiManager.getStickerViewTheme().setSelectedColor(0xff82ADD9);
AXEmojiManager.getStickerViewTheme().setBackgroundColor(0xFF1E2632);
AXEmojiManager.getStickerViewTheme().setCategoryColor(0xFF1E2632);
AXEmojiManager.getStickerViewTheme().setDividerColor(0xFF1B242D);
AXEmojiManager.getStickerViewTheme().setDefaultColor(0xFF677382);

Output :

  • Style 2
AXEmojiManager.getEmojiViewTheme().setFooterEnabled(true);
AXEmojiManager.getEmojiViewTheme().setSelectionColor(Color.TRANSPARENT);
AXEmojiManager.getEmojiViewTheme().setSelectedColor(0xff82ADD9);
AXEmojiManager.getEmojiViewTheme().setFooterSelectedItemColor(0xff82ADD9);
AXEmojiManager.getEmojiViewTheme().setBackgroundColor(0xFF1E2632);
AXEmojiManager.getEmojiViewTheme().setCategoryColor(0xFF232D3A);
AXEmojiManager.getEmojiViewTheme().setFooterBackgroundColor(0xFF232D3A);
AXEmojiManager.getEmojiViewTheme().setVariantPopupBackgroundColor(0xFF232D3A);
AXEmojiManager.getEmojiViewTheme().setVariantDividerEnabled(false);
AXEmojiManager.getEmojiViewTheme().setDividerColor(0xFF1B242D);
AXEmojiManager.getEmojiViewTheme().setDefaultColor(0xFF677382);
AXEmojiManager.getEmojiViewTheme().setTitleColor(0xFF677382);
AXEmojiManager.getEmojiViewTheme().setAlwaysShowDivider(true);

AXEmojiManager.getStickerViewTheme().setSelectionColor(0xff82ADD9);
AXEmojiManager.getStickerViewTheme().setSelectedColor(0xff82ADD9);
AXEmojiManager.getStickerViewTheme().setBackgroundColor(0xFF1E2632);
AXEmojiManager.getStickerViewTheme().setCategoryColor(0xFF232D3A);
AXEmojiManager.getStickerViewTheme().setDividerColor(0xFF1B242D);
AXEmojiManager.getStickerViewTheme().setDefaultColor(0xFF677382);
AXEmojiManager.getStickerViewTheme().setAlwaysShowDivider(true);

Output :

Back to contents

Views

  • AXEmojiPopupLayout
  • AXEmojiBase / AXEmojiLayout
  • AXEmojiView
  • AXSingleEmojiView
  • AXStickerView
  • AXEmojiSearchView
  • AXEmojiEditText
  • AXEmojiMultiAutoCompleteTextView
  • AXEmojiButton
  • AXEmojiImageView
  • AXEmojiTextView
  • AXEmojiCheckBox
  • AXEmojiRadioButton

Back to contents

Listeners

onEmojiActions :

    void onClick (View view, Emoji emoji, boolean fromRecent, boolean fromVariant);
    void onLongClick (View view, Emoji emoji, boolean fromRecent, boolean fromVariant);

onStickerActions :

    void onClick(View view, Sticker sticker, boolean fromRecent);
    void onLongClick(View view, Sticker sticker, boolean fromRecent);

onEmojiPagerPageChanged :

    void onPageChanged (AXEmojiPager emojiPager, AXEmojiBase base, int position);

PopupListener :

    void onDismiss();
    void onShow();
    void onKeyboardOpened(int height);
    void onKeyboardClosed();
    void onViewHeightChanged(int height);

Back to contents

Replace String With Emojis

first you need to get Unicode of emoji :

String unicode = AXEmojiUtils.getEmojiUnicode(0x1f60d); // or Emoji.getUnicode();

Or

String unicode = "😍";

now set it to your view with AXEmojiUtils.replaceWithEmojis.

Example: Set ActionBar Title :

String title = "AXEmojiView " + unicode;
getSupportActionBar().setTitle(AXEmojiUtils.replaceWithEmojis(this, title, 20));

Output :

Back to contents

RecentManager And VariantManager

you can add your custom recentManager for emojis and stickers . implements to RecentEmoji/RecentSticker

AXEmojiManager.setRecentEmoji(emojiRecentManager);
AXEmojiManager.setRecentSticker(stickerRecentManager);

Disable RecentManagers :

AXEmojiManager.getInstance().disableRecentManagers();

Back to contents

Variant View

you can also create your own VariantPopupView ! but you don't need to, the default one is also nice :)

The Default Variant:

New Variants!

Back to contents

Emoji Loader

you can add an custom EmojiLoader with AXEmojiLoader :

AXEmojiManager.setEmojiLoader(new EmojiLoader(){
  @Override
  public void loadEmoji (AXEmojiImageView imageView,Emoji emoji){
   imageView.setImageDrawable(emoji.getDrawable(imageView.getContext());
  }
});

Back to contents

AnimatedStickers (AXrLottie)

See AXrLottie

Back to contents

AXMemojiView is a page for AXEmojiView which shows memoji just like stickers

AXMemojiView

AXMemojiView AXMemojiView AXMemojiView

Back to contents

Download Apk

  • Version: 1.5.2 (Microsoft3DProvider)
    LastUpdate: 12 August 2022
    Download Apk

  • Version: 1.3.0 (iOSProvider)
    LastUpdate: 4 January 2021
    Download Apk

Back to contents

Author

TelegramID : @KingAmir272

License

Copyright 2020 Amir Hossein Aghajari
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

LCoders | AmirHosseinAghajari
Amir Hossein Aghajari • EmailGitHub

axemojiview's People

Contributors

aghajari avatar dor-naim avatar vonox7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

axemojiview's Issues

EmojiSize

Awesome library! I have one issue though. I want to find out if the text contains only emojis and then assign a size to the emoji(s). If its a single emoji, it should be 40sp and if multiple emojis, it should be 30sp. If the text has a combination of text and emojis, the default size is preserved. But the first two conditions cut the emojis in half and are not fully visible. Any pointers, please? Attached is a screen shot.

Screenshot_20200916-195217

Please note, "messageContent" is an AXEmojiTextView

if (EmojiUtils.isOnlyEmojis(content) {
                    if (EmojiUtils.emojisCount(content) == 1) {
                        messageContent.setEmojiSizeRes(R.dimen.emoji_size_single_emoji, false); // 40sp
                    } else {
                        messageContent.setEmojiSizeRes(R.dimen.emoji_size_only_emojis, false); // 30sp
                    }
                    messageContent.setText2(content);
                } else {
                    messageContent.setEmojiSizeRes(R.dimen.emoji_size_default); // 20sp
                    messageContent.setText2(content);
                }
}

Help me!!!

error: incompatible types: CAP#1 cannot be converted to int
Glide.with(view).load((int) sticker.getData()).apply(RequestOptions.fitCenterTransform()).into((AppCompatImageView)view);

Instructions missing on how to update emojis

AXEmojiView currently uses Emoji 12.1 (released on 2019-10-29).
Emoji 13.0 and Emoji 13.1 (released on major platforms in 2020 and 2021) are both missing in AXEmojiView.

It would be helpful to have in the Readme instructions how to update the emoji database to the new set of emojis to allow the community to create PRs with for Emoji updates. (and possibly update it to Emoji 13.1)

Not working on Chromebook

I'd like to run my app on Chromebooks. I tried your demo project and when I press the smiley nothing happens. It probably has to do with Chromebooks having a hardware keyboard, so there is no soft keyboard, hence no place for the emojis to go to.

I just connected my Bluetooth keyboard from my old iMac to my phone. The emojis don't show here either, so hardware keyboards is definitely the problem.

disable recently AxPage?

Hi, i didnt add recently page but it's always show in emoji keyboard, please help


public class UI {

    public static void loadTheme(){
        // release theme
        AXEmojiManager.setStickerViewTheme(new AXEmojiTheme());

        // set EmojiView Theme
        AXEmojiManager.getEmojiViewTheme().setFooterEnabled(false);
        AXEmojiManager.getEmojiViewTheme().setSelectionColor(0xffFF4081);
        AXEmojiManager.getEmojiViewTheme().setFooterSelectedItemColor(0xffFF4081);
        AXEmojiManager.getStickerViewTheme().setSelectionColor(0xffFF4081);
        AXEmojiManager.getInstance().setBackspaceCategoryEnabled(true);
    }


    public static AXEmojiPager loadView(final Context context, EditText editText){
        loadTheme();
        AXEmojiPager emojiPager = new AXEmojiPager(context);
        AXStickerView stickerView = new AXStickerView(context, "stickers", new WhatsAppProvider());
        emojiPager.addPage(stickerView, R.drawable.ic_msg_panel_stickers);

        //add sticker click listener
        stickerView.setOnStickerActionsListener(new OnStickerActions() {
            @Override
            public void onClick(View view, Sticker sticker, boolean fromRecent) {
                Toast.makeText(view.getContext(),sticker.toString()+" clicked!", Toast.LENGTH_SHORT).show();
                Integer data = (Integer)sticker.getData();
                Log.e("", "" +  data);
            }

            @Override
            public void onLongClick(View view, Sticker sticker, boolean fromRecent) {

            }
        });

        // set target emoji edit text to emojiViewPager
        emojiPager.setEditText(editText);
        emojiPager.setSwipeWithFingerEnabled(false);
        emojiPager.setLeftIcon(R.drawable.ic_ab_search);
        emojiPager.setOnFooterItemClicked(new AXEmojiPager.OnFooterItemClicked() {
            @Override
            public void onClick(View view,boolean leftIcon) {
                if (leftIcon) Toast.makeText(context,"Search Clicked", Toast.LENGTH_SHORT).show();
            }
        });
        return emojiPager;
    }
}

The left icon is not displayed

In my app everything works fine but the left icon is not displayed

         private void setupEmojis() {
               mEmojiLayout = findViewById(R.id.emojiPopupLayout);
               AXEmojiPager emojiPager = new AXEmojiPager(this);
               AXSingleEmojiView singleEmojiView = new AXSingleEmojiView(this);
               AXStickerView stickerView = new AXStickerView(this, "stickers", new a18StickerProvider());
               emojiPager.addPage(singleEmojiView, R.drawable.ic_action_emoji);
               emojiPager.addPage(stickerView, R.drawable.ic_action_sticker);
               emojiPager.setSwipeWithFingerEnabled(true);
               emojiPager.setEditText(mMessageEmojiEditText);
               mEmojiLayout.initPopupView(emojiPager);
               emojiPager.setLeftIcon(R.drawable.ic_action_search);
               mEmojiLayout.setPopupAnimationEnabled(true);
               mEmojiLayout.setPopupAnimationDuration(200);
               mEmojiLayout.setSearchViewAnimationEnabled(true);
               mEmojiLayout.setSearchViewAnimationDuration(200);
               mEmojiLayout.setSearchView(new AXEmojiSearchView(this, emojiPager.getPage(0)));
               emojiPager.setOnFooterItemClicked((view, leftIcon) -> {
                   if (leftIcon) mEmojiLayout.showSearchView();
               });

               ImageView emoji = findViewById(R.id.emoji);
               emoji.setOnClickListener(v -> {
                   if (mEmojiLayout.isShowing() && !mEmojiLayout.isKeyboardOpen()) {
                       mEmojiLayout.openKeyboard();
                   } else {
                       mEmojiLayout.show();
                   }
               });

               mEmojiLayout.setPopupListener(new SimplePopupAdapter() {
                   @Override
                   public void onDismiss() {
                       emoji.setImageResource(R.drawable.ic_action_emoji);
                   }

                   @Override
                   public void onShow() {
                       emoji.setImageResource(R.drawable.ic_action_keyboard);
                   }

                   @Override
                   public void onKeyboardOpened(int height) {
                       emoji.setImageResource(R.drawable.ic_action_emoji);
                   }

                   @Override
                   public void onKeyboardClosed() {
                       emoji.setImageResource(mEmojiLayout.isShowing() ? R.drawable.ic_action_keyboard : R.drawable.ic_action_emoji);
                   }
               });
           }```

some small question : hide pager titleView/ sticker keyboard does not show full screen

Hi, first thanks you very much for great library, it's help me a lot about using custom gif as emoji keyboard. I totally done with your library, but i still have some question below.

  1. I just want to show my custom gif page only, so i dont need page TitleView, so can you give me some advice to hide it?
  2. When show gif keyboard, i saw the last row is not display totally, as the video i uploaded, please help

https://streamable.com/7qbea2 ( the video i just uploading, may be it's need a bit of time to show)

It Doesn't Work on Android 12

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.newproject7/com.my.newproject7.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'com.aghajari.emojiview.emoji.EmojiCategory[] com.aghajari.emojiview.AXEmojiManager.getCategories()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3838)
at

Is it feasible, to use TextView in AXEmojiRecyclerAdapter, if we only intent to support Google emoji in Android only?

Thank you for providing such useful framework.

Currently, our requirements are

  • Providing an emoji picker
  • Support Google emoji only
  • Will only run in Android

I notice by using AXEmojiView-GoogleProvider, it can full-fill our requirement. However, the project itself come with >3000 PNG files, with total size >15MB.

We only plan to use TextView and EditText for rendering.

We prefer not to use a predefined PNG image files in our case. Not only it consumes more space, it will also outdated, if Google ever change their emoji look n feel, in future Android release.

I was wondering, is it feasible for us, to use TextView in AXEmojiRecyclerAdapter?

For instance, changing the code from

@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
    FrameLayout frameLayout = new FrameLayout(viewGroup.getContext());
    AXEmojiImageView emojiView = new AXEmojiImageView(viewGroup.getContext());
    int cw = Utils.getColumnWidth(viewGroup.getContext());
    frameLayout.setLayoutParams(new FrameLayout.LayoutParams(cw, cw));
    frameLayout.addView(emojiView);

    int dp6 = Utils.dpToPx(viewGroup.getContext(), 6);
    emojiView.setPadding(dp6, dp6, dp6, dp6);

    return new ViewHolder(frameLayout);
}

@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
    FrameLayout frameLayout = (FrameLayout) viewHolder.itemView;
    final AXEmojiImageView emojiView = (AXEmojiImageView) frameLayout.getChildAt(0);

    Emoji emoji = emojis.get(i);
    emojiView.setEmoji(variantEmoji.getVariant(emoji));
    //ImageLoadingTask currentTask = new ImageLoadingTask(emojiView);
    //currentTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, emoji, null, null);
    emojiView.setOnEmojiActions(events, false);

}

to

@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
    FrameLayout frameLayout = new FrameLayout(viewGroup.getContext());
    AXEmojiImageView emojiView = new AXEmojiImageView(viewGroup.getContext());
    int cw = Utils.getColumnWidth(viewGroup.getContext());
    frameLayout.setLayoutParams(new FrameLayout.LayoutParams(cw, cw));
    //frameLayout.addView(emojiView);

    TextView textView = new TextView(viewGroup.getContext());
    textView.setTextColor(Color.BLACK);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
    frameLayout.addView(textView);

    int dp6 = Utils.dpToPx(viewGroup.getContext(), 6);
    emojiView.setPadding(dp6, dp6, dp6, dp6);

    return new ViewHolder(frameLayout);
}

@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
    FrameLayout frameLayout = (FrameLayout) viewHolder.itemView;
    final TextView emojiView = (TextView) frameLayout.getChildAt(0);

    Emoji emoji = emojis.get(i);
    emojiView.setText(variantEmoji.getVariant(emoji).getUnicode());

    //ImageLoadingTask currentTask = new ImageLoadingTask(emojiView);
    //currentTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, emoji, null, null);
    //emojiView.setOnEmojiActions(events, false);

}

(I know the code is not yet handle hasVariants. But, this is the basic idea)

I was wondering, is it feasible, to use TextView in AXEmojiRecyclerAdapter, if we only intent to support Google emoji in Android only? It seems possible from initial testing. But, I may be missing out something.

Thank you.

Emojis icon sizes Not Working in CustomRecycleAdapter

device-2020-08-28-011802

I have gone through so many libraries and this is the first one I was able to implement successfully so thank you. Just a little challenge. I am unable to increase the icon size in for emojis inside a custom recycle adapter.
I tried holder.textView.setEmojiSize(40, true); but the icons remain the same size. Please any suggestion?

Search is not working

Search is not working while i am using popup
When i am using popup layout keyboard is show below the layout when i set search view.

Not working with androidx

When creating the object of AXEmojiView, a "NoClassDefFoundError" is thrown:

java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/recyclerview/widget/RecyclerView$OnScrollListener;

NullPointerException object Pattern

Hello. I save a String from AXEmojiEditText to storage when I close the fragment. When I open this fragment again, I take the value from the database and set the text to AXEmojiEditText. The error occurs when emoji are present in the saved text. The error doesn't happen every time. I initialize emojiView before the method restoreDraft. Please help me solve this problem.

 private fun restoreDraft() {
        val draft = viewModel.getChat(getParams().id)?.draftMessage
        if (draft != null) `binding.chatInput.setText(draft)
    }

java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.regex.Matcher java.util.regex.Pattern.matcher(java.lang.CharSequence)' on a null object reference

Crash in Android 12 Samsung device

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.aghajari.emojiview.emoji.EmojiCategory[] com.aghajari.emojiview.AXEmojiManager.getCategories()' on a null object reference at com.aghajari.emojiview.view.AXSingleEmojiView.init(AXSingleEmojiView.java:195) at com.aghajari.emojiview.view.AXSingleEmojiView.<init>(AXSingleEmojiView.java:42)

AXEmojiTextView Problem

Hi There,
The AXEmojiTextView does not display emojis when opened for first time when using my own Recyclerview and Adapter.
When I close and reopen the activity it displays the emojis normally.
For this reason I had to use AXEmojiEditText since it does not have such probelms.
But I am unable to use Multiline and at the same time make it non editable.
What to do?

PROGUARD Rules needed to activate AXEmojiView

Hi..
Your library works awesome..
But when I turn on proguard for release, I can't see any emoji or sticker in my release app..
I try to keep all AXEmoji class and class member buat still nothing happened..

-keep class com.aghajari.emojiview.** { *; }
-keep class com.aghajari.emojiview.R.** { *; }
-keep class com.aghajari.emojiview.adapters.** { *; }
-keep class com.aghajari.emojiview.view.** { *; }
-keep class com.aghajari.emojiview.emoji.** { *; }
-keep class com.aghajari.emojiview.sticker.** { *; }
-keep class com.aghajari.emojiview.listener.** { *; }
-keep class com.aghajari.emojiview.utils.** { *; }
-keep class com.aghajari.emojiview.whatsappprovider.** { *; }

-keepnames class com.aghajari.emojiview.** { *; }
-keep interface com.aghajari.emojiview.** { *; }
-keep enum com.aghajari.emojiview.** { *; }
-keepclassmembers class com.aghajari.emojiview.** {
    *;
}
-keepclassmembers class com.aghajari.emojiview.view.** {
    *;
}

Is there any other proguard rules we need to write?

EmojiPopupLayout with AXSingleEmojiView fails to calculate height

When you try to instantiate a view of AXSingleEmojiView it fails if keyboard hasn't been opened yet.
This is my code:

binding.emojiPopupLayout.initPopupView(
    AXSingleEmojiView(requireContext()).apply {
        editText = binding.emojiEditText
        onEmojiActionsListener = this
    }
)
binding.emojiPopupLayout.show()

If the keyboard is not open, the height is calculated wrong and the layout has 48dp of height (approximately).
After opening the keyboard and calling this function, it works well. I think this issue could also give support to a custom height defined by user and/or make it expandable through the whole view/screen.

When the popupLayout is hidden, the keyboard pops out the edittext as if leaving room for the PopupLayout.

Please, help me solve this problem

My layout:

`
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/cl_chat"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/input_layout"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:elevation="6dp"
    app:layout_constraintBottom_toTopOf="@id/layout"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/standard_panel"
        android:layout_width="0dp"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/white"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        <ImageButton
            android:id="@+id/button_send_message"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:layout_gravity="center_vertical"
            android:layout_marginHorizontal="16dp"
            android:background="?attr/selectableItemBackgroundBorderless"
            android:src="@drawable/ic_material_send_24"
            android:visibility="gone"
            app:layout_constraintBottom_toBottomOf="@id/standard_panel"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@id/standard_panel"
            app:tint="@color/blue_300" />

    </androidx.constraintlayout.widget.ConstraintLayout>

    <com.aghajari.emojiview.view.AXEmojiEditText
        android:id="@+id/chat_input"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="12dp"
        android:layout_marginEnd="12dp"
        android:background="@android:color/transparent"
        android:cursorVisible="true"
        android:fadingEdge="vertical"
        android:filterTouchesWhenObscured="false"
        android:hint="@string/chat_input_hint"
        android:imeOptions="actionSend|flagNoExtractUi"
        android:inputType="textAutoCorrect|textCapSentences|textMultiLine"
        android:maxLines="6"
        android:paddingTop="8dp"
        android:scrollbars="vertical"
        app:layout_constraintBottom_toBottomOf="@id/button_emoticon"
        app:layout_constraintEnd_toStartOf="@id/button_attach"
        app:layout_constraintStart_toEndOf="@id/button_emoticon"
        app:layout_goneMarginEnd="52dp" />

    <ImageButton
        android:id="@+id/button_emoticon"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_gravity="center_vertical"
        android:layout_marginStart="16dp"
        android:background="@color/transparent"
        app:layout_constraintBottom_toBottomOf="@id/standard_panel"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@id/standard_panel"
        app:srcCompat="@drawable/ic_emoticon_outline"
        app:tint="@color/grey_500" />


    <ImageButton
        android:id="@+id/button_attach"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_marginHorizontal="20dp"
        android:background="@color/transparent"
        android:src="@drawable/ic_attach"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@id/btn_record"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_goneMarginEnd="50dp"
        app:tint="@color/grey_500" />

    <ImageButton
        android:id="@+id/btn_record"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:clickable="false"
        android:layout_marginHorizontal="16dp"
        android:background="@color/transparent"
        android:filterTouchesWhenObscured="false"
        android:src="@drawable/ic_microphone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:tint="@color/grey_500" />

</androidx.constraintlayout.widget.ConstraintLayout>

<com.aghajari.emojiview.view.AXEmojiPopupLayout
    android:id="@+id/layout"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"/>

</androidx.constraintlayout.widget.ConstraintLayout>`

My code:
`
AXEmojiManager.install(requireContext(), AXGoogleEmojiProvider(requireContext()))
val emojiView = AXEmojiView(requireContext())
emojiView.editText = binding.chatInput
binding.layout.initPopupView(emojiView)

    binding.buttonEmoticon.setOnClickListener {
        if (binding.layout.isShowing) binding.layout.hideAndOpenKeyboard() else
            binding.layout.toggle()
    }

``

1e53bec7-3010-448e-9df4-d80afcbc40a8

AxEmojiPopupLayout - Failed to instantiate one or more classes

I am unable to preview the design of my xml file on Android Studio. Here's how I have added it to my code:

<com.aghajari.emojiview.view.AXEmojiPopupLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/emojiLayout"
        android:layout_gravity="bottom"
        />

Here is the error that it shows:

The following classes could not be instantiated:
- com.aghajari.emojiview.view.AXEmojiPopupLayout (Open Class, Show Exception, Clear Cache)

 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.  If this is an unexpected error you can also try to build the project, then manually refresh the layout.

java.lang.IllegalArgumentException: The passed Context is not an Activity.
	at com.aghajari.emojiview.utils.Utils.asActivity(Utils.java:228)
	at com.aghajari.emojiview.view.AXEmojiPopupLayout$KeyboardHeightProvider.<init>(AXEmojiPopupLayout.java:269)
	at com.aghajari.emojiview.view.AXEmojiPopupLayout.initKeyboardHeightProvider(AXEmojiPopupLayout.java:73)
	at com.aghajari.emojiview.view.AXEmojiPopupLayout.<init>(AXEmojiPopupLayout.java:55)
	at com.aghajari.emojiview.view.AXEmojiPopupLayout.<init>(AXEmojiPopupLayout.java:49)
	at jdk.internal.reflect.GeneratedConstructorAccessor1780.newInstance(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:351)
	at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:200)
	at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:161)
	at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:294)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:417)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:428)
	at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:332)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1127)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:505)
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:359)
	at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:436)
	at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:121)
	at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:717)
	at com.android.tools.idea.rendering.RenderTask.lambda$inflate$9(RenderTask.java:873)
	at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$3.run(RenderExecutor.kt:192)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

I tried rebuilding the project and refreshing the layout, but it does not work. Please let me know if there's a way I can fix this.

Thank you!

How to implement the sticker inside custom keyboard?

I'm trying to include the AXEmoji inside a custom android keyboard / IME. Which is run on a service not activity.
I try to use AXEmojiPopupLayout into keyboard layout, but it's throw Exception because the parameter needed is context from Activity not from service.

this line throw Exception.
parentView = Utils.asActivity(popupLayout.getContext()).findViewById(android.R.id.content);

Can you solve this?
I hope it's can be run on android keyboard.
Thanks in advance.

Support for AXrLottieDrawable possible ?

Hello there,

Thanks for your great work. This lib rocks. Is it possible to extend the lib to support AXrLottieDrawable? Idea is to render animated stickers within the text. For what I could see AXPresetEmojiReplacer does the work by transforming emoji into their corresponding drawables. How could one extend the method to also generate a AXrLottieDrawable?

Thanks a lot

Expand to full screen

Is it possible to expand the AXEmojiPopupLayout to have a height of the display screen? In case I would want it to be a standalone component? Or to display it above the edit text itself?

How to display stickers?

Hey Amir,
Your library is really good. can you please tell me how to display stickers? as in your demo app when we clicked on sticker it's show toast. onClickMethod have 3 params but how to use them?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.