diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..681f41a --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 1bbc21d..7765d85 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -3,15 +3,21 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index c60d22d..e05fe48 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,43 +1,45 @@ - - - - - - - - - - - - - - + diff --git a/.idea/modules.xml b/.idea/modules.xml index 352ac86..6683619 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,7 +3,8 @@ - + + \ No newline at end of file diff --git a/README.md b/README.md index 4199631..897e42a 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,93 @@ -#Android TagView -Android TagView-HashTagView +# Android SimpleTagView +Android SimpleTagView derived from Cüneyt Çarıkçi -[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-TagView-green.svg?style=flat)](https://android-arsenal.com/details/1/2566) +This lib includes two customViews: +* **SimpleTagView** to show wrapped TextViews in the form of tags with icon and delete capability +* **SimpleTagRelativeLayout** to dynamically add and remove tags within a custom RelativeLayout. +* Additional static function to expose **font-awesome** functions -Simple android view to display collection of colorful tags efficiently. -You can edit the tag's style, and set listener of selecting or deleting tag. -Example usages can be found in example project. - -#Screen - - +Lib was forked from Cüneyt ViewTag, but I tried to expose also single-tagView API, +not forcing the user to pass thru a *containing* RelativeLayout view. SimpleTagView +is simpler, since it uses layout, but also supports **font-awesome** to put an icon on your TAGs. +You can edit the tag's color and set listener for selecting or deleting. #Feature -* Editable Style of Text, such as Font size and color. -* Editable Style of Tag, Background/Pressed Color, Radius effect, Custom Background, Delete mode. +* SimpleTagView extends GroupView, it represents a single TAG. Can be deletable or not +* SimpleTagRelativeLayout is a group of TAGs, allowing add, removal and listeners. * Listener of tag selecting and deleting. +* Font-awesome 4.7.0 native support * Can be created from XML file or Java code. -#Usage -
<cuneyt.example.com.tagview.Tag.TagView
+![demo app screenshot](https://10428.https.cdn.softlayer.net/8010428/dal05.objectstorage.softlayer.net/v1/AUTH_3c173d3a-8847-45dc-9d93-faf1d6e70fe5/screenshots/fe21ca31-54a8-4c80-ae49-7bfe6ea936c7)
+
+# Usage
+You'll need to add gradle dependency from *jcenter()* as usualadding the following
+to your *build.gradle* 
+
+
+   compile 'it.angelic:tagView:1.4.0'
+
+ +## Usage in XML +After having declared the namespace, with something like
xmlns:tagview="http://schemas.android.com/apk/res-auto"
+you may declare a Tag group like this: + +
<it.angelic.tagviewlib.SimpleTagRelativeLayout
             android:id="@+id/tag_group"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:layout_margin="10dp" />
 
+ +or a single tag like this: + +
<it.angelic.tagviewlib.SimpleTagView
+            android:id="@+id/myTestTag"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            tagview:tagColor="@android:color/holo_purple"
+            tagview:tagAwesome="fa-hand-spock-o"
+            tagview:titleText="My HashTag" />
+
-
- TagView tagGroup = (TagView)findviewById(R.id.tag_view);
- //You can add one tag
- tagGroup.addTag(Tag tag);
+## Usage in code
+You can add one tag inside SimpleTagRelativeLayout:
+
+ SimpleTagRelativeLayout tagGroup = (SimpleTagRelativeLayout) findviewById(R.id.tag_view);
+ tagGroup.addTag(SimpleTagView tag);
  //You can add multiple tag via ArrayList
  tagGroup.addTags(ArrayList tags);
  //Via string array
  addTags(String[] tags);
- 
-  
-   //set click listener
-      tagGroup.setOnTagClickListener(new OnTagClickListener() {
+ //click listener example
+ tagGroup.setOnTagClickListener(new OnTagClickListener() {
             @Override
             public void onTagClick(Tag tag, int position) {
             }
-        });
-        
-   //set delete listener
-            tagGroup.setOnTagDeleteListener(new OnTagDeleteListener() {
-            @Override
-            public void onTagDeleted(final TagView view, final Tag tag, final int position) {
-            }
-        });  
+ });     
+ //delete listener example
+ tagGroup.setOnTagDeleteListener(new OnTagDeleteListener() {
+   @Override
+   public void onTagDeleted(final TagView view, final Tag tag, final int position) {
+   }
+ });
+ 
+ + Or you can add SimpleTagView directly to your Views like this: +
+ SimpleTagView tagTer2 = new SimpleTagView(getApplicationContext());
+ tagTer2.setText("Programmatic Deletable");
+ //Set font-awesome icon to be used
+ tagTer2.setFontAwesome("fa-warning");
+ tagTer2.setDeletable(true);
 
-#Sample APK -https://www.dropbox.com/s/m1y1npssj5b4bck/app-debug.apk?dl=0 - -#Libraries Used -ButterKnife by Jake Wharton
-MaterialDialog by drakeet +# Libraries & Credits +ButterKnife by Jake Wharton -#License -Copyright 2015 Cüneyt Çarıkçi. +Font Awesome by Dave Gandy -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 +Copyright 2016 shine@angelic.it forking Cüneyt Çarıkçi - 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. + diff --git a/ReleaseNotes.md b/ReleaseNotes.md new file mode 100644 index 0000000..9546030 --- /dev/null +++ b/ReleaseNotes.md @@ -0,0 +1,29 @@ +# 1.4.0 +* Updated to Android 9 + +# 1.3.0 +* Updated to Font-awesome 4.7.0 + +# 1.2.2 +* better font-awesome APIs +* some unit-testing + +# 1.2.1 +* unit testing, lint fixes, bugfixes + +# 1.2.0 +* font-awesome support + +# 1.1.0 +* text size support in XML + +# 1.0.1 +* Adjustments for publish +* Published on [bintray](https://bintray.com/shineangelic/maven/SimpleTagView/view#) + +# 1.0.0 +* First test release +* SimpleTagView added + +# Fork +* forked from Cutta's [TagView](https://github.com/Cutta/TagView/) \ No newline at end of file diff --git a/TagView.iml b/TagView.iml index 516cc17..62769c2 100644 --- a/TagView.iml +++ b/TagView.iml @@ -1,5 +1,5 @@ - + diff --git a/app/app.iml b/app/app.iml deleted file mode 100644 index fdc8f8b..0000000 --- a/app/app.iml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index a831456..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,27 +0,0 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 23 - buildToolsVersion "22.0.1" - - defaultConfig { - applicationId "cuneyt.example.com.tagview" - minSdkVersion 15 - targetSdkVersion 23 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.1.1' - compile 'com.jakewharton:butterknife:6.1.0' - compile 'me.drakeet.materialdialog:library:1.2.2' -} diff --git a/app/src/main/java/cuneyt/example/com/tagview/Activity/MainActivity.java b/app/src/main/java/cuneyt/example/com/tagview/Activity/MainActivity.java deleted file mode 100644 index dca0f5b..0000000 --- a/app/src/main/java/cuneyt/example/com/tagview/Activity/MainActivity.java +++ /dev/null @@ -1,185 +0,0 @@ -package cuneyt.example.com.tagview.Activity; - -import android.graphics.Color; -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.Button; -import android.widget.EditText; -import android.widget.Toast; - -import org.json.JSONArray; -import org.json.JSONObject; - -import java.util.ArrayList; - -import butterknife.ButterKnife; -import butterknife.InjectView; -import cuneyt.example.com.tagview.R; -import cuneyt.example.com.tagview.Tag.Constants; -import cuneyt.example.com.tagview.Tag.OnTagClickListener; -import cuneyt.example.com.tagview.Tag.OnTagDeleteListener; -import cuneyt.example.com.tagview.Tag.Tag; -import cuneyt.example.com.tagview.Tag.TagView; -import cuneyt.example.com.tagview.Models.TagClass; -import me.drakeet.materialdialog.MaterialDialog; - -public class MainActivity extends AppCompatActivity { - - @InjectView(R.id.tag_group) - TagView tagGroup; - - @InjectView(R.id.editText) - EditText editText; - - - /** - * sample country list - */ - ArrayList tagList; - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - ButterKnife.inject(this); - prepareTags(); - - - editText.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - setTags(s); - } - - @Override - public void afterTextChanged(Editable s) { - - } - }); - - tagGroup.setOnTagClickListener(new OnTagClickListener() { - @Override - public void onTagClick(Tag tag, int position) { - editText.setText(tag.text); - editText.setSelection(tag.text.length());//to set cursor position - - } - }); - tagGroup.setOnTagDeleteListener(new OnTagDeleteListener() { - - @Override - public void onTagDeleted(final TagView view, final Tag tag, final int position) { - - final MaterialDialog dialog = new MaterialDialog(MainActivity.this); - dialog.setMessage("\"" + tag.text + "\" will be delete. Are you sure?"); - dialog.setPositiveButton("Yes", new View.OnClickListener() { - @Override - public void onClick(View v) { - view.remove(position); - Toast.makeText(MainActivity.this, "\"" + tag.text + "\" deleted", Toast.LENGTH_SHORT).show(); - dialog.dismiss(); - } - }); - dialog.setNegativeButton("No", new View.OnClickListener() { - @Override - public void onClick(View v) { - dialog.dismiss(); - } - }); - dialog.show(); - - } - }); - - - } - - private void prepareTags() { - tagList = new ArrayList<>(); - JSONArray jsonArray = null; - JSONObject temp; - try { - jsonArray = new JSONArray(Constants.COUNTRIES); - for (int i = 0; i < jsonArray.length(); i++) { - temp = jsonArray.getJSONObject(i); - tagList.add(new TagClass(temp.getString("code"), temp.getString("name"))); - - } - } catch (Exception e) { - e.printStackTrace(); - } - - } - - private void setTags(CharSequence cs) { - String text = cs.toString(); - ArrayList tags = new ArrayList<>(); - Tag tag; - /** - * counter for prevent frozen effect - * if the tags number is greather than 20 some device will a bit frozen - */ - int counter = 0; - - /** - * for empty edittext - */ - if (text.equals("")) { - tagGroup.addTags(new ArrayList()); - return; - } - - for (int i = 0; i < tagList.size(); i++) { - if (tagList.get(i).getName().toLowerCase().startsWith(text.toLowerCase())) { - tag = new Tag(tagList.get(i).getName()); - tag.radius = 10f; - tag.layoutColor = (Color.parseColor(tagList.get(i).getColor())); - if (i % 2 == 0) // you can set deletable or not - tag.isDeletable = true; - tags.add(tag); - counter++; - /** - * if you don't want show all tags. You can set a limit. - if (counter == 10) - break; - */ - - } - } - tagGroup.addTags(tags); - - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.menu_main, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - int id = item.getItemId(); - - //noinspection SimplifiableIfStatement - if (id == R.id.action_settings) { - return true; - } - - return super.onOptionsItemSelected(item); - } -} diff --git a/app/src/main/java/cuneyt/example/com/tagview/Tag/OnTagClickListener.java b/app/src/main/java/cuneyt/example/com/tagview/Tag/OnTagClickListener.java deleted file mode 100644 index b0c33d1..0000000 --- a/app/src/main/java/cuneyt/example/com/tagview/Tag/OnTagClickListener.java +++ /dev/null @@ -1,8 +0,0 @@ -package cuneyt.example.com.tagview.Tag; - -/** - * listener for tag delete - */ -public interface OnTagClickListener { - void onTagClick(Tag tag, int position); -} \ No newline at end of file diff --git a/app/src/main/java/cuneyt/example/com/tagview/Tag/OnTagDeleteListener.java b/app/src/main/java/cuneyt/example/com/tagview/Tag/OnTagDeleteListener.java deleted file mode 100644 index 309ad0d..0000000 --- a/app/src/main/java/cuneyt/example/com/tagview/Tag/OnTagDeleteListener.java +++ /dev/null @@ -1,8 +0,0 @@ -package cuneyt.example.com.tagview.Tag; - -/** - * listener for tag delete - */ -public interface OnTagDeleteListener { - void onTagDeleted(TagView view, Tag tag, int position); -} \ No newline at end of file diff --git a/app/src/main/java/cuneyt/example/com/tagview/Tag/Tag.java b/app/src/main/java/cuneyt/example/com/tagview/Tag/Tag.java deleted file mode 100644 index d2f1b4e..0000000 --- a/app/src/main/java/cuneyt/example/com/tagview/Tag/Tag.java +++ /dev/null @@ -1,52 +0,0 @@ -package cuneyt.example.com.tagview.Tag; - -import android.graphics.drawable.Drawable; - - - -public class Tag { - - public int id; - public String text; - public int tagTextColor; - public float tagTextSize; - public int layoutColor; - public int layoutColorPress; - public boolean isDeletable; - public int deleteIndicatorColor; - public float deleteIndicatorSize; - public float radius; - public String deleteIcon; - public float layoutBorderSize; - public int layoutBorderColor; - public Drawable background; - - - public Tag(String text) { - init(0, text, Constants.DEFAULT_TAG_TEXT_COLOR, Constants.DEFAULT_TAG_TEXT_SIZE, Constants.DEFAULT_TAG_LAYOUT_COLOR, Constants.DEFAULT_TAG_LAYOUT_COLOR_PRESS, - Constants.DEFAULT_TAG_IS_DELETABLE, Constants.DEFAULT_TAG_DELETE_INDICATOR_COLOR, Constants.DEFAULT_TAG_DELETE_INDICATOR_SIZE, Constants.DEFAULT_TAG_RADIUS, Constants.DEFAULT_TAG_DELETE_ICON, Constants.DEFAULT_TAG_LAYOUT_BORDER_SIZE, Constants.DEFAULT_TAG_LAYOUT_BORDER_COLOR); - } - - public Tag(String text, int color) { - init(0, text, Constants.DEFAULT_TAG_TEXT_COLOR, Constants.DEFAULT_TAG_TEXT_SIZE, color, Constants.DEFAULT_TAG_LAYOUT_COLOR_PRESS, Constants.DEFAULT_TAG_IS_DELETABLE, - Constants.DEFAULT_TAG_DELETE_INDICATOR_COLOR, Constants.DEFAULT_TAG_DELETE_INDICATOR_SIZE, Constants.DEFAULT_TAG_RADIUS, Constants.DEFAULT_TAG_DELETE_ICON, Constants.DEFAULT_TAG_LAYOUT_BORDER_SIZE, Constants.DEFAULT_TAG_LAYOUT_BORDER_COLOR); - - } - - private void init(int id, String text, int tagTextColor, float tagTextSize, int layout_color, int layout_color_press, boolean isDeletable, int deleteIndicatorColor, - float deleteIndicatorSize, float radius, String deleteIcon, float layoutBorderSize, int layoutBorderColor) { - this.id = id; - this.text = text; - this.tagTextColor = tagTextColor; - this.tagTextSize = tagTextSize; - this.layoutColor = layout_color; - this.layoutColorPress = layout_color_press; - this.isDeletable = isDeletable; - this.deleteIndicatorColor = deleteIndicatorColor; - this.deleteIndicatorSize = deleteIndicatorSize; - this.radius = radius; - this.deleteIcon = deleteIcon; - this.layoutBorderSize = layoutBorderSize; - this.layoutBorderColor = layoutBorderColor; - } -} diff --git a/app/src/main/java/cuneyt/example/com/tagview/Tag/TagView.java b/app/src/main/java/cuneyt/example/com/tagview/Tag/TagView.java deleted file mode 100644 index d9bd977..0000000 --- a/app/src/main/java/cuneyt/example/com/tagview/Tag/TagView.java +++ /dev/null @@ -1,424 +0,0 @@ -package cuneyt.example.com.tagview.Tag; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Canvas; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.GradientDrawable; -import android.graphics.drawable.StateListDrawable; -import android.util.AttributeSet; -import android.util.TypedValue; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewTreeObserver; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.TextView; - - -import java.util.ArrayList; -import java.util.List; - -import cuneyt.example.com.tagview.R; - -public class TagView extends RelativeLayout { - - /** tag list */ - private List mTags = new ArrayList(); - - /** - * System Service - */ - private LayoutInflater mInflater; - private ViewTreeObserver mViewTreeObserber; - - /** - * listener - */ - private OnTagClickListener mClickListener; - private OnTagDeleteListener mDeleteListener; - - /** view size param */ - private int mWidth; - - /** - * layout initialize flag - */ - private boolean mInitialized = false; - - /** - * custom layout param - */ - int lineMargin; - int tagMargin; - int textPaddingLeft; - int textPaddingRight; - int textPaddingTop; - int texPaddingBottom; - - - /** - * constructor - * - * @param ctx - */ - public TagView(Context ctx) { - super(ctx, null); - initialize(ctx, null, 0); - } - - /** - * constructor - * - * @param ctx - * @param attrs - */ - public TagView(Context ctx, AttributeSet attrs) { - super(ctx, attrs); - initialize(ctx, attrs, 0); - } - - /** - * constructor - * - * @param ctx - * @param attrs - * @param defStyle - */ - public TagView(Context ctx, AttributeSet attrs, int defStyle) { - super(ctx, attrs, defStyle); - initialize(ctx, attrs, defStyle); - } - - /** - * initalize instance - * - * @param ctx - * @param attrs - * @param defStyle - */ - private void initialize(Context ctx, AttributeSet attrs, int defStyle) { - mInflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - mViewTreeObserber = getViewTreeObserver(); - mViewTreeObserber.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - if (!mInitialized) { - mInitialized = true; - drawTags(); - } - } - }); - - // get AttributeSet - TypedArray typeArray = ctx.obtainStyledAttributes(attrs, R.styleable.TagView, defStyle, defStyle); - this.lineMargin =(int) typeArray.getDimension(R.styleable.TagView_lineMargin,Utils.dipToPx(this.getContext(),Constants.DEFAULT_LINE_MARGIN) ); - this.tagMargin =(int) typeArray.getDimension(R.styleable.TagView_tagMargin,Utils.dipToPx(this.getContext(),Constants.DEFAULT_TAG_MARGIN) ); - this.textPaddingLeft =(int) typeArray.getDimension(R.styleable.TagView_textPaddingLeft, Utils.dipToPx(this.getContext(),Constants.DEFAULT_TAG_TEXT_PADDING_LEFT)); - this.textPaddingRight =(int) typeArray.getDimension(R.styleable.TagView_textPaddingRight, Utils.dipToPx(this.getContext(),Constants.DEFAULT_TAG_TEXT_PADDING_RIGHT)); - this.textPaddingTop =(int) typeArray.getDimension(R.styleable.TagView_textPaddingTop, Utils.dipToPx(this.getContext(),Constants.DEFAULT_TAG_TEXT_PADDING_TOP)); - this.texPaddingBottom =(int) typeArray.getDimension(R.styleable.TagView_textPaddingBottom, Utils.dipToPx(this.getContext(),Constants.DEFAULT_TAG_TEXT_PADDING_BOTTOM)); - typeArray.recycle(); - } - - /** - * onSizeChanged - * - * @param w - * @param h - * @param oldw - * @param oldh - */ - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w,h,oldw,oldh); - mWidth = w; - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - int width = getMeasuredWidth(); - if (width<=0)return; - mWidth=getMeasuredWidth(); - } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - drawTags(); - } - - /** - * tag draw - */ - private void drawTags() { - - if (!mInitialized) { - return; - } - - // clear all tag - removeAllViews(); - - // layout padding left & layout padding right - float total = getPaddingLeft() + getPaddingRight(); - - int listIndex = 1;// List Index - int index_bottom=1;// The Tag to add below - int index_header=1;// The header tag of this line - Tag tag_pre=null; - for (Tag item : mTags) { - final int position = listIndex-1; - final Tag tag = item; - - // inflate tag layout - View tagLayout = (View) mInflater.inflate(R.layout.tagview_item, null); - tagLayout.setId(listIndex); - tagLayout.setBackgroundDrawable(getSelector(tag)); - - // tag text - TextView tagView = (TextView) tagLayout.findViewById(R.id.tv_tag_item_contain); - tagView.setText(tag.text); - //tagView.setPadding(textPaddingLeft, textPaddingTop, textPaddingRight, texPaddingBottom); - LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) tagView.getLayoutParams(); - params.setMargins(textPaddingLeft, textPaddingTop, textPaddingRight, texPaddingBottom); - tagView.setLayoutParams(params); - tagView.setTextColor(tag.tagTextColor); - tagView.setTextSize(TypedValue.COMPLEX_UNIT_SP ,tag.tagTextSize); - tagLayout.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if (mClickListener != null) { - mClickListener.onTagClick(tag, position); - } - } - }); - - // calculate of tag layout width - float tagWidth = tagView.getPaint().measureText(tag.text) + textPaddingLeft + textPaddingRight; - // tagView padding (left & right) - - // deletable text - TextView deletableView = (TextView) tagLayout.findViewById(R.id.tv_tag_item_delete); - if (tag.isDeletable) { - deletableView.setVisibility(View.VISIBLE); - deletableView.setText(tag.deleteIcon); - int offset = Utils.dipToPx(getContext(),2f); - deletableView.setPadding(offset, textPaddingTop, textPaddingRight+offset, texPaddingBottom); - /*params = (LinearLayout.LayoutParams) deletableView.getLayoutParams(); - params.setMargins(offset, textPaddingTop, textPaddingRight+offset, texPaddingBottom); - deletableView.setLayoutParams(params);*/ - deletableView.setTextColor(tag.deleteIndicatorColor); - deletableView.setTextSize(TypedValue.COMPLEX_UNIT_SP, tag.deleteIndicatorSize); - deletableView.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - //TagView.this.remove(position); - if (mDeleteListener != null) { - Tag targetTag = tag; - mDeleteListener.onTagDeleted(TagView.this,targetTag, position); - } - } - }); - tagWidth += deletableView.getPaint().measureText(tag.deleteIcon) +textPaddingLeft + textPaddingRight; - // deletableView Padding (left & right) - } else { - deletableView.setVisibility(View.GONE); - } - - LayoutParams tagParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - //tagParams.setMargins(0, 0, 0, 0); - - //add margin of each line - tagParams.bottomMargin = lineMargin; - - if (mWidth <= total + tagWidth + Utils.dipToPx(this.getContext(),Constants.LAYOUT_WIDTH_OFFSET)) { - //need to add in new line - tagParams.addRule(RelativeLayout.BELOW, index_bottom); - // initialize total param (layout padding left & layout padding right) - total = getPaddingLeft() + getPaddingRight(); - index_bottom = listIndex; - index_header =listIndex; - } else { - //no need to new line - tagParams.addRule(RelativeLayout.ALIGN_TOP, index_header); - //not header of the line - if (listIndex!=index_header) { - tagParams.addRule(RelativeLayout.RIGHT_OF, listIndex - 1); - tagParams.leftMargin = tagMargin; - total += tagMargin; - if (tag_pre!=null&&tag_pre.tagTextSize0){ - gd_normal.setStroke(Utils.dipToPx(getContext(),tag.layoutBorderSize), tag.layoutBorderColor); - } - GradientDrawable gd_press = new GradientDrawable(); - gd_press.setColor(tag.layoutColorPress); - gd_press.setCornerRadius(tag.radius); - states.addState(new int[] { android.R.attr.state_pressed }, gd_press); - //must add state_pressed first,or state_pressed will not take effect - states.addState(new int[] {}, gd_normal); - return states; - } - - - - - - //public methods - //----------------- separator -----------------// - - /** - * - * @param tag - */ - public void addTag(Tag tag) { - - mTags.add(tag); - drawTags(); - } - - public void addTags(ArrayList tags){ - if (tags==null)return; - mTags = new ArrayList<>(); - if (tags.size() == 0) - drawTags(); - for(Tag item:tags){ - addTag(item); - } - } - - - public void addTags(String[] tags){ - if (tags==null)return; - for(String item:tags){ - Tag tag = new Tag(item); - addTag(tag); - } - } - /*public void addTags(ArrayList tags){ - if (tags==null)return; - for(String item:tags){ - Tag tag = new Tag(item); - addTag(tag); - } - }*/ - - /** - * get tag list - * - * @return mTags TagObject List - */ - public List getTags() { - return mTags; - } - - /** - * remove tag - * - * @param position - */ - public void remove(int position) { - if (position < mTags.size()) { - mTags.remove(position); - drawTags(); - } - } - - /** - * - */ - public void removeAll(){ - removeAllViews(); - } - - public int getLineMargin() { - return lineMargin; - } - - public void setLineMargin(float lineMargin) { - this.lineMargin = Utils.dipToPx(getContext(), lineMargin); - } - - public int getTagMargin() { - return tagMargin; - } - - public void setTagMargin(float tagMargin) { - this.tagMargin = Utils.dipToPx(getContext(),tagMargin ); - } - - public int getTextPaddingLeft() { - return textPaddingLeft; - } - - public void setTextPaddingLeft(float textPaddingLeft) { - this.textPaddingLeft = Utils.dipToPx(getContext(), textPaddingLeft); - } - - public int getTextPaddingRight() { - return textPaddingRight; - } - - public void setTextPaddingRight(float textPaddingRight) { - this.textPaddingRight = Utils.dipToPx(getContext(), textPaddingRight); - } - - public int getTextPaddingTop() { - return textPaddingTop; - } - - public void setTextPaddingTop(float textPaddingTop) { - this.textPaddingTop = Utils.dipToPx(getContext(), textPaddingTop); - } - - public int getTexPaddingBottom() { - return texPaddingBottom; - } - - public void setTexPaddingBottom(float texPaddingBottom) { - this.texPaddingBottom = Utils.dipToPx(getContext(), texPaddingBottom); - } - - /** - * setter for OnTagSelectListener - * - * @param clickListener - */ - public void setOnTagClickListener(OnTagClickListener clickListener) { - mClickListener = clickListener; - } - - /** - * setter for OnTagDeleteListener - * - * @param deleteListener - */ - public void setOnTagDeleteListener(OnTagDeleteListener deleteListener) { - mDeleteListener = deleteListener; - } - -} diff --git a/app/src/main/java/cuneyt/example/com/tagview/Tag/Utils.java b/app/src/main/java/cuneyt/example/com/tagview/Tag/Utils.java deleted file mode 100644 index 58730ce..0000000 --- a/app/src/main/java/cuneyt/example/com/tagview/Tag/Utils.java +++ /dev/null @@ -1,13 +0,0 @@ -package cuneyt.example.com.tagview.Tag; - -import android.content.Context; -import android.util.DisplayMetrics; -import android.util.TypedValue; - -public class Utils { - - public static int dipToPx(Context c,float dipValue) { - DisplayMetrics metrics = c.getResources().getDisplayMetrics(); - return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics); - } -} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index f281da7..0000000 --- a/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - diff --git a/app/src/main/res/layout/tagview_item.xml b/app/src/main/res/layout/tagview_item.xml deleted file mode 100644 index 16533e5..0000000 --- a/app/src/main/res/layout/tagview_item.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml deleted file mode 100644 index b1cb908..0000000 --- a/app/src/main/res/menu/menu_main.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - diff --git a/app/src/main/res/values-w820dp/tagview_attr.xml b/app/src/main/res/values-w820dp/tagview_attr.xml deleted file mode 100644 index 73825de..0000000 --- a/app/src/main/res/values-w820dp/tagview_attr.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml deleted file mode 100644 index 9fa722d..0000000 --- a/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - TagView - - Hello world! - Settings - - diff --git a/build.gradle b/build.gradle index 1b7886d..b53ebdd 100644 --- a/build.gradle +++ b/build.gradle @@ -3,17 +3,23 @@ buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:1.3.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath 'com.android.tools.build:gradle:3.5.1' } } +// ext is a gradle closure allowing the declaration of global properties +ext { + PUBLISH_GROUP_ID = 'it.angelic' + PUBLISH_ARTIFACT_ID = 'tagView' + PUBLISH_VERSION = '1.4.1' +} + allprojects { repositories { jcenter() + google() } } diff --git a/gradle.properties b/gradle.properties index 1d3591c..915f0e6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,4 +15,6 @@ # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true \ No newline at end of file +# org.gradle.parallel=true +android.enableJetifier=true +android.useAndroidX=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 845e8b8..9c1c7bc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Sep 26 23:18:29 EEST 2015 +#Tue Oct 29 11:43:10 CET 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/settings.gradle b/settings.gradle index e7b4def..4f75671 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app' +include ':tagViewDemoApp', ':tagviewlib' diff --git a/app/.gitignore b/tagViewDemoApp/.gitignore similarity index 100% rename from app/.gitignore rename to tagViewDemoApp/.gitignore diff --git a/tagViewDemoApp/build.gradle b/tagViewDemoApp/build.gradle new file mode 100644 index 0000000..b2a7746 --- /dev/null +++ b/tagViewDemoApp/build.gradle @@ -0,0 +1,31 @@ +apply plugin: 'com.android.application' + + +android { + compileSdkVersion 29 + buildToolsVersion "28.0.3" + + defaultConfig { + minSdkVersion 15 + targetSdkVersion 29 + versionCode 5 + versionName project.PUBLISH_VERSION + + + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation 'androidx.annotation:annotation:1.1.0' + implementation 'androidx.appcompat:appcompat:1.1.0' + annotationProcessor 'com.jakewharton:butterknife:7.0.1' + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation 'com.jakewharton:butterknife:7.0.1' + implementation project(':tagviewlib') +} diff --git a/app/proguard-rules.pro b/tagViewDemoApp/proguard-rules.pro similarity index 100% rename from app/proguard-rules.pro rename to tagViewDemoApp/proguard-rules.pro diff --git a/tagViewDemoApp/src/androidTest/java/cuneyt/example/AwesomeTest.java b/tagViewDemoApp/src/androidTest/java/cuneyt/example/AwesomeTest.java new file mode 100644 index 0000000..7f8c7cf --- /dev/null +++ b/tagViewDemoApp/src/androidTest/java/cuneyt/example/AwesomeTest.java @@ -0,0 +1,44 @@ +package cuneyt.example; + +import android.content.Context; + + +import android.test.AndroidTestCase; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.RelativeLayout; +import android.widget.TextView; + + +import java.util.ArrayList; + +import it.angelic.tagviewlib.OnSimpleTagDeleteListener; +import it.angelic.tagviewlib.SimpleTagRelativeLayout; +import it.angelic.tagviewlib.SimpleTagView; +import it.angelic.tagviewlib.SimpleTagViewUtils; + + +public class AwesomeTest extends AndroidTestCase { + + + @Override + public void setUp() throws Exception { + super.setUp(); + + } + + + @Override + public void tearDown() throws Exception { + super.tearDown(); + } + + public void testAwesomeCodesValidator() { + + assertNotNull(mContext.getResources()); + assertTrue(SimpleTagViewUtils.getAwesomeCodes(mContext).size() == + SimpleTagViewUtils.getAwesomeCodes(mContext).size()); + } + + +} \ No newline at end of file diff --git a/tagViewDemoApp/src/androidTest/java/cuneyt/example/TestSimpleTagView.java b/tagViewDemoApp/src/androidTest/java/cuneyt/example/TestSimpleTagView.java new file mode 100644 index 0000000..0ae8414 --- /dev/null +++ b/tagViewDemoApp/src/androidTest/java/cuneyt/example/TestSimpleTagView.java @@ -0,0 +1,74 @@ +package cuneyt.example; + +import android.test.AndroidTestCase; +import android.view.View; + +import it.angelic.tagviewlib.OnSimpleTagDeleteListener; +import it.angelic.tagviewlib.SimpleTagRelativeLayout; +import it.angelic.tagviewlib.SimpleTagView; +import it.angelic.tagviewlib.SimpleTagViewUtils; + + +public class TestSimpleTagView extends AndroidTestCase { + + + @Override + public void setUp() throws Exception { + super.setUp(); + + } + + + @Override + public void tearDown() throws Exception { + super.tearDown(); + } + + + + public void testSimpleTagListeners() { + + final int key = 0; + SimpleTagView tester = new SimpleTagView(mContext); + + tester.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + v.setTag(Boolean.TRUE); + } + }); + tester.setOnSimpleTagDeleteListener(new OnSimpleTagDeleteListener() { + @Override + public void onTagDeleted(SimpleTagView tag) { + + } + }); + + tester.performClick(); + assertTrue((Boolean) tester.getTag()); + } + public void testSimpleTagViewAwesome() { + SimpleTagView pirelli = new SimpleTagView(mContext); + pirelli.setFontAwesome("fa-warning"); + pirelli.setDeletable(false); + pirelli.measure(0, 0); + + assertTrue(pirelli.getMeasuredWidth() > 0); + } + public void testSimpleTagViewDeletable() { + SimpleTagView pirelli = new SimpleTagView(mContext); + pirelli.measure(0,0); + assertTrue(pirelli.getWidth() == 0); + pirelli.setDeletable(true); + pirelli.measure(0,0); + + assertTrue(pirelli.getMeasuredWidth() > 0); + } + public void testSimpleTagRelative() { + SimpleTagRelativeLayout relTest = new SimpleTagRelativeLayout(mContext); + relTest.addTag(new SimpleTagView(mContext,"farfallone")); + + assertEquals("farfallone", relTest.getTags().get(0).getText()); + assertTrue(relTest.getTags().get(0).getRadius() > 0); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/tagViewDemoApp/src/main/AndroidManifest.xml similarity index 60% rename from app/src/main/AndroidManifest.xml rename to tagViewDemoApp/src/main/AndroidManifest.xml index f2c5fa6..802f83e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/tagViewDemoApp/src/main/AndroidManifest.xml @@ -1,21 +1,27 @@ + package="cuneyt.example" > + + - + diff --git a/tagViewDemoApp/src/main/java/cuneyt/example/MainActivity.java b/tagViewDemoApp/src/main/java/cuneyt/example/MainActivity.java new file mode 100644 index 0000000..6d3faf2 --- /dev/null +++ b/tagViewDemoApp/src/main/java/cuneyt/example/MainActivity.java @@ -0,0 +1,201 @@ +package cuneyt.example; + +import android.graphics.Color; +import android.os.Bundle; +import android.text.Editable; +import android.text.TextWatcher; +import android.util.Log; +import android.view.View; +import android.widget.AdapterView; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.Spinner; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; + +import org.json.JSONArray; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.Random; + +import androidx.appcompat.app.AppCompatActivity; +import butterknife.Bind; +import butterknife.ButterKnife; +import cuneyt.example.model.TagClass; +import it.angelic.tagviewlib.Constants; +import it.angelic.tagviewlib.OnSimpleTagClickListener; +import it.angelic.tagviewlib.OnSimpleTagDeleteListener; +import it.angelic.tagviewlib.SimpleTagRelativeLayout; +import it.angelic.tagviewlib.SimpleTagView; +import it.angelic.tagviewlib.SimpleTagViewUtils; + +public class MainActivity extends AppCompatActivity { + + @Bind(R.id.tag_group) + SimpleTagRelativeLayout tagGroup; + + @Bind(R.id.editText) + EditText editText; + + @Bind(R.id.test_laoyut) + LinearLayout testRel; + + @Bind(R.id.nuovoTag) + SimpleTagView testRaff; + + @Bind(R.id.nuovoTagAwesome) + SimpleTagView testAwe; + + @Bind(R.id.AwesomeSpinner) + Spinner testSpinner; + + /** + * sample country list + */ + private ArrayList tagList; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + ButterKnife.bind(this); + prepareTags(); + + + editText.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + Log.d("TagView TEST", "onTextChanged: " + s); + setTags(s); + } + + @Override + public void afterTextChanged(Editable s) { + + } + }); + + //programmatic Tag examples + SimpleTagView tagTer = new SimpleTagView(this); + tagTer.setText("Programmatic"); + + SimpleTagView tagTer2 = new SimpleTagView(this); + tagTer2.setText("Programmatic Deletable"); + tagTer2.setDeletable(true); + + SimpleTagView tagTer3 = new SimpleTagView(this); + tagTer3.setText("Programmatic Red"); + tagTer3.setFontAwesome("fa-shower"); + tagTer3.setColor(Color.argb(255, 255, 0, 0)); + + testRel.addView(tagTer); + testRel.addView(tagTer2); + testRel.addView(tagTer3); + + OnSimpleTagClickListener commonTagListener = new OnSimpleTagClickListener() { + @Override + public void onSimpleTagClick(SimpleTagView tag) { + Log.d("TagView TEST", "TAG click: " + tag.getText()); + } + }; + + //DEMO listeners + tagTer2.setOnSimpleTagClickListener(commonTagListener); + tagTer3.setOnSimpleTagClickListener(commonTagListener); + tagTer2.setOnSimpleTagDeleteListener(new OnSimpleTagDeleteListener() { + @Override + public void onTagDeleted(SimpleTagView tag) { + testRel.removeView(tag); + Log.w("TagView TEST", "TAG delete: " + tag.getText()); + Toast.makeText(MainActivity.this, "Tag Deleted! " + tag.getText(), Toast.LENGTH_SHORT).show(); + } + }); + + tagGroup.setOnSimpleTagClickListener(commonTagListener); + + tagGroup.setOnSimpleTagDeleteListener(new OnSimpleTagDeleteListener() { + @Override + public void onTagDeleted(final SimpleTagView tag) { + tagGroup.remove(tag); + Toast.makeText(MainActivity.this, "Tag Deleted! " + tag.getText(), Toast.LENGTH_SHORT).show(); + } + }); + + //dynamically test font-awesome + testSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parentView, View selectedItemView, int position, long id) { + // int idx = testSpinner.getSelectedItemPosition(); + String awSom = SimpleTagViewUtils.getAwesomeNames(MainActivity.this).get(position); + testAwe.setFontAwesome(awSom); + testAwe.setText(awSom); + } + + @Override + public void onNothingSelected(AdapterView parentView) { + // your code here + } + + }); + } + + private void prepareTags() { + tagList = new ArrayList<>(); + JSONArray jsonArray = null; + JSONObject temp; + try { + jsonArray = new JSONArray(Constants.COUNTRIES); + for (int i = 0; i < jsonArray.length(); i++) { + temp = jsonArray.getJSONObject(i); + tagList.add(new TagClass(temp.getString("code"), temp.getString("name"))); + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + + + private void setTags(CharSequence cs) { + Random rnd = new Random(); + String text = cs.toString(); + ArrayList tags = new ArrayList<>(); + SimpleTagView tag; + + /** + * for empty edittext + */ + if (text.equals("")) { + tagGroup.setTags(new ArrayList()); + return; + } + + Log.d("TagView TEST", "setTags size: " + tagList.size()); + for (int i = 0; i < tagList.size(); i++) { + if (tagList.get(i).getName().toLowerCase().startsWith(text.toLowerCase())) { + tag = new SimpleTagView(MainActivity.this, tagList.get(i).getName()); + tag.setRadius(8); + tag.setColor(Color.parseColor(tagList.get(i).getColor())); + if (i % 2 == 0) // you can set deletable or not + tag.setDeletable(true); + if (i % 3 == 0) {//add random icons + int rndIdx = rnd.nextInt(SimpleTagViewUtils.getAwesomeNames(MainActivity.this).size()); + tag.setFontAwesome(SimpleTagViewUtils.getAwesomeNames(MainActivity.this).get(rndIdx)); + } + tags.add(tag); + Log.d("TagView TEST", "match found: " + tag); + } + } + tagGroup.setTags(tags); + + } + + +} \ No newline at end of file diff --git a/app/src/main/java/cuneyt/example/com/tagview/Models/TagClass.java b/tagViewDemoApp/src/main/java/cuneyt/example/model/TagClass.java similarity index 67% rename from app/src/main/java/cuneyt/example/com/tagview/Models/TagClass.java rename to tagViewDemoApp/src/main/java/cuneyt/example/model/TagClass.java index 7d72d91..719c3f9 100644 --- a/app/src/main/java/cuneyt/example/com/tagview/Models/TagClass.java +++ b/tagViewDemoApp/src/main/java/cuneyt/example/model/TagClass.java @@ -1,17 +1,19 @@ -package cuneyt.example.com.tagview.Models; +package cuneyt.example.model; import java.util.ArrayList; import java.util.Random; /** + * Inner support POJO to keep TAG's data + * * Created by Cuneyt on 21.8.2015. */ public class TagClass { - String code; - String name; - String color; + private String code; + private String name; + private String color; public TagClass() { @@ -26,16 +28,19 @@ public TagClass(String sinif, String name) { public String getRandomColor() { ArrayList colors = new ArrayList<>(); - colors.add("#ED7D31"); + colors.add("#997D99"); colors.add("#00B0F0"); - colors.add("#FF0000"); - colors.add("#D0CECE"); - colors.add("#00B050"); + colors.add("#aa66cc");//Holo purple + colors.add("#330033"); + colors.add("#BB5050"); colors.add("#9999FF"); - colors.add("#FF5FC6"); - colors.add("#FFC000"); - colors.add("#7F7F7F"); - colors.add("#4800FF"); + colors.add("#99cc66");//colore verde gatta + colors.add("#FFC0FF"); + colors.add("#444444"); + colors.add("#FFCC81"); + + //aa66cc + return colors.get(new Random().nextInt(colors.size())); } diff --git a/tagViewDemoApp/src/main/res/layout/activity_main.xml b/tagViewDemoApp/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..116aa05 --- /dev/null +++ b/tagViewDemoApp/src/main/res/layout/activity_main.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/tagViewDemoApp/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-hdpi/ic_launcher.png rename to tagViewDemoApp/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/tagViewDemoApp/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-mdpi/ic_launcher.png rename to tagViewDemoApp/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/tagViewDemoApp/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to tagViewDemoApp/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/tagViewDemoApp/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to tagViewDemoApp/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/app/src/main/res/values-w820dp/dimens.xml b/tagViewDemoApp/src/main/res/values-w820dp/dimens.xml similarity index 100% rename from app/src/main/res/values-w820dp/dimens.xml rename to tagViewDemoApp/src/main/res/values-w820dp/dimens.xml diff --git a/app/src/main/res/values/dimens.xml b/tagViewDemoApp/src/main/res/values/dimens.xml similarity index 100% rename from app/src/main/res/values/dimens.xml rename to tagViewDemoApp/src/main/res/values/dimens.xml diff --git a/tagViewDemoApp/src/main/res/values/strings.xml b/tagViewDemoApp/src/main/res/values/strings.xml new file mode 100644 index 0000000..4a5f720 --- /dev/null +++ b/tagViewDemoApp/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + SimpleTagViewDemo + Settings + diff --git a/app/src/main/res/values/styles.xml b/tagViewDemoApp/src/main/res/values/styles.xml similarity index 100% rename from app/src/main/res/values/styles.xml rename to tagViewDemoApp/src/main/res/values/styles.xml diff --git a/tagViewDemoApp/tagViewDemoApp.iml b/tagViewDemoApp/tagViewDemoApp.iml new file mode 100644 index 0000000..669e9a1 --- /dev/null +++ b/tagViewDemoApp/tagViewDemoApp.iml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tagview2/build.gradle b/tagview2/build.gradle deleted file mode 100644 index 5e49738..0000000 --- a/tagview2/build.gradle +++ /dev/null @@ -1,25 +0,0 @@ -apply plugin: 'com.android.library' - -android { - compileSdkVersion 23 - buildToolsVersion "23.0.2" - - defaultConfig { - minSdkVersion 15 - targetSdkVersion 23 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:23.1.1' -} diff --git a/tagview2/src/androidTest/java/example/cunoraz/com/tagview/ApplicationTest.java b/tagview2/src/androidTest/java/example/cunoraz/com/tagview/ApplicationTest.java deleted file mode 100644 index a78b1ae..0000000 --- a/tagview2/src/androidTest/java/example/cunoraz/com/tagview/ApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package example.cunoraz.com.tagview; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} \ No newline at end of file diff --git a/tagview2/src/main/AndroidManifest.xml b/tagview2/src/main/AndroidManifest.xml deleted file mode 100644 index 65f0485..0000000 --- a/tagview2/src/main/AndroidManifest.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/tagview2/src/main/res/values/strings.xml b/tagview2/src/main/res/values/strings.xml deleted file mode 100644 index 5829bf3..0000000 --- a/tagview2/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - TagView - diff --git a/tagview2/src/test/java/example/cunoraz/com/tagview/ExampleUnitTest.java b/tagview2/src/test/java/example/cunoraz/com/tagview/ExampleUnitTest.java deleted file mode 100644 index f375fe2..0000000 --- a/tagview2/src/test/java/example/cunoraz/com/tagview/ExampleUnitTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package example.cunoraz.com.tagview; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * To work on unit tests, switch the Test Artifact in the Build Variants view. - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() throws Exception { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file diff --git a/tagview2/tagview2.iml b/tagview2/tagview2.iml deleted file mode 100644 index 61d36a5..0000000 --- a/tagview2/tagview2.iml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tagview2/.gitignore b/tagviewlib/.gitignore similarity index 100% rename from tagview2/.gitignore rename to tagviewlib/.gitignore diff --git a/tagviewlib/build.gradle b/tagviewlib/build.gradle new file mode 100644 index 0000000..3043894 --- /dev/null +++ b/tagviewlib/build.gradle @@ -0,0 +1,30 @@ +apply plugin: 'com.android.library' +apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle' + +//facciamo cosi +//http://blog.blundellapps.co.uk/locally-release-an-android-library-for-jcenter-or-maven-central-inclusion/ +//https://bintray.com/shineangelic# + +//./gradlew clean build generateRelease +android { + compileSdkVersion 28 + buildToolsVersion "28.0.3" + + defaultConfig { + minSdkVersion 14 + targetSdkVersion 28 + versionCode 6 + versionName project.PUBLISH_VERSION + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation 'androidx.appcompat:appcompat:1.1.0' + +} diff --git a/tagview2/proguard-rules.pro b/tagviewlib/proguard-rules.pro similarity index 87% rename from tagview2/proguard-rules.pro rename to tagviewlib/proguard-rules.pro index be5b184..8a2f402 100644 --- a/tagview2/proguard-rules.pro +++ b/tagviewlib/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified -# in C:\Users\lnvo\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt +# in C:\Android\sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # diff --git a/app/src/androidTest/java/cuneyt/example/com/tagview/ApplicationTest.java b/tagviewlib/src/androidTest/java/it/angelic/tagviewlib/ApplicationTest.java similarity index 78% rename from app/src/androidTest/java/cuneyt/example/com/tagview/ApplicationTest.java rename to tagviewlib/src/androidTest/java/it/angelic/tagviewlib/ApplicationTest.java index 9d2bca9..e415752 100644 --- a/app/src/androidTest/java/cuneyt/example/com/tagview/ApplicationTest.java +++ b/tagviewlib/src/androidTest/java/it/angelic/tagviewlib/ApplicationTest.java @@ -1,7 +1,6 @@ -package cuneyt.example.com.tagview; +package it.angelic.tagviewlib; import android.app.Application; -import android.test.ApplicationTestCase; /** * Testing Fundamentals diff --git a/tagviewlib/src/main/AndroidManifest.xml b/tagviewlib/src/main/AndroidManifest.xml new file mode 100644 index 0000000..15a27be --- /dev/null +++ b/tagviewlib/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + diff --git a/tagviewlib/src/main/assets/fontawesome-webfont.ttf b/tagviewlib/src/main/assets/fontawesome-webfont.ttf new file mode 100644 index 0000000..35acda2 Binary files /dev/null and b/tagviewlib/src/main/assets/fontawesome-webfont.ttf differ diff --git a/app/src/main/java/cuneyt/example/com/tagview/Tag/Constants.java b/tagviewlib/src/main/java/it/angelic/tagviewlib/Constants.java similarity index 93% rename from app/src/main/java/cuneyt/example/com/tagview/Tag/Constants.java rename to tagviewlib/src/main/java/it/angelic/tagviewlib/Constants.java index 6f4ceea..fcf2002 100644 --- a/app/src/main/java/cuneyt/example/com/tagview/Tag/Constants.java +++ b/tagviewlib/src/main/java/it/angelic/tagviewlib/Constants.java @@ -1,6 +1,4 @@ -package cuneyt.example.com.tagview.Tag; - -import android.graphics.Color; +package it.angelic.tagviewlib; public class Constants { @@ -15,19 +13,8 @@ public class Constants { public static final float DEFAULT_TAG_TEXT_PADDING_BOTTOM = 5; public static final float LAYOUT_WIDTH_OFFSET = 2; - - //----------------- separator Tag Item-----------------// - public static final float DEFAULT_TAG_TEXT_SIZE = 14f; - public static final float DEFAULT_TAG_DELETE_INDICATOR_SIZE = 14f; - public static final float DEFAULT_TAG_LAYOUT_BORDER_SIZE = 0f; - public static final float DEFAULT_TAG_RADIUS = 100; - public static final int DEFAULT_TAG_LAYOUT_COLOR = Color.parseColor("#AED374"); - public static final int DEFAULT_TAG_LAYOUT_COLOR_PRESS = Color.parseColor("#88363636"); - public static final int DEFAULT_TAG_TEXT_COLOR = Color.parseColor("#ffffff"); - public static final int DEFAULT_TAG_DELETE_INDICATOR_COLOR = Color.parseColor("#ffffff"); - public static final int DEFAULT_TAG_LAYOUT_BORDER_COLOR = Color.parseColor("#ffffff"); - public static final String DEFAULT_TAG_DELETE_ICON = "×"; - public static final boolean DEFAULT_TAG_IS_DELETABLE = false; + + public static final String FONT = "fontawesome-webfont.ttf"; /** * list from: @@ -39,7 +26,7 @@ public class Constants { "{\"name\": \"Albania\", \"code\": \"AL\"}, \n" + "{\"name\": \"Algeria\", \"code\": \"DZ\"}, \n" + "{\"name\": \"American Samoa\", \"code\": \"AS\"}, \n" + - "{\"name\": \"AndorrA\", \"code\": \"AD\"}, \n" + + "{\"name\": \"Andorra\", \"code\": \"AD\"}, \n" + "{\"name\": \"Angola\", \"code\": \"AO\"}, \n" + "{\"name\": \"Anguilla\", \"code\": \"AI\"}, \n" + "{\"name\": \"Antarctica\", \"code\": \"AQ\"}, \n" + @@ -201,7 +188,6 @@ public class Constants { "{\"name\": \"Oman\", \"code\": \"OM\"}, \n" + "{\"name\": \"Pakistan\", \"code\": \"PK\"}, \n" + "{\"name\": \"Palau\", \"code\": \"PW\"}, \n" + - "{\"name\": \"Palestinian Territory, Occupied\", \"code\": \"PS\"}, \n" + "{\"name\": \"Panama\", \"code\": \"PA\"}, \n" + "{\"name\": \"Papua New Guinea\", \"code\": \"PG\"}, \n" + "{\"name\": \"Paraguay\", \"code\": \"PY\"}, \n" + @@ -278,4 +264,6 @@ public class Constants { "{\"name\": \"Zambia\", \"code\": \"ZM\"}, \n" + "{\"name\": \"Zimbabwe\", \"code\": \"ZW\"} \n" + "]"; + protected static final int TAG_TEXT_ALPHA = 0xBB; + protected static final float TAG_TEXT_WHITE_THOLD = 126f; } diff --git a/tagviewlib/src/main/java/it/angelic/tagviewlib/FontNotFoundException.java b/tagviewlib/src/main/java/it/angelic/tagviewlib/FontNotFoundException.java new file mode 100644 index 0000000..89ba686 --- /dev/null +++ b/tagviewlib/src/main/java/it/angelic/tagviewlib/FontNotFoundException.java @@ -0,0 +1,14 @@ +package it.angelic.tagviewlib; + +import android.content.res.Resources; + +/** + * Thrown when some awesome font symbol is not found + * + * Created by shine@angelic.it on 19/03/2016. + */ +public class FontNotFoundException extends Resources.NotFoundException { + public FontNotFoundException(String s) { + super(s); + } +} diff --git a/tagviewlib/src/main/java/it/angelic/tagviewlib/OnSimpleTagClickListener.java b/tagviewlib/src/main/java/it/angelic/tagviewlib/OnSimpleTagClickListener.java new file mode 100644 index 0000000..014063f --- /dev/null +++ b/tagviewlib/src/main/java/it/angelic/tagviewlib/OnSimpleTagClickListener.java @@ -0,0 +1,8 @@ +package it.angelic.tagviewlib; + +/** + * listener for tag delete + */ +public interface OnSimpleTagClickListener { + void onSimpleTagClick(SimpleTagView tag); +} \ No newline at end of file diff --git a/tagviewlib/src/main/java/it/angelic/tagviewlib/OnSimpleTagDeleteListener.java b/tagviewlib/src/main/java/it/angelic/tagviewlib/OnSimpleTagDeleteListener.java new file mode 100644 index 0000000..33ac560 --- /dev/null +++ b/tagviewlib/src/main/java/it/angelic/tagviewlib/OnSimpleTagDeleteListener.java @@ -0,0 +1,8 @@ +package it.angelic.tagviewlib; + +/** + * listener for tag delete + */ +public interface OnSimpleTagDeleteListener { + void onTagDeleted(SimpleTagView tag ); +} \ No newline at end of file diff --git a/tagviewlib/src/main/java/it/angelic/tagviewlib/SimpleTag.java b/tagviewlib/src/main/java/it/angelic/tagviewlib/SimpleTag.java new file mode 100644 index 0000000..188ec60 --- /dev/null +++ b/tagviewlib/src/main/java/it/angelic/tagviewlib/SimpleTag.java @@ -0,0 +1,55 @@ +package it.angelic.tagviewlib; + +/** + * Classic POJO for {@link SimpleTagView}'s data + * + * Created by shine@angelic.it on 14/03/2016. + */ +class SimpleTag { + private boolean isDeletable; + private String name; + private int color; + private int radius; + + public String getFontAwesomeCode() { + return fontAwesomeCode; + } + + public void setFontAwesomeCode(String fontAwesomeCode) { + this.fontAwesomeCode = fontAwesomeCode; + } + + private String fontAwesomeCode; + + public boolean isDeletable() { + return isDeletable; + } + + public void setDeletable(boolean isVisible) { + this.isDeletable = isVisible; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getColor() { + return color; + } + + public void setColor(int color) { + this.color = color; + } + + public int getRadius() { + return radius; + } + + public void setRadius(int radius) { + this.radius = radius; + } +} diff --git a/tagviewlib/src/main/java/it/angelic/tagviewlib/SimpleTagRelativeLayout.java b/tagviewlib/src/main/java/it/angelic/tagviewlib/SimpleTagRelativeLayout.java new file mode 100644 index 0000000..11281be --- /dev/null +++ b/tagviewlib/src/main/java/it/angelic/tagviewlib/SimpleTagRelativeLayout.java @@ -0,0 +1,366 @@ +package it.angelic.tagviewlib; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Canvas; +import android.util.AttributeSet; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.List; + + +public class SimpleTagRelativeLayout extends RelativeLayout { + + /** + * custom layout param + */ + private int lineMargin; + private int tagMargin; + private int textPaddingLeft; + private int textPaddingRight; + private int textPaddingTop; + private int texPaddingBottom; + /** + * tag list + */ + private List mTags = new ArrayList(); + /** + * listener + */ + private OnSimpleTagClickListener mClickListener; + private OnSimpleTagDeleteListener mDeleteListener; + /** + * view size param + */ + private int mWidth; + private int mHeight; + /** + * layout initialize flag + */ + private boolean mInitialized = false; + + public SimpleTagRelativeLayout(Context ctx) { + super(ctx, null); + initialize(ctx, null, 0); + } + + public SimpleTagRelativeLayout(Context ctx, AttributeSet attrs) { + super(ctx, attrs); + initialize(ctx, attrs, 0); + } + + public SimpleTagRelativeLayout(Context ctx, AttributeSet attrs, int defStyle) { + super(ctx, attrs, defStyle); + initialize(ctx, attrs, defStyle); + } + + /** + * initalize instance + * + * @param ctx + * @param attrs + * @param defStyle + */ + private void initialize(Context ctx, AttributeSet attrs, int defStyle) { + /* + System Service + */ + LayoutInflater mInflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + ViewTreeObserver mViewTreeObserber = getViewTreeObserver(); + mViewTreeObserber.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + if (!mInitialized) { + mInitialized = true; + drawTags(); + } + } + }); + // get AttributeSet + TypedArray typeArray = ctx.obtainStyledAttributes(attrs, R.styleable.TagRelativeLayout, defStyle, defStyle); + this.lineMargin = (int) typeArray.getDimension(R.styleable.TagRelativeLayout_lineMargin, SimpleTagViewUtils.dipToPx(this.getContext(), Constants.DEFAULT_LINE_MARGIN)); + this.tagMargin = (int) typeArray.getDimension(R.styleable.TagRelativeLayout_tagMargin, SimpleTagViewUtils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_MARGIN)); + this.textPaddingLeft = (int) typeArray.getDimension(R.styleable.TagRelativeLayout_textPaddingLeft, SimpleTagViewUtils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_LEFT)); + this.textPaddingRight = (int) typeArray.getDimension(R.styleable.TagRelativeLayout_textPaddingRight, SimpleTagViewUtils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_RIGHT)); + this.textPaddingTop = (int) typeArray.getDimension(R.styleable.TagRelativeLayout_textPaddingTop, SimpleTagViewUtils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_TOP)); + this.texPaddingBottom = (int) typeArray.getDimension(R.styleable.TagRelativeLayout_textPaddingBottom, SimpleTagViewUtils.dipToPx(this.getContext(), Constants.DEFAULT_TAG_TEXT_PADDING_BOTTOM)); + typeArray.recycle(); + + mWidth = getWidth(); + } + + + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + super.onSizeChanged(w, h, oldw, oldh); + mWidth = w; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int parentWidth = MeasureSpec.getSize(widthMeasureSpec); + int parentHeight = MeasureSpec.getSize(heightMeasureSpec); + this.setMeasuredDimension(parentWidth, parentHeight); + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + mWidth = parentWidth; + mHeight = parentHeight; + mWidth = getMeasuredWidth(); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + drawTags(); + } + + /** + * tag draw + */ + private void drawTags() { + + if (!mInitialized) { + Log.e("TagView TEST", "INIT MISS"); + return; + } + // clear all tag, discutibile + removeAllViews(); + + // layout padding left & layout padding right + float total = getPaddingLeft() + getPaddingRight(); + + int listIndex = 0;// List Index + int indexBottom = 1;// The Tag to add below + int indexHeader = 1;// The header tag of this line + + SimpleTagView tag_pre = null; + Log.d("TagView TEST", "Drawing Tags: " + mTags.size()); + for (final SimpleTagView item : mTags) { + final int position = listIndex; + // inflate tag layout + //TagView tagLayout = tag; + // tagLayout.setTagId(listIndex); + // tagLayout.setBackgroundDrawable(getSelector(tag)); + + //tagLayout.sett + // tag text + TextView tagTextView = (TextView) item.findViewById(R.id.tagName); + item.setText(item.getText()); + item.setId(position + 1);//inside Rel Layout, id are rewritten + + item.setOnSimpleTagClickListener(new OnSimpleTagClickListener() { + @Override + public void onSimpleTagClick(SimpleTagView tag) { + if (mClickListener != null) { + mClickListener.onSimpleTagClick(tag); + } + } + + }); + + int sHint = (int) tagTextView.getPaint().measureText(item.getText()); + item.measure(sHint, 40); + // calculate of tag layout width + float tagWidth = item.getMeasuredWidth() ; + // tagTextView padding (left & right) + Log.d("TagView TEST", "re-adding " + item.getText() + " id: " + item.getId() + "- tagWidth=" + tagWidth + " mHeight=" + item.getMeasuredHeight()); + // deletable text + TextView deletableView = (TextView) item.findViewById(R.id.isDeletable); + if (item.isDeletable()) { + // attach delete Listener + deletableView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + //TagView.this.remove(position); + if (mDeleteListener != null) { + mDeleteListener.onTagDeleted( item ); + } + } + }); + tagWidth += deletableView.getPaint().measureText("×") ; + // deletableView Padding (left & right) + } else { + deletableView.setVisibility(View.GONE); + } + + LayoutParams tagParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + tagParams.setMargins(0, 0, 0, 0); + + //add margin of each line + tagParams.bottomMargin = lineMargin; + Log.d("TagView TEST", "adding. mWidth:" + mWidth + " total:" + total); + if (mWidth <= total + tagWidth + SimpleTagViewUtils.dipToPx(this.getContext(), Constants.LAYOUT_WIDTH_OFFSET)) { + //need to add in new line + Log.d("TagView TEST", "new line.BELOW indexBottom:" + indexBottom); + tagParams.addRule(RelativeLayout.BELOW, indexBottom); + // initialize total param (layout padding left & layout padding right) + total = getPaddingLeft() + getPaddingRight(); + indexBottom = item.getId(); + indexHeader = item.getId(); + } else { + //no need to new line + Log.d("TagView TEST", "NO new line. indexHeader:" + indexHeader + " me:" + item.getId()); + tagParams.addRule(RelativeLayout.ALIGN_TOP, indexHeader); + //not header of the line + if (tag_pre != null && item.getId() != indexHeader) { + Log.d("TagView TEST", "NO new line NO HEAD line. RIGHT_OF:" + tag_pre.getId()); + tagParams.addRule(RelativeLayout.RIGHT_OF, tag_pre.getId()); + tagParams.leftMargin = tagMargin; + total += tagMargin; + if (tag_pre.getMeasuredWidth() < item.getMeasuredWidth()) { + Log.d("TagView TEST", "NEXT will wrap, indexBottom:" + item.getId()); + indexBottom = item.getId(); + } + } + } + total += tagWidth; + //measure(mWidth, mHeight); + item.setLayoutParams(tagParams); + addView(item); + Log.d("TagView TEST", "getMeasuredWidth after add:" + item.getMeasuredWidth()); + tag_pre = item; + listIndex++; + } + } + + + //public methods + //----------------- separator -----------------// + + /** + * Add a single tag, the draw them all + * @param tag + */ + public void addTag(SimpleTagView tag) { + mTags.add(tag); + drawTags(); + } + + public void setTags(ArrayList tags) { + if (tags == null) return; + mTags = tags; + drawTags(); + } + + /** + * Add a tag array, then draw them all + * @param tags to be added to existing one + */ + public void setTags(SimpleTagView[] tags) { + if (tags == null) return; + for (SimpleTagView item : tags) { + addTag(item); + } + drawTags(); + } + + /** + * get tag list + * + * @return mTags TagObject List + */ + public List getTags() { + return mTags; + } + + /** + * remove tag + * + * @param position index of element to remove + */ + public void remove(int position) { + if (position < mTags.size()) { + mTags.remove(position); + drawTags(); + } + } + + /** + * remove tag + * + * @param position + */ + public void remove(SimpleTagView position) { + mTags.remove(position); + drawTags(); + } + + public void removeAll() { + removeAllViews(); + mTags.clear(); + drawTags(); + } + + public int getLineMargin() { + return lineMargin; + } + + public void setLineMargin(float lineMargin) { + this.lineMargin = SimpleTagViewUtils.dipToPx(getContext(), lineMargin); + } + + public int getTagMargin() { + return tagMargin; + } + + public void setTagMargin(float tagMargin) { + this.tagMargin = SimpleTagViewUtils.dipToPx(getContext(), tagMargin); + } + + public int getTextPaddingLeft() { + return textPaddingLeft; + } + + public void setTextPaddingLeft(float textPaddingLeft) { + this.textPaddingLeft = SimpleTagViewUtils.dipToPx(getContext(), textPaddingLeft); + } + + public int getTextPaddingRight() { + return textPaddingRight; + } + + public void setTextPaddingRight(float textPaddingRight) { + this.textPaddingRight = SimpleTagViewUtils.dipToPx(getContext(), textPaddingRight); + } + + public int getTextPaddingTop() { + return textPaddingTop; + } + + public void setTextPaddingTop(float textPaddingTop) { + this.textPaddingTop = SimpleTagViewUtils.dipToPx(getContext(), textPaddingTop); + } + + public int getTexPaddingBottom() { + return texPaddingBottom; + } + + public void setTexPaddingBottom(float texPaddingBottom) { + this.texPaddingBottom = SimpleTagViewUtils.dipToPx(getContext(), texPaddingBottom); + } + + /** + * setter for OnTagSelectListener + * + * @param clickListener + */ + public void setOnSimpleTagClickListener(OnSimpleTagClickListener clickListener) { + mClickListener = clickListener; + } + + /** + * setter for OnTagDeleteListener + * + * @param deleteListener + */ + public void setOnSimpleTagDeleteListener(OnSimpleTagDeleteListener deleteListener) { + mDeleteListener = deleteListener; + } + +} diff --git a/tagviewlib/src/main/java/it/angelic/tagviewlib/SimpleTagView.java b/tagviewlib/src/main/java/it/angelic/tagviewlib/SimpleTagView.java new file mode 100644 index 0000000..66deab6 --- /dev/null +++ b/tagviewlib/src/main/java/it/angelic/tagviewlib/SimpleTagView.java @@ -0,0 +1,319 @@ +package it.angelic.tagviewlib; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Color; +import android.graphics.Typeface; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; +import android.graphics.drawable.StateListDrawable; +import android.util.AttributeSet; +import android.util.Log; +import android.util.TypedValue; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.TextView; + +public class SimpleTagView extends LinearLayout { + + + private static Typeface mFont; + private final View tagRootView; + private final int backgroundDefaultColor; + private final int textDefaultColor; + private final int textDefaultColorInverse; + private final int textDefaultColorAccent; + private TextView tagAwesomeText; + private TextView tagTextView; + private TextView tagDeleteTextView; + private SimpleTag content; + private OnSimpleTagClickListener mClickListener; + private OnSimpleTagDeleteListener mDeleteListener; + + public SimpleTagView(Context context) { + this(context, (AttributeSet) null); + } + + public SimpleTagView(Context context, String tagName) { + this(context, (AttributeSet) null); + content.setName(tagName); + } + + public SimpleTagView(Context context, AttributeSet attrs) { + super(context, attrs); + content = new SimpleTag(); + + //load defaults + TypedArray arrayTheme = context.getTheme().obtainStyledAttributes(new int[]{ + android.R.attr.colorBackground, + android.R.attr.textColorPrimary, + android.R.attr.textColorPrimaryInverse, + android.R.attr.colorAccent + }); + backgroundDefaultColor = arrayTheme.getColor(0, 0xFF00FF); + textDefaultColor = arrayTheme.getColor(1, Color.GRAY); + textDefaultColorInverse = arrayTheme.getColor(2, Color.WHITE); + textDefaultColorAccent = arrayTheme.getColor(3, Color.GREEN); + arrayTheme.recycle(); + + //styleable attrs in XML + TypedArray a = context.obtainStyledAttributes(attrs, + R.styleable.SimpleTagView, 0, 0); + String titleText = a.getString(R.styleable.SimpleTagView_tagText); + + int valueColor = a.getColor(R.styleable.SimpleTagView_tagColor, + Color.DKGRAY); + int valueRadius = a.getInt(R.styleable.SimpleTagView_tagRadius, 4); + boolean valueDelete = a.getBoolean(R.styleable.SimpleTagView_isDeletable, false); + float textSize = a.getDimensionPixelSize(R.styleable.SimpleTagView_textSize, 0); + String tagAwesome = a.getString(R.styleable.SimpleTagView_tagAwesome); + + content.setColor(valueColor); + content.setName(titleText); + content.setRadius(valueRadius); + content.setDeletable(valueDelete); + a.recycle(); + + setOrientation(LinearLayout.HORIZONTAL); + setGravity(Gravity.CENTER_VERTICAL); + + //INFLATION + LayoutInflater inflater = (LayoutInflater) context + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + tagRootView = inflater.inflate(R.layout.simple_tag_view, this, true); + tagAwesomeText = (TextView) getChildAt(1); + + tagTextView = (TextView) getChildAt(2); + tagTextView.setText(titleText); + + //tagTextView.setTextColor(textDefaultColor); + tagDeleteTextView = (TextView) getChildAt(3); + if (textSize > 0) { + tagTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX,textSize); + tagDeleteTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX,textSize); + tagAwesomeText.setTextSize(TypedValue.COMPLEX_UNIT_PX,textSize); + } + try { + tagAwesomeText.setTypeface(SimpleTagViewUtils.getAwesomeTypeface(context)); + setFontAwesome(tagAwesome); + } catch (FontNotFoundException nf) { + Log.e("SimpleTagView", "FONT-AWESOME not found in asset folder"); + } + tagDeleteTextView.setVisibility(valueDelete ? View.VISIBLE : View.GONE); + + //richiama selector + color + setRadius(content.getRadius()); + //resetTextColor(); + setColor(content.getColor()); + + tagTextView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if (mClickListener != null) { + mClickListener.onSimpleTagClick(SimpleTagView.this); + } + } + }); + tagDeleteTextView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if (mDeleteListener != null) { + mDeleteListener.onTagDeleted(SimpleTagView.this); + } + } + }); + } + + private void resetTextColor() { + //compute text color + int computed; + if (Color.alpha(content.getColor()) > 50){ + if (SimpleTagViewUtils.getWeigthedColorLuminosity(content.getColor()) > Constants.TAG_TEXT_WHITE_THOLD) { + //Log.d("SimpleTagView", "BRIG selected for: " + content.getName() + " -" + Integer.toHexString(content.getColor()) + " -" + Integer.toHexString(textDefaultColor)); + //testo scuro + computed = Color.argb(Constants.TAG_TEXT_ALPHA, Color.red(textDefaultColor), Color.green(textDefaultColor), Color.blue(textDefaultColor)); + } else { //use #ffffff + //Log.d("SimpleTagView", "DARK selected for: " + content.getName() + " -" + Integer.toHexString(content.getColor()) + " -" + Integer.toHexString(textDefaultColorInverse)); + computed = Color.argb(Constants.TAG_TEXT_ALPHA, Color.red(textDefaultColorInverse), Color.green(textDefaultColorInverse), Color.blue(textDefaultColorInverse)); + } + tagDeleteTextView.setTextColor(computed); + tagTextView.setTextColor(computed); + tagAwesomeText.setTextColor(computed);} + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int tagWidth; + // Log.d("---", content.getName()); + if (tagTextView != null && content.getName() != null) + tagWidth = (int) tagTextView.getPaint().measureText(content.getName()); + else + tagWidth = 0; + + if (tagAwesomeText != null && content.getFontAwesomeCode() != null) + tagWidth += (int) tagAwesomeText.getPaint().measureText(tagAwesomeText.getText().toString()); + + //Log.d("tagWidth", Integer.toString(getWidth())); + super.onMeasure(tagWidth, heightMeasureSpec); + } + + /** + * Get main TAG's TextView text + * + * @see TextView#getText() + */ + public String getText() { + return content.getName(); + } + + /** + * Set main TextView's text + * + * @param tagText TAG's title + * @see TextView#setText(CharSequence) + */ + public void setText(CharSequence tagText) { + content.setName(tagText.toString()); + tagTextView.setText(tagText); + invalidate(); + } + + /** + * Set a font-awesome symbol to be used + * as TAG's icon. All symbols included in + * font-awesome 2.4.5 will work + * {@see https://fortawesome.github.io/Font-Awesome/cheatsheet/} + * + * @param fontName font-awesome icon + * @throws FontNotFoundException + * @attr ref R.styleable.SimpleTagView_tagAwesome + */ + public void setFontAwesome(String fontName) throws FontNotFoundException { + try { + String code = translateAwesomeCode(fontName); + content.setFontAwesomeCode(code); + tagAwesomeText.setText(code); + tagAwesomeText.setVisibility(View.VISIBLE); + } catch (FontNotFoundException fg) { + Log.e("SimpleTagView", "tagAwesome not found: " + fontName); + tagAwesomeText.setVisibility(View.GONE); + } + + invalidate(); + } + + private String translateAwesomeCode(String fontName) throws FontNotFoundException { + int codeidx; + Log.d("SimpleTagView", "translateAwesomeCode set for: " + fontName); + try { + if (fontName.startsWith("&")) { + codeidx = SimpleTagViewUtils.getAwesomeCodes(getContext()).indexOf(fontName); + } else {//try translate + //codes according to http://fortawesome.github.io/Font-Awesome/cheatsheet/ + codeidx = SimpleTagViewUtils.getAwesomeNames(getContext()).indexOf(fontName); + } + String ret = SimpleTagViewUtils.getAwesomeCodes(getContext()).get(codeidx); + Log.d("SimpleTagView", "code Idx found: " + ret); + return ret; + } catch (FontNotFoundException | ArrayIndexOutOfBoundsException | NullPointerException fr) { + throw new FontNotFoundException("Font with code not found: " + fontName); + } + } + + + /** + * Better using gradius up to 10px + * {@link GradientDrawable } + * + * @return tag background corner radius in pixels + * @see GradientDrawable#getGradientRadius() + */ + public int getRadius() { + return content.getRadius(); + } + + /** + * set corner radius by GradientDrawable.setCornerRadius + * + * @param newRadius corner Radius in pixels + * @see GradientDrawable#setCornerRadius(float) + */ + public void setRadius(int newRadius) { + content.setRadius(newRadius); + tagRootView.setBackgroundDrawable(getSelector(content)); + } + + /** + * Text color will be determined automatically based on + * threshold value {@link Constants#TAG_TEXT_WHITE_THOLD} + * + * @return TAG's title color + */ + public int getColor() { + return content.getColor(); + } + + /** + * @param tee + * @attr ref R.styleable#SimpleTagView_tagText + * @see TextView#setTextColor(int) + * @see TextView#getTextColors() + */ + public void setColor(int tee) { + content.setColor(tee); + resetTextColor(); + tagRootView.setBackgroundDrawable(getSelector(content)); + } + + /** + * Deletable tags automatically adds the symbol '×', + * but you still need to attach a listener to make it work + * + * @return whether TAG is deletable or not + */ + public boolean isDeletable() { + return content.isDeletable(); + } + + /** + * toggles delete icon's visibility + * + * @param isVisible + */ + public void setDeletable(boolean isVisible) { + content.setDeletable(isVisible); + tagDeleteTextView.setVisibility(isVisible ? View.VISIBLE : View.GONE); + } + + private Drawable getSelector(SimpleTag tag) { + // if (tag.getBackground() != null) return tag.getBackground(); + StateListDrawable states = new StateListDrawable(); + GradientDrawable gd_normal = new GradientDrawable(); + gd_normal.setColor(getColor()); + gd_normal.setCornerRadius(getRadius()); + //transparent border grant + gd_normal.setStroke(SimpleTagViewUtils.dipToPx(getContext(), 2f), Color.TRANSPARENT); + GradientDrawable gd_press = new GradientDrawable(); + gd_press.setColor(textDefaultColorAccent); + gd_press.setCornerRadius(tag.getRadius()); + states.addState(new int[]{android.R.attr.state_pressed}, gd_press); + //must add state_pressed first,or state_pressed will not take effect + states.addState(new int[]{}, gd_normal); + return states; + } + + /** + * setter for OnTagSelectListener + * + * @param clickListener + */ + public void setOnSimpleTagClickListener(OnSimpleTagClickListener clickListener) { + mClickListener = clickListener; + } + + public void setOnSimpleTagDeleteListener(OnSimpleTagDeleteListener delListener) { + mDeleteListener = delListener; + } +} diff --git a/tagviewlib/src/main/java/it/angelic/tagviewlib/SimpleTagViewUtils.java b/tagviewlib/src/main/java/it/angelic/tagviewlib/SimpleTagViewUtils.java new file mode 100644 index 0000000..5916a41 --- /dev/null +++ b/tagviewlib/src/main/java/it/angelic/tagviewlib/SimpleTagViewUtils.java @@ -0,0 +1,75 @@ +package it.angelic.tagviewlib; + +import android.content.Context; +import android.graphics.Color; +import android.graphics.Typeface; +import android.util.DisplayMetrics; +import android.util.TypedValue; + +import java.util.ArrayList; +import java.util.Arrays; + +public class SimpleTagViewUtils { + private static ArrayList mAllIcons; + private static ArrayList mAllIconNames; + + private static Typeface mFont; + + + static int dipToPx(Context c, float dipValue) { + DisplayMetrics metrics = c.getResources().getDisplayMetrics(); + return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics); + } + + static double getWeigthedColorLuminosity(int col) { + return Color.red(col) * 0.299 + Color.green(col) * 0.587 + Color.blue(col) * 0.114; + } + + /** + * Returns the font-awesome Typeface from the given context. + * Use this typeface with entities returned by {@link #getAwesomeCodes(Context)} + * + * @param context Context to get the assets from + * @return Typeface from the given context with the given name + */ + public static Typeface getAwesomeTypeface(Context context ) throws FontNotFoundException { + if (mFont == null) { + try { + mFont = Typeface.createFromAsset(context.getAssets(), Constants.FONT); + } catch (Exception e) { + throw new FontNotFoundException(e.getMessage()); + } + } + return mFont; + } + + /** + * Used to retrieve Entities used to map font-awesome symbols + * as mapped on font-awesome 4.5.0 cheatsheet + * + * @param ctx Context to get the symbols from + * @return ArrayList of all font-awesome unicodes + */ + public static ArrayList getAwesomeCodes(Context ctx) { + if (mAllIcons == null) { + mAllIcons = new ArrayList(); + mAllIcons = new ArrayList<>(Arrays.asList(ctx.getResources().getStringArray(R.array.all_icons))); + } + return mAllIcons; + } + /** + * Used to retrieve Entities'position used when mapping + * font-awesome codes. + * + * @param ctx + * @return ArrayList of all font-awesome icons + */ + public static ArrayList getAwesomeNames(Context ctx) { + if (mAllIconNames == null) { + mAllIconNames = new ArrayList(); + mAllIconNames = new ArrayList<>(Arrays.asList(ctx.getResources().getStringArray(R.array.all_icon_names))); + } + return mAllIconNames; + } + +} diff --git a/tagviewlib/src/main/res/layout/simple_tag_view.xml b/tagviewlib/src/main/res/layout/simple_tag_view.xml new file mode 100644 index 0000000..ec090c2 --- /dev/null +++ b/tagviewlib/src/main/res/layout/simple_tag_view.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/tagviewlib/src/main/res/values/arrays.xml b/tagviewlib/src/main/res/values/arrays.xml new file mode 100644 index 0000000..1a959bd --- /dev/null +++ b/tagviewlib/src/main/res/values/arrays.xml @@ -0,0 +1,1578 @@ + + + + + fa-500px + fa-address-book + fa-address-book-o + fa-address-card + fa-address-card-o + fa-adjust + fa-adn + fa-align-center + fa-align-justify + fa-align-left + fa-align-right + fa-amazon + fa-ambulance + fa-american-sign-language-interpreting + fa-anchor + fa-android + fa-angellist + fa-angle-double-down + fa-angle-double-left + fa-angle-double-right + fa-angle-double-up + fa-angle-down + fa-angle-left + fa-angle-right + fa-angle-up + fa-apple + fa-archive + fa-area-chart + fa-arrow-circle-down + fa-arrow-circle-left + fa-arrow-circle-o-down + fa-arrow-circle-o-left + fa-arrow-circle-o-right + fa-arrow-circle-o-up + fa-arrow-circle-right + fa-arrow-circle-up + fa-arrow-down + fa-arrow-left + fa-arrow-right + fa-arrow-up + fa-arrows + fa-arrows-alt + fa-arrows-h + fa-arrows-v + fa-asl-interpreting + fa-assistive-listening-systems + fa-asterisk + fa-at + fa-audio-description + fa-automobile + fa-backward + fa-balance-scale + fa-ban + fa-bandcamp + fa-bank + fa-bar-chart + fa-bar-chart-o + fa-barcode + fa-bars + fa-bath + fa-bathtub + fa-battery + fa-battery-0 + fa-battery-1 + fa-battery-2 + fa-battery-3 + fa-battery-4 + fa-battery-empty + fa-battery-full + fa-battery-half + fa-battery-quarter + fa-battery-three-quarters + fa-bed + fa-beer + fa-behance + fa-behance-square + fa-bell + fa-bell-o + fa-bell-slash + fa-bell-slash-o + fa-bicycle + fa-binoculars + fa-birthday-cake + fa-bitbucket + fa-bitbucket-square + fa-bitcoin + fa-black-tie + fa-blind + fa-bluetooth + fa-bluetooth-b + fa-bold + fa-bolt + fa-bomb + fa-book + fa-bookmark + fa-bookmark-o + fa-braille + fa-briefcase + fa-btc + fa-bug + fa-building + fa-building-o + fa-bullhorn + fa-bullseye + fa-bus + fa-buysellads + fa-cab + fa-calculator + fa-calendar + fa-calendar-check-o + fa-calendar-minus-o + fa-calendar-o + fa-calendar-plus-o + fa-calendar-times-o + fa-camera + fa-camera-retro + fa-car + fa-caret-down + fa-caret-left + fa-caret-right + fa-caret-square-o-down + fa-caret-square-o-left + fa-caret-square-o-right + fa-caret-square-o-up + fa-caret-up + fa-cart-arrow-down + fa-cart-plus + fa-cc + fa-cc-amex + fa-cc-diners-club + fa-cc-discover + fa-cc-jcb + fa-cc-mastercard + fa-cc-paypal + fa-cc-stripe + fa-cc-visa + fa-certificate + fa-chain + fa-chain-broken + fa-check + fa-check-circle + fa-check-circle-o + fa-check-square + fa-check-square-o + fa-chevron-circle-down + fa-chevron-circle-left + fa-chevron-circle-right + fa-chevron-circle-up + fa-chevron-down + fa-chevron-left + fa-chevron-right + fa-chevron-up + fa-child + fa-chrome + fa-circle + fa-circle-o + fa-circle-o-notch + fa-circle-thin + fa-clipboard + fa-clock-o + fa-clone + fa-close + fa-cloud + fa-cloud-download + fa-cloud-upload + fa-cny + fa-code + fa-code-fork + fa-codepen + fa-codiepie + fa-coffee + fa-cog + fa-cogs + fa-columns + fa-comment + fa-comment-o + fa-commenting + fa-commenting-o + fa-comments + fa-comments-o + fa-compass + fa-compress + fa-connectdevelop + fa-contao + fa-copy + fa-copyright + fa-creative-commons + fa-credit-card + fa-credit-card-alt + fa-crop + fa-crosshairs + fa-css3 + fa-cube + fa-cubes + fa-cut + fa-cutlery + fa-dashboard + fa-dashcube + fa-database + fa-deaf + fa-deafness + fa-dedent + fa-delicious + fa-desktop + fa-deviantart + fa-diamond + fa-digg + fa-dollar + fa-dot-circle-o + fa-download + fa-dribbble + fa-drivers-license + fa-drivers-license-o + fa-dropbox + fa-drupal + fa-edge + fa-edit + fa-eercast + fa-eject + fa-ellipsis-h + fa-ellipsis-v + fa-empire + fa-envelope + fa-envelope-o + fa-envelope-open + fa-envelope-open-o + fa-envelope-square + fa-envira + fa-eraser + fa-etsy + fa-eur + fa-euro + fa-exchange + fa-exclamation + fa-exclamation-circle + fa-exclamation-triangle + fa-expand + fa-expeditedssl + fa-external-link + fa-external-link-square + fa-eye + fa-eye-slash + fa-eyedropper + fa-fa + fa-facebook + fa-facebook-f + fa-facebook-official + fa-facebook-square + fa-fast-backward + fa-fast-forward + fa-fax + fa-feed + fa-female + fa-fighter-jet + fa-file + fa-file-archive-o + fa-file-audio-o + fa-file-code-o + fa-file-excel-o + fa-file-image-o + fa-file-movie-o + fa-file-o + fa-file-pdf-o + fa-file-photo-o + fa-file-picture-o + fa-file-powerpoint-o + fa-file-sound-o + fa-file-text + fa-file-text-o + fa-file-video-o + fa-file-word-o + fa-file-zip-o + fa-files-o + fa-film + fa-filter + fa-fire + fa-fire-extinguisher + fa-firefox + fa-first-order + fa-flag + fa-flag-checkered + fa-flag-o + fa-flash + fa-flask + fa-flickr + fa-floppy-o + fa-folder + fa-folder-o + fa-folder-open + fa-folder-open-o + fa-font + fa-font-awesome + fa-fonticons + fa-fort-awesome + fa-forumbee + fa-forward + fa-foursquare + fa-free-code-camp + fa-frown-o + fa-futbol-o + fa-gamepad + fa-gavel + fa-gbp + fa-ge + fa-gear + fa-gears + fa-genderless + fa-get-pocket + fa-gg + fa-gg-circle + fa-gift + fa-git + fa-git-square + fa-github + fa-github-alt + fa-github-square + fa-gitlab + fa-gittip + fa-glass + fa-glide + fa-glide-g + fa-globe + fa-google + fa-google-plus + fa-google-plus-circle + fa-google-plus-official + fa-google-plus-square + fa-google-wallet + fa-graduation-cap + fa-gratipay + fa-grav + fa-group + fa-h-square + fa-hacker-news + fa-hand-grab-o + fa-hand-lizard-o + fa-hand-o-down + fa-hand-o-left + fa-hand-o-right + fa-hand-o-up + fa-hand-paper-o + fa-hand-peace-o + fa-hand-pointer-o + fa-hand-rock-o + fa-hand-scissors-o + fa-hand-spock-o + fa-hand-stop-o + fa-handshake-o + fa-hard-of-hearing + fa-hashtag + fa-hdd-o + fa-header + fa-headphones + fa-heart + fa-heart-o + fa-heartbeat + fa-history + fa-home + fa-hospital-o + fa-hotel + fa-hourglass + fa-hourglass-1 + fa-hourglass-2 + fa-hourglass-3 + fa-hourglass-end + fa-hourglass-half + fa-hourglass-o + fa-hourglass-start + fa-houzz + fa-html5 + fa-i-cursor + fa-id-badge + fa-id-card + fa-id-card-o + fa-ils + fa-image + fa-imdb + fa-inbox + fa-indent + fa-industry + fa-info + fa-info-circle + fa-inr + fa-instagram + fa-institution + fa-internet-explorer + fa-intersex + fa-ioxhost + fa-italic + fa-joomla + fa-jpy + fa-jsfiddle + fa-key + fa-keyboard-o + fa-krw + fa-language + fa-laptop + fa-lastfm + fa-lastfm-square + fa-leaf + fa-leanpub + fa-legal + fa-lemon-o + fa-level-down + fa-level-up + fa-life-bouy + fa-life-buoy + fa-life-ring + fa-life-saver + fa-lightbulb-o + fa-line-chart + fa-link + fa-linkedin + fa-linkedin-square + fa-linode + fa-linux + fa-list + fa-list-alt + fa-list-ol + fa-list-ul + fa-location-arrow + fa-lock + fa-long-arrow-down + fa-long-arrow-left + fa-long-arrow-right + fa-long-arrow-up + fa-low-vision + fa-magic + fa-magnet + fa-mail-forward + fa-mail-reply + fa-mail-reply-all + fa-male + fa-map + fa-map-marker + fa-map-o + fa-map-pin + fa-map-signs + fa-mars + fa-mars-double + fa-mars-stroke + fa-mars-stroke-h + fa-mars-stroke-v + fa-maxcdn + fa-meanpath + fa-medium + fa-medkit + fa-meetup + fa-meh-o + fa-mercury + fa-microchip + fa-microphone + fa-microphone-slash + fa-minus + fa-minus-circle + fa-minus-square + fa-minus-square-o + fa-mixcloud + fa-mobile + fa-mobile-phone + fa-modx + fa-money + fa-moon-o + fa-mortar-board + fa-motorcycle + fa-mouse-pointer + fa-music + fa-navicon + fa-neuter + fa-newspaper-o + fa-object-group + fa-object-ungroup + fa-odnoklassniki + fa-odnoklassniki-square + fa-opencart + fa-openid + fa-opera + fa-optin-monster + fa-outdent + fa-pagelines + fa-paint-brush + fa-paper-plane + fa-paper-plane-o + fa-paperclip + fa-paragraph + fa-paste + fa-pause + fa-pause-circle + fa-pause-circle-o + fa-paw + fa-paypal + fa-pencil + fa-pencil-square + fa-pencil-square-o + fa-percent + fa-phone + fa-phone-square + fa-photo + fa-picture-o + fa-pie-chart + fa-pied-piper + fa-pied-piper-alt + fa-pied-piper-pp + fa-pinterest + fa-pinterest-p + fa-pinterest-square + fa-plane + fa-play + fa-play-circle + fa-play-circle-o + fa-plug + fa-plus + fa-plus-circle + fa-plus-square + fa-plus-square-o + fa-podcast + fa-power-off + fa-print + fa-product-hunt + fa-puzzle-piece + fa-qq + fa-qrcode + fa-question + fa-question-circle + fa-question-circle-o + fa-quora + fa-quote-left + fa-quote-right + fa-ra + fa-random + fa-ravelry + fa-rebel + fa-recycle + fa-reddit + fa-reddit-alien + fa-reddit-square + fa-refresh + fa-registered + fa-remove + fa-renren + fa-reorder + fa-repeat + fa-reply + fa-reply-all + fa-resistance + fa-retweet + fa-rmb + fa-road + fa-rocket + fa-rotate-left + fa-rotate-right + fa-rouble + fa-rss + fa-rss-square + fa-rub + fa-ruble + fa-rupee + fa-s15 + fa-safari + fa-save + fa-scissors + fa-scribd + fa-search + fa-search-minus + fa-search-plus + fa-sellsy + fa-send + fa-send-o + fa-server + fa-share + fa-share-alt + fa-share-alt-square + fa-share-square + fa-share-square-o + fa-shekel + fa-sheqel + fa-shield + fa-ship + fa-shirtsinbulk + fa-shopping-bag + fa-shopping-basket + fa-shopping-cart + fa-shower + fa-sign-in + fa-sign-language + fa-sign-out + fa-signal + fa-signing + fa-simplybuilt + fa-sitemap + fa-skyatlas + fa-skype + fa-slack + fa-sliders + fa-slideshare + fa-smile-o + fa-snapchat + fa-snapchat-ghost + fa-snapchat-square + fa-snowflake-o + fa-soccer-ball-o + fa-sort + fa-sort-alpha-asc + fa-sort-alpha-desc + fa-sort-amount-asc + fa-sort-amount-desc + fa-sort-asc + fa-sort-desc + fa-sort-down + fa-sort-numeric-asc + fa-sort-numeric-desc + fa-sort-up + fa-soundcloud + fa-space-shuttle + fa-spinner + fa-spoon + fa-spotify + fa-square + fa-square-o + fa-stack-exchange + fa-stack-overflow + fa-star + fa-star-half + fa-star-half-empty + fa-star-half-full + fa-star-half-o + fa-star-o + fa-steam + fa-steam-square + fa-step-backward + fa-step-forward + fa-stethoscope + fa-sticky-note + fa-sticky-note-o + fa-stop + fa-stop-circle + fa-stop-circle-o + fa-street-view + fa-strikethrough + fa-stumbleupon + fa-stumbleupon-circle + fa-subscript + fa-subway + fa-suitcase + fa-sun-o + fa-superpowers + fa-superscript + fa-support + fa-table + fa-tablet + fa-tachometer + fa-tag + fa-tags + fa-tasks + fa-taxi + fa-telegram + fa-television + fa-tencent-weibo + fa-terminal + fa-text-height + fa-text-width + fa-th + fa-th-large + fa-th-list + fa-themeisle + fa-thermometer + fa-thermometer-0 + fa-thermometer-1 + fa-thermometer-2 + fa-thermometer-3 + fa-thermometer-4 + fa-thermometer-empty + fa-thermometer-full + fa-thermometer-half + fa-thermometer-quarter + fa-thermometer-three-quarters + fa-thumb-tack + fa-thumbs-down + fa-thumbs-o-down + fa-thumbs-o-up + fa-thumbs-up + fa-ticket + fa-times + fa-times-circle + fa-times-circle-o + fa-times-rectangle + fa-times-rectangle-o + fa-tint + fa-toggle-down + fa-toggle-left + fa-toggle-off + fa-toggle-on + fa-toggle-right + fa-toggle-up + fa-trademark + fa-train + fa-transgender + fa-transgender-alt + fa-trash + fa-trash-o + fa-tree + fa-trello + fa-tripadvisor + fa-trophy + fa-truck + fa-try + fa-tty + fa-tumblr + fa-tumblr-square + fa-turkish-lira + fa-tv + fa-twitch + fa-twitter + fa-twitter-square + fa-umbrella + fa-underline + fa-undo + fa-universal-access + fa-university + fa-unlink + fa-unlock + fa-unlock-alt + fa-unsorted + fa-upload + fa-usb + fa-usd + fa-user + fa-user-circle + fa-user-circle-o + fa-user-md + fa-user-o + fa-user-plus + fa-user-secret + fa-user-times + fa-users + fa-vcard + fa-vcard-o + fa-venus + fa-venus-double + fa-venus-mars + fa-viacoin + fa-viadeo + fa-viadeo-square + fa-video-camera + fa-vimeo + fa-vimeo-square + fa-vine + fa-vk + fa-volume-control-phone + fa-volume-down + fa-volume-off + fa-volume-up + fa-warning + fa-wechat + fa-weibo + fa-weixin + fa-whatsapp + fa-wheelchair + fa-wheelchair-alt + fa-wifi + fa-wikipedia-w + fa-window-close + fa-window-close-o + fa-window-maximize + fa-window-minimize + fa-window-restore + fa-windows + fa-won + fa-wordpress + fa-wpbeginner + fa-wpexplorer + fa-wpforms + fa-wrench + fa-xing + fa-xing-square + fa-y-combinator + fa-y-combinator-square + fa-yahoo + fa-yc + fa-yc-square + fa-yelp + fa-yen + fa-yoast + fa-youtube + fa-youtube-play + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tagviewlib/src/main/res/values/attr.xml b/tagviewlib/src/main/res/values/attr.xml new file mode 100644 index 0000000..a9c39b3 --- /dev/null +++ b/tagviewlib/src/main/res/values/attr.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tagviewlib/tagviewlib.iml b/tagviewlib/tagviewlib.iml new file mode 100644 index 0000000..5001c30 --- /dev/null +++ b/tagviewlib/tagviewlib.iml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file