GithubHelp home page GithubHelp logo

spyglass's Introduction

Spyglass Build Status

A powerful Android library that provides highly-customizable widgets (with smart defaults) to easily add social-media-esque mention (aka tag) support to your app

For a broad overview, check out our blog post at the LinkedIn engineering blog.

Features

  • A subclass of EditText that contains enhanced functionality in order to tokenize user input and display mentions
  • A custom view, similar to a MultiAutoCompleteTextView, that displays suggestions in an embedded ListView rather than a Popup
  • Custom tokenizer interface, including a default implementation containing several options for customization
  • Designed to handle suggestions dynamically as are retrieved from multiple data sources
  • Supports both implicit and explicit (i.e. "@User Name") mentions

Getting Started

Grab via Maven:

<dependency>
  <groupId>com.linkedin.android.spyglass</groupId>
  <artifactId>spyglass</artifactId>
  <version>3.0.3</version>
</dependency>

or Gradle:

api 'com.linkedin.android.spyglass:spyglass:3.0.3'

Overview

Spyglass is divided into three, customizable layers: tokenization, suggestions, and mentions. Together, these layers form the update lifecycle used within Spyglass:

  1. User types a character
  2. Tokenize input
  3. Generate and display suggestions
  4. User taps a suggestion
  5. Insert and display mention

Let's talk about each layer individually:

Tokenization

After the user types a character, Spyglass will use a tokenizer to determine which part of the inputted text it should be considering and whether it could be a valid mention. While you may create your own tokenizer, most people should use the highly-configurable default tokenizer, the WordTokenizer. Here are some of the features you can define and customize:

  • Define characters that will trigger an explicit mention (defaults to the '@' character)
  • Set the number of characters required to have been typed in the current word before displaying any suggestions (defaults to 3)
  • Define the maximum number of words to return as part of your current token (defaults to 1). This option would allow you to recommend suggestions based on more than just the currently-typed word (i.e. if value is 2 and user has typed "New Mex", you could recommend "New Mexico" before just "Mexico")
  • Set which characters are considered word-breaking and line-breaking characters by the tokenizer (defaults to spaces, periods, and newline characters)

For more information about implementation and configuration options, see the documentation in the WordTokenizer class.

If the input being inspected by the tokenizer is currently valid, it will generate a QueryToken containing the keywords that will ultimately be used to generate suggestions.

Suggestions

Once the tokenizer has generated a valid QueryToken, Spyglass must now determine which suggestions to display using that token. It will call an implementation of QueryTokenReceiver. This is the only interface you are required to implement to use Spyglass. This interface defines one method that takes in the generated QueryToken. Your app can then use the token to query data from any number of data sources (i.e. servers, databases, caches, etc.) asynchronously. The function must return a list of strings, where each string is as an identifier for one of the data sources used for the given QueryToken. Each data source must then call the SuggestionsResultListener with the resulting suggestions and the same string identifier representing the data source for the suggestions.

As the suggestions come in from multiple data sources, the suggestions must be displayed. If you use the RichEditorView, the suggestions will be displayed via a default view without any special ordering. You may customize the view and the order of its suggestions by providing your own implementation of SuggestionsListBuilder. If you are using the MentionsEditText, you will need to implement your own SuggestionsResultListener and use the given suggestions to build your own views (typically using either a ListView, GridView, or more recently, a RecyclerView). When a suggestion is selected, you will also need to call the insertMention method on the MentionsEditText with the suggestion to insert as a mention.

Mentions

All mentions that Spyglass insert must be a subclass of the MentionSpan. By default, you can easily tweak how your mentions appear (i.e. highlight and text colors). Additionally, you may alter how they behave when they are deleted via multi-stage deletions. We use this extensively in the LinkedIn app to allow users to delete only the last name of a mentioned member (leaving just the first name).

Usage

To use Spyglass, you have two options: the MentionsEditText and the RichEditorView.

The MentionsEditText is a subclass of EditText. It contains extra functionality for tokenizing user input into query tokens and inserting new mentions to be displayed. Note that it does not have any view associated with displaying suggestions. You must provide that. This gives you the most power to customize how your mentions-enabled text box feels and behaves. See the "Grid Mentions" example in the sample app for a demo.

The RichEditorView is the quickest way to add mentions into your app. It is built on top of the aforementioned MentionsEditText and displays suggestions in an embedded ListView. It serves a similar functionality as Android's MultiAutoCompleteTextView. Note that you can still alter how suggestion items are displayed in the list, and you can still alter the tokenization and mention displaying options used by the underlying MentionsEditText.

Sample App

The ''spyglass-sample'' app contains several examples of using the library. For more detailed information, see the documentation here.

Testing

We use the Robolectric framework coupled with Mockito for our unit tests. You can run them via the gradle clean test command.

Snapshots

You can use snapshot builds to test the latest unreleased changes. A new snapshot is published after every merge to the main branch by the Deploy Snapshot Github Action workflow.

Just add the Sonatype snapshot repository to your Gradle scripts:

repositories {
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
}

You can find the latest snapshot version to use in the gradle.properties file.

spyglass's People

Contributors

bolder5 avatar bpappin avatar calebgomer avatar chao2zhang avatar csv8674xn avatar drewhannay avatar f-lolom avatar hello696969 avatar hongdongni avatar lu16j avatar nhibner avatar sagar-waghmare-rsl avatar saka-shin avatar shoulongli avatar tiembo avatar wuchongxiang0 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spyglass's Issues

Insert text and mention in richeditorview

Hi Sir,
I want to set text combined with text and mention in RichEditorView.
eg-good morning Amit and Dinesh
here Amit and Dinesh are mentionable.
comment_discription.setText("good morning Amit and Dinesh");

Calling `insertMention` results in strange editable text

  1. Set up a tokenizer with maxKeywords = 2, no explicit characters
  2. Type two keywords
  3. Call insertMention on a valid suggestion for the keywords

Expected:
Both keywords are removed, and replaced with the mention

Actual:
Only the second keyword is replaced with a mention, the first keyword remains

There appears to be code in insertMention which changes the (correct) start index for implicit mentions with multiple keywords here:

How to insert several mentions at the "same" time?

Hi guys!

First at all thank you very much for this awesome library!

I have a "problem": I can't add several mentions at the same time. The first one is added (OK), but other nothing, because the EditableText is not yet update...

// Add these mentions
for (Mentionable mention : mentions) {
mDescriptionEditText.insertMention(mention);
}

If I add one by one it works, but in a loop only the first one is take account.

Could you help me please?

Thank you very much guys!

Spyglass with standard HTML tags

Hi guys!

In my string I have mentions (OK) and HTML tags like bold and links.

I use setText(Html.fromHtml(text, null, null)); but it doesn't work properly when there are mix of mentions and HTML tags. Is there a simple way to do that? May I parse by myself all the HTML tags?

Thank you very much

ClassNotFoundException when unmarshalling

Thank you for releasing this awesome library. I found an issue in the library or setup. It could be recreated with the sample app by following these steps:

  1. Do an @ mention, the suggestions list will be shown.
  2. Keep the list open and dump the view hierarchy in Android Device Monitor.
  3. The following exceptions occur:
java.lang.ClassNotFoundException: com.linkedin.android.spyglass.mentions.MentionsEditable
     at java.lang.Class.classForName(Native Method)
     at java.lang.Class.forName(Class.java:309)
     at java.lang.Class.forName(Class.java:273)
     ...
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.linkedin.android.spyglass.mentions.MentionsEditable" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
      at java.lang.Class.classForName(Native Method)
      at java.lang.Class.forName(Class.java:309)
      at java.lang.Class.forName(Class.java:273)
      at android.os.Parcel.readParcelableCreator(Parcel.java:2281)
      at android.os.Parcel.readParcelable(Parcel.java:2245)
      at android.os.Parcel.readValue(Parcel.java:2152)
      at android.os.Parcel.readListInternal(Parcel.java:2526)
      at android.os.Parcel.readList(Parcel.java:1661)
      at android.view.accessibility.AccessibilityEvent.readAccessibilityRecordFromParcel(AccessibilityEvent.java:1110)
      at android.view.accessibility.AccessibilityEvent.initFromParcel(AccessibilityEvent.java:1072)
      at android.view.accessibility.AccessibilityEvent$1.createFromParcel(AccessibilityEvent.java:1415)
      at android.view.accessibility.AccessibilityEvent$1.createFromParcel(AccessibilityEvent.java:1412)
      at android.view.accessibility.IAccessibilityManager$Stub.onTransact(IAccessibilityManager.java:68)
      at android.os.Binder.execTransact(Binder.java:446)
    Suppressed: java.lang.ClassNotFoundException: com.linkedin.android.spyglass.mentions.MentionsEditable
      at java.lang.Class.classForName(Native Method)
      at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
      at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
      ... 15 more

