add flutter
1
OnTime_Driver_live/lib/TextDrawable/sample/.gitignore
vendored
Executable file
@@ -0,0 +1 @@
|
||||
/build
|
||||
26
OnTime_Driver_live/lib/TextDrawable/sample/build.gradle
Executable file
@@ -0,0 +1,26 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 21
|
||||
buildToolsVersion "21.1.1"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.amulyakhare.td"
|
||||
minSdkVersion 10
|
||||
targetSdkVersion 21
|
||||
versionCode 2
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile project(':library')
|
||||
compile 'com.android.support:appcompat-v7:21.0.3'
|
||||
}
|
||||
17
OnTime_Driver_live/lib/TextDrawable/sample/proguard-rules.pro
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /home/gardev/android/adt-bundle-linux/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
25
OnTime_Driver_live/lib/TextDrawable/sample/src/main/AndroidManifest.xml
Executable file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.amulyakhare.td" >
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name="com.amulyakhare.td.sample.MainActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.amulyakhare.td.sample.ListActivity"
|
||||
android:label="@string/title_activity_check_box" >
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,193 @@
|
||||
package com.amulyakhare.td.sample;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.amulyakhare.td.R;
|
||||
import com.amulyakhare.td.sample.sample.DrawableProvider;
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ListActivity extends ActionBarActivity {
|
||||
|
||||
private static final int HIGHLIGHT_COLOR = 0x999be6ff;
|
||||
|
||||
// list of data items
|
||||
private List<ListData> mDataList = Arrays.asList(
|
||||
new ListData("Iron Man"),
|
||||
new ListData("Captain America"),
|
||||
new ListData("James Bond"),
|
||||
new ListData("Harry Potter"),
|
||||
new ListData("Sherlock Holmes"),
|
||||
new ListData("Black Widow"),
|
||||
new ListData("Hawk Eye"),
|
||||
new ListData("Iron Man"),
|
||||
new ListData("Guava"),
|
||||
new ListData("Tomato"),
|
||||
new ListData("Pineapple"),
|
||||
new ListData("Strawberry"),
|
||||
new ListData("Watermelon"),
|
||||
new ListData("Pears"),
|
||||
new ListData("Kiwi"),
|
||||
new ListData("Plums")
|
||||
);
|
||||
|
||||
// declare the color generator and drawable builder
|
||||
private ColorGenerator mColorGenerator = ColorGenerator.MATERIAL;
|
||||
private TextDrawable.IBuilder mDrawableBuilder;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_list);
|
||||
|
||||
Intent intent = getIntent();
|
||||
int type = intent.getIntExtra(MainActivity.TYPE, DrawableProvider.SAMPLE_RECT);
|
||||
|
||||
// initialize the builder based on the "TYPE"
|
||||
switch (type) {
|
||||
case DrawableProvider.SAMPLE_RECT:
|
||||
mDrawableBuilder = TextDrawable.builder()
|
||||
.rect();
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_ROUND_RECT:
|
||||
mDrawableBuilder = TextDrawable.builder()
|
||||
.roundRect(10);
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_ROUND:
|
||||
mDrawableBuilder = TextDrawable.builder()
|
||||
.round();
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_RECT_BORDER:
|
||||
mDrawableBuilder = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.withBorder(4)
|
||||
.endConfig()
|
||||
.rect();
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_ROUND_RECT_BORDER:
|
||||
mDrawableBuilder = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.withBorder(4)
|
||||
.endConfig()
|
||||
.roundRect(10);
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_ROUND_BORDER:
|
||||
mDrawableBuilder = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.withBorder(4)
|
||||
.endConfig()
|
||||
.round();
|
||||
break;
|
||||
}
|
||||
|
||||
// init the list view and its adapter
|
||||
ListView listView = (ListView) findViewById(R.id.listView);
|
||||
listView.setAdapter(new SampleAdapter());
|
||||
}
|
||||
|
||||
private class SampleAdapter extends BaseAdapter {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mDataList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListData getItem(int position) {
|
||||
return mDataList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
final ViewHolder holder;
|
||||
if (convertView == null) {
|
||||
convertView = View.inflate(ListActivity.this, R.layout.list_item_layout, null);
|
||||
holder = new ViewHolder(convertView);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
ListData item = getItem(position);
|
||||
|
||||
// provide support for selected state
|
||||
updateCheckedState(holder, item);
|
||||
holder.imageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// when the image is clicked, update the selected state
|
||||
ListData data = getItem(position);
|
||||
data.setChecked(!data.isChecked);
|
||||
updateCheckedState(holder, data);
|
||||
}
|
||||
});
|
||||
holder.textView.setText(item.data);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
private void updateCheckedState(ViewHolder holder, ListData item) {
|
||||
if (item.isChecked) {
|
||||
holder.imageView.setImageDrawable(mDrawableBuilder.build(" ", 0xff616161));
|
||||
holder.view.setBackgroundColor(HIGHLIGHT_COLOR);
|
||||
holder.checkIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
TextDrawable drawable = mDrawableBuilder.build(String.valueOf(item.data.charAt(0)), mColorGenerator.getColor(item.data));
|
||||
holder.imageView.setImageDrawable(drawable);
|
||||
holder.view.setBackgroundColor(Color.TRANSPARENT);
|
||||
holder.checkIcon.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class ViewHolder {
|
||||
|
||||
private View view;
|
||||
|
||||
private ImageView imageView;
|
||||
|
||||
private TextView textView;
|
||||
|
||||
private ImageView checkIcon;
|
||||
|
||||
private ViewHolder(View view) {
|
||||
this.view = view;
|
||||
imageView = (ImageView) view.findViewById(R.id.imageView);
|
||||
textView = (TextView) view.findViewById(R.id.textView);
|
||||
checkIcon = (ImageView) view.findViewById(R.id.check_icon);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ListData {
|
||||
|
||||
private String data;
|
||||
|
||||
private boolean isChecked;
|
||||
|
||||
public ListData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public void setChecked(boolean isChecked) {
|
||||
this.isChecked = isChecked;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.amulyakhare.td.sample;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.*;
|
||||
|
||||
import com.amulyakhare.td.R;
|
||||
import com.amulyakhare.td.sample.sample.DataItem;
|
||||
import com.amulyakhare.td.sample.sample.DataSource;
|
||||
|
||||
public class MainActivity extends ActionBarActivity implements AdapterView.OnItemClickListener {
|
||||
|
||||
public static final String TYPE = "TYPE";
|
||||
private DataSource mDataSource;
|
||||
private ListView mListView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
mListView = (ListView) findViewById(R.id.listView);
|
||||
mDataSource = new DataSource(this);
|
||||
mListView.setAdapter(new SampleAdapter());
|
||||
mListView.setOnItemClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
DataItem item = (DataItem) mListView.getItemAtPosition(position);
|
||||
|
||||
// if navigation is supported, open the next activity
|
||||
if (item.getNavigationInfo() != DataSource.NO_NAVIGATION) {
|
||||
Intent intent = new Intent(this, ListActivity.class);
|
||||
intent.putExtra(TYPE, item.getNavigationInfo());
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private class SampleAdapter extends BaseAdapter {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mDataSource.getCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataItem getItem(int position) {
|
||||
return mDataSource.getItem(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
ViewHolder holder;
|
||||
if (convertView == null) {
|
||||
convertView = View.inflate(MainActivity.this, R.layout.list_item_layout, null);
|
||||
holder = new ViewHolder(convertView);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
DataItem item = getItem(position);
|
||||
|
||||
final Drawable drawable = item.getDrawable();
|
||||
holder.imageView.setImageDrawable(drawable);
|
||||
holder.textView.setText(item.getLabel());
|
||||
|
||||
// if navigation is supported, show the ">" navigation icon
|
||||
if (item.getNavigationInfo() != DataSource.NO_NAVIGATION) {
|
||||
holder.textView.setCompoundDrawablesWithIntrinsicBounds(null,
|
||||
null,
|
||||
getResources().getDrawable(R.drawable.ic_action_next_item),
|
||||
null);
|
||||
}
|
||||
else {
|
||||
holder.textView.setCompoundDrawablesWithIntrinsicBounds(null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
|
||||
// fix for animation not playing for some below 4.4 devices
|
||||
if (drawable instanceof AnimationDrawable) {
|
||||
holder.imageView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
((AnimationDrawable) drawable).stop();
|
||||
((AnimationDrawable) drawable).start();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ViewHolder {
|
||||
|
||||
private ImageView imageView;
|
||||
|
||||
private TextView textView;
|
||||
|
||||
private ViewHolder(View view) {
|
||||
imageView = (ImageView) view.findViewById(R.id.imageView);
|
||||
textView = (TextView) view.findViewById(R.id.textView);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.amulyakhare.td.sample.sample;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
/**
|
||||
* @author amulya
|
||||
* @datetime 17 Oct 2014, 3:50 PM
|
||||
*/
|
||||
public class DataItem {
|
||||
|
||||
private String label;
|
||||
|
||||
private Drawable drawable;
|
||||
|
||||
private int navigationInfo;
|
||||
|
||||
public DataItem(String label, Drawable drawable, int navigationInfo) {
|
||||
this.label = label;
|
||||
this.drawable = drawable;
|
||||
this.navigationInfo = navigationInfo;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public Drawable getDrawable() {
|
||||
return drawable;
|
||||
}
|
||||
|
||||
public int getNavigationInfo() {
|
||||
return navigationInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.amulyakhare.td.sample.sample;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author amulya
|
||||
* @datetime 17 Oct 2014, 3:49 PM
|
||||
*/
|
||||
public class DataSource {
|
||||
|
||||
public static final int NO_NAVIGATION = -1;
|
||||
|
||||
private ArrayList<DataItem> mDataSource;
|
||||
private DrawableProvider mProvider;
|
||||
|
||||
public DataSource(Context context) {
|
||||
mProvider = new DrawableProvider(context);
|
||||
mDataSource = new ArrayList<DataItem>();
|
||||
mDataSource.add(itemFromType(DrawableProvider.SAMPLE_RECT));
|
||||
mDataSource.add(itemFromType(DrawableProvider.SAMPLE_ROUND_RECT));
|
||||
mDataSource.add(itemFromType(DrawableProvider.SAMPLE_ROUND));
|
||||
mDataSource.add(itemFromType(DrawableProvider.SAMPLE_RECT_BORDER));
|
||||
mDataSource.add(itemFromType(DrawableProvider.SAMPLE_ROUND_RECT_BORDER));
|
||||
mDataSource.add(itemFromType(DrawableProvider.SAMPLE_ROUND_BORDER));
|
||||
mDataSource.add(itemFromType(DrawableProvider.SAMPLE_MULTIPLE_LETTERS));
|
||||
mDataSource.add(itemFromType(DrawableProvider.SAMPLE_FONT));
|
||||
mDataSource.add(itemFromType(DrawableProvider.SAMPLE_SIZE));
|
||||
mDataSource.add(itemFromType(DrawableProvider.SAMPLE_ANIMATION));
|
||||
mDataSource.add(itemFromType(DrawableProvider.SAMPLE_MISC));
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return mDataSource.size();
|
||||
}
|
||||
|
||||
public DataItem getItem(int position) {
|
||||
return mDataSource.get(position);
|
||||
}
|
||||
|
||||
private DataItem itemFromType(int type) {
|
||||
String label = null;
|
||||
Drawable drawable = null;
|
||||
switch (type) {
|
||||
case DrawableProvider.SAMPLE_RECT:
|
||||
label = "Rectangle with Text";
|
||||
drawable = mProvider.getRect("A");
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_ROUND_RECT:
|
||||
label = "Round Corner with Text";
|
||||
drawable = mProvider.getRoundRect("B");
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_ROUND:
|
||||
label = "Round with Text";
|
||||
drawable = mProvider.getRound("C");
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_RECT_BORDER:
|
||||
label = "Rectangle with Border";
|
||||
drawable = mProvider.getRectWithBorder("D");
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_ROUND_RECT_BORDER:
|
||||
label = "Round Corner with Border";
|
||||
drawable = mProvider.getRoundRectWithBorder("E");
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_ROUND_BORDER:
|
||||
label = "Round with Border";
|
||||
drawable = mProvider.getRoundWithBorder("F");
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_MULTIPLE_LETTERS:
|
||||
label = "Support multiple letters";
|
||||
drawable = mProvider.getRectWithMultiLetter();
|
||||
type = NO_NAVIGATION;
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_FONT:
|
||||
label = "Support variable font styles";
|
||||
drawable = mProvider.getRoundWithCustomFont();
|
||||
type = NO_NAVIGATION;
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_SIZE:
|
||||
label = "Support for custom size";
|
||||
drawable = mProvider.getRectWithCustomSize();
|
||||
type = NO_NAVIGATION;
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_ANIMATION:
|
||||
label = "Support for animations";
|
||||
drawable = mProvider.getRectWithAnimation();
|
||||
type = NO_NAVIGATION;
|
||||
break;
|
||||
case DrawableProvider.SAMPLE_MISC:
|
||||
label = "Miscellaneous";
|
||||
drawable = mProvider.getRect("\u03c0");
|
||||
type = NO_NAVIGATION;
|
||||
break;
|
||||
}
|
||||
return new DataItem(label, drawable, type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.amulyakhare.td.sample.sample;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||
|
||||
/**
|
||||
* @author amulya
|
||||
* @datetime 17 Oct 2014, 4:02 PM
|
||||
*/
|
||||
public class DrawableProvider {
|
||||
|
||||
public static final int SAMPLE_RECT = 1;
|
||||
public static final int SAMPLE_ROUND_RECT = 2;
|
||||
public static final int SAMPLE_ROUND = 3;
|
||||
public static final int SAMPLE_RECT_BORDER = 4;
|
||||
public static final int SAMPLE_ROUND_RECT_BORDER = 5;
|
||||
public static final int SAMPLE_ROUND_BORDER = 6;
|
||||
public static final int SAMPLE_MULTIPLE_LETTERS = 7;
|
||||
public static final int SAMPLE_FONT = 8;
|
||||
public static final int SAMPLE_SIZE = 9;
|
||||
public static final int SAMPLE_ANIMATION = 10;
|
||||
public static final int SAMPLE_MISC = 11;
|
||||
|
||||
private final ColorGenerator mGenerator;
|
||||
private final Context mContext;
|
||||
|
||||
public DrawableProvider(Context context) {
|
||||
mGenerator = ColorGenerator.DEFAULT;
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public TextDrawable getRect(String text) {
|
||||
return TextDrawable.builder()
|
||||
.buildRect(text, mGenerator.getColor(text));
|
||||
}
|
||||
|
||||
public TextDrawable getRound(String text) {
|
||||
return TextDrawable.builder()
|
||||
.buildRound(text, mGenerator.getColor(text));
|
||||
}
|
||||
|
||||
public TextDrawable getRoundRect(String text) {
|
||||
return TextDrawable.builder()
|
||||
.buildRoundRect(text, mGenerator.getColor(text), toPx(10));
|
||||
}
|
||||
|
||||
public TextDrawable getRectWithBorder(String text) {
|
||||
return TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.withBorder(toPx(2))
|
||||
.endConfig()
|
||||
.buildRect(text, mGenerator.getColor(text));
|
||||
}
|
||||
|
||||
public TextDrawable getRoundWithBorder(String text) {
|
||||
return TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.withBorder(toPx(2))
|
||||
.endConfig()
|
||||
.buildRound(text, mGenerator.getColor(text));
|
||||
}
|
||||
|
||||
public TextDrawable getRoundRectWithBorder(String text) {
|
||||
return TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.withBorder(toPx(2))
|
||||
.endConfig()
|
||||
.buildRoundRect(text, mGenerator.getColor(text), toPx(10));
|
||||
}
|
||||
|
||||
public TextDrawable getRectWithMultiLetter() {
|
||||
String text = "AK";
|
||||
return TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.fontSize(toPx(20))
|
||||
.toUpperCase()
|
||||
.endConfig()
|
||||
.buildRect(text, mGenerator.getColor(text));
|
||||
}
|
||||
|
||||
public TextDrawable getRoundWithCustomFont() {
|
||||
String text = "Bold";
|
||||
return TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.fontSize(toPx(15))
|
||||
.textColor(0xfff58559)
|
||||
.bold()
|
||||
.endConfig()
|
||||
.buildRect(text, Color.DKGRAY /*toPx(5)*/);
|
||||
}
|
||||
|
||||
public Drawable getRectWithCustomSize() {
|
||||
String leftText = "I";
|
||||
String rightText = "J";
|
||||
|
||||
TextDrawable.IBuilder builder = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.width(toPx(29))
|
||||
.withBorder(toPx(2))
|
||||
.endConfig()
|
||||
.rect();
|
||||
|
||||
TextDrawable left = builder
|
||||
.build(leftText, mGenerator.getColor(leftText));
|
||||
|
||||
TextDrawable right = builder
|
||||
.build(rightText, mGenerator.getColor(rightText));
|
||||
|
||||
Drawable[] layerList = {
|
||||
new InsetDrawable(left, 0, 0, toPx(31), 0),
|
||||
new InsetDrawable(right, toPx(31), 0, 0, 0)
|
||||
};
|
||||
return new LayerDrawable(layerList);
|
||||
}
|
||||
|
||||
public Drawable getRectWithAnimation() {
|
||||
TextDrawable.IBuilder builder = TextDrawable.builder()
|
||||
.rect();
|
||||
|
||||
AnimationDrawable animationDrawable = new AnimationDrawable();
|
||||
for (int i = 10; i > 0; i--) {
|
||||
TextDrawable frame = builder.build(String.valueOf(i), mGenerator.getRandomColor());
|
||||
animationDrawable.addFrame(frame, 1200);
|
||||
}
|
||||
animationDrawable.setOneShot(false);
|
||||
animationDrawable.start();
|
||||
|
||||
return animationDrawable;
|
||||
}
|
||||
|
||||
public int toPx(int dp) {
|
||||
Resources resources = mContext.getResources();
|
||||
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 980 B |
|
After Width: | Height: | Size: 585 B |
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 688 B |
|
After Width: | Height: | Size: 942 B |
|
After Width: | Height: | Size: 427 B |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 727 B |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 1021 B |
|
After Width: | Height: | Size: 19 KiB |
@@ -0,0 +1,16 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="com.amulyakhare.td.sample.ListActivity">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/imageButton"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,8 @@
|
||||
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/listView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.amulyakhare.td.sample.MiscActivity">
|
||||
|
||||
</ListView>
|
||||
@@ -0,0 +1,8 @@
|
||||
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/listView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.amulyakhare.td.sample.MiscActivity">
|
||||
|
||||
</ListView>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:padding="16dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:id="@+id/imageView"/>
|
||||
|
||||
<ImageView
|
||||
android:visibility="gone"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:src="@drawable/check_sm"
|
||||
android:id="@+id/check_icon"/>
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:id="@+id/textView"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.amulyakhare.td.sample.ListActivity" >
|
||||
<item android:id="@+id/action_settings"
|
||||
android:title="@string/action_settings"
|
||||
android:orderInCategory="100"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
9
OnTime_Driver_live/lib/TextDrawable/sample/src/main/res/menu/list.xml
Executable file
@@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.amulyakhare.td.sample.MiscActivity" >
|
||||
<item android:id="@+id/action_settings"
|
||||
android:title="@string/action_settings"
|
||||
android:orderInCategory="100"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
9
OnTime_Driver_live/lib/TextDrawable/sample/src/main/res/menu/main.xml
Executable file
@@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".MainActivity" >
|
||||
<item android:id="@+id/action_settings"
|
||||
android:title="@string/action_settings"
|
||||
android:orderInCategory="100"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
@@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
||||
@@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
||||
10
OnTime_Driver_live/lib/TextDrawable/sample/src/main/res/values/strings.xml
Executable file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">TextDrawable Sample</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="title_activity_list">TextDrawable Sample</string>
|
||||
<string name="title_activity_check_box">TextDrawable Sample</string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,8 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||