Coder Social home page Coder Social logo

doodlescheduling / android-material-chips Goto Github PK

View Code? Open in Web Editor NEW
268.0 13.0 57.0 1.27 MB

A different approach to implement android material chips since using transformed images inside an EditText cause too many exceptions on older devices and older versions.

Home Page: http://doodle.com

License: Apache License 2.0

Java 100.00%

android-material-chips's Introduction

Android Material Chips

A different approach to implement android material chips since using transformed images inside an EditText cause too many exceptions on older devices and older versions.

Features

Enter an email address and it will automatically transform into a chip

Email validation dialog

*** UPDATE: The dialog is not included in version 1.2.0 anymore. Show your own dialog instead. ***

Customize your layout and text

Sample

APK: sample-apk-1.0.1

Download

Gradle:

via jCenter

buildscript {
    repositories {
        jcenter()
    }
}

dependencies {
    compile 'com.doodle.android:android-material-chips:1.2.0'
}

via JitPack.io

repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    compile 'com.github.DoodleScheduling:android-material-chips:1.2.0'
}

Usage

Use the ChipsView class in your layout file.

<com.doodle.android.chips.ChipsView
    android:id="@+id/chipsView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

Customize

Layout

Include xmlns:app="http://schemas.android.com/apk/res-auto" and customize your layout file.

<com.doodle.android.chips.ChipsView
	android:id="@+id/chipsView"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	app:cv_max_height="120dp"
	app:cv_vertical_spacing="2dp"
	app:cv_bg_color="#f00"
	app:cv_bg_color_clicked="#0f0"
	app:cv_color="#00f"
	app:cv_color_clicked="#721"
	app:cv_text_color="#199"
	app:cv_text_color_clicked="#180"
	app:cv_bg_color_indelible="#f00"
	app:cv_text_color_indelible="#0f0"
	app:cv_icon_placeholder="@drawable/ic_bug_report_24dp"
	app:cv_icon_placeholder_tint="#06f"
	app:cv_icon_delete="@drawable/ic_close_24dp"
	app:cv_text_hint="This is the hint text"
	app:cv_chips_margin="2dp"

====== Find the View in your Activity or Fragment class.

mChipsView = (ChipsView) findViewById(R.id.chipsView);

Listener

The ChipsView provides a listener to interact with your data.

mChipsView.setChipsListener(new ChipsView.ChipsListener() {
    @Override
    public void onChipAdded(ChipsView.Chip chip) {
        // chip added
    }

    @Override
    public void onChipDeleted(ChipsView.Chip chip) {
        // chip deleted
    }

    @Override
    public void onTextChanged(CharSequence text) {
        // text was changed
    }
            
    @Override
    public boolean onInputNotRecognized(String text) {
        // return true to delete the input
        return false; // keep the typed text
    }
});

Add a new chip

mChipsView.addChip(email, imgUrl, contact);

Add a non-removable chip.

mChipsView.addChip(email, imgUrl, contact, true);

Remove a chip

mChipsView.removeChipBy(contact);

Add Custom chip validator

mChipsView.setChipsValidator(new ChipsView.ChipValidator() {
    @Override
    public boolean isValid(Contact contact) {
        return true;
    }
});

Apps with Android chips:

License

Copyright (C) 2016 Doodle AG.

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.

android-material-chips's People

Contributors

alexanderthiele avatar bryant1410 avatar myacxy avatar pravsonawane 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

android-material-chips's Issues

Return email to chip on cancel

Is there a way to return the email to a chip on cancel?

The text is editable as soon as the user cancel the delete's action

check boxes and chips are not synchronized

If add a user by checking a check box from list then delete that item from chipsview, in the list checkbox is still selected. Also if I add a user by typing it to chipsview in the list that user wont be selected.

Compatibility issue with Picasso causing crashes

Hello,

My app started crashing recently when adding chips.
It looks like a compatibility issue with Picasso:

java.lang.NoSuchMethodError: No static method with(Landroid/content/Context;)Lcom/squareup/picasso/Picasso; in class Lcom/squareup/picasso/Picasso; or its super classes (declaration of 'com.squareup.picasso.Picasso' appears in /data/app/com.synkers.synkers.debug-xgbBJJ_V1j-_K7dtif3uvA==/base.apk:classes3.dex)
        at com.doodle.android.chips.ChipsView$Chip.updateViews(ChipsView.java:723)
        at com.doodle.android.chips.ChipsView$Chip.getView(ChipsView.java:710)
        at com.doodle.android.chips.views.ChipsVerticalLinearLayout.onChipsChanged(ChipsVerticalLinearLayout.java:62)
        at com.doodle.android.chips.ChipsView.onChipsChanged(ChipsView.java:372)
        at com.doodle.android.chips.ChipsView.addChip(ChipsView.java:291)
        at com.doodle.android.chips.ChipsView.addChip(ChipsView.java:277)
        at com.doodle.android.chips.ChipsView.addChip(ChipsView.java:273)

Is anyone having this problem?
Will you be fixing this soon?

Evitar Duplicade Chip?

Hello, first of all excellent bookshop.
My question is, how to avoid duplicating Chips that have the same data.?

Why the min SDK version is 16?

I tested the lib with min SDK version with 14 and works perfectly. I didn't find any thing for which we have to restrict min sdk to version 16. Please update the min sdk version so it can be used in lower end android devices.

Now working with the modified(changed gradle to minSdkVersion:14) source to meet my goal(cause my project min version is 14). If you guys modify your project minSdkVersion to lower then we guys can use gradle dependency in our project and get updated lib whenever update comes.

Thanks for the lib. :)

Broken Chip

When i add a chip in my project, one side is rounded and other is not rounded but when i run the same code as a seperate program the chip is displayed properly can you explain y ?

