Closed PrabhbirJ closed 10 months ago
This does not even build
> Task :compileDebugJavaWithJavac FAILED
/home/wolny/dev/capacitor-inappbrowsers/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java:164: error: method setVisibleTitle(boolean) is already defined in class Options
public void setVisibleTitle(boolean _showArrow)
^
/home/wolny/dev/capacitor-inappbrowsers/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java:126: error: cannot find symbol
_toolbar.setBackgroundColor(Color.parseColor(_options.getToolbarColor));
^
symbol: variable getToolbarColor
location: variable _options of type Options
/home/wolny/dev/capacitor-inappbrowsers/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java:126: error: cannot find symbol
_toolbar.setBackgroundColor(Color.parseColor(_options.getToolbarColor));
^
symbol: variable Color
location: class WebViewDialog
/home/wolny/dev/capacitor-inappbrowsers/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java:161: error: method showArrow in class Options cannot be applied to given types;
options.showArrow(call.getBoolean("showArrow",false));
^
required: no arguments
found: Boolean
reason: actual and formal argument lists differ in length
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
4 errors
FAILURE: Build failed with an exception.
Also I was not able to get the stringToColor
to work in a playground.
I used the following code
import Foundation
struct UIColor {
var red: CGFloat
var green: CGFloat
var blue: CGFloat
var alpha = 0
}
func stringToColor(stringColor: String) -> UIColor {
var hexInt: UInt32 = 0
stringColor.remove(at: stringColor.startIndex)
let scanner = NSScanner(string: stringColor)
scanner.scanHexInt(&hexInt)
let color = UIColor(
red: CGFloat((hexInt & 0xFF0000) >> 16)/255,
green: CGFloat((hexInt & 0xFF00) >> 8)/255,
blue: CGFloat((hexInt & 0xFF))/255,
alpha: 1)
return color
}
and the online compiler threw
swift /tmp/19x1GLtfvI.swift
/tmp/19x1GLtfvI.swift:12:17: error: cannot use mutating member on immutable value: 'stringColor' is a 'let' constant
stringColor.remove(at: stringColor.startIndex)
~~~~~~~~~~~ ^
/tmp/19x1GLtfvI.swift:13:19: error: cannot find 'NSScanner' in scope
let scanner = NSScanner(string: stringColor)
I was able to get this to work but I had to modify the stringToColor
to look like this:
// Inout string so that it is mutable
func stringToColor(stringColor: inout String) -> UIColor {
var hexInt: UInt32 = 0
stringColor.remove(at: stringColor.startIndex)
// Scanner instead of NSScanner
let scanner = Scanner(string: stringColor)
// scanHexInt32 instead of scanHexInt
scanner.scanHexInt32(&hexInt)
let color = UIColor(
red: CGFloat((hexInt & 0xFF0000) >> 16)/255,
green: CGFloat((hexInt & 0xFF00) >> 8)/255,
blue: CGFloat((hexInt & 0xFF))/255,
alpha: 1)
return color
}
Even with this changed code I found no error handling. Here are some of the result I got
var color = "#ffffff"
print(stringToColor(stringColor: &color))
// UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1)
var color = "jhbnveqkejbv jnhqolikvbjmeq"
print(stringToColor(stringColor: &color))
// UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1)
var color = "!!$@#!!&"
print(stringToColor(stringColor: &color))
// UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1)
Also I found the formatting of the swift code to be extremely weird. Have you linted this code?
I'll see to it right away. Can you run the android version as well? Let me know what you find. Thank you @WcaleNieWolny
Can you run the android version as well
No, I cannot. It does not build as I shown above
Hi @WcaleNieWolny I have made a new pull request with solving the build issues on android. I can't seem to have any build issues on my machine. Also changed the UI color code. Please let me know more if you face any more errors. Thank you for your time and notifying me of my errors.
/claim #70 Made changes for the required functionalities.