Skip to content

Commit

Permalink
Merge pull request #295 from wwwdata/fix-android-config-options
Browse files Browse the repository at this point in the history
Fix config options for Android release builds
  • Loading branch information
pichillilorenzo authored May 9, 2020
2 parents 9c7ac0d + a7100ae commit 001c95e
Show file tree
Hide file tree
Showing 4 changed files with 474 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import com.pichillilorenzo.flutter_inappwebview.Options;

public class ChromeCustomTabsOptions extends Options {
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class ChromeCustomTabsOptions implements Options {

final static String LOG_TAG = "ChromeCustomTabsOptions";

Expand All @@ -12,4 +16,47 @@ public class ChromeCustomTabsOptions extends Options {
public boolean enableUrlBarHiding = false;
public boolean instantAppsEnabled = false;

ChromeCustomTabsOptions parse(HashMap<String, Object> options) {
Iterator it = options.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Object> pair = (Map.Entry<String, Object>) it.next();
String key = pair.getKey();
Object value = pair.getValue();
if (value == null) {
continue;
}

switch (key) {
case "addShareButton":
addShareButton = (boolean) value;
break;
case "showTitle":
showTitle = (boolean) value;
break;
case "toolbarBackgroundColor":
toolbarBackgroundColor = (String) value;
break;
case "enableUrlBarHiding":
enableUrlBarHiding = (boolean) value;
break;
case "instantAppsEnabled":
instantAppsEnabled = (boolean) value;
break;
}
}

return this;
}

@Override
public HashMap<String, Object> getHashMap() {
HashMap<String, Object> options = new HashMap<>();
options.put("addShareButton", addShareButton);
options.put("showTitle", showTitle);
options.put("toolbarBackgroundColor", toolbarBackgroundColor);
options.put("enableUrlBarHiding", enableUrlBarHiding);
options.put("instantAppsEnabled", instantAppsEnabled);

return options;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.pichillilorenzo.flutter_inappwebview;

public class InAppBrowserOptions extends Options {
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class InAppBrowserOptions implements Options {

public static final String LOG_TAG = "InAppBrowserOptions";

Expand All @@ -13,4 +17,60 @@ public class InAppBrowserOptions extends Options {
public boolean hideTitleBar = false;
public boolean closeOnCannotGoBack = true;
public boolean progressBar = true;

public InAppBrowserOptions parse(HashMap<String, Object> options) {
Iterator it = options.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Object> pair = (Map.Entry<String, Object>) it.next();
String key = pair.getKey();
Object value = pair.getValue();
if (value == null) {
continue;
}

switch (key) {
case "hidden":
hidden = (boolean) value;
break;
case "toolbarTop":
toolbarTop = (boolean) value;
break;
case "toolbarTopBackgroundColor":
toolbarTopBackgroundColor = (String) value;
break;
case "toolbarTopFixedTitle":
toolbarTopFixedTitle = (String) value;
break;
case "hideUrlBar":
hideUrlBar = (boolean) value;
break;
case "hideTitleBar":
hideTitleBar = (boolean) value;
break;
case "closeOnCannotGoBack":
closeOnCannotGoBack = (boolean) value;
break;
case "progressBar":
progressBar = (boolean) value;
break;
}
}

return this;
}

@Override
public HashMap<String, Object> getHashMap() {
final HashMap<String, Object> options = new HashMap<>();
options.put("hidden", hidden);
options.put("toolbarTop", toolbarTop);
options.put("toolbarTopBackgroundColor", toolbarTopBackgroundColor);
options.put("toolbarTopFixedTitle", toolbarTopFixedTitle);
options.put("hideUrlBar", hideUrlBar);
options.put("hideTitleBar", hideTitleBar);
options.put("closeOnCannotGoBack", closeOnCannotGoBack);
options.put("progressBar", progressBar);

return options;
}
}
Loading

0 comments on commit 001c95e

Please sign in to comment.