Exemplo n.º 1
0
 private static String getCustomColorShareString(GCSavedSet savedSet) {
   ArrayList<Integer> indexList = new ArrayList<>();
   String customColorString = "";
   int index = 0;
   for (GCPoweredColor poweredColor : savedSet.getColors()) {
     if (poweredColor.getColor().getTitle().equalsIgnoreCase(GCConstants.COLOR_CUSTOM)) {
       indexList.add(index);
     }
     index++;
   }
   for (int i = 0; i < indexList.size(); i++) {
     int[] rgbValues = savedSet.getCustomColors().get(indexList.get(i));
     customColorString +=
         "("
             + Integer.toString(indexList.get(i))
             + ","
             + rgbValues[0]
             + "-"
             + rgbValues[1]
             + "-"
             + rgbValues[2]
             + ")";
   }
   return customColorString;
 }
Exemplo n.º 2
0
  public static SpannableStringBuilder generateMultiColoredString(GCSavedSet savedSet) {
    SpannableStringBuilder builder = new SpannableStringBuilder();

    String shortenedColorString = convertColorListToShortenedColorString(savedSet.getColors());

    List<String> stringParts = getParts(shortenedColorString, 3);
    int index = 0;
    for (String colorAbbrev : stringParts) {
      String colorString = colorAbbrev.substring(0, 2);
      String powerString = colorAbbrev.substring(2, 3);
      GCColor color = GCColorUtil.getColorUsingAbbrev(colorString);
      GCPowerLevel powerLevel = GCPowerLevelUtil.getPowerLevelUsingAbbrev(powerString);
      int[] rgbValues;
      if (color.getTitle().equalsIgnoreCase(GCConstants.COLOR_CUSTOM)) {
        rgbValues = convertRgbToPowerLevel(savedSet.getCustomColors().get(index), powerLevel);
      } else {
        rgbValues = convertRgbToPowerLevel(color.getRGBValues(), powerLevel);
      }

      if (colorString.equalsIgnoreCase("--")) {
        SpannableString spannableString = new SpannableString(colorString);
        spannableString.setSpan(
            new ForegroundColorSpan(Color.argb(255, 255, 255, 255)), 0, colorString.length(), 0);
        builder.append(spannableString);
      } else {
        SpannableString spannableString = new SpannableString(colorAbbrev);
        spannableString.setSpan(
            new ForegroundColorSpan(Color.argb(255, rgbValues[0], rgbValues[1], rgbValues[2])),
            0,
            3,
            0);
        spannableString.setSpan(
            new SuperscriptSpan(),
            colorAbbrev.length() - 1,
            colorAbbrev.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        spannableString.setSpan(
            new RelativeSizeSpan(0.75f),
            colorAbbrev.length() - 1,
            colorAbbrev.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        builder.append(spannableString);
      }
      index++;
    }

    return builder;
  }