示例#1
0
  private void init(MainView v, Object params) {
    Context ctx = RhodesActivity.getContext();

    view = new MyView(ctx);
    view.setOrientation(LinearLayout.VERTICAL);
    view.setGravity(Gravity.BOTTOM);
    view.setLayoutParams(new LinearLayout.LayoutParams(FILL_PARENT, FILL_PARENT));

    webView = null;
    if (v != null) webView = v.detachWebView();
    if (webView == null) webView = RhodesActivity.safeGetInstance().createWebView();
    view.addView(webView, new LinearLayout.LayoutParams(FILL_PARENT, 0, 1));

    LinearLayout bottom = new LinearLayout(ctx);
    bottom.setOrientation(LinearLayout.HORIZONTAL);
    bottom.setBackgroundColor(Color.GRAY);
    bottom.setLayoutParams(new LinearLayout.LayoutParams(FILL_PARENT, WRAP_CONTENT, 0));
    view.addView(bottom);

    toolBar = bottom;

    setupToolbar(toolBar, params);

    webView.requestFocus();
  }
示例#2
0
  public void addNavBar(String title, Map<Object, Object> left, Map<Object, Object> right) {
    removeNavBar();

    Context ctx = RhodesActivity.getContext();

    LinearLayout top = new LinearLayout(ctx);
    top.setOrientation(LinearLayout.HORIZONTAL);
    top.setBackgroundColor(Color.GRAY);
    top.setGravity(Gravity.CENTER);
    top.setLayoutParams(new LinearLayout.LayoutParams(FILL_PARENT, WRAP_CONTENT, 0));

    View leftButton = createButton(left);
    leftButton.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT, 1));
    top.addView(leftButton);

    TextView label = new TextView(ctx);
    label.setText(title);
    label.setGravity(Gravity.CENTER);
    label.setTextSize((float) 30.0);
    label.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT, 2));
    top.addView(label);

    if (right != null) {
      View rightButton = createButton(right);
      rightButton.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT, 1));
      top.addView(rightButton);
    }

    navBar = top;
    view.addView(navBar, 0);
  }
示例#3
0
  @SuppressWarnings("unchecked")
  private void setupToolbar(LinearLayout tool_bar, Object params) {
    Context ctx = RhodesActivity.getContext();

    mCustomBackgroundColorEnable = false;

    Vector<Object> buttons = null;
    if (params != null) {
      if (params instanceof Vector<?>) {
        buttons = (Vector<Object>) params;
      } else if (params instanceof Map<?, ?>) {
        Map<Object, Object> settings = (Map<Object, Object>) params;

        Object colorObj = settings.get("color");
        if (colorObj != null && (colorObj instanceof Map<?, ?>)) {
          Map<Object, Object> color = (Map<Object, Object>) colorObj;

          Object redObj = color.get("red");
          Object greenObj = color.get("green");
          Object blueObj = color.get("blue");

          if (redObj != null
              && greenObj != null
              && blueObj != null
              && (redObj instanceof String)
              && (greenObj instanceof String)
              && (blueObj instanceof String)) {
            try {
              int red = Integer.parseInt((String) redObj);
              int green = Integer.parseInt((String) greenObj);
              int blue = Integer.parseInt((String) blueObj);

              mCustomBackgroundColor =
                  ((red & 0xFF) << 16) | ((green & 0xFF) << 8) | ((blue & 0xFF)) | 0xFF000000;
              mCustomBackgroundColorEnable = true;

              tool_bar.setBackgroundColor(Color.rgb(red, green, blue));
            } catch (NumberFormatException e) {
              // Do nothing here
            }
          }
        }

        Object bkgObj = settings.get("background_color");
        if ((bkgObj != null) && (bkgObj instanceof String)) {
          int color = Integer.decode(((String) bkgObj)).intValue();
          int red = (color & 0xFF0000) >> 16;
          int green = (color & 0xFF00) >> 8;
          int blue = (color & 0xFF);
          tool_bar.setBackgroundColor(Color.rgb(red, green, blue));
          mCustomBackgroundColor = color | 0xFF000000;
          mCustomBackgroundColorEnable = true;
        }

        Object buttonsObj = settings.get("buttons");
        if (buttonsObj != null && (buttonsObj instanceof Vector<?>))
          buttons = (Vector<Object>) buttonsObj;
      }
    }

    if (params != null) {
      LinearLayout group = null;
      // First group should have gravity LEFT
      int gravity = Gravity.LEFT;
      for (int i = 0, lim = buttons.size(); i < lim; ++i) {
        Object param = buttons.elementAt(i);
        if (!(param instanceof Map<?, ?>)) throw new IllegalArgumentException("Hash expected");

        Map<Object, Object> hash = (Map<Object, Object>) param;

        View button = createButton(hash);
        if (button == null) {
          group = null;
          gravity = Gravity.CENTER;
          continue;
        }

        button.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
        if (group == null) {
          group = new LinearLayout(ctx);
          group.setGravity(gravity);
          group.setOrientation(LinearLayout.HORIZONTAL);
          group.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, FILL_PARENT, 1));
          tool_bar.addView(group);
        }
        group.addView(button);
      }

      // Last group should have gravity RIGHT
      if (group != null) {
        group.setGravity(Gravity.RIGHT);
        tool_bar.requestLayout();
      }
    }
  }
