-
Notifications
You must be signed in to change notification settings - Fork 56
RoboDemo Starter Guide
stephanenicolas edited this page Sep 27, 2012
·
2 revisions
There are 3 steps to follow to add RoboDemo into your project :
- Create a RoboDemo sublcass like this, providing a
DrawViewAdapter
public class MainActivityDemoActivity extends DemoActivity {
private static final int DEFAULT_FONT_SIZE = 22;
@Override
public DrawViewAdapter getDrawViewAdapter() {
Drawable drawable = getResources().getDrawable( R.drawable.ic_lockscreen_handle_pressed );
TextPaint textPaint = new TextPaint();
textPaint.setColor( getResources().getColor( android.R.color.white ) );
textPaint.setShadowLayer( 2.0f, 0, 2.0f, getResources().getColor( android.R.color.black ) );
textPaint.setAntiAlias( true );
// http://stackoverflow.com/questions/3061930/how-to-set-unit-for-paint-settextsize
textPaint.setTextSize( TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, DEFAULT_FONT_SIZE, getResources().getDisplayMetrics() ) );
return new DefaultDrawViewAdapter( this, drawable, textPaint, getListPoints() );
}
}
- Add this activity to your AndroidManifest, using a predefined theme :
<activity
android:noHistory="true"
android:configChanges="orientation|screenSize"
android:name=".MainActivityDemoActivity"
android:theme="@style/Theme.RoboDemo" />
- In your Activity under showcase, prepare to start your
DemoActivity
, passing it all the points and texts you want to include in the showcase :
private void displayDemoIfNeeded() {
boolean neverShowDemoAgain = RoboDemo.isNeverShowAgain( this, DEMO_ACTIVITY_ID );
if ( !neverShowDemoAgain && showDemo ) {
showDemo = false;
ArrayList< LabeledPoint > arrayListPoints = new ArrayList< LabeledPoint >();
// create a list of LabeledPoints
LabeledPoint p = new LabeledPoint( clearButton, getString( R.string.text_move_demo_step_1 ) );
arrayListPoints.add( p );
p = new LabeledPoint( this, 0.95f, 0.05f, getString( R.string.text_move_demo_step_2 ) );
arrayListPoints.add( p );
// start DemoActivity.
Intent intent = new Intent( this, MainActivityDemoActivity.class );
RoboDemo.prepareDemoActivityIntent( intent, DEMO_ACTIVITY_ID, arrayListPoints );
startActivity( intent );
}
}
RoboDemo can be customized in quite a number of ways :
- using a custom drawable via the DefaultDrawViewAdapter
- using transparency or not to highlight the areas to click on, by subclassing DrawView
- using custom
Paint
to render text, and the grey area under texts, via the DefaultDrawViewAdapter - using custom drawable and text locations, by subclassing DrawViewAdapter
- and some more for sure...
To learn more, browse RoboDemo Javadocs online.