Skip to content

Commit

Permalink
Fixed issue itzikBraun#11 NPE when not setting the typeface
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraun committed Sep 7, 2015
1 parent e3027c5 commit 1a74a1a
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 35 deletions.
53 changes: 53 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
12 changes: 3 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ def versionPatch = 2
def versionBuild = 2 // bump for dogfood builds, public betas, etc.

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
compileSdkVersion 23
buildToolsVersion "23.0.0"

defaultConfig {
applicationId "com.braunster.tutorialviewapp"
minSdkVersion 15
targetSdkVersion 22
targetSdkVersion 23

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand All @@ -32,12 +32,6 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':tutorial_view')


// App dependencies
compile 'com.android.support:support-annotations:22.1.0'

androidTestCompile 'com.android.support:support-annotations:22.1.0'

// Testing-only dependencies
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private TutorialBuilder getBasicBuilderForTest(View v){
.setInfoText("This is the explanation about the view.")
.setBackgroundColor(randomColor())
.setTutorialTextColor(Color.WHITE)
.setTutorialTextTypeFaceName("fonts/olivier.ttf")
.setTutorialTextTypeFaceName("fonts/roboto-light.ttf")
.setTutorialTextSize(30)
.setAnimationDuration(500);

Expand Down
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ allprojects {
repositories {
jcenter()
mavenCentral()

}
// Fix for a conflict with support library that included with espresso
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:23.0.0'
}
}

Expand Down
53 changes: 53 additions & 0 deletions tutorial_view/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
10 changes: 6 additions & 4 deletions tutorial_view/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ def versionBuild = 0 // bump for dogfood builds, public betas, etc.
version = "${versionMajor}.${versionMinor}.${versionPatch}"

android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
compileSdkVersion 23
buildToolsVersion "23.0.0"

defaultConfig {
minSdkVersion 15
targetSdkVersion 22
targetSdkVersion 23

versionCode versionMajor * 1000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
versionName version
Expand All @@ -29,6 +29,8 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:support-annotations:23.0.0'
}

apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
//apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
Expand Down Expand Up @@ -154,7 +156,7 @@ public AbstractTutorialView(Context context, AttributeSet attrs, int defStyleAtt
}

public interface TutorialClosedListener{
public void onClosed();
void onClosed();
}

public abstract void closeTutorial();
Expand Down Expand Up @@ -292,8 +294,8 @@ public void setTutorial(Tutorial tutorial, boolean show){
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);

if (isInEditMode())
return;
/*if (isInEditMode())
return;*/
/*
// No need to draw if does not have any view to surround,
// Or the view size is null (in case we do not use a view but only its coordinates).
Expand Down Expand Up @@ -342,21 +344,18 @@ protected void inflateTutorialInfo(){
// Inflating the "Got It" button.
mGotItButton = inflate(getContext(), R.layout.got_it_button_view, null);
((TextView) mGotItButton).setTextColor(mTutorial.getTutorialTextColor());
if (mTutorialTextTypeFace != null)
{
((TextView) mGotItButton).setTypeface(mTutorialTextTypeFace);
}


setTypeFaceOnTextView(((TextView) mGotItButton));

// Adding skip button if the tutorial is a part of a Walkthrough.
if (isWalkThrough())
{
// Inflating the "Skip" button.
mSkipButton = inflate(getContext(), R.layout.skip_button_view, null);
((TextView) mSkipButton).setTextColor(mTutorial.getTutorialTextColor());
if (mTutorialTextTypeFace != null)
{
((TextView) mSkipButton).setTypeface(mTutorialTextTypeFace);
}

setTypeFaceOnTextView(((TextView) mSkipButton));
}

// Inflating the Title for the tutorial if has any.
Expand All @@ -365,11 +364,8 @@ protected void inflateTutorialInfo(){
mTitleView = inflate(getContext(), R.layout.title_view, null);
((TextView) mTitleView).setTextColor(mTutorial.getTutorialTextColor());
((TextView) mTitleView).setText(mTutorial.getTitle());

if (mTutorialTextTypeFace != null)
{
((TextView) mTitleView).setTypeface(mTutorialTextTypeFace);
}

setTypeFaceOnTextView(((TextView) mTitleView));
}

mTutorialInfoView.post(tutorialInfoViewPost);
Expand Down Expand Up @@ -401,10 +397,7 @@ private void checkTutorialDefault(){

txtTutorial.setTextColor(mTutorial.getTutorialTextColor());

if (mTutorialTextTypeFace != null)
{
txtTutorial.setTypeface(mTutorialTextTypeFace);
}
setTypeFaceOnTextView((txtTutorial));
}
}

Expand Down Expand Up @@ -463,7 +456,10 @@ protected void dispatchTutorialClosed(){
* Initialize the type face object from the mTutorial object type face name.
***/
protected void initTypeFace (){
mTutorialTextTypeFace = Typeface.createFromAsset(getResources().getAssets(), mTutorial.getTutorialTextTypeFace());
if (!TextUtils.isEmpty(mTutorial.getTutorialTextTypeFace())){
mTutorialTextTypeFace =
Typeface.createFromAsset(getResources().getAssets(), mTutorial.getTutorialTextTypeFace());
}
}

protected void initActionBar(String title){
Expand Down Expand Up @@ -1015,4 +1011,10 @@ private void animate(){
animation.start();
}
};

private void setTypeFaceOnTextView(@NonNull TextView textView){
if (mTutorialTextTypeFace != null){
textView.setTypeface(mTutorialTextTypeFace);
}
}
}

0 comments on commit 1a74a1a

Please sign in to comment.