tweaked account selector ui
This commit is contained in:
parent
6c5fd5a2a1
commit
a4f3fd94f8
|
@ -1,7 +1,6 @@
|
||||||
package org.mariotaku.microblog.library.statusnet.api;
|
package org.mariotaku.microblog.library.statusnet.api;
|
||||||
|
|
||||||
import org.mariotaku.restfu.annotation.method.GET;
|
import org.mariotaku.restfu.annotation.method.GET;
|
||||||
import org.mariotaku.restfu.annotation.method.POST;
|
|
||||||
import org.mariotaku.restfu.annotation.param.Path;
|
import org.mariotaku.restfu.annotation.param.Path;
|
||||||
import org.mariotaku.restfu.annotation.param.Query;
|
import org.mariotaku.restfu.annotation.param.Query;
|
||||||
import org.mariotaku.microblog.library.statusnet.model.StatusNetConfig;
|
import org.mariotaku.microblog.library.statusnet.model.StatusNetConfig;
|
||||||
|
|
|
@ -22,7 +22,6 @@ package org.mariotaku.microblog.library.twitter.api;
|
||||||
import org.mariotaku.microblog.library.twitter.template.StatusAnnotationTemplate;
|
import org.mariotaku.microblog.library.twitter.template.StatusAnnotationTemplate;
|
||||||
import org.mariotaku.restfu.annotation.method.GET;
|
import org.mariotaku.restfu.annotation.method.GET;
|
||||||
import org.mariotaku.restfu.annotation.method.POST;
|
import org.mariotaku.restfu.annotation.method.POST;
|
||||||
import org.mariotaku.restfu.annotation.param.KeyValue;
|
|
||||||
import org.mariotaku.restfu.annotation.param.Param;
|
import org.mariotaku.restfu.annotation.param.Param;
|
||||||
import org.mariotaku.restfu.annotation.param.Queries;
|
import org.mariotaku.restfu.annotation.param.Queries;
|
||||||
import org.mariotaku.restfu.annotation.param.Query;
|
import org.mariotaku.restfu.annotation.param.Query;
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.mariotaku.microblog.library.twitter.api;
|
||||||
|
|
||||||
import org.mariotaku.microblog.library.twitter.template.StatusAnnotationTemplate;
|
import org.mariotaku.microblog.library.twitter.template.StatusAnnotationTemplate;
|
||||||
import org.mariotaku.restfu.annotation.method.GET;
|
import org.mariotaku.restfu.annotation.method.GET;
|
||||||
import org.mariotaku.restfu.annotation.param.KeyValue;
|
|
||||||
import org.mariotaku.restfu.annotation.param.Queries;
|
import org.mariotaku.restfu.annotation.param.Queries;
|
||||||
import org.mariotaku.restfu.annotation.param.Query;
|
import org.mariotaku.restfu.annotation.param.Query;
|
||||||
import org.mariotaku.microblog.library.MicroBlogException;
|
import org.mariotaku.microblog.library.MicroBlogException;
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.mariotaku.microblog.library.twitter.api;
|
||||||
|
|
||||||
import org.mariotaku.microblog.library.twitter.template.StatusAnnotationTemplate;
|
import org.mariotaku.microblog.library.twitter.template.StatusAnnotationTemplate;
|
||||||
import org.mariotaku.restfu.annotation.method.GET;
|
import org.mariotaku.restfu.annotation.method.GET;
|
||||||
import org.mariotaku.restfu.annotation.param.KeyValue;
|
|
||||||
import org.mariotaku.restfu.annotation.param.Path;
|
import org.mariotaku.restfu.annotation.param.Path;
|
||||||
import org.mariotaku.restfu.annotation.param.Queries;
|
import org.mariotaku.restfu.annotation.param.Queries;
|
||||||
import org.mariotaku.restfu.annotation.param.Query;
|
import org.mariotaku.restfu.annotation.param.Query;
|
||||||
|
|
|
@ -2,8 +2,6 @@ package org.mariotaku.twidere.annotation;
|
||||||
|
|
||||||
import android.support.annotation.StringDef;
|
import android.support.annotation.StringDef;
|
||||||
|
|
||||||
import org.mariotaku.twidere.model.ParcelableAccount;
|
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
@ -69,7 +70,7 @@ public class AlphaPatternDrawable extends Drawable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOpacity() {
|
public int getOpacity() {
|
||||||
return 0;
|
return PixelFormat.OPAQUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2012 Wireless Designs, LLC
|
* Copyright (c) 2012 Wireless Designs, LLC
|
||||||
*
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
* "Software"), to deal in the Software without restriction, including
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
@ -8,10 +8,10 @@
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
* the following conditions:
|
* the following conditions:
|
||||||
*
|
* <p>
|
||||||
* The above copyright notice and this permission notice shall be
|
* The above copyright notice and this permission notice shall be
|
||||||
* included in all copies or substantial portions of the Software.
|
* included in all copies or substantial portions of the Software.
|
||||||
*
|
* <p>
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
@ -32,6 +32,7 @@ import android.graphics.Color;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
@ -45,9 +46,9 @@ import android.util.TypedValue;
|
||||||
* A Drawable object that draws text. A TextDrawable accepts most of the same
|
* A Drawable object that draws text. A TextDrawable accepts most of the same
|
||||||
* parameters that can be applied to {@link android.widget.TextView} for
|
* parameters that can be applied to {@link android.widget.TextView} for
|
||||||
* displaying and formatting text.
|
* displaying and formatting text.
|
||||||
*
|
*
|
||||||
* Optionally, a {@link Path} may be supplied on which to draw the text.
|
* Optionally, a {@link Path} may be supplied on which to draw the text.
|
||||||
*
|
*
|
||||||
* A TextDrawable has an intrinsic size equal to that required to draw all the
|
* A TextDrawable has an intrinsic size equal to that required to draw all the
|
||||||
* text it has been supplied, when possible. In cases where a {@link Path} has
|
* text it has been supplied, when possible. In cases where a {@link Path} has
|
||||||
* been supplied, the caller must explicitly call
|
* been supplied, the caller must explicitly call
|
||||||
|
@ -56,395 +57,395 @@ import android.util.TypedValue;
|
||||||
*/
|
*/
|
||||||
public class TextDrawable extends Drawable {
|
public class TextDrawable extends Drawable {
|
||||||
|
|
||||||
/* Platform XML constants for typeface */
|
/* Platform XML constants for typeface */
|
||||||
private static final int SANS = 1;
|
private static final int SANS = 1;
|
||||||
private static final int SERIF = 2;
|
private static final int SERIF = 2;
|
||||||
private static final int MONOSPACE = 3;
|
private static final int MONOSPACE = 3;
|
||||||
|
|
||||||
/* Resources for scaling values to the given device */
|
/* Resources for scaling values to the given device */
|
||||||
private final Resources mResources;
|
private final Resources mResources;
|
||||||
/* Paint to hold most drawing primitives for the text */
|
/* Paint to hold most drawing primitives for the text */
|
||||||
private final TextPaint mTextPaint;
|
private final TextPaint mTextPaint;
|
||||||
/* Layout is used to measure and draw the text */
|
/* Layout is used to measure and draw the text */
|
||||||
private StaticLayout mTextLayout;
|
private StaticLayout mTextLayout;
|
||||||
/* Alignment of the text inside its bounds */
|
/* Alignment of the text inside its bounds */
|
||||||
private Layout.Alignment mTextAlignment = Layout.Alignment.ALIGN_NORMAL;
|
private Layout.Alignment mTextAlignment = Layout.Alignment.ALIGN_NORMAL;
|
||||||
/* Optional path on which to draw the text */
|
/* Optional path on which to draw the text */
|
||||||
private Path mTextPath;
|
private Path mTextPath;
|
||||||
/* Stateful text color list */
|
/* Stateful text color list */
|
||||||
private ColorStateList mTextColors;
|
private ColorStateList mTextColors;
|
||||||
/* Container for the bounds to be reported to widgets */
|
/* Container for the bounds to be reported to widgets */
|
||||||
private final Rect mTextBounds;
|
private final Rect mTextBounds;
|
||||||
/* Text string to draw */
|
/* Text string to draw */
|
||||||
private CharSequence mText = "";
|
private CharSequence mText = "";
|
||||||
|
|
||||||
/* Attribute lists to pull default values from the current theme */
|
/* Attribute lists to pull default values from the current theme */
|
||||||
private static final int[] themeAttributes = { android.R.attr.textAppearance };
|
private static final int[] themeAttributes = {android.R.attr.textAppearance};
|
||||||
private static final int[] appearanceAttributes = { android.R.attr.textSize, android.R.attr.typeface,
|
private static final int[] appearanceAttributes = {android.R.attr.textSize, android.R.attr.typeface,
|
||||||
android.R.attr.textStyle, android.R.attr.textColor };
|
android.R.attr.textStyle, android.R.attr.textColor};
|
||||||
|
|
||||||
public TextDrawable(final Context context) {
|
public TextDrawable(final Context context) {
|
||||||
super();
|
super();
|
||||||
// Used to load and scale resource items
|
// Used to load and scale resource items
|
||||||
mResources = context.getResources();
|
mResources = context.getResources();
|
||||||
// Definition of this drawables size
|
// Definition of this drawables size
|
||||||
mTextBounds = new Rect();
|
mTextBounds = new Rect();
|
||||||
// Paint to use for the text
|
// Paint to use for the text
|
||||||
mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||||
mTextPaint.density = mResources.getDisplayMetrics().density;
|
mTextPaint.density = mResources.getDisplayMetrics().density;
|
||||||
mTextPaint.setDither(true);
|
mTextPaint.setDither(true);
|
||||||
|
|
||||||
int textSize = 15;
|
int textSize = 15;
|
||||||
ColorStateList textColor = null;
|
ColorStateList textColor = null;
|
||||||
int styleIndex = -1;
|
int styleIndex = -1;
|
||||||
int typefaceIndex = -1;
|
int typefaceIndex = -1;
|
||||||
|
|
||||||
// Set default parameters from the current theme
|
// Set default parameters from the current theme
|
||||||
final TypedArray a = context.getTheme().obtainStyledAttributes(themeAttributes);
|
final TypedArray a = context.getTheme().obtainStyledAttributes(themeAttributes);
|
||||||
final int appearanceId = a.getResourceId(0, -1);
|
final int appearanceId = a.getResourceId(0, -1);
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
TypedArray ap = null;
|
TypedArray ap = null;
|
||||||
if (appearanceId != -1) {
|
if (appearanceId != -1) {
|
||||||
ap = context.obtainStyledAttributes(appearanceId, appearanceAttributes);
|
ap = context.obtainStyledAttributes(appearanceId, appearanceAttributes);
|
||||||
}
|
}
|
||||||
if (ap != null) {
|
if (ap != null) {
|
||||||
for (int i = 0; i < ap.getIndexCount(); i++) {
|
for (int i = 0; i < ap.getIndexCount(); i++) {
|
||||||
final int attr = ap.getIndex(i);
|
final int attr = ap.getIndex(i);
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
case 0: // Text Size
|
case 0: // Text Size
|
||||||
textSize = a.getDimensionPixelSize(attr, textSize);
|
textSize = a.getDimensionPixelSize(attr, textSize);
|
||||||
break;
|
break;
|
||||||
case 1: // Typeface
|
case 1: // Typeface
|
||||||
typefaceIndex = a.getInt(attr, typefaceIndex);
|
typefaceIndex = a.getInt(attr, typefaceIndex);
|
||||||
break;
|
break;
|
||||||
case 2: // Text Style
|
case 2: // Text Style
|
||||||
styleIndex = a.getInt(attr, styleIndex);
|
styleIndex = a.getInt(attr, styleIndex);
|
||||||
break;
|
break;
|
||||||
case 3: // Text Color
|
case 3: // Text Color
|
||||||
textColor = a.getColorStateList(attr);
|
textColor = a.getColorStateList(attr);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ap.recycle();
|
ap.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
setTextColor(textColor != null ? textColor : ColorStateList.valueOf(0xFF000000));
|
setTextColor(textColor != null ? textColor : ColorStateList.valueOf(0xFF000000));
|
||||||
setRawTextSize(textSize);
|
setRawTextSize(textSize);
|
||||||
|
|
||||||
Typeface tf = null;
|
Typeface tf = null;
|
||||||
switch (typefaceIndex) {
|
switch (typefaceIndex) {
|
||||||
case SANS:
|
case SANS:
|
||||||
tf = Typeface.SANS_SERIF;
|
tf = Typeface.SANS_SERIF;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SERIF:
|
case SERIF:
|
||||||
tf = Typeface.SERIF;
|
tf = Typeface.SERIF;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MONOSPACE:
|
case MONOSPACE:
|
||||||
tf = Typeface.MONOSPACE;
|
tf = Typeface.MONOSPACE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTypeface(tf, styleIndex);
|
setTypeface(tf, styleIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(@NonNull final Canvas canvas) {
|
public void draw(@NonNull final Canvas canvas) {
|
||||||
if (mTextPath == null) {
|
if (mTextPath == null) {
|
||||||
// Allow the layout to draw the text
|
// Allow the layout to draw the text
|
||||||
mTextLayout.draw(canvas);
|
mTextLayout.draw(canvas);
|
||||||
} else {
|
} else {
|
||||||
// Draw directly on the canvas using the supplied path
|
// Draw directly on the canvas using the supplied path
|
||||||
canvas.drawTextOnPath(mText.toString(), mTextPath, 0, 0, mTextPaint);
|
canvas.drawTextOnPath(mText.toString(), mTextPath, 0, 0, mTextPaint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIntrinsicHeight() {
|
public int getIntrinsicHeight() {
|
||||||
// Return the vertical bounds measured, or -1 if none
|
// Return the vertical bounds measured, or -1 if none
|
||||||
if (mTextBounds.isEmpty())
|
if (mTextBounds.isEmpty())
|
||||||
return -1;
|
return -1;
|
||||||
else
|
else
|
||||||
return mTextBounds.bottom - mTextBounds.top;
|
return mTextBounds.bottom - mTextBounds.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIntrinsicWidth() {
|
public int getIntrinsicWidth() {
|
||||||
// Return the horizontal bounds measured, or -1 if none
|
// Return the horizontal bounds measured, or -1 if none
|
||||||
if (mTextBounds.isEmpty())
|
if (mTextBounds.isEmpty())
|
||||||
return -1;
|
return -1;
|
||||||
else
|
else
|
||||||
return mTextBounds.right - mTextBounds.left;
|
return mTextBounds.right - mTextBounds.left;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOpacity() {
|
public int getOpacity() {
|
||||||
return mTextPaint.getAlpha();
|
return PixelFormat.TRANSLUCENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the text currently being displayed
|
* Return the text currently being displayed
|
||||||
*/
|
*/
|
||||||
public CharSequence getText() {
|
public CharSequence getText() {
|
||||||
return mText;
|
return mText;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current text alignment setting
|
* Return the current text alignment setting
|
||||||
*/
|
*/
|
||||||
public Layout.Alignment getTextAlign() {
|
public Layout.Alignment getTextAlign() {
|
||||||
return mTextAlignment;
|
return mTextAlignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the horizontal stretch factor of the text
|
* Return the horizontal stretch factor of the text
|
||||||
*/
|
*/
|
||||||
public float getTextScaleX() {
|
public float getTextScaleX() {
|
||||||
return mTextPaint.getTextScaleX();
|
return mTextPaint.getTextScaleX();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current text size, in pixels
|
* Return the current text size, in pixels
|
||||||
*/
|
*/
|
||||||
public float getTextSize() {
|
public float getTextSize() {
|
||||||
return mTextPaint.getTextSize();
|
return mTextPaint.getTextSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current typeface and style that the Paint using for display.
|
* Return the current typeface and style that the Paint using for display.
|
||||||
*/
|
*/
|
||||||
public Typeface getTypeface() {
|
public Typeface getTypeface() {
|
||||||
return mTextPaint.getTypeface();
|
return mTextPaint.getTypeface();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isStateful() {
|
public boolean isStateful() {
|
||||||
/*
|
/*
|
||||||
* The drawable's ability to represent state is based on the text color
|
* The drawable's ability to represent state is based on the text color
|
||||||
* list set
|
* list set
|
||||||
*/
|
*/
|
||||||
return mTextColors.isStateful();
|
return mTextColors.isStateful();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAlpha(final int alpha) {
|
public void setAlpha(final int alpha) {
|
||||||
if (mTextPaint.getAlpha() != alpha) {
|
if (mTextPaint.getAlpha() != alpha) {
|
||||||
mTextPaint.setAlpha(alpha);
|
mTextPaint.setAlpha(alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setColorFilter(final ColorFilter cf) {
|
public void setColorFilter(final ColorFilter cf) {
|
||||||
if (mTextPaint.getColorFilter() != cf) {
|
if (mTextPaint.getColorFilter() != cf) {
|
||||||
mTextPaint.setColorFilter(cf);
|
mTextPaint.setColorFilter(cf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the text that will be displayed
|
* Set the text that will be displayed
|
||||||
*
|
*
|
||||||
* @param text Text to display
|
* @param text Text to display
|
||||||
*/
|
*/
|
||||||
public void setText(CharSequence text) {
|
public void setText(CharSequence text) {
|
||||||
if (text == null) {
|
if (text == null) {
|
||||||
text = "";
|
text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
mText = text;
|
mText = text;
|
||||||
|
|
||||||
measureContent();
|
measureContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the text alignment. The alignment itself is based on the text layout
|
* Set the text alignment. The alignment itself is based on the text layout
|
||||||
* direction. For LTR text NORMAL is left aligned and OPPOSITE is right
|
* direction. For LTR text NORMAL is left aligned and OPPOSITE is right
|
||||||
* aligned. For RTL text, those alignments are reversed.
|
* aligned. For RTL text, those alignments are reversed.
|
||||||
*
|
*
|
||||||
* @param align Text alignment value. Should be set to one of:
|
* @param align Text alignment value. Should be set to one of:
|
||||||
*
|
*
|
||||||
* {@link Layout.Alignment#ALIGN_NORMAL},
|
* {@link Layout.Alignment#ALIGN_NORMAL},
|
||||||
* {@link Layout.Alignment#ALIGN_NORMAL},
|
* {@link Layout.Alignment#ALIGN_NORMAL},
|
||||||
* {@link Layout.Alignment#ALIGN_OPPOSITE}.
|
* {@link Layout.Alignment#ALIGN_OPPOSITE}.
|
||||||
*/
|
*/
|
||||||
public void setTextAlign(final Layout.Alignment align) {
|
public void setTextAlign(final Layout.Alignment align) {
|
||||||
if (mTextAlignment != align) {
|
if (mTextAlignment != align) {
|
||||||
mTextAlignment = align;
|
mTextAlignment = align;
|
||||||
measureContent();
|
measureContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the text color as a state list
|
* Set the text color as a state list
|
||||||
*
|
*
|
||||||
* @param colorStateList ColorStateList of text colors, such as inflated
|
* @param colorStateList ColorStateList of text colors, such as inflated
|
||||||
* from an R.color resource
|
* from an R.color resource
|
||||||
*/
|
*/
|
||||||
public void setTextColor(final ColorStateList colorStateList) {
|
public void setTextColor(final ColorStateList colorStateList) {
|
||||||
mTextColors = colorStateList;
|
mTextColors = colorStateList;
|
||||||
updateTextColors(getState());
|
updateTextColors(getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a single text color for all states
|
* Set a single text color for all states
|
||||||
*
|
*
|
||||||
* @param color Color value such as {@link Color#WHITE} or
|
* @param color Color value such as {@link Color#WHITE} or
|
||||||
* {@link Color#argb(int, int, int, int)}
|
* {@link Color#argb(int, int, int, int)}
|
||||||
*/
|
*/
|
||||||
public void setTextColor(final int color) {
|
public void setTextColor(final int color) {
|
||||||
setTextColor(ColorStateList.valueOf(color));
|
setTextColor(ColorStateList.valueOf(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional Path object on which to draw the text. If this is set,
|
* Optional Path object on which to draw the text. If this is set,
|
||||||
* TextDrawable cannot properly measure the bounds this drawable will need.
|
* TextDrawable cannot properly measure the bounds this drawable will need.
|
||||||
* You must call {@link #setBounds(int, int, int, int) setBounds()} before
|
* You must call {@link #setBounds(int, int, int, int) setBounds()} before
|
||||||
* applying this TextDrawable to any View.
|
* applying this TextDrawable to any View.
|
||||||
*
|
*
|
||||||
* Calling this method with <code>null</code> will remove any Path currently
|
* Calling this method with <code>null</code> will remove any Path currently
|
||||||
* attached.
|
* attached.
|
||||||
*/
|
*/
|
||||||
public void setTextPath(final Path path) {
|
public void setTextPath(final Path path) {
|
||||||
if (mTextPath != path) {
|
if (mTextPath != path) {
|
||||||
mTextPath = path;
|
mTextPath = path;
|
||||||
measureContent();
|
measureContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the horizontal stretch factor of the text
|
* Set the horizontal stretch factor of the text
|
||||||
*
|
*
|
||||||
* @param size Text scale factor
|
* @param size Text scale factor
|
||||||
*/
|
*/
|
||||||
public void setTextScaleX(final float size) {
|
public void setTextScaleX(final float size) {
|
||||||
if (size != mTextPaint.getTextScaleX()) {
|
if (size != mTextPaint.getTextScaleX()) {
|
||||||
mTextPaint.setTextScaleX(size);
|
mTextPaint.setTextScaleX(size);
|
||||||
measureContent();
|
measureContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the text size. The value will be interpreted in "sp" units
|
* Set the text size. The value will be interpreted in "sp" units
|
||||||
*
|
*
|
||||||
* @param size Text size value, in sp
|
* @param size Text size value, in sp
|
||||||
*/
|
*/
|
||||||
public void setTextSize(final float size) {
|
public void setTextSize(final float size) {
|
||||||
setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
|
setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the text size, using the supplied complex units
|
* Set the text size, using the supplied complex units
|
||||||
*
|
*
|
||||||
* @param unit Units for the text size, such as dp or sp
|
* @param unit Units for the text size, such as dp or sp
|
||||||
* @param size Text size value
|
* @param size Text size value
|
||||||
*/
|
*/
|
||||||
public void setTextSize(final int unit, final float size) {
|
public void setTextSize(final int unit, final float size) {
|
||||||
final float dimension = TypedValue.applyDimension(unit, size, mResources.getDisplayMetrics());
|
final float dimension = TypedValue.applyDimension(unit, size, mResources.getDisplayMetrics());
|
||||||
setRawTextSize(dimension);
|
setRawTextSize(dimension);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the typeface and style in which the text should be displayed. Note
|
* Sets the typeface and style in which the text should be displayed. Note
|
||||||
* that not all Typeface families actually have bold and italic variants, so
|
* that not all Typeface families actually have bold and italic variants, so
|
||||||
* you may need to use {@link #setTypeface(Typeface, int)} to get the
|
* you may need to use {@link #setTypeface(Typeface, int)} to get the
|
||||||
* appearance that you actually want.
|
* appearance that you actually want.
|
||||||
*/
|
*/
|
||||||
public void setTypeface(final Typeface tf) {
|
public void setTypeface(final Typeface tf) {
|
||||||
if (mTextPaint.getTypeface() != tf) {
|
if (mTextPaint.getTypeface() != tf) {
|
||||||
mTextPaint.setTypeface(tf);
|
mTextPaint.setTypeface(tf);
|
||||||
|
|
||||||
measureContent();
|
measureContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the typeface and style in which the text should be displayed, and
|
* Sets the typeface and style in which the text should be displayed, and
|
||||||
* turns on the fake bold and italic bits in the Paint if the Typeface that
|
* turns on the fake bold and italic bits in the Paint if the Typeface that
|
||||||
* you provided does not have all the bits in the style that you specified.
|
* you provided does not have all the bits in the style that you specified.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setTypeface(Typeface tf, final int style) {
|
public void setTypeface(Typeface tf, final int style) {
|
||||||
if (style > 0) {
|
if (style > 0) {
|
||||||
if (tf == null) {
|
if (tf == null) {
|
||||||
tf = Typeface.defaultFromStyle(style);
|
tf = Typeface.defaultFromStyle(style);
|
||||||
} else {
|
} else {
|
||||||
tf = Typeface.create(tf, style);
|
tf = Typeface.create(tf, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTypeface(tf);
|
setTypeface(tf);
|
||||||
// now compute what (if any) algorithmic styling is needed
|
// now compute what (if any) algorithmic styling is needed
|
||||||
final int typefaceStyle = tf != null ? tf.getStyle() : 0;
|
final int typefaceStyle = tf != null ? tf.getStyle() : 0;
|
||||||
final int need = style & ~typefaceStyle;
|
final int need = style & ~typefaceStyle;
|
||||||
mTextPaint.setFakeBoldText((need & Typeface.BOLD) != 0);
|
mTextPaint.setFakeBoldText((need & Typeface.BOLD) != 0);
|
||||||
mTextPaint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0);
|
mTextPaint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0);
|
||||||
} else {
|
} else {
|
||||||
mTextPaint.setFakeBoldText(false);
|
mTextPaint.setFakeBoldText(false);
|
||||||
mTextPaint.setTextSkewX(0);
|
mTextPaint.setTextSkewX(0);
|
||||||
setTypeface(tf);
|
setTypeface(tf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBoundsChange(final Rect bounds) {
|
protected void onBoundsChange(final Rect bounds) {
|
||||||
// Update the internal bounds in response to any external requests
|
// Update the internal bounds in response to any external requests
|
||||||
mTextBounds.set(bounds);
|
mTextBounds.set(bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onStateChange(final int[] state) {
|
protected boolean onStateChange(final int[] state) {
|
||||||
// Upon state changes, grab the correct text color
|
// Upon state changes, grab the correct text color
|
||||||
return updateTextColors(state);
|
return updateTextColors(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal method to take measurements of the current contents and apply
|
* Internal method to take measurements of the current contents and apply
|
||||||
* the correct bounds when possible.
|
* the correct bounds when possible.
|
||||||
*/
|
*/
|
||||||
private void measureContent() {
|
private void measureContent() {
|
||||||
// If drawing to a path, we cannot measure intrinsic bounds
|
// If drawing to a path, we cannot measure intrinsic bounds
|
||||||
// We must resly on setBounds being called externally
|
// We must resly on setBounds being called externally
|
||||||
if (mTextPath != null) {
|
if (mTextPath != null) {
|
||||||
// Clear any previous measurement
|
// Clear any previous measurement
|
||||||
mTextLayout = null;
|
mTextLayout = null;
|
||||||
mTextBounds.setEmpty();
|
mTextBounds.setEmpty();
|
||||||
} else {
|
} else {
|
||||||
// Measure text bounds
|
// Measure text bounds
|
||||||
final float desired = Layout.getDesiredWidth(mText, mTextPaint);
|
final float desired = Layout.getDesiredWidth(mText, mTextPaint);
|
||||||
mTextLayout = new StaticLayout(mText, mTextPaint, (int) desired, mTextAlignment, 1.0f, 0.0f, false);
|
mTextLayout = new StaticLayout(mText, mTextPaint, (int) desired, mTextAlignment, 1.0f, 0.0f, false);
|
||||||
mTextBounds.set(0, 0, mTextLayout.getWidth(), mTextLayout.getHeight());
|
mTextBounds.set(0, 0, mTextLayout.getWidth(), mTextLayout.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
// We may need to be redrawn
|
// We may need to be redrawn
|
||||||
invalidateSelf();
|
invalidateSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the text size, in raw pixels
|
* Set the text size, in raw pixels
|
||||||
*/
|
*/
|
||||||
private void setRawTextSize(final float size) {
|
private void setRawTextSize(final float size) {
|
||||||
if (size != mTextPaint.getTextSize()) {
|
if (size != mTextPaint.getTextSize()) {
|
||||||
mTextPaint.setTextSize(size);
|
mTextPaint.setTextSize(size);
|
||||||
|
|
||||||
measureContent();
|
measureContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal method to apply the correct text color based on the drawable's
|
* Internal method to apply the correct text color based on the drawable's
|
||||||
* state
|
* state
|
||||||
*/
|
*/
|
||||||
private boolean updateTextColors(final int[] stateSet) {
|
private boolean updateTextColors(final int[] stateSet) {
|
||||||
final int newColor = mTextColors.getColorForState(stateSet, Color.WHITE);
|
final int newColor = mTextColors.getColorForState(stateSet, Color.WHITE);
|
||||||
if (mTextPaint.getColor() != newColor) {
|
if (mTextPaint.getColor() != newColor) {
|
||||||
mTextPaint.setColor(newColor);
|
mTextPaint.setColor(newColor);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -28,7 +28,6 @@ import android.support.annotation.Nullable;
|
||||||
import android.support.v4.util.LruCache;
|
import android.support.v4.util.LruCache;
|
||||||
|
|
||||||
import org.mariotaku.microblog.library.twitter.model.User;
|
import org.mariotaku.microblog.library.twitter.model.User;
|
||||||
import org.mariotaku.twidere.TwidereConstants;
|
|
||||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||||
import org.mariotaku.twidere.model.ParcelableUser;
|
import org.mariotaku.twidere.model.ParcelableUser;
|
||||||
import org.mariotaku.twidere.model.ParcelableUserList;
|
import org.mariotaku.twidere.model.ParcelableUserList;
|
||||||
|
|
|
@ -24,7 +24,6 @@ import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.OnClickListener
|
|
||||||
import android.widget.AdapterView
|
import android.widget.AdapterView
|
||||||
import android.widget.AdapterView.OnItemClickListener
|
import android.widget.AdapterView.OnItemClickListener
|
||||||
import android.widget.ListView
|
import android.widget.ListView
|
||||||
|
@ -41,7 +40,7 @@ import org.mariotaku.twidere.model.UserKey
|
||||||
import org.mariotaku.twidere.model.util.AccountUtils
|
import org.mariotaku.twidere.model.util.AccountUtils
|
||||||
import org.mariotaku.twidere.util.DataStoreUtils
|
import org.mariotaku.twidere.util.DataStoreUtils
|
||||||
|
|
||||||
class AccountSelectorActivity : BaseActivity(), OnClickListener, OnItemClickListener {
|
class AccountSelectorActivity : BaseActivity(), OnItemClickListener {
|
||||||
|
|
||||||
private lateinit var adapter: AccountDetailsAdapter
|
private lateinit var adapter: AccountDetailsAdapter
|
||||||
|
|
||||||
|
@ -70,7 +69,7 @@ class AccountSelectorActivity : BaseActivity(), OnClickListener, OnItemClickList
|
||||||
|
|
||||||
private val isSingleSelection: Boolean
|
private val isSingleSelection: Boolean
|
||||||
get() {
|
get() {
|
||||||
return intent.getBooleanExtra(EXTRA_SINGLE_SELECTION, false)
|
return intent.getBooleanExtra(EXTRA_SINGLE_SELECTION, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,21 +121,16 @@ class AccountSelectorActivity : BaseActivity(), OnClickListener, OnItemClickList
|
||||||
if (adapter.count == 1 && isSelectOnlyItemAutomatically) {
|
if (adapter.count == 1 && isSelectOnlyItemAutomatically) {
|
||||||
selectSingleAccount(0)
|
selectSingleAccount(0)
|
||||||
}
|
}
|
||||||
}
|
confirmSelection.setOnClickListener {
|
||||||
|
val checkedIds = accountsList.checkedItemIds
|
||||||
override fun onClick(view: View) {
|
if (checkedIds.isEmpty() && !isSelectNoneAllowed) {
|
||||||
when (view.id) {
|
Toast.makeText(this, R.string.message_toast_no_account_selected, Toast.LENGTH_SHORT).show()
|
||||||
R.id.save -> {
|
return@setOnClickListener
|
||||||
val checkedIds = accountsList.checkedItemIds
|
|
||||||
if (checkedIds.isEmpty() && !isSelectNoneAllowed) {
|
|
||||||
Toast.makeText(this, R.string.message_toast_no_account_selected, Toast.LENGTH_SHORT).show()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val data = Intent()
|
|
||||||
data.putExtra(EXTRA_IDS, checkedIds)
|
|
||||||
setResult(Activity.RESULT_OK, data)
|
|
||||||
finish()
|
|
||||||
}
|
}
|
||||||
|
val data = Intent()
|
||||||
|
data.putExtra(EXTRA_IDS, checkedIds)
|
||||||
|
setResult(Activity.RESULT_OK, data)
|
||||||
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +138,7 @@ class AccountSelectorActivity : BaseActivity(), OnClickListener, OnItemClickList
|
||||||
selectSingleAccount(position)
|
selectSingleAccount(position)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun selectSingleAccount(position: Int) {
|
private fun selectSingleAccount(position: Int) {
|
||||||
val account = adapter.getItem(position)
|
val account = adapter.getItem(position)
|
||||||
val data = Intent()
|
val data = Intent()
|
||||||
data.putExtra(EXTRA_ID, account.key.id)
|
data.putExtra(EXTRA_ID, account.key.id)
|
||||||
|
|
|
@ -36,19 +36,19 @@
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/selectAccountButtons"
|
android:id="@+id/selectAccountButtons"
|
||||||
style="?android:buttonBarStyle"
|
style="?attr/buttonBarStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/element_spacing_normal"
|
||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
|
android:gravity="center_vertical|end"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/confirmSelection"
|
android:id="@+id/confirmSelection"
|
||||||
style="?android:borderlessButtonStyle"
|
style="?attr/buttonBarPositiveButtonStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
|
||||||
android:onClick="onClick"
|
|
||||||
android:text="@android:string/ok"/>
|
android:text="@android:string/ok"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue