Skip to content

Commit

Permalink
Adjusted notifier font size for pre-Gingerbread systems. Font was too
Browse files Browse the repository at this point in the history
large.

Added new SDK levels through 17

Change-Id: I151d2b2397e865878e44b8399efef31e9ab084c3
  • Loading branch information
halatmit authored and jisqyv committed Dec 6, 2012
1 parent d0efdf8 commit 8762cfa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.YaVersion;
import com.google.appinventor.components.runtime.util.SdkLevel;

import android.app.Activity;
import android.app.AlertDialog;
Expand Down Expand Up @@ -168,7 +169,6 @@ public void ShowTextDialog(String message, String title) {
* @param title the title for the alert box
*/
private void textInputAlert(String message, String title) {
Log.i(LOG_TAG, "Text input alert: " + message);
AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
alertDialog.setTitle(title);
alertDialog.setMessage(message);
Expand Down Expand Up @@ -212,13 +212,20 @@ public void run() {
// show a toast using a TextView, which allows us to set the
// font size. The default toast is too small.
private void toastNow (String message) {
// The notifier font size for more recent releases seems too
// small compared to early releases.
// This sets the fontsize according to SDK level, There is almost certainly
// a better way to do this, with display metrics for example, but
// I (hal) can't figure it out.
int fontsize = (SdkLevel.getLevel() >= SdkLevel.LEVEL_ICE_CREAM_SANDWICH)
? 22 : 15;
Toast toast = Toast.makeText(activity, message, Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, toast.getXOffset() / 2, toast.getYOffset() / 2);
TextView textView = new TextView(activity);
textView.setBackgroundColor(Color.DKGRAY);
textView.setTextColor(Color.WHITE);
textView.setTextSize(20);
Typeface typeface = Typeface.create("serif", Typeface.NORMAL);
textView.setTextSize(fontsize);
Typeface typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL);
textView.setTypeface(typeface);
textView.setPadding(10, 10, 10, 10);
textView.setText(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@
* @author [email protected] (Sharon Perl)
*/
public class SdkLevel {
public static final int LEVEL_CUPCAKE = 3; // a.k.a. 1.5
public static final int LEVEL_DONUT = 4; // a.k.a. 1.6
public static final int LEVEL_ECLAIR = 5; // a.k.a. 2.0
public static final int LEVEL_ECLAIR_0_1 = 6; // a.k.a. 2.0.1
public static final int LEVEL_ECLAIR_MR1 = 7; // a.k.a. 2.1
public static final int LEVEL_FROYO = 8; // a.k.a. 2.2
public static final int LEVEL_GINGERBREAD = 9; // a.k.a. 2.3
public static final int LEVEL_GINGERBREAD_MR1 = 10; // a.k.a. 2.3.3
public static final int LEVEL_HONEYCOMB = 11; // a.k.a. 3.0
public static final int LEVEL_CUPCAKE = 3; // a.k.a. 1.5
public static final int LEVEL_DONUT = 4; // a.k.a. 1.6
public static final int LEVEL_ECLAIR = 5; // a.k.a. 2.0
public static final int LEVEL_ECLAIR_0_1 = 6; // a.k.a. 2.0.1
public static final int LEVEL_ECLAIR_MR1 = 7; // a.k.a. 2.1
public static final int LEVEL_FROYO = 8; // a.k.a. 2.2
public static final int LEVEL_GINGERBREAD = 9; // a.k.a. 2.3
public static final int LEVEL_GINGERBREAD_MR1 = 10; // a.k.a. 2.3.3
public static final int LEVEL_HONEYCOMB = 12; // a.k.a. 3.0
public static final int LEVEL_ICE_CREAM_SANDWICH = 14; // a.k.a. 4.0
public static final int LEVEL_JELLYBEAN = 16; // a.k.a. 4.1
public static final int LEVEL_JELLYBEAN_MR1 = 17; // a.k.a. 4.2

private SdkLevel() {
}
Expand Down

0 comments on commit 8762cfa

Please sign in to comment.