AI2 Component  (Version nb184)
HoneycombThemeHelper.java
Go to the documentation of this file.
1 // -*- mode: java; c-basic-offset: 2; -*-
2 // Copyright 2018 MIT, All rights reserved
3 // Released under the Apache License, Version 2.0
4 // http://www.apache.org/licenses/LICENSE-2.0
5 
6 package com.google.appinventor.components.runtime.util.theme;
7 
8 import android.app.ActionBar;
9 import android.graphics.Color;
10 import android.text.Html;
11 import android.view.Window;
16 
17 public class HoneycombThemeHelper implements ThemeHelper {
18 
19  private final AppInventorCompatActivity activity;
20 
22  this.activity = activity;
23  }
24 
25  @Override
26  public void requestActionBar() {
27  if (!activity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR)) {
28  activity.getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
29  }
30  }
31 
32  @Override
33  public boolean setActionBarVisible(boolean visible) {
34  ActionBar actionBar = activity.getActionBar();
35  if (actionBar == null) {
36  if (activity instanceof Form) {
37  ((Form) activity).dispatchErrorOccurredEvent((Form) activity, "ActionBar", ErrorMessages.ERROR_ACTIONBAR_NOT_SUPPORTED);
38  }
39  return false;
40  } else if (visible) {
41  actionBar.show();
42  } else {
43  actionBar.hide();
44  }
45  return true;
46  }
47 
48  @Override
49  public boolean hasActionBar() {
50  return activity.getActionBar() != null;
51  }
52 
53  @Override
54  public void setTitle(String title) {
55  ActionBar actionBar = activity.getActionBar();
56  if (actionBar != null) {
57  actionBar.setTitle(title);
58  }
59  }
60 
61  @Override
62  public void setActionBarAnimation(boolean enabled) {
63  // Canceling the transition animation is only provided in the AppCompat version
64  }
65 
66  @Override
67  public void setTitle(String title, boolean black) {
68  ActionBar actionBar = activity.getActionBar();
69  if (actionBar != null) {
70  if (black) {
71  actionBar.setTitle(Html.fromHtml("<font color=\"black\">" + title + "</font>"));
72  ImageViewUtil.setMenuButtonColor(activity, Color.BLACK);
73  } else {
74  actionBar.setTitle(title);
75  ImageViewUtil.setMenuButtonColor(activity, Color.WHITE);
76  }
77  }
78  }
79 }
com.google.appinventor.components.runtime.util.theme.HoneycombThemeHelper.setActionBarVisible
boolean setActionBarVisible(boolean visible)
Definition: HoneycombThemeHelper.java:33
com.google.appinventor.components.runtime.util.ErrorMessages
Definition: ErrorMessages.java:17
com.google.appinventor.components.runtime.util
-*- mode: java; c-basic-offset: 2; -*-
Definition: AccountChooser.java:7
com.google.appinventor.components.runtime.util.theme.HoneycombThemeHelper.hasActionBar
boolean hasActionBar()
Definition: HoneycombThemeHelper.java:49
com.google.appinventor.components.runtime.util.ImageViewUtil.setMenuButtonColor
static void setMenuButtonColor(Activity activity, int color)
Definition: ImageViewUtil.java:28
com.google.appinventor.components
com.google.appinventor.components.runtime.util.theme.HoneycombThemeHelper.setActionBarAnimation
void setActionBarAnimation(boolean enabled)
Definition: HoneycombThemeHelper.java:62
com.google.appinventor.components.runtime.util.theme.HoneycombThemeHelper.requestActionBar
void requestActionBar()
Definition: HoneycombThemeHelper.java:26
com.google.appinventor.components.runtime.util.ErrorMessages.ERROR_ACTIONBAR_NOT_SUPPORTED
static final int ERROR_ACTIONBAR_NOT_SUPPORTED
Definition: ErrorMessages.java:119
com.google.appinventor.components.runtime.util.theme.HoneycombThemeHelper
Definition: HoneycombThemeHelper.java:17
com.google.appinventor.components.runtime.util.theme.ThemeHelper
Definition: ThemeHelper.java:8
com.google.appinventor.components.runtime.util.theme.HoneycombThemeHelper.setTitle
void setTitle(String title, boolean black)
Definition: HoneycombThemeHelper.java:67
com.google.appinventor.components.runtime.util.ImageViewUtil
Definition: ImageViewUtil.java:19
com.google.appinventor.components.runtime.util.theme.HoneycombThemeHelper.HoneycombThemeHelper
HoneycombThemeHelper(AppInventorCompatActivity activity)
Definition: HoneycombThemeHelper.java:21
com.google.appinventor.components.runtime
Copyright 2009-2011 Google, All Rights reserved.
Definition: AccelerometerSensor.java:8
com.google.appinventor.components.runtime.AppInventorCompatActivity
Definition: AppInventorCompatActivity.java:40
com.google
com
com.google.appinventor.components.runtime.util.theme.HoneycombThemeHelper.setTitle
void setTitle(String title)
Definition: HoneycombThemeHelper.java:54
com.google.appinventor.components.runtime.Form
Definition: Form.java:126
com.google.appinventor