Skip to content

Commit

Permalink
[fix] isWifiEnabled and isFullscreen (#73)
Browse files Browse the repository at this point in the history
* Also fix callBoolean method typo
  • Loading branch information
mwoz123 authored and Frenzie committed Oct 28, 2017
1 parent bd88561 commit 5541846
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions assets/android.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ function JNI:callBooleanMethod(object, method, signature, ...)
local clazz = self.env[0].GetObjectClass(self.env, object)
local methodID = self.env[0].GetMethodID(self.env, clazz, method, signature)
self.env[0].DeleteLocalRef(self.env, clazz)
return self.env[0].callBooleanMethod(self.env, object, methodID, ...)
return self.env[0].CallBooleanMethod(self.env, object, methodID, ...)
end

function JNI:callStaticBooleanMethod(class, method, signature, ...)
Expand Down Expand Up @@ -1363,10 +1363,10 @@ local function run(android_app_state)
local fullscreen = JNI:callIntMethod(
android.app.activity.clazz,
"isFullscreen",
"()Z"
"()I"
)
android.LOGI("is fullscreen =", fullscreen)
return fullscreen
return fullscreen == 1
end)
end
android.setFullscreen = function(fullscreen)
Expand Down Expand Up @@ -1398,10 +1398,10 @@ local function run(android_app_state)
local isWifiEnabled = JNI:callIntMethod(
android.app.activity.clazz,
"isWifiEnabled",
"()Z"
"()I"
)
android.LOGI("is WifiEnabled =", isWifiEnabled)
return isWifiEnabled
return isWifiEnabled == 1
end)
end

Expand Down
8 changes: 4 additions & 4 deletions src/org/koreader/launcher/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,17 @@ public void run() {
});
}

public boolean isFullscreen() {
return (getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0;
public int isFullscreen() {
return ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0) ? 1: 0;
}


public void setWifiEnabled(final boolean enabled) {
this.getWifiManager().setWifiEnabled(enabled);
}

public boolean isWifiEnabled() {
return this.getWifiManager().isWifiEnabled();
public int isWifiEnabled() {
return this.getWifiManager().isWifiEnabled() ? 1 : 0;
}

private WifiManager getWifiManager() {
Expand Down

0 comments on commit 5541846

Please sign in to comment.