示例#4
0
  private View createButton(Map<Object, Object> hash) {
    Context ctx = RhodesActivity.getContext();

    Object actionObj = hash.get("action");
    if (actionObj == null || !(actionObj instanceof String))
      throw new IllegalArgumentException("'action' should be String");

    String action = (String) actionObj;
    if (action.length() == 0) throw new IllegalArgumentException("'action' should not be empty");

    Drawable icon = null;
    String label = null;
    View.OnClickListener onClick = null;

    if (action.equalsIgnoreCase("back")) {
      icon = ctx.getResources().getDrawable(AndroidR.drawable.back);
      onClick = new ActionBack();
    } else if (action.equalsIgnoreCase("forward")) {
      if (RhodesService.isJQTouch_mode()) {
        return null;
      }
      icon = ctx.getResources().getDrawable(AndroidR.drawable.next);
      onClick = new ActionForward();
    } else if (action.equalsIgnoreCase("home")) {
      icon = ctx.getResources().getDrawable(AndroidR.drawable.home);
      onClick = new ActionHome();
    } else if (action.equalsIgnoreCase("options")) {
      icon = ctx.getResources().getDrawable(AndroidR.drawable.options);
      onClick = new ActionOptions();
    } else if (action.equalsIgnoreCase("refresh")) {
      icon = ctx.getResources().getDrawable(AndroidR.drawable.refresh);
      onClick = new ActionRefresh();
    } else if (action.equalsIgnoreCase("close") || action.equalsIgnoreCase("exit")) {
      icon = ctx.getResources().getDrawable(AndroidR.drawable.exit);
      onClick = new ActionExit();
    } else if (action.equalsIgnoreCase("separator")) return null;

    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(metrics);

    Object iconObj = hash.get("icon");
    if (iconObj != null) {
      if (!(iconObj instanceof String))
        throw new IllegalArgumentException("'icon' should be String");
      String iconPath = "apps/" + (String) iconObj;
      iconPath = RhoFileApi.normalizePath(iconPath);
      Bitmap bitmap = BitmapFactory.decodeStream(RhoFileApi.open(iconPath));
      if (bitmap == null) throw new IllegalArgumentException("Can't find icon: " + iconPath);
      bitmap.setDensity(DisplayMetrics.DENSITY_MEDIUM);
      icon = new BitmapDrawable(bitmap);
    }

    if (icon == null) {
      Object labelObj = hash.get("label");
      if (labelObj == null || !(labelObj instanceof String))
        throw new IllegalArgumentException("'label' should be String");
      label = (String) labelObj;
    }

    if (icon == null && label == null)
      throw new IllegalArgumentException("One of 'icon' or 'label' should be specified");

    if (onClick == null) onClick = new ActionCustom(action);

    View button;
    if (icon != null) {
      ImageButton btn = new ImageButton(ctx);
      btn.setImageDrawable(icon);
      button = btn;
      if (mCustomBackgroundColorEnable) {
        Drawable d = btn.getBackground();
        if (d != null) {
          d.setColorFilter(mCustomBackgroundColor, android.graphics.PorterDuff.Mode.SRC_OVER);
        } else {
          btn.setBackgroundColor(mCustomBackgroundColor);
        }
      }
    } else {
      Button btn = new Button(ctx);
      btn.setText(label);
      if (mCustomBackgroundColorEnable) {
        btn.setBackgroundColor(mCustomBackgroundColor);
        int gray =
            (((mCustomBackgroundColor & 0xFF0000) >> 16)
                    + ((mCustomBackgroundColor & 0xFF00) >> 8)
                    + ((mCustomBackgroundColor & 0xFF)))
                / 3;
        if (gray > 128) {
          btn.setTextColor(0xFF000000);
        } else {
          btn.setTextColor(0xFFFFFFFF);
        }
      }
      button = btn;
    }

    button.setOnClickListener(onClick);

    return button;
  }
