Skip to content

Commit

Permalink
Merge pull request #83 from CruGlobal/action-bar
Browse files Browse the repository at this point in the history
Account for action bar in layouts
  • Loading branch information
ryancarlson committed Feb 9, 2016
2 parents 01e9387 + 68d8917 commit 6ecca1b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/org/keynote/godtools/android/SnuffyPWActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Bundle;
Expand Down Expand Up @@ -119,7 +120,7 @@ protected void onCreate(Bundle savedInstanceState)
mConfigFileName = getIntent().getStringExtra("ConfigFileName");
mPackageStatus = getIntent().getStringExtra("Status"); // live = draft
mPageLeft = getIntent().getIntExtra("PageLeft", 0);
mPageTop = getIntent().getIntExtra("PageTop", 0);
mPageTop = actionBarHeightWithFallback();
mPageWidth = getIntent().getIntExtra("PageWidth", 320); // set defaults but they will not be used
mPageHeight = getIntent().getIntExtra("PageHeight", 480); // caller will always determine these and pass them in
Log.i("ScreenSize", "Left = " + mPageLeft + ", Top = " + mPageTop + ", Width = " + mPageWidth + ", Height = " + mPageHeight);
Expand Down Expand Up @@ -185,6 +186,19 @@ public void registrationFailed()
}
}

/*
* Falls back to the height passed in through the intent extra if no action bar is found.
*/
private int actionBarHeightWithFallback()
{
final TypedArray styledAttributes = getApplicationContext().getTheme().obtainStyledAttributes(
new int[] { android.R.attr.actionBarSize });
final int actionBarSize = (int) styledAttributes.getDimension(0, 0);

styledAttributes.recycle();
return actionBarSize != 0 ? actionBarSize : getIntent().getIntExtra("PageTop", 0);
}

private void handleLanguagesWithAlternateFonts()
{
if (LanguagesNotSupportedByDefaultFont.contains(mAppLanguage))
Expand Down

0 comments on commit 6ecca1b

Please sign in to comment.