diff --git a/CalligraphySample/src/main/java/uk/co/chrisjenx/calligraphy/sample/PlaceholderFragment.java b/CalligraphySample/src/main/java/uk/co/chrisjenx/calligraphy/sample/PlaceholderFragment.java index 0404877..0b5cad1 100644 --- a/CalligraphySample/src/main/java/uk/co/chrisjenx/calligraphy/sample/PlaceholderFragment.java +++ b/CalligraphySample/src/main/java/uk/co/chrisjenx/calligraphy/sample/PlaceholderFragment.java @@ -1,6 +1,7 @@ package uk.co.chrisjenx.calligraphy.sample; import android.app.AlertDialog; +import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -12,6 +13,8 @@ import butterknife.ButterKnife; import butterknife.OnClick; +import uk.co.chrisjenx.calligraphy.CalligraphyConfig; +import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper; /** * A placeholder fragment containing a simple view. @@ -57,4 +60,19 @@ public void onClick(DialogInterface dialog, int which) { }); builder.create().show(); } + + @OnClick(R.id.button_non_default_config) + public void onClickNonDefaultConfig() { + final Context calligraphyContext = + CalligraphyContextWrapper.wrap(getActivity(), new CalligraphyConfig.Builder() + .setDefaultFontPath("fonts/Oswald-Stencbab.ttf") + .setFontAttrId(R.attr.fontPath) + .addCustomViewWithSetTypeface(CustomViewWithTypefaceSupport.class) + .addCustomStyle(TextField.class, R.attr.textFieldStyle) + .build()); + new android.support.v7.app.AlertDialog.Builder(calligraphyContext) + .setTitle(R.string.dialog_non_default_config_title) + .setView(R.layout.dialog_non_default_config) + .show(); + } } diff --git a/CalligraphySample/src/main/res/layout/dialog_non_default_config.xml b/CalligraphySample/src/main/res/layout/dialog_non_default_config.xml new file mode 100644 index 0000000..942ad58 --- /dev/null +++ b/CalligraphySample/src/main/res/layout/dialog_non_default_config.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CalligraphySample/src/main/res/layout/fragment_main.xml b/CalligraphySample/src/main/res/layout/fragment_main.xml index 7dff524..8e4ad8b 100644 --- a/CalligraphySample/src/main/res/layout/fragment_main.xml +++ b/CalligraphySample/src/main/res/layout/fragment_main.xml @@ -128,5 +128,14 @@ android:layout_marginTop="12dp" android:text="@string/button_defined"/> +