示例#5
0
  @Override
  public void takePicture(Map<String, String> propertyMap, IMethodResult result) {
    Logger.T(TAG, "takePicture");
    try {
      Map<String, String> actualPropertyMap = new HashMap<String, String>();
      actualPropertyMap.putAll(getPropertiesMap());
      actualPropertyMap.putAll(propertyMap);
      setActualPropertyMap(actualPropertyMap);

      String outputFormat = actualPropertyMap.get("outputFormat");
      String filePath = null;
      if (!actualPropertyMap.containsKey("fileName")) {
        filePath =
            "/sdcard/DCIM/Camera/IMG_"
                + dateFormat.format(new Date(System.currentTimeMillis()))
                + ".jpg";
      } else {
        filePath = actualPropertyMap.get("fileName");
      }
      if (outputFormat.equalsIgnoreCase("image")) {
        filePath = actualPropertyMap.get("fileName") + ".jpg";
        Logger.T(TAG, "outputFormat: " + outputFormat + ", path: " + filePath);
      } else if (outputFormat.equalsIgnoreCase("dataUri")) {
        Logger.T(TAG, "outputFormat: " + outputFormat);
      } else {
        throw new RuntimeException("Unknown 'outputFormat' value: " + outputFormat);
      }

      Intent intent = null;
      if (Boolean.parseBoolean(actualPropertyMap.get("useSystemViewfinder"))) {
        if (outputFormat.equalsIgnoreCase("image")) {
          values = new ContentValues();
          fileUri =
              RhodesActivity.getContext()
                  .getContentResolver()
                  .insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
          intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
          actualPropertyMap.put("captureUri", fileUri.toString());
          propertyMap.put("dataURI", "");
          // intent is null with MediaStore.EXTRA_OUTPUT so adding fileuri to map and get it with
          // same key
          // if instead of MediaStore.EXTRA_OUTPUT any other key is used then the bitmap is null
          // though the file is getting created
          intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
        } else if (outputFormat.equalsIgnoreCase("dataUri")) {

        }
      } else {
        intent = new Intent(ContextFactory.getUiContext(), CameraActivity.class);
        intent.putExtra(CameraExtension.INTENT_EXTRA_PREFIX + "CAMERA_ID", getId());
      }
      ((CameraFactory) CameraFactorySingleton.getInstance())
          .getRhoListener()
          .setMethodResult(result);
      ((CameraFactory) CameraFactorySingleton.getInstance())
          .getRhoListener()
          .setActualPropertyMap(actualPropertyMap);

      RhodesActivity.safeGetInstance()
          .startActivityForResult(
              intent,
              RhoExtManager.getInstance()
                  .getActivityResultNextRequestCode(CameraRhoListener.getInstance()));
    } catch (RuntimeException e) {
      Logger.E(TAG, e);
      result.setError(e.getMessage());
    }
  }
示例#6
0
  @SuppressWarnings("unchecked")
  public TabbedMainView(Object params) {
    Context ctx = RhodesActivity.getContext();

    mBackgroundColorEnable = false;

    Vector<Object> tabs = null;
    boolean place_tabs_bottom = false;
    if (params instanceof Vector<?>) tabs = (Vector<Object>) params;
    else if (params instanceof Map<?, ?>) {
      Map<Object, Object> settings = (Map<Object, Object>) params;

      Object bkgObj = settings.get("background_color");
      if ((bkgObj != null) && (bkgObj instanceof String)) {
        int color = Integer.parseInt((String) bkgObj) | 0xFF000000;
        mBackgroundColor = color;
        mBackgroundColorEnable = true;
      }

      Object callbackObj = settings.get("on_change_tab_callback");
      if ((callbackObj != null) && (callbackObj instanceof String)) {
        mChangeTabCallback = new String(((String) callbackObj));
      }

      Object placeBottomObj = settings.get("place_tabs_bottom");
      if ((placeBottomObj != null) && (placeBottomObj instanceof String)) {
        place_tabs_bottom = ((String) placeBottomObj).equalsIgnoreCase("true");
      }

      Object tabsObj = settings.get("tabs");
      if (tabsObj != null && (tabsObj instanceof Vector<?>)) tabs = (Vector<Object>) tabsObj;
    }

    if (tabs == null) throw new IllegalArgumentException("No tabs specified");

    int size = tabs.size();

    host = new TabHost(ctx, null);

    tabData = new Vector<TabData>(size);
    tabIndex = 0;

    TabWidget tabWidget = new TabWidget(ctx);
    tabWidget.setId(android.R.id.tabs);

    FrameLayout frame = new FrameLayout(ctx);
    FrameLayout.LayoutParams lpf = null;
    TabHost.LayoutParams lpt = null;
    if (place_tabs_bottom) {
      frame.setId(android.R.id.tabcontent);
      lpf =
          new FrameLayout.LayoutParams(
              LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, Gravity.TOP);
      host.addView(frame, lpf);

      lpt =
          new TabHost.LayoutParams(
              LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
      host.addView(tabWidget, lpt);
    } else {
      lpt =
          new TabHost.LayoutParams(
              LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, Gravity.TOP);
      host.addView(tabWidget, lpt);

      frame = new FrameLayout(ctx);
      frame.setId(android.R.id.tabcontent);
      lpf =
          new FrameLayout.LayoutParams(
              LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, Gravity.BOTTOM);
      host.addView(frame, lpf);
    }

    host.setup();

    TabHost.TabSpec spec;
    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(metrics);

    int selected_color = 0;
    boolean selected_color_enable = false;

    for (int i = 0; i < size; ++i) {
      Object param = tabs.elementAt(i);
      if (!(param instanceof Map<?, ?>)) throw new IllegalArgumentException("Hash expected");

      Map<Object, Object> hash = (Map<Object, Object>) param;

      Object labelObj = hash.get("label");
      if (labelObj == null || !(labelObj instanceof String))
        throw new IllegalArgumentException("'label' should be String");

      Object actionObj = hash.get("action");

      boolean use_current_view_for_tab = false;
      Object use_current_view_for_tab_Obj = hash.get("use_current_view_for_tab");
      if (use_current_view_for_tab_Obj != null) {
        use_current_view_for_tab = ((String) use_current_view_for_tab_Obj).equalsIgnoreCase("true");
      }

      if (use_current_view_for_tab) {
        actionObj = new String("none");
      }
      if (actionObj == null || !(actionObj instanceof String))
        throw new IllegalArgumentException("'action' should be String");

      String label = (String) labelObj;
      String action = (String) actionObj;
      String icon = null;
      boolean reload = false;
      boolean disabled = false;
      int web_bkg_color = 0xFFFFFFFF;

      Object iconObj = hash.get("icon");
      if (iconObj != null && (iconObj instanceof String)) icon = "apps/" + (String) iconObj;

      Object reloadObj = hash.get("reload");
      if (reloadObj != null && (reloadObj instanceof String))
        reload = ((String) reloadObj).equalsIgnoreCase("true");

      Object selected_color_Obj = hash.get("selected_color");
      if ((selected_color_Obj != null) && (selected_color_Obj instanceof String)) {
        selected_color_enable = true;
        selected_color = Integer.parseInt((String) selected_color_Obj) | 0xFF000000;
      }

      Object disabled_Obj = hash.get("disabled");
      if (disabled_Obj != null && (disabled_Obj instanceof String))
        disabled = ((String) disabled_Obj).equalsIgnoreCase("true");

      Object web_bkg_color_Obj = hash.get("web_bkg_color");
      if (web_bkg_color_Obj != null && (web_bkg_color_Obj instanceof String)) {
        web_bkg_color = Integer.parseInt((String) web_bkg_color_Obj) | 0xFF000000;
      }

      spec = host.newTabSpec(Integer.toString(i));

      // Set label and icon
      BitmapDrawable drawable = null;

      if (icon != null) {
        String iconPath = RhoFileApi.normalizePath(icon);
        Bitmap bitmap = BitmapFactory.decodeStream(RhoFileApi.open(iconPath));
        if (disabled && (bitmap != null)) {
          // replace Bitmap to gray
          bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true); // prepare mutable bitmap
          int x;
          int y;
          int bw = bitmap.getWidth();
          int bh = bitmap.getHeight();
          int nc = DISABLED_IMG_COLOR & 0xFFFFFF;
          int c;
          for (y = 0; y < bh; y++) {
            for (x = 0; x < bw; x++) {
              c = bitmap.getPixel(x, y);
              c = nc | (c & 0xFF000000);
              bitmap.setPixel(x, y, c);
            }
          }
        }

        if (bitmap != null)
          bitmap.setDensity(DisplayMetrics.DENSITY_MEDIUM); // Bitmap.DENSITY_NONE);
        drawable = new BitmapDrawable(bitmap);
        drawable.setTargetDensity(metrics);
      }
      if (drawable == null) spec.setIndicator(label);
      else spec.setIndicator(label, drawable);

      SimpleMainView view = null;
      if (use_current_view_for_tab) {
        RhodesService r = RhodesService.getInstance();
        MainView mainView = r.getMainView();
        action = mainView.currentLocation(-1);
        view = new SimpleMainView(mainView);
      } else {
        view = new SimpleMainView();
      }
      // Set view factory

      if (web_bkg_color_Obj != null) {
        if (!use_current_view_for_tab) {
          view.setWebBackgroundColor(web_bkg_color);
        }
        host.setBackgroundColor(web_bkg_color);
      }

      TabData data = new TabData();
      data.view = view;
      data.url = action;
      data.reload = reload;

      if (use_current_view_for_tab) {
        data.loaded = true;
        tabIndex = i;
      }

      data.selected_color = selected_color;
      data.selected_color_enabled = selected_color_enable;
      data.disabled = disabled;

      TabViewFactory factory = new TabViewFactory(data);
      spec.setContent(factory);

      tabData.addElement(data);
      host.addTab(spec);
    }

    tabWidget.measure(host.getWidth(), host.getHeight());
    int hh = tabWidget.getMeasuredHeight();
    // if (hh < 64) {
    //	hh = 64;
    // }
    if (place_tabs_bottom) {
      lpf.setMargins(0, 0, 0, hh);
    } else {
      lpf.setMargins(0, hh, 0, 0);
    }
    host.updateViewLayout(frame, lpf);
  }
