Hi fuse. I am trying to figure out how to use foreign code. this is the code i wrote to get print out some text using Log.d .
can anyone please help me to figure this out. i really want to learn this and i will write some community libraries after that.
Thank you…
my uno file - (CallLog.uno)
using Uno.Threading;
using Uno;
using Uno.UX;
using Uno.Compiler.ExportTargetInterop;
using Android;
using Uno.Permissions;
using Fuse;
using Fuse.Scripting;
[extern(Android) ForeignInclude(Language.Java, "android.content.Context")]
[UXGlobalModule]
public class CallLog : NativeModule{
public CallLog(){
AddMember(new NativeFunction("callHistory",(NativeCallback)callHistory));
}
object callHistory(Context c, object[] args){
callHistory();
return null;
}
[Foreign(Language.Java)]
public static extern(Android) void callHistory()
@{
android.util.Log.d("ForeignCodeExample","hi");
@}
static extern(!Android) void callHistory(){
debug_log("Notifications not supported on this platform.");
}
}
my ux file
<App>
<DockPanel>
<StatusBarBackground Dock="Top" />
<BottomBarBackground Dock="Bottom" />
<CallLog ux:Global="CallLog" />
<JavaScript>
var Observable = require("FuseJS/Observable");
var Log = require("CallLog");
var val = Observable("");
function call() {
Log.callHistory();
}
module.exports = {call};
</JavaScript>
<Panel Height="60" Width="200">
<Rectangle Color="Blue">
<Clicked Handler="{call}" />
</Rectangle>
</Panel>
</DockPanel>
</App>
my unoproj file -
{
"RootNamespace":"",
"Packages": [
"Fuse",
"FuseJS",
"Uno.Permissions"
],
"Includes": [
"*",
"*.uno"
]
}