Skip to content

Commit

Permalink
fix(android): fixed some TiConvert.toColor warnings (#13630)
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed Nov 3, 2022
1 parent 6c91a4c commit 12b2a71
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public boolean forwardDelete(View view, Editable content, int keyCode, KeyEvent
TextInputLayout.LayoutParams.MATCH_PARENT, TextInputLayout.LayoutParams.MATCH_PARENT));

if (hasPropertyAndNotNull(TiC.PROPERTY_COLOR)) {
editText.setTextColor(TiConvert.toColor(getProperty(TiC.PROPERTY_COLOR).toString()));
editText.setTextColor(TiConvert.toColor(getProperty(TiC.PROPERTY_COLOR).toString(), activity));
}

return textInputLayout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public ColorProxy getColorResource(Object idOrName)
@Kroll.method
public String harmonizedColor(String value)
{
int color = TiConvert.toColor(value);
int color = TiConvert.toColor(value, TiApplication.getAppCurrentActivity());
return String.format("#%06X",
(0xFFFFFF & MaterialColors.harmonizeWithPrimary(TiApplication.getAppCurrentActivity(), color)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollFunction;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.TiDimension;
import org.appcelerator.titanium.proxy.TiViewProxy;
Expand Down Expand Up @@ -229,11 +230,12 @@ public void applyOptions(HashMap options)
}

if (options.containsKey(TiC.PROPERTY_BACKGROUND_COLOR)) {
backgroundColor = TiConvert.toColor(options, TiC.PROPERTY_BACKGROUND_COLOR);
backgroundColor = TiConvert.toColor(options, TiC.PROPERTY_BACKGROUND_COLOR,
TiApplication.getAppCurrentActivity());
}

if (options.containsKey(TiC.PROPERTY_COLOR)) {
color = TiConvert.toColor(options, TiC.PROPERTY_COLOR);
color = TiConvert.toColor(options, TiC.PROPERTY_COLOR, TiApplication.getAppCurrentActivity());
}

if (options.containsKey(TiC.PROPERTY_ELEVATION)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiDimension;
import org.appcelerator.titanium.TiPoint;
import org.appcelerator.titanium.util.TiConvert;
Expand Down Expand Up @@ -299,7 +300,7 @@ private void loadColors(Object[] colors)
// We were given a Titanium "GradientColorRef" dictionary. Fetch its color.
@SuppressWarnings({ "rawtypes", "unchecked" })
HashMap<String, Object> colorRefObject = (HashMap) color;
this.colors[i] = TiConvert.toColor(colorRefObject, "color");
this.colors[i] = TiConvert.toColor(colorRefObject, "color", TiApplication.getAppCurrentActivity());

// Fetch the offset from the "GradientColorRef" dictionary.
// Note: Make sure value does not exceed the 0.0 - 1.0 normalized range.
Expand All @@ -319,7 +320,7 @@ private void loadColors(Object[] colors)
}
} else {
// Fetch the color value from the array.
this.colors[i] = TiConvert.toColor(color.toString());
this.colors[i] = TiConvert.toColor(color.toString(), TiApplication.getAppCurrentActivity());
}
}

Expand Down

0 comments on commit 12b2a71

Please sign in to comment.