示例#7
0
    public void draw(Canvas canvas) {
      Rect rect = getBounds();

      int c_R = (color & 0xFF0000) >> 16;
      int c_G = (color & 0xFF00) >> 8;
      int c_B = (color & 0xFF);
      int height = rect.bottom - rect.top + 1;

      int gap = 3;

      Context ctx = RhodesActivity.getContext();
      DisplayMetrics metrics = new DisplayMetrics();
      WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
      wm.getDefaultDisplay().getMetrics(metrics);

      int lcd_density = metrics.densityDpi;
      if (lcd_density > 200) gap = 4;
      int left_gap = gap;
      int right_gap = gap;
      if (lcd_density > 200) left_gap += 1;
      if (lcd_density > 200) right_gap += 1;
      if (first_tab) left_gap = 0;
      if (last_tab) right_gap = 0;

      switch (style) {
        case NORMAL:
          {
            int dark_k = 16;
            int dark_k2 = 128;
            int c_dark_R = modifyColorComponent(c_R, -dark_k);
            int c_dark_G = modifyColorComponent(c_G, -dark_k);
            int c_dark_B = modifyColorComponent(c_B, -dark_k);

            int c_dark2_R = modifyColorComponent(c_R, -dark_k2);
            int c_dark2_G = modifyColorComponent(c_G, -dark_k2);
            int c_dark2_B = modifyColorComponent(c_B, -dark_k2);

            int y0 = rect.top;
            int y1 = rect.top + ((height - gap) / 10);
            int y2 = rect.top + ((height - gap) / 2);
            int y3 = rect.bottom - ((height - gap) / 10) - gap;
            int y4 = rect.bottom - gap;

            drawVerticalGradient(
                canvas,
                rect.left + left_gap,
                y0,
                rect.right - right_gap,
                y1,
                c_dark2_R,
                c_dark2_G,
                c_dark2_B,
                c_dark_R,
                c_dark_G,
                c_dark_B);

            drawVerticalGradient(
                canvas,
                rect.left + left_gap,
                y1,
                rect.right - right_gap,
                y2,
                c_dark_R,
                c_dark_G,
                c_dark_B,
                c_R,
                c_G,
                c_B);

            drawVerticalGradient(
                canvas,
                rect.left + left_gap,
                y2,
                rect.right - right_gap,
                y3,
                c_R,
                c_G,
                c_B,
                c_dark_R,
                c_dark_G,
                c_dark_B);

            drawVerticalGradient(
                canvas,
                rect.left + left_gap,
                y3,
                rect.right - right_gap,
                y4,
                c_dark_R,
                c_dark_G,
                c_dark_B,
                c_dark2_R,
                c_dark2_G,
                c_dark2_B);

            Paint paint = new Paint();
            paint.setAntiAlias(false);
            paint.setARGB(32, 0, 0, 0);
            canvas.drawRect(
                rect.left + left_gap, rect.top, rect.left + left_gap + 1, rect.bottom - gap, paint);
            canvas.drawRect(
                rect.right - right_gap - 1,
                rect.top,
                rect.right - right_gap,
                rect.bottom - gap,
                paint);
          }
          break;
        case SELECTED:
          {
            int light_k = 16;
            int dark_k = 16;
            int light_k2 = 64;
            int dark_k2 = 64;

            int c_0_R = modifyColorComponent(c_R, light_k2);
            int c_0_G = modifyColorComponent(c_G, light_k2);
            int c_0_B = modifyColorComponent(c_B, light_k2);

            int c_1_R = modifyColorComponent(c_R, light_k);
            int c_1_G = modifyColorComponent(c_G, light_k);
            int c_1_B = modifyColorComponent(c_B, light_k);

            int c_3_R = modifyColorComponent(c_R, -dark_k);
            int c_3_G = modifyColorComponent(c_G, -dark_k);
            int c_3_B = modifyColorComponent(c_B, -dark_k);

            int c_4_R = modifyColorComponent(c_R, -dark_k2);
            int c_4_G = modifyColorComponent(c_G, -dark_k2);
            int c_4_B = modifyColorComponent(c_B, -dark_k2);

            int y0 = rect.top;
            int y1 = rect.top + ((height - gap) / 4);
            int y2 = rect.top + ((height - gap) / 2);
            int y3 = rect.bottom - ((height - gap) / 4) - gap;
            int y4 = rect.bottom - gap;

            drawVerticalGradient(
                canvas,
                rect.left + left_gap,
                y0,
                rect.right - right_gap,
                y1,
                c_0_R,
                c_0_G,
                c_0_B,
                c_1_R,
                c_1_G,
                c_1_B);

            drawVerticalGradient(
                canvas,
                rect.left + left_gap,
                y1,
                rect.right - right_gap,
                y2,
                c_1_R,
                c_1_G,
                c_1_B,
                c_R,
                c_G,
                c_B);

            drawVerticalGradient(
                canvas,
                rect.left + left_gap,
                y2,
                rect.right - right_gap,
                y3,
                c_R,
                c_G,
                c_B,
                c_3_R,
                c_3_G,
                c_3_B);

            drawVerticalGradient(
                canvas,
                rect.left + left_gap,
                y3,
                rect.right - right_gap,
                y4,
                c_3_R,
                c_3_G,
                c_3_B,
                c_4_R,
                c_4_G,
                c_4_B);

            Paint paint = new Paint();
            paint.setAntiAlias(false);
            paint.setARGB(32, 0, 0, 0);
            canvas.drawRect(
                rect.left + left_gap, rect.top, rect.left + left_gap + 1, rect.bottom, paint);
            canvas.drawRect(
                rect.right - right_gap - 1, rect.top, rect.right - right_gap, rect.bottom, paint);
            paint.setARGB(255, c_4_R, c_4_G, c_4_B);
            canvas.drawRect(rect.left, rect.bottom - gap, rect.right, rect.bottom - 1, paint);
          }
          break;
        case DISABLED:
          {
            c_R = (DISABLED_BKG_COLOR & 0xFF0000) >> 16;
            c_G = (DISABLED_BKG_COLOR & 0xFF00) >> 8;
            c_B = (DISABLED_BKG_COLOR & 0xFF);

            int dark_k = 0;
            int dark_k2 = 32;
            int c_dark_R = modifyColorComponent(c_R, -dark_k);
            int c_dark_G = modifyColorComponent(c_G, -dark_k);
            int c_dark_B = modifyColorComponent(c_B, -dark_k);

            int c_dark2_R = modifyColorComponent(c_R, -dark_k2);
            int c_dark2_G = modifyColorComponent(c_G, -dark_k2);
            int c_dark2_B = modifyColorComponent(c_B, -dark_k2);

            int y0 = rect.top;
            int y1 = rect.top + ((height - gap) / 10);
            int y2 = rect.top + ((height - gap) / 2);
            int y3 = rect.bottom - ((height - gap) / 10) - gap;
            int y4 = rect.bottom - gap;

            drawVerticalGradient(
                canvas,
                rect.left + left_gap,
                y0,
                rect.right - right_gap,
                y1,
                c_dark2_R,
                c_dark2_G,
                c_dark2_B,
                c_dark_R,
                c_dark_G,
                c_dark_B);

            drawVerticalGradient(
                canvas,
                rect.left + left_gap,
                y1,
                rect.right - right_gap,
                y2,
                c_dark_R,
                c_dark_G,
                c_dark_B,
                c_R,
                c_G,
                c_B);

            drawVerticalGradient(
                canvas,
                rect.left + left_gap,
                y2,
                rect.right - right_gap,
                y3,
                c_R,
                c_G,
                c_B,
                c_dark_R,
                c_dark_G,
                c_dark_B);

            drawVerticalGradient(
                canvas,
                rect.left + left_gap,
                y3,
                rect.right - right_gap,
                y4,
                c_dark_R,
                c_dark_G,
                c_dark_B,
                c_dark2_R,
                c_dark2_G,
                c_dark2_B);

            Paint paint = new Paint();
            paint.setAntiAlias(false);
            paint.setARGB(32, 0, 0, 0);
            canvas.drawRect(
                rect.left + left_gap, rect.top, rect.left + left_gap + 1, rect.bottom - gap, paint);
            canvas.drawRect(
                rect.right - right_gap - 1,
                rect.top,
                rect.right - right_gap,
                rect.bottom - gap,
                paint);
          }
          break;
      }
    }