MCPcopy Index your code
hub / github.com/DavidPizarro/AutoLabelUI

github.com/DavidPizarro/AutoLabelUI @version_1.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release version_1.0.1 ↗ · + Follow
176 symbols 333 edges 10 files 34 documented · 19%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

AutoLabelUI

Android Arsenal Maven Central Android Gems

Android library to place labels next to another. If there is not enough space for the next label, it will be added in a new line.

Example screenshot

Try out the sample application on Google Play.

AutoLabelUI Sample on Google Play

Demo

Example gif

Including in Your Project

Last version is 1.0.0

Just add the following statement in your build.gradle

compile 'com.github.davidpizarro:autolabelui:VERSION'

You may also add the library as an Android Library to your project. All the library files live in library.

Usage

To add the AutoLabelUI to your layout, add this to your xml

<com.dpizarro.autolabel.library.AutoLabelUI
        android:id="@+id/label_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

You can add custom attributes in your xml to customize: drawables, colors, counters, background, behaviors...


<com.dpizarro.autolabel.library.AutoLabelUI
        android:id="@+id/label_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        autolabel:max_labels="10"
        autolabel:show_cross="true"
        autolabel:text_color="@android:color/white"
        autolabel:text_size="@dimen/label_title_size"
        autolabel:icon_cross="@drawable/cross"
        autolabel:background_res="@color/default_background_label"
        autolabel:label_clickable="true"/>

Review attrs.xml file to know the list of shapes ready to be used in the library.

This configuration can be also provided programmatically. You can use AutoLabelUI programatically, using the Builder class to set the settings and the desired functionalities:

AutoLabelUI mAutoLabel = (AutoLabelUI) view.findViewById(R.id.label_view);

AutoLabelUISettings autoLabelUISettings = new AutoLabelUISettings.Builder()
                                                                 .withMaxLabels(5)
                                                                 .withIconCross(R.drawable.cross)
                                                                 .withBackgroundResource(android.R.color.holo_blue_bright)
                                                                 .withLabelsClickables(false)
                                                                 .withShowCross(true)
                                                                 .withTextColor(android.R.color.holo_red_dark)
                                                                 .withTextSize(R.dimen.label_title_size)
                                                                 .build();

mAutoLabel.setSettings(autoLabelUISettings);

You can set/get values programatically:

mAutoLabel.getBackgroundResource();
mAutoLabel.getTextColor();
mAutoLabel.getTextSize();
mAutoLabel.isLabelsClickables();
mAutoLabel.setTextColor(android.R.color.holo_red_dark);
mAutoLabel.setMaxLabels(5);
...

You can get Label using:

Label label = mAutoLabel.getLabel(1);
List<Label> labels = mAutoLabel.getLabels();

or remove them all:

mAutoLabel.clear();

To know when you have reached the limit of Labels to add, you will need to implement the onLabelsCompleted interface:

mAutoLabel.setOnLabelsCompletedListener(new AutoLabelUI.OnLabelsCompletedListener() {
    @Override
    public void onLabelsCompleted() {
        Toast.makeText(getActivity(), "Completed!", Toast.LENGTH_SHORT).show();
    }
});

To know when you have deleted all Labels, you will need to implement the onLabelsEmpty interface:

mAutoLabel.setOnLabelsEmptyListener(new AutoLabelUI.OnLabelsEmptyListener() {
    @Override
    public void onLabelsEmpty() {
        Toast.makeText(getActivity(), "EMPTY!", Toast.LENGTH_SHORT).show();
    }
});

To know when you have deleted a Label, you will need to implement the onRemoveLabel interface:

mAutoLabel.setOnRemoveLabelListener(new AutoLabelUI.OnRemoveLabelListener() {
    @Override
    public void onRemoveLabel(View view, int position) {
        adapter.setItemSelected(position, false);
    }
});

To know when you have clicked a Label, you will need to implement the onClickLabel interface:

mAutoLabel.setOnLabelClickListener(new AutoLabelUI.OnLabelClickListener() {
    @Override
    public void onClickLabel(View v) {
        Toast.makeText(getActivity(), ((Label) v).getText() , Toast.LENGTH_SHORT).show();
    }
});

Or browse the source code of the sample application for a complete example of use.

Contribution

Pull requests are welcome!

I'd like to improve this library with your help! If you've fixed a bug or have a feature you've added, just create a pull request. Issues can be reported on the github issue tracker.

Author

David Pizarro (dpizarro89@gmail.com)

Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2015 David Pizarro

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.

Extension points exported contracts — how you extend this code

OnLabelClickListener (Interface)
Interface for a callback listener when the Label is clicked. Container Activity/Fragment must implement this int [3 implementers]
library/src/main/java/com/dpizarro/autolabel/library/AutoLabelUI.java
OnItemClickListener (Interface)
(no doc) [1 implementers]
app/src/main/java/com/dpizarro/libraries/autolabelui/MyRecyclerAdapter.java
OnLabelClickListener (Interface)
Interface for a callback listener when the Label is clicked. Container Activity/Fragment must implement this int [3 implementers]
library/src/main/java/com/dpizarro/autolabel/library/Label.java
OnRemoveLabelListener (Interface)
Interface for a callback when a label is removed. Container Activity/Fragment must implement this interface [2 implementers]
library/src/main/java/com/dpizarro/autolabel/library/AutoLabelUI.java
OnLabelsCompletedListener (Interface)
Interface for a callback listener when there are the maximum number of labels. Container Activity/Fragment must implemen [2 …
library/src/main/java/com/dpizarro/autolabel/library/AutoLabelUI.java
OnLabelsEmptyListener (Interface)
Interface for a callback listener when there are not labels. Container Activity/Fragment must implement this interface [2 …
library/src/main/java/com/dpizarro/autolabel/library/AutoLabelUI.java

Core symbols most depended-on inside this repo

getText
called by 6
library/src/main/java/com/dpizarro/autolabel/library/Label.java
setText
called by 5
library/src/main/java/com/dpizarro/autolabel/library/Label.java
addLabel
called by 4
library/src/main/java/com/dpizarro/autolabel/library/AutoLabelUI.java
getLabelsCounter
called by 4
library/src/main/java/com/dpizarro/autolabel/library/AutoLabelUI.java
clear
called by 4
library/src/main/java/com/dpizarro/autolabel/library/AutoLabelUI.java
onLabelsEmpty
called by 4
library/src/main/java/com/dpizarro/autolabel/library/AutoLabelUI.java
setOnLabelClickListener
called by 4
library/src/main/java/com/dpizarro/autolabel/library/Label.java
decreaseLabelsCounter
called by 3
library/src/main/java/com/dpizarro/autolabel/library/AutoLabelUI.java

Shape

Method 155
Class 14
Interface 7

Languages

Java100%

Modules by API surface

library/src/main/java/com/dpizarro/autolabel/library/AutoLabelUI.java46 symbols
library/src/main/java/com/dpizarro/autolabel/library/AutoLabelUISettings.java33 symbols
app/src/main/java/com/dpizarro/libraries/autolabelui/RecyclerViewFragment.java15 symbols
app/src/main/java/com/dpizarro/libraries/autolabelui/MyRecyclerAdapter.java15 symbols
app/src/main/java/com/dpizarro/libraries/autolabelui/Person.java14 symbols
library/src/main/java/com/dpizarro/autolabel/library/Label.java12 symbols
app/src/main/java/com/dpizarro/libraries/autolabelui/SimpleFragment.java12 symbols
app/src/main/java/com/dpizarro/libraries/autolabelui/MainActivity.java11 symbols
library/src/main/java/com/dpizarro/autolabel/library/LabelValues.java10 symbols
library/src/main/java/com/dpizarro/autolabel/library/AutoViewGroup.java8 symbols

For agents

$ claude mcp add AutoLabelUI \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page