Commit 8762cfa9 authored by halatmit's avatar halatmit Committed by Jeffrey I. Schiller

Adjusted notifier font size for pre-Gingerbread systems. Font was too

large.

Added new SDK levels through 17

Change-Id: I151d2b2397e865878e44b8399efef31e9ab084c3
parent d0efdf84
......@@ -11,6 +11,7 @@ import com.google.appinventor.components.annotations.SimpleFunction;
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;
......@@ -168,7 +169,6 @@ public final class Notifier extends AndroidNonvisibleComponent implements Compon
* @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);
......@@ -212,13 +212,20 @@ public final class Notifier extends AndroidNonvisibleComponent implements Compon
// 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);
......
......@@ -24,7 +24,10 @@ public class SdkLevel {
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_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() {
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment