Permalink
Browse files

Use Alegreya Sans SC:700 for the title

  • Loading branch information...
rsheeter committed Aug 22, 2017
1 parent f1c997b commit ac55478ea9dabd1d63480a4b4a6dd4bbba001764
@@ -34,9 +34,13 @@
import android.net.NetworkInfo;
import android.net.NetworkRequest;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.provider.FontRequest;
import android.support.v4.provider.FontsContractCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.widget.GridLayoutManager;
@@ -50,6 +54,7 @@
import android.text.style.ImageSpan;
import android.text.style.StyleSpan;
import android.transition.TransitionManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
@@ -97,6 +102,8 @@
public class HomeActivity extends Activity {
private static final String TAG = "PlaidHomeActivity";
private static final int RC_SEARCH = 0;
private static final int RC_AUTH_DRIBBBLE_FOLLOWING = 1;
private static final int RC_AUTH_DRIBBBLE_USER_LIKES = 2;
@@ -125,6 +132,9 @@
private DesignerNewsPrefs designerNewsPrefs;
private DribbblePrefs dribbblePrefs;
// We'll need a thread to wait
private Handler fontHandler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -141,6 +151,26 @@ protected void onCreate(Bundle savedInstanceState) {
}
setExitSharedElementCallback(FeedAdapter.createSharedElementReenterCallback(this));
FontRequest fontRequest = new FontRequest("com.google.android.gms.fonts",
"com.google.android.gms",
"name=Alegreya Sans SC&weight=700",
R.array.com_google_android_gms_fonts_certs);
FontsContractCompat.FontRequestCallback toolbarFontCallback =
new FontsContractCompat.FontRequestCallback() {
@Override public void onTypefaceRetrieved(Typeface typeface) {
// If we got our font apply it to the toolbar
styleToolbar(typeface);
}
@Override public void onTypefaceRequestFailed(int reason) {
Log.w(TAG, "Failed to fetch Toolbar font: " + reason);
}
};
// Start async fetch on the handler thread
FontsContractCompat.requestFont(this, fontRequest, toolbarFontCallback,
getFontHandlerThread());
dribbblePrefs = DribbblePrefs.get(this);
designerNewsPrefs = DesignerNewsPrefs.get(this);
filtersAdapter = new FilterAdapter(this, SourceManager.getSources(this),
@@ -247,6 +277,8 @@ public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
});
setupTaskDescription();
filtersList.setAdapter(filtersAdapter);
filtersList.setItemAnimator(new FilterAdapter.FilterAnimator());
filtersAdapter.registerFilterChangedCallback(filtersChangedCallbacks);
@@ -695,6 +727,28 @@ private void setupTaskDescription() {
overviewIcon.recycle();
}
private void styleToolbar(Typeface typeface) {
// this is gross but toolbar doesn't expose it's children
for (int i = 0; i < toolbar.getChildCount(); i++) {
View rawView = toolbar.getChildAt(i);
if (!(rawView instanceof TextView)) {
continue;
}
TextView textView = (TextView) rawView;
textView.setTypeface(typeface);
}
}
private Handler getFontHandlerThread() {
if (fontHandler == null) {
HandlerThread handlerThread = new HandlerThread("fonts");
handlerThread.start();
fontHandler = new Handler(handlerThread.getLooper());
}
return fontHandler;
}
private void animateToolbar() {
// this is gross but toolbar doesn't expose it's children to animate them :(
View t = toolbar.getChildAt(0);
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="name=Alegreya Sans SC&amp;weight=700"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs"
app:fontProviderFetchStrategy="blocking">
</font-family>
@@ -3,5 +3,6 @@
<array name="preloaded_fonts" translatable="false">
<item>@font/alegreya</item>
<item>@font/alegreya_black</item>
<item>@font/alegreya_sans_sc_bold</item>
</array>
</resources>
@@ -170,6 +170,7 @@
<item name="android:background">@null</item>
<item name="android:elevation">0dp</item>
<item name="android:theme">@android:style/ThemeOverlay.Material.Dark</item>
</style>
<style name="Widget.Plaid.OverlayToolbar" parent="android:Widget.Material.ActionBar">

0 comments on commit ac55478

Please sign in to comment.