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

Custom Font and Delete button support #72

Open
wants to merge 8 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
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.android.tools.build:gradle:3.0.1'
}
}

Expand All @@ -15,5 +16,6 @@ allprojects {

repositories {
jcenter()
google()
}
}
11 changes: 6 additions & 5 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
compileSdkVersion 27
buildToolsVersion '26.0.2'
defaultConfig {
applicationId 'me.gujun.android.taggroup.demo'
minSdkVersion 8
targetSdkVersion 21
minSdkVersion 19
targetSdkVersion 27
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
}
Expand All @@ -22,5 +22,6 @@ android {

dependencies {
compile project(':library')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:appcompat-v7:27.0.2'

}
Binary file added demo/src/main/assets/font/Lobster-Regular.ttf
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.gujun.android.taggroup.demo;

import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
Expand All @@ -9,6 +10,10 @@
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

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

Expand Down Expand Up @@ -36,10 +41,14 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTagsManager = TagsManager.getInstance(getApplicationContext());
String[] tags = mTagsManager.getTags();
List<TagData> tags = new ArrayList<>();
tags.add(new TagData(0L, "hello"));
tags.add(new TagData(0L, "how"));
tags.add(new TagData(0L, "are"));
tags.add(new TagData(0L, "you"));

mPromptText = (TextView) findViewById(R.id.tv_prompt);
mPromptText.setVisibility((tags == null || tags.length == 0) ? View.VISIBLE : View.GONE);
mPromptText.setVisibility((tags == null || tags.size() == 0) ? View.VISIBLE : View.GONE);
mPromptText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -52,7 +61,10 @@ public void onClick(View v) {
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) {
// font/Lobster-Regular.ttf
mLargeTagGroup.setCustomTypeface(Typeface.createFromAsset(getAssets(), "font/Lobster-Regular.ttf"));
mBeautyInverseTagGroup.showDeleteBtn(R.drawable.letter_x);
if (tags != null && tags.size() > 0) {
mDefaultTagGroup.setTags(tags);
mSmallTagGroup.setTags(tags);
mLargeTagGroup.setTags(tags);
Expand All @@ -78,8 +90,13 @@ public void onClick(View v) {
@Override
protected void onResume() {
super.onResume();
String[] tags = mTagsManager.getTags();
mPromptText.setVisibility((tags == null || tags.length == 0) ? View.VISIBLE : View.GONE);

List<TagData> tags = new ArrayList<>();
tags.add(new TagData(0L, "hello"));
tags.add(new TagData(0L, "how"));
tags.add(new TagData(0L, "are"));
tags.add(new TagData(0L, "you"));
mPromptText.setVisibility((tags == null || tags.size() == 0) ? View.VISIBLE : View.GONE);
mDefaultTagGroup.setTags(tags);
mSmallTagGroup.setTags(tags);
mLargeTagGroup.setTags(tags);
Expand Down
69 changes: 69 additions & 0 deletions demo/src/main/java/me/gujun/android/taggroup/demo/TagData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package me.gujun.android.taggroup.demo;

import android.os.Parcel;
import android.os.Parcelable;

public class TagData implements Parcelable {


public TagData(Long id, String name) {
this.id = id;
this.name = name;
}

private Long id;
private String name;


public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Override
public String toString() {
return name;
}

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(this.id);
dest.writeString(this.name);
}

public TagData() {
}

protected TagData(Parcel in) {
this.id = (Long) in.readValue(Long.class.getClassLoader());
this.name = in.readString();
}

public static final Parcelable.Creator<TagData> CREATOR = new Parcelable.Creator<TagData>() {
@Override
public TagData createFromParcel(Parcel source) {
return new TagData(source);
}

@Override
public TagData[] newArray(int size) {
return new TagData[size];
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import android.view.Menu;
import android.view.MenuItem;

import java.util.Arrays;
import java.util.List;

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

Expand All @@ -19,7 +22,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_tag_editor);

mTagsManager = TagsManager.getInstance(getApplicationContext());
String[] tags = mTagsManager.getTags();
List<String> tags = Arrays.asList(mTagsManager.getTags());

mTagGroup = (TagGroup) findViewById(R.id.tag_group);
mTagGroup.setTags(tags);
Expand All @@ -34,7 +37,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
mTagsManager.updateTags(mTagGroup.getTags());
// mTagsManager.updateTags(mTagGroup.getTags());
finish();
return true;
} else if (item.getItemId() == R.id.action_submit) {
Expand All @@ -46,7 +49,7 @@ public boolean onOptionsItemSelected(MenuItem item) {

@Override
public void onBackPressed() {
mTagsManager.updateTags(mTagGroup.getTags());
// mTagsManager.updateTags(mTagGroup.getTags());
super.onBackPressed();
}
}
Binary file added demo/src/main/res/drawable-xxxhdpi/letter_x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

VERSION_NAME=1.4
VERSION_NAME=1.5
VERSION_CODE=14
GROUP=me.gujun.android.taggroup

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Mon Oct 30 12:02:15 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
8 changes: 4 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
compileSdkVersion 27
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
minSdkVersion 18
targetSdkVersion 27
}
lintOptions {
abortOnError false
Expand Down
Loading