tintColor not working on watchOS 5 complication - watchos

I have several complications for watchOS 5 and Apple Watch Series 4 that aren't properly making use of their tintColor. Instead, they just display with white text. Other 3rd party complications on the same face show their color.
Is there a trick other than using tintColor on the leadingTextProvider and trailingTextProvider of a Graphic Circular complication?
I'm using Objective-C in case that matters here.

You can do that with CLKSimpleTextProvider, the trick thing is that you can't do it with CLKTextProvider.
For example,
t.leadingTextProvider = {
let t = CLKSimpleTextProvider(text: String(6))
t.tintColor = .red
return t
}()
works
t.leadingTextProvider = {
let t = CLKTextProvider(format: String(6))
t.tintColor = .red
return t
}()
doesn't work.
In Apple's Documents of CLKTextProvider, it says
You do not create instances of this class yourself. Instead, you create instances of an appropriate subclass, based on the type of text data you are trying to create. You can also use the textProviderWithFormat: class method to create a generic text provider constructed from a format string and the data from other text provider.
Besides, you also need a watch face that allows tint color, like mine.
Xcode 11.0 (11A420a)
watchOS simulator 6.0

Is it possible that you‘re initializing your UIColor incorrectly? Can you show the relevant code?
A common mistake is using integers (e.g. 0-255) for the RGB values of UIColor (see this question).

Related

"python function decorator" for objective-c to change a method's behavior

I want to modify the behavior of some function without being the author of that function. What I control is that I can ask the author to follow some pattern, e.g. use a base class, use a certain decorator, property etc.
If in python, I would use a decorator to change the behavior of a method.
As an example, My goal: Improve code coverage by automatically testing over multiple input data.
Pseudo code:
#implementation SomeTestSuiteClass
// If in python, I would add a decorator here to change the behavior of the following method
-(void)testSample1 {
input = SpecialProvider();
output = FeatureToTest(input);
SpecialAssert(output);
}
#end
What I want: During test, the testSample1 method will be called multiple times. Each time, the SpecialProvider will emit a different input data. Same for the SpecialAssert, which can verify the output corresponding to the given input.
SpecialProvider and SpecialAssert will be API under my control/ownership (i.e. I write them).
The SomeTestSuiteClass together with the testSample1 will be written by the user (i.e. test writer).
Is there a way for Objective-C to achieve "what I want" above?
You could mock objects and/or its methods using objective-c runtime or some third party frameworks. I discourage it though. That is a sign of poor architecture choices in the 1st place. The main problem in your approach are hidden dependencies in your code directly referencing
SpecialProvider & SpecialAssert symbols directly.
A much better way to this would be like this:
-(void)testSample1:(SpecialProvider*)provider assert:(BOOL (^)(parameterTypes))assertBlock {
input = provider;
output = FeatureToTest(input);
if (assertBlock != nil) {
assertBlock(output);
}
}
Since Objective-c does not support default argument values like Swift does you could emulate it with:
-(void)testSample1 {
[self testSample1:DefaultSpecialProvider() assert:DefaultAssert()];
}
not to call the explicit -(void)testSample1:(SpecialProvider*)provider assert:(BOOL (^)(parameterTypes))assertBlock all the time, however in tests you would always use the explicit 2 argument variant to allow substituting the implementation(s) not being under test.
Further improvement idea:
Put the SpecialProvider and SpecialAssert behind protocols(i.e. equivalent of interfaces in other programming languages) so you can easily exchange the implementation.

Qt Quick (QML) color declaration

I have following statement inside ListView declaratation:
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
Everything is ok, but I was just wondering, which file in is word lightsteelblue declared, so I can review other predefined colors?
The documentation says it is normally specified as an SVG color name, and provides this reference page. I understand QML supports the different keyword names listed in there.
EDIT: as pointed out by #dbrianj (thanks), you can find them in the qtbase/src/gui/painting/qcolor_p.cpp file.

How to detect if it's inside Backboardd in my tweak of iOS?

I want to inject some functions to Backboardd, because of some reasons, I can not use plist to restrict it, so I want to use "if" to determine whether it's inside Backboardd.I know in 'Logos' I can use like that:
%ctor{
if (%c(SpringBoard)) {
}
}
But without Logos, can I do it like below?It doesn't work.
MSInitialize {
if (objc_getClass("Backboardd")) {
CFMessagePortRef local = CFMessagePortCreateLocal(NULL, CFSTR(MACH_PORT_NAME), messageCallBack, NULL, NULL);
CFRunLoopSourceRef source = CFMessagePortCreateRunLoopSource(NULL, local, 0);
CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopDefaultMode);
}
}
In general, you need to find some obj-c class that is unique to what you are hooking. Ideally, it should be class defined inside that binary, not imported from a framework. For example, in SpringBoard there is SpringBoard class that can only be found inside SpringBoard's binary. If objc_getClass("SpringBoard") returns non NULL value then you're inside the SpringBoard.
Now, backboardd. What I'm doing in cases like that is copying binary on my PC and obtaining the list of all classes inside that binary using class-dump or IDA. In case of backboardd, good candidate would be BKApplication. So
if (objc_getClass("BKApplication")) {
...
}
would do the job. There is no Backboardd class in backboardd.
And just for the future, use more popular tags for the questions like that. You have a better chance of getting an answer if you use jailbreak or iphone-privateapi tags.

Custom CSS attributes while using LESS?

I have been using SASS for a while now, and one thing I really like is how I can use it for my FlashBuilder projects also, namely that is supports custom CSS attributes, like 'embedAsCFF' and 'unicodeRange'.
I'm trying out LESS for the first time, and it will not let me compile to CSS while using these two custom attributes:
embedAsCFF: true;
unicodeRange: U+0021, U+0023-U+0026, U+0028-U+002a, U+002c, U+002e-U+0039, U+0040-U+005d, U+0061-U+007d;
I receive a 'Less Compilation Error: Syntax Error...'
Any LESS users know how I need to add in support for these custom attributes? Thanks in advance.
Update: This issue will be resolved in the release of LESS 1.4.2
Not a Custom Name but a Format Issue
It appears on my experimenting that the issue is really the fact that you are using capital letters in the property names (not that they are custom attributes themselves). Capital letters are apparently not supported by LESS. In other words, these work:
embedascff: true;
embed-as-cff: true;
unicoderange: U+0021; //etc.
unicode-range: U+0021; //etc.
But this does not:
Color: red;
I have not for certain isolated where in the actual LESS code itself this might be fixed (if it can be fixed for the way LESS handles the property rules). I suspect the cause is in the parser.js file lines 1578-1584 (as of this writing), which are:
property: function () {
var name;
if (name = $(/^(\*?-?[_a-z0-9-]+)\s*:/)) {
return name[1];
}
}
This seems to be filtering out allowing for capital letters. I don't know what the consequences would be if that regular expression was changed to allow for them.

Invisible Marker in Eclipse

I've got an unusual error and I might be missing something - I've written a test plugin that should simply show an error marker on the first line of a file. I'm using this code, triggered from a button press
public void createMarkerForResource(IResource resource) throws CoreException {
HashMap map = new HashMap();
MarkerUtilities.setLineNumber(map, 1);
MarkerUtilities.setMessage(map, "HAZARD");
map.put(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
MarkerUtilities.createMarker(resource, map, IMarker.TEXT);
}
The code appeared not to work - but on closer inspection something is happening. There is now a 'clickable' area on the ruler, but no icon...
Before:
After:
Any ideas?
(I'm aware there's a similar question - but it was self-solved and as we are using different approaches and getting different responses I thought it was worth opening this one up.)
As far as I can see, you define a org.eclipse.core.resources.textmarker.
But I cannot find a org.eclipse.ui.ide.markerImageProviders with an image for the marker type. So I simply believe, there are no image for this type.
Try using a different type of marker type, define your own marker type or define your own image for the textmarker marker type (not recommended).