Space double functionality

Is there a way to use space as word breaker and as a part of query, for example by pasting John Wi allowing to search John Wick, John Witwicky, etc.

Copy/Paste issue

I am not able to paste duplicate text. I followed these steps and encountered an issue:

  1. Type - @ Matthew Andrews and select the name from the list. Then, type the word "text".
    So, the edit text should now have the following - Mathew Andrews text.
  2. Then copy the word "text" and paste it at the end. But, the word "text" won't paste at the end.
    The expected result should be - Mathew Andrews text text.

Can't input aaxaa (chinese input method)

  1. input aax
    2.input "aa" one time.

MentionsEditable.replace is the problem.
// On certain software keyboards, the editor appears to append a word minus the last character when it is really
// trying to just delete the last character. Until we can figure out the root cause of this issue, the following
// code remaps this situation to do a proper delete.

Need find the root cause.

Support Multiple Tokenizers?

Is there a way to define multiple tokenizers?
I would like to use "@" to query a list of users and "#" to query a list of hash tags

IndexOutOfBoundsException

An IndexOutofBoundsException occurs if you follow these steps:

  1. Write some text and do a mentions such as "Hello @linkedin test".
  2. Copy the text "in test" and paste it at the same place.
  3. The following exception will occur:
java.lang.IndexOutOfBoundsException: replace (28 ... 36) ends beyond length 32
      at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1022)
      at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:462)
      at com.linkedin.android.spyglass.mentions.MentionsEditable.replace(MentionsEditable.java:113)
      at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:456)
      at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:33)
      at com.linkedin.android.spyglass.ui.MentionsEditText.ensureMentionSpanIntegrity(MentionsEditText.java:574)
      at com.linkedin.android.spyglass.ui.MentionsEditText.access$900(MentionsEditText.java:56)
      at com.linkedin.android.spyglass.ui.MentionsEditText$MyWatcher.afterTextChanged(MentionsEditText.java:381)
      at android.widget.TextView.sendAfterTextChanged(TextView.java:9007)
      at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:11588)
      at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:976)
      at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:520)
      at com.linkedin.android.spyglass.mentions.MentionsEditable.replace(MentionsEditable.java:113)
      at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:456)
      at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:33)
      at android.widget.TextView.paste(TextView.java:10898)
      at android.widget.TextView.onTextContextMenuItem(TextView.java:10316)

If I follow the same scenario in the LinkedIn app, this exception doesn't occur.

Mention Click Listener

Hello Guys, Great job so far .
Please I was wondering if their is any way to add on mention click listener to MentionEditText ?

Not able to post smilies

When I post Smilies to another platform (IOS) from RichEditor. The smilies are not getting displayed on the IOS.

Insert text before the first mention is not possible

Hi there!

I've tested your sample, and specifically GridMentions; if I add at the beginning a mention, then after I can't insert anytext before it. It's not possible to move the cursor at the beginning of text.

Ps : it's with MentionsEditText

sans titre

Thank you very much for your help!

Symbol missing warnings when building

Building the library and sample app results in some symbol-missing warnings. They do not affect the build (library and sample apps still compile and execute just fine), but we should eliminate these warnings.

See this example build or the output below: https://travis-ci.org/linkedin/Spyglass/builds/78640506

:spyglass-sample:mockableAndroidJar/home/travis/build/linkedin/Spyglass/spyglass/src/main/java/com/linkedin/android/spyglass/mentions/MentionSpan.java:28: error: cannot find symbol
import com.linkedin.android.spyglass.R;
                                    ^
  symbol:   class R
  location: package com.linkedin.android.spyglass
/home/travis/build/linkedin/Spyglass/spyglass/src/main/java/com/linkedin/android/spyglass/ui/RichEditorView.java:35: error: cannot find symbol
import com.linkedin.android.spyglass.R;
                                    ^
  symbol:   class R
  location: package com.linkedin.android.spyglass
/home/travis/build/linkedin/Spyglass/spyglass/src/main/java/com/linkedin/android/spyglass/ui/wrappers/RichEditorFragment.java:20: error: package android.support.v4.app does not exist
import android.support.v4.app.Fragment;
                             ^
/home/travis/build/linkedin/Spyglass/spyglass/src/main/java/com/linkedin/android/spyglass/ui/wrappers/RichEditorFragment.java:21: error: package android.support.v4.app does not exist
import android.support.v4.app.FragmentManager;
                             ^
/home/travis/build/linkedin/Spyglass/spyglass/src/main/java/com/linkedin/android/spyglass/ui/wrappers/RichEditorFragment.java:26: error: cannot find symbol
import com.linkedin.android.spyglass.R;
                                    ^
  symbol:   class R
  location: package com.linkedin.android.spyglass
/home/travis/build/linkedin/Spyglass/spyglass/src/main/java/com/linkedin/android/spyglass/ui/wrappers/RichEditorFragment.java:32: error: cannot find symbol
public class RichEditorFragment extends Fragment {
                                        ^
  symbol: class Fragment
/home/travis/build/linkedin/Spyglass/spyglass/src/main/java/com/linkedin/android/spyglass/ui/wrappers/RichEditorFragment.java:53: error: cannot find symbol
    public static RichEditorFragment getInstance(FragmentManager fragmentManager, Bundle args) {
                                                 ^
  symbol:   class FragmentManager
  location: class RichEditorFragment

Add mention if not found

So here is my WordTokenizer
WordTokenizer(WordTokenizerConfig.Builder().setWordBreakChars(" ") .setExplicitChars("#").setMaxNumKeywords(1).setThreshold(2).build())

Is there a way to add new mention automatically, when suggestions are not found and I press space (" " my word break).
So lets say I entered: "Spyglass", no suggestions are found, I entered space (" ") and this Spyglass became new Mention with "#" automatically added.

Sorry for a complicated explanation...

MentionsEditable#getMentionSpans is affected by Android 7 ordering bug

In Android 7, there is a bug where SpannableStringBuilder#getSpans returns spans in the wrong order. You can refer the issue here https://issuetracker.google.com/issues/37129364

The workaround mention is to sort the spans array. implemented in the context of this lib:

// MentionsEditable.java
@NonNull
public List<MentionSpan> getMentionSpans() {
    MentionSpan[] mentionSpans = getSpans(0, length(), MentionSpan.class);
    List<MentionSpan> list = (mentionSpans != null)
            ? Arrays.asList(mentionSpans)
            : new ArrayList<MentionSpan>();
    Collections.sort(list, new Comparator<MentionSpan>() {
        @Override
        public int compare(MentionSpan o1, MentionSpan o2) {
            return getSpanStart(o1) - getSpanStart(o2);
        }
    });
    return list;
}

Fatal Exception: java.lang.RuntimeException: Could not read input channel file descriptors from parcel.

Hi guys!

First at all, thank you very much for your awesome library!

An user of my App, had a strange crash yesterday on Samsung SM-G950F (Android 7.0). It's the first time. I never seen this crash before.

Do you have some explanations?

Thank you very much

Fatal Exception: java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
       at android.view.InputChannel.nativeReadFromParcel(InputChannel.java)
       at android.view.InputChannel.readFromParcel(InputChannel.java:148)
       at android.view.InputChannel$1.createFromParcel(InputChannel.java:39)
       at android.view.InputChannel$1.createFromParcel(InputChannel.java:37)
       at com.android.internal.view.InputBindResult.<init>(InputBindResult.java:68)
       at com.android.internal.view.InputBindResult$1.createFromParcel(InputBindResult.java:112)
       at com.android.internal.view.InputBindResult$1.createFromParcel(InputBindResult.java:111)
       at com.android.internal.view.IInputMethodManager$Stub$Proxy.startInputOrWindowGainedFocus(IInputMethodManager.java:840)
       at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:1765)
       at android.view.inputmethod.InputMethodManager.restartInput(InputMethodManager.java:1588)
       at com.linkedin.android.spyglass.ui.MentionsEditText.restartInput(MentionsEditText.java:1089)
       at com.linkedin.android.spyglass.ui.MentionsEditText.ensureMentionSpanIntegrity(MentionsEditText.java:835)
       at com.linkedin.android.spyglass.ui.MentionsEditText.access$1100(MentionsEditText.java:80)
       at com.linkedin.android.spyglass.ui.MentionsEditText$MyWatcher.afterTextChanged(MentionsEditText.java:612)
       at android.widget.TextView.sendAfterTextChanged(TextView.java:9506)
       at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:12455)
       at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:1218)
       at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:579)
       at com.linkedin.android.spyglass.mentions.MentionsEditable.replace(MentionsEditable.java:105)
       at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:230)
       at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:229)
       at android.text.method.BaseKeyListener.backspaceOrForwardDelete(BaseKeyListener.java:349)
       at android.text.method.BaseKeyListener.backspace(BaseKeyListener.java:68)
       at android.text.method.BaseKeyListener.onKeyDown(BaseKeyListener.java:458)
       at android.text.method.QwertyKeyListener.onKeyDown(QwertyKeyListener.java:357)
       at android.text.method.TextKeyListener.onKeyDown(TextKeyListener.java:136)
       at android.widget.TextView.doKeyDown(TextView.java:7407)
       at android.widget.TextView.onKeyDown(TextView.java:7190)
       at android.view.KeyEvent.dispatch(KeyEvent.java:3337)
       at android.view.View.dispatchKeyEvent(View.java:10615)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1697)
       at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:599)
       at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1880)
       at android.app.Activity.dispatchKeyEvent(Activity.java:3164)
       at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:534)
       at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:58)
       at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:316)
       at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:58)
       at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:476)
       at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:5048)
       at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5010)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4539)
       at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4592)
       at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4558)
       at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4691)
       at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4566)
       at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4748)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4539)
       at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4592)
       at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4558)
       at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4566)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4539)
       at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7098)
       at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7030)
       at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6991)
       at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:4188)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6776)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

How to genrate tags that can be shared over network.

Hello,

I have implemented this library in my android code, I want to share the tags over internet and want to show it on other end, Please suggest me how to achieve this. I am using mention edit text.

  • is their any formatted output which can i use to generate tags on the other device.

Editing feature

Is there a way to manually create Mentions?
This is to cater to editing existing post/status updates. Based on the current sample implementations, its only for creating a non-editable status.
In order to edit, there should be some sort of way to notify a range of text is a Mention and convert it accordingly

How to delete/remove mention when unchecked via checkbox?

Hi,

I am working on a feature, where we add mentions to RichEditorView when user clicks on a checkbox from an available list of mentions.

I want to implement a thing where the mention would be deleted when user unchecked the checkbox corresponding to the respective mention.

I tried looking into the already existing code, but can't seem to figure it out.

I am aware of onMentionDeleted() but that method is called when a mention is deleted from RichEditorView, I want to implement something that deletes a mention from RichEditorView.

I see a similar thing happening with LinkedIn Android app, but I can't seem to determine how I can perform this.

Thanks.

Get string in a form that I can send off to the server

Hey there, thanks for this amazing library, i am facing some issues.

I need to obtain the text in a format that I can send it to the server. Something like this:

user text with mentions : "I want to thanks to @john and to @jane "

server text: "I want to thanks to [John, id:45] and to [Jane, id:156]"

How I could achieve this ?
Thanks.

Turn off "implicit" mentions

Hey, me again :D

This is my "Tokenizer" configuration
WordTokenizerConfig config = new WordTokenizerConfig.Builder().setThreshold(2).setMaxNumKeywords(100).build();

I just want to see suggestions when "@" is entered. But whenever 2 characters are entered suggestions starts showing. "setThreshold(2)" is because I want to cater space " " in between text while searching. For example, "A M".
Let me know if this makes sense, otherwise I will try to explain further.

Thanks,
Shahroz

How to include '@' (explicit character) in the mention ?

Hey guys, great library !! 🥇

I am exploring this lib since 3 days for the user mention feature & I have a requirement to show '@' (explicit character) in the MentionEditText, even after the user selects a suggestion from the list of suggestions.
Here is an example:

Current behaviour:
Hello there, Rahul Deshpande here.

Expected behaviour:
Hello there, explicit character -> @Rahul Deshpande here.

Having needed this, that explicit character must be spanned with the highlighted colour, etc.. just like the mention & must behave same like it.
In short, it must be a part of that mention.

I tried to search in the library, but couldn't find any convenience method for this configuration, so could any please help me ?

💃 Cheers !!

Save state of the mention edit text.

Hi I am having an issue with saving the state of the mention edit text.

I am tagging some users in the mention edit text in an activity and closing the activity. Now returning to the activity and checking what users I have tagged in the mention edit text. But I cannot seem to set the users in my mention edit text again. The following is what I have tried,

                   `for (User user : userList) {
                        eTxtTag.insertMention(user);
                         eTxtTag.setText(user.getUserName()+ " " + eTxtTag.getText());
                          //int ei = user.getUserName().length();
                          //Selection.setSelection(eTxtTag.getText(), ei);
                }` 

Here the user is my mentionable object and the userlist is the list of mention users. So how can I fix the issue.

Can i recreate mention programatically from server response

Am not sure whether this accounts for an issue or not. I couldn't find enough help, that's why am here.
The problem i face is while editing the comment. The server gives response in a form where the tag is coming as a href link. I could recreate the mention like, Person class in sample, using regex from the link. But am not able to replace the link with mentionspan item, like we get in MentionsEditText when we select any suggestion.
Is there any way to achieve it? If not, please provide some suggestions in this regard.

How to set Explicit Character?

Hello, Currently I am using WordTokenizer with MentionsEditText as showed in GridMentions Sample!
This is my config :
private WordTokenizerConfig tokenizerConfig = new WordTokenizerConfig.Builder().setMaxNumKeywords(3).setThreshold(3).build();

Problem is that this triggers the OnQueryReceived and looks for suggestions on any random text input but I want that to be triggered only when the user uses @ keyword.

This currently works like this ->
User Input: I went (Query Is Triggered) on a dinner

What I want ->
User Input: I went on a dinner with @faraz (Here I want the query to be triggered and show suggestions)

Having emoticon characters in the mention causes problem to delete

If I have emoticon characters in the mention, I can not delete the MentionSpan properly.

For example, use this emoticon character 😄 as one of the contact's last name in people.json in the sample, and then try to mention that person's first name to find it in the suggestion, select that name and try to delete it from the edit text.

Stops searching on "space"

Hey There, thanks for this amazing library, i am facing this issue.
Whenever I enter space, i don't get any thing in
// public List onQueryReceived(@nonnull QueryToken queryToken) {
How can i fix this? I need to cater space as a part of search.
Thanks.

Suggestible.getId() conflicts with everything

Any bean that has an ID has a getId method, but its not always an int return type (in fact in modern code, it's seldom an int).

This should be changed to differentiate it from a POJO's id.

Suggestible.getSuggestibleId();

While your at it, the String getPrimaryText(); method is too generic. maybe rename it to getSuggestiblePrimaryText();.

As for right now, I'm looking for a workaround for this little showstopper.
I don't mind fixing it and generating a pull request if that will help.

Counter is Visible after using mentions

After choosing one of the possible suggestions in the mentions, the visibility of the counterview is visible again after i have used initially this method

composerMessageView.displayTextCounter(false)

But when the onReceiveSuggestionsResult(result, BUCKET) is been called for the second time, it changes the visibility

Select mention then delete it, doesn'work

Hi guys!

I select a mention (with index start and end from my EditText), then I tape on backpress key or another letter (doesn't matter), this mention stays. It's due to "PlaceHolderSpan" in MentionsEditText...

So how can I replace a mention? Is there a hack to do that?

Thank you very much guys!

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.