More links

Adobe Connect | Adobe Conect Custom Pods | AutoHotkey | Android | Arduino | Blog | COMM140Fractals | Grammar Checkers | Knots | a Million Dots |  Processing | RedBubble | Tutorials | Weather | World Time Meeting Planner |

Home >Tutorials > Android Apps

> Chauffeurs Name Board > Chauffeurs Name Board Version 4.0 (no ads - no permissions)

Chauffeurs Name Board Version 4.0

A simple app that allows Chauffeurs & Taxi drives to display the name of a passenger full screen on an Android phone or tablet.
I am selling it for AU 99c on Google Play.


ChauffeursNameBoard020.zip 3.7 Mb

ChauffeursNameBoard020.7z 2.1 Mb


While Version 4.0 is a significant improvement on version 1's manual approach to enlarging the text to fit the screen, I am now working on Version 4.0. The main difference between v2 and v3 is that the user will with luck be able to long press, and or fling on the enlarged text to open the editing screen. In v2 users have to open the menu and press a button to edit the text.

Unfortunately this improved user interface will probably require a total rewrite as I can not work out how to implement the long press and swipe with the BigButton approach to enlarging the text as provided by catchthecows/BigTextButton

Flash SMS Feature Graphic



package au.id.rupert.chauffeurs_name_board;

//Version 15
//Based on code from
//See also https://github.com/catchthecows/BigTextButton

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.widget.ImageButton;
import android.widget.Toast;

public class BigTextButton extends ImageButton {
String mText = "";
Paint mTextPaint;

int mViewWidth;
int mViewHeight;
int mTextBaseline;

public BigTextButton(Context context) {


public BigTextButton(Context context, AttributeSet attrs) {
super(context, attrs);


public BigTextButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);


* Dig out Attributes to find text setting
* This could be expanded to pull out settings for textColor, etc if desired
* @param attrs

private void parseAttrs(AttributeSet attrs) {
for (int i = 0; i < attrs.getAttributeCount(); i++) {
String s = attrs.getAttributeName(i);
if (s.equalsIgnoreCase("text")) {
mText = attrs.getAttributeValue(i);

public void setText(CharSequence text) {
mText = text.toString();
onSizeChanged(getWidth(), getHeight(), getWidth(), getHeight());

* initialize Paint for text, it will be modified when the view size is set
private void init() {
mTextPaint = new TextPaint();
// Set text colour to White

* set the scale of the text Paint objects so that the text will draw and
* take up the full screen width
void adjustTextScale() {
// do calculation with scale of 1.0 (no scale)
Rect bounds = new Rect();
// ask the paint for the bounding rect if it were to draw this
// text.
mTextPaint.getTextBounds(mText, 0, mText.length(), bounds);

// determine the width
int w = bounds.right - bounds.left;

// calculate the baseline to use so that the
// entire text is visible including the descenders
int text_h = bounds.bottom - bounds.top;
mTextBaseline = bounds.bottom + ((mViewHeight - text_h) / 2);

// determine how much to scale the width to fit the view
float xscale = ((float) (mViewWidth - getPaddingLeft() - getPaddingRight())) / w;

// set the scale for the text paint

* determine the proper text size to use to fill the full height
void adjustTextSize() {
if (mText.isEmpty()) {
Rect bounds = new Rect();
// ask the paint for the bounding rect if it were to draw this
// text
mTextPaint.getTextBounds(mText, 0, mText.length(), bounds);

// get the height that would have been produced
int h = bounds.bottom - bounds.top;

// make the text text up 70% of the height
float target = (float) mViewHeight * .7f;

// figure out what textSize setting would create that height
// of text
float size = ((target / h) * 100f);

// and set it into the paint

* When the view size is changed, recalculate the paint settings to have the
* text on the fill the view area
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);

// save view size
mViewWidth = w;
mViewHeight = h;

// first determine font point size
// then determine width scaling
// this is done in two steps in case the
// point size change affects the width boundary

protected void onDraw(Canvas canvas) {
// let the ImageButton paint background as normal

// draw the text
// position is centered on width
// and the baseline is calculated to be positioned from the
// view bottom
canvas.drawText(mText, mViewWidth / 2, mViewHeight - mTextBaseline,


public void update() {
// TODO Auto-generated method stub

// Redraws the screen with the new text