Beispiel #1
0
  private static String getShareString(GCSavedSet savedSet) {
    String shareString = "";

    // Get title
    String title = savedSet.getTitle();
    title = title.replace(" ", "_");
    shareString += title;
    shareString += BREAK_CHARACTER_FOR_SHARING;

    // Get chipset
    String chip = savedSet.getChipSet().getTitle();
    chip = chip.replace(" ", "_");
    shareString += chip;
    shareString += BREAK_CHARACTER_FOR_SHARING;

    // Get colors
    ArrayList<GCPoweredColor> newColorList = savedSet.getColors();
    shareString += convertColorListToShortenedColorString(newColorList);
    shareString += BREAK_CHARACTER_FOR_SHARING;

    // Get mode
    String mode = savedSet.getMode().getTitle();
    mode = mode.replace(" ", "_");
    shareString += mode;
    shareString += BREAK_CHARACTER_FOR_SHARING;

    // Get custom colors
    shareString += getCustomColorShareString(savedSet);

    return shareString;
  }
Beispiel #2
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;
 }
Beispiel #3
0
 public static String convertSetListToString(ArrayList<GCSavedSet> setArrayList) {
   String setListString = "";
   for (GCSavedSet set : setArrayList) {
     setListString += set.getId();
     setListString += ",";
   }
   return setListString;
 }
Beispiel #4
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;
  }
Beispiel #5
0
 public static ArrayList<GCSavedSet> convertStringToSetList(
     Context context, String setListString) {
   ArrayList<GCSavedSet> setArrayList = new ArrayList<>();
   String[] stringParts = setListString.split(",");
   ArrayList<GCSavedSet> allSavedSets =
       GCDatabaseHelper.getInstance(context).SAVED_SET_DATABASE.getAllData();
   for (String part : stringParts) {
     for (GCSavedSet set : allSavedSets) {
       if (set.getId() == Integer.parseInt(part)) {
         setArrayList.add(set);
         break;
       }
     }
   }
   return setArrayList;
 }