Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed enter key #62

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 37 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
# `AndroidTagGroup`
# `Droid Tag Group 2017 version`

[![Release 1.4](https://img.shields.io/badge/Release-1.4.1-green.svg)](https://github.com/2dxgujun/AndroidTagGroup/releases)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/me.gujun.android.taggroup/library/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/me.gujun.android.taggroup/library)
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-AndroidTagGroup-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1539)
[![Build Status](https://travis-ci.org/2dxgujun/AndroidTagGroup.png?branch=master)](https://travis-ci.org/2dxgujun/AndroidTagGroup)
[![](https://jitpack.io/v/LorenzoZaccagnini/DroidTag.svg)](https://jitpack.io/#LorenzoZaccagnini/DroidTag)

The TagGroup is a special layout with a set of tags. You can use it to tag people, books or anything you want.

Also you can contribute new idea to me.

# Demo

### Screenshot
![screenshot1](http://ww4.sinaimg.cn/large/bce2dea9jw1esbsby9v5fj20u00w8jxx.jpg)

### Edit Tags
![screenshot2](http://ww4.sinaimg.cn/large/bce2dea9jw1esbsbngv8fj20u005w75v.jpg)
![screenshot3](http://ww4.sinaimg.cn/large/bce2dea9jw1esbsbmoagij20u005sabl.jpg)
![screenshot1](https://preview.ibb.co/bBobP5/normaltag_Crop.png)
![screenshot1](https://preview.ibb.co/jMKfHQ/autocomplete_Crop.png)

[Download Demo](https://github.com/2dxgujun/AndroidTagGroup/releases/download/v1.4/AndroidTagGroup-Demo-v1.4.apk)

# Usage

Expand All @@ -27,18 +20,16 @@ Also you can contribute new idea to me.
#### Gradle
```groovy
dependencies {
compile 'me.gujun.android.taggroup:library:1.4@aar'
}
compile 'com.github.LorenzoZaccagnini:DroidTag:1.6'}
```

#### Maven
```xml
<dependency>
<groupId>me.gujun.android.taggroup</groupId>
<artifactId>library</artifactId>
<version>1.4</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.github.LorenzoZaccagnini</groupId>
<artifactId>DroidTag</artifactId>
<version>1.6</version>
</dependency>
```

## Step 2
Expand All @@ -60,12 +51,25 @@ Use `setTags(...)` to set the initial tags in the group.

To "submit" a new tag as user press "Enter" or tap the blank area of the tag group, also you can "submit" a new tag via `submitTag()`.

**Note**: Google keyboard (a few soft keyboard not honour the key event) currently not supported "Enter" key to "submit" a new tag.

#### How to delete a tag?

To delete a tag as user press "Backspace" key or double-tap the tag which you want to delete.


#### How to add an autocomplete list?

Just add a string array, this an example for a fragment

private String[] suggestionsArray = { "Tag1", "Tag2", "Tag3", "Tag4", "Tag5"};

mTagGroup.setOnTagCharEntryListener(new TagGroup.OnTagCharEntryListener() {
@Override
public void onCharEntry(String text) {

mTagGroup.getTagView().setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, suggestionsArray));
}
});

#### How to detect tag click event?

Implement a callback interface: `TagGroup.OnTagClickListener`, and set the listener via `setOnTagClickListener()`.
Expand Down Expand Up @@ -107,7 +111,18 @@ There are several attributes you can set:
| atg_horizontalPadding | 12dp | The horizontal tag padding.(Mark3) |
| atg_verticalPadding | 3dp | The vertical tag padding.(Mark4) |

# Developed By
# New version by

Lorenzo Zaccagnini - <[email protected]>

<a href="https://www.facebook.com/DrLorenzoZaccagnini">
<img alt="Follow me on Facebook" src="https://www.brandsbay.com/media/wysiwyg/facebook-icon.jpg"/>
</a>
<a href="https://www.linkedin.com/in/lorenzo-zaccagnini/">
<img alt="Follow me on LinkedIn" src="https://www.rochester.edu/templatefiles/rwd/img/social-linkedin.png"/>
</a>

# Fork of

Jun Gu - <[email protected]>

Expand Down
1 change: 1 addition & 0 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

apply plugin: 'com.android.application'

android {
Expand Down
8 changes: 0 additions & 8 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".TagEditorActivity"
android:label="@string/title_activity_tag_editor"
android:parentActivityName=".MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="me.gujun.android.taggroup.demo.MainActivity" />
</activity>
</application>

</manifest>
109 changes: 12 additions & 97 deletions demo/src/main/java/me/gujun/android/taggroup/demo/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,116 +1,31 @@
package me.gujun.android.taggroup.demo;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ArrayAdapter;

import me.gujun.android.taggroup.TagGroup;
import me.gujun.android.taggroup.demo.db.TagsManager;


public class MainActivity extends ActionBarActivity {
private TextView mPromptText;

private TagGroup mDefaultTagGroup;
private TagGroup mSmallTagGroup;
private TagGroup mLargeTagGroup;
private TagGroup mBeautyTagGroup;
private TagGroup mBeautyInverseTagGroup;

private TagsManager mTagsManager;

private TagGroup.OnTagClickListener mTagClickListener = new TagGroup.OnTagClickListener() {
@Override
public void onTagClick(String tag) {
Toast.makeText(MainActivity.this, tag, Toast.LENGTH_SHORT).show();
}
};

private TagGroup mTagGroup;
//TODO REMOVE suggestion string when backend is ready
private String[] autoFakeServerCompleteTag = { "Tag1", "Tag2", "Tag3", "Tag4", "Tag5"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTagsManager = TagsManager.getInstance(getApplicationContext());
String[] tags = mTagsManager.getTags();

mPromptText = (TextView) findViewById(R.id.tv_prompt);
mPromptText.setVisibility((tags == null || tags.length == 0) ? View.VISIBLE : View.GONE);
mPromptText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
launchTagEditorActivity();
}
});

mDefaultTagGroup = (TagGroup) findViewById(R.id.tag_group);
mSmallTagGroup = (TagGroup) findViewById(R.id.tag_group_small);
mLargeTagGroup = (TagGroup) findViewById(R.id.tag_group_large);
mBeautyTagGroup = (TagGroup) findViewById(R.id.tag_group_beauty);
mBeautyInverseTagGroup = (TagGroup) findViewById(R.id.tag_group_beauty_inverse);
if (tags != null && tags.length > 0) {
mDefaultTagGroup.setTags(tags);
mSmallTagGroup.setTags(tags);
mLargeTagGroup.setTags(tags);
mBeautyTagGroup.setTags(tags);
mBeautyInverseTagGroup.setTags(tags);
}

MyTagGroupOnClickListener tgClickListener = new MyTagGroupOnClickListener();

mDefaultTagGroup.setOnClickListener(tgClickListener);
mSmallTagGroup.setOnClickListener(tgClickListener);
mLargeTagGroup.setOnClickListener(tgClickListener);
mBeautyTagGroup.setOnClickListener(tgClickListener);
mBeautyInverseTagGroup.setOnClickListener(tgClickListener);

mDefaultTagGroup.setOnTagClickListener(mTagClickListener);
mSmallTagGroup.setOnTagClickListener(mTagClickListener);
mLargeTagGroup.setOnTagClickListener(mTagClickListener);
mBeautyTagGroup.setOnTagClickListener(mTagClickListener);
mBeautyInverseTagGroup.setOnTagClickListener(mTagClickListener);
}

@Override
protected void onResume() {
super.onResume();
String[] tags = mTagsManager.getTags();
mPromptText.setVisibility((tags == null || tags.length == 0) ? View.VISIBLE : View.GONE);
mDefaultTagGroup.setTags(tags);
mSmallTagGroup.setTags(tags);
mLargeTagGroup.setTags(tags);
mBeautyTagGroup.setTags(tags);
mBeautyInverseTagGroup.setTags(tags);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main_activity, menu);
return true;
}
mTagGroup = (TagGroup) findViewById(R.id.tag_group);

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_edit) {
launchTagEditorActivity();
return true;
}
return false;
}
//get Fake Autocomplete server string array

protected void launchTagEditorActivity() {
Intent intent = new Intent(MainActivity.this, TagEditorActivity.class);
startActivity(intent);
}
mTagGroup.setOnTagCharEntryListener(new TagGroup.OnTagCharEntryListener() {
@Override
public void onCharEntry(String text) {

class MyTagGroupOnClickListener implements View.OnClickListener {
@Override
public void onClick(View v) {
launchTagEditorActivity();
}
mTagGroup.getTagView().setAdapter(new ArrayAdapter<>(MainActivity.this, R.layout.taglist, autoFakeServerCompleteTag));
}
});
}
}

This file was deleted.

Loading