Text and Chips are not at the same level

When you add an email manually, the cursor is not at the same level of the chips but it is under that.
This cause to have a bigger view when it's not necessary.

For example if I want to have a 56dp height chipsView and I set android:minHeight="56dp" the cursor is in the correct position, but the chips haven't a padding from the top.
Adding a paddingTop to the view cause the view to have a greater height, so it's not correct again.

Following the material design specs, the cursor shold be at the same level of the chips.

Unable to resolve dependency - Maven Central

Searching the maven central repository, I can't seem to find the project. Is it hosted on a different repository?

http://search.maven.org/#search%7Cga%7C1%7Ccom.doodle.android yields no results, and my gradle can't resolve the dependency to build my project.

Extra top margin added when email's length exceeds ChipsView's width

I'm getting an issue while integration this library into a project.

If the length of the email exceeds the width of the ChipsView, the embedded EditText has an oversized top margin.

I can reproduce the issue with the Sample app, and with the Doodle app as well, just by typing a long email. The issue is more visible if the layout_width of the ChipsView is smaller.

screenshot_20180516-131938

Weird behavious > 5.0 OS

Hi,

I see weird behavior in Android OS > 5.0 , ChipsView works fine with lesser version.
Issue : When I click on ChipsView , Keyboard comes up and it actually cover my app with white screen.

My layout contains CoordinatorLayout, AppBarLayout and ChipsVIew below TextView . Attaching image for reference. Sorry I brushed image due to privacy policy.

Earlier I though my anyof layout is over coming but I verified it by changing background color of each elements still WHITE color was coming up. In some devices it coming over to AppBarLayout.

Tested version : 5.1 , 6.0

Works fine with : 4.4.4

image1

Not working with API level 28

Android resource linking failed
../app/build/intermediates/incremental/mergeStagingDebugResources/merged.dir/values/values.xml:7651: error: style attribute 'attr/textColorError (aka package_name:attr/textColorError)' not found.
error: failed linking references.

Could you fix this error?

View gets slowdown when more than 20 items selected.

Hello,
I'm using your beautiful library. Recently I found that when more than 20 items selected the main thread gets slow down and some of chips looses images.

It'd be nice if you find this issue and provide the solution.

Thanks.

Move Cursor with hint appear everytime

I am using this library i have a issue with cursor move. when i create a chip not in the list then my cursor stay with starting on a chip. and i also want my hint will be always appear after chip.

Ability to Add User @ Mentions in addition to Email address

Hi there,

I am developing with this library and found the need to extend it to support @ mentions in addition to email addresses. I aim to add the flexibility to use custom regex patterns too.

Please let me know if this is something you are currently working on.

Otherwise, expect a pull request with these improvements soon.

Arjun

Just wondering why it's so tied to Contact data type

Would it be possible to create something that takes Countries, for example? Also, how do you insert a chip at a certain position?

That's it. It would also be nice to have control on the layout of the chip. Oh well, I keep looking. Google should really release an official library for this.

Fixed height ChipsView does not scroll

When setting the layout_height to a fixed height, instead of wrap_content it's not possible to scroll through the chips added.

EDIT
It's easy to wrap the ChipsView in a ScrollView with a fixed height, and setting the ChipsView to match_parent. This almost gives the desired result. An odd case where if the scroll view is not scrolled it is not possible to remove chips, the second "remove" tap is swallowed. A work around is to fullScroll(VIEW.FOCUS_DOWN) on the containing scroll view each time a chip is added in the ChipsListener call back. This properly allows the removal of chips again.

I stepped through this in the debugger a bit, and it's a difficult problem to express. If the ChipsView is contained in a ScrollView the unSelectChipsExcept() function acts up. It always marks all chips as unselected, but the UI never updates to reflect that. The chip remains visually selected, but its selected flag is set to false. For whatever reason this is mitigated when the ScrollView is scrolled.

Adapting the content for other data types

Thanks for your work. I wonder if instead of telephone contacts or emails, as I can load a list of categories with their images and writing me a dropdown appear with what I want to filter. Thank you.

Chip margin not working on 5.0.2

Separation between chips not working on android 5.0.2.

When adding app:cv_chips_margin="3dp" margin does not show up.

On android 7.1.1 it's working than.. any idea what's the problem?

Add `OnChipSelected` method to ChipsListener Interface

I was using this library, and I found this feature necessary, so I did this myself by cloning this repo and adding it myself. It's a very small change and quite useful, I'd be glad to make the PR if you thought it was appropriate to add this feature.

ChipsEmailDialogFragment and orientation changes

ChipsEmailDialogFragment has set*Listener methods. Due to the nature of fragment->activity interaction, if not cleared manually, those become view leak after activity is recreated. What is more, newly (re)created fragment won't work because nobody called set*Listener on it.

I think there are to possible solutions as follow:

  • either use local broadcast manager to communicate dialog->view,
  • require chip view host to implement callback and be responsible for forwarding that call to chipview.

I would go for the first and I can prepare fix if you agree on the issue and suggested fix.

ChipsView does not get cursor focus

I've tried adding the sample MainActivity to an existing Android project (Conversations, an XMPP client). I copied the code and layout 1-to-1, merely renaming the activity and making it extend Activity instead of AppCompatActivity (since I don't need the additional features).

In the example, I can add chips via the RecycleView without any problem whatsoever, just like in the provided sample project. I also can click into the added chips, remove them, or click twice on them such as to activate the "edit" functionality.

However, the cursor never appears when I click on the ChipsView and keyboard for text input never appear. Not when I click into the ChipsView when it is empty, not when chips are already present, not even when editing a Chip.

Any idea why this might be happening? You can also check out https://github.com/Natanji/Conversations (just run the ConferenceKeywordsActivity directly) if you want to see this behaviour first-hand.

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.