GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - hanggrian/socialview: Text and text fields with hashtag, mention and hyperlink support

BranchesTags
Open more actions menu

Latest commit

 

History

172 Commits
172 Commits

Folders and files

NameName
Last commit message
Last commit date
.circleci
.circleci
 
 
config/checkstyle
config/checkstyle
 
 
gradle
gradle
 
 
sample
sample
 
 
socialview-autocomplete
socialview-autocomplete
 
 
socialview
socialview
 
 
website
website
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle.kts
build.gradle.kts
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle.kts
settings.gradle.kts
 
 

Repository files navigation

CircleCI Codecov Maven Central Android SDK
Figma Layers Pinterest

SocialView

TextView and EditText with hashtag, mention, and hyperlink support.

  • Pre-loaded with default views, but also installable to any custom view.
  • Display hashtag and mention suggestions as you type.

Download

repositories {
    mavenCentral()
    google()
}
dependencies {
    // base widgets
    implementation "com.hanggrian.socialview:socialview:$version"

    // auto-complete widgets
    implementation "com.hanggrian.socialview:socialview-autocomplete:$version"
}

Usage

Base library contains SocialTextView, SocialEditText and helper class to apply such behavior in any TextView.

<com.hanggrian.socialview.SocialTextView
  android:id="@+id/textView"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:text="#hashtag and @mention."
  app:socialFlags="hashtag|mention"
  app:hashtagColor="@color/blue"
  app:mentionColor="@color/red"/>

See attrs.xml for full list of available attributes.

Modify its state and set listeners programmatically.

textView.setMentionEnabled(false);
textView.setHashtagColor(Color.RED);
textView.setOnHashtagClickListener((view, s) -> {
    // ...
});

Auto-complete

Extended library comes with SocialAutoCompleteTextView.

<com.hanggrian.socialview.autocomplete.SocialAutoCompleteTextView
  android:id="@+id/textView"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:hint="What's on your mind?"
  app:socialFlags="hyperlink"
  app:hyperlinkColor="@color/red"/>

To display suggestions, it is required to setHashtagAdapter() and setMentionAdapter().

ArrayAdapter<Hashtag> hashtagAdapter = new HashtagAdapter(getContext());
hashtagAdapter.add(new Hashtag("isell"));
hashtagAdapter.add(new Hashtag("isellpropane", 500));
textView.setHashtagAdapter(hashtagAdapter);

ArrayAdapter<Mention> mentionAdapter = new MentionAdapter(getContext());
mentionAdapter.add(new Mention("hank"));
mentionAdapter.add(new Mention("hankhill", "Hank Hill", R.drawable.ic_person));
textView.setMentionAdapter(mentionAdapter);

To customize hashtag or mention adapter, create a custom adapter using customized SocialAdapter or write your own ArrayAdapter.

Custom adapters are experimental, see sample for example.

public class Person {
    public final String name;

    public Person(String name) {
        this.name = name;
    }
}

// easier
public class PersonAdapter extends SocialAdapter<Person> {
    public PersonAdapter(@NonNull Context context) {
        super(context, R.layout.item_person, R.id.textview_person);
    }

    @Override
    public String convertToString(Person $receiver) {
        return $receiver.name;
    }

    @Override
    public View getView(int position, View convertView, @NonNull ViewGroup parent) {
        // ...
    }
}

// this works too
public class PersonAdapter extends ArrayAdapter<Person> {
    // your own adapter layout, view holder, data binding
    // and of course, filtering logic
}

Then, use the custom adapter.

ArrayAdapter<Person> adapter = new PersonAdapter(getContext());
adapter.add(personA);
adapter.add(personB);
textView.setMentionAdapter(adapter);

About

Text and text fields with hashtag, mention and hyperlink support

hanggrian.com/socialview/

Topics

android-librarysocial-mediasuggestions

Resources

Readme
Apache-2.0 license
Activity

Stars

329 stars

Watchers

9 watching

Forks

78 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.