正在查看: Clash Legends v0.0.1 应用的 UberController.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 UberController.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package in.juspay.godel.ui.uber;
import android.app.Dialog;
import android.content.DialogInterface;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import com.onesignal.inAppMessages.internal.display.impl.WebViewManager;
import com.payu.upisdk.util.UpiConstant;
import in.juspay.godel.R;
import in.juspay.godel.analytics.Event;
import in.juspay.godel.analytics.GodelTracker;
import in.juspay.godel.browser.UberWebViewClient;
import in.juspay.godel.core.AssetService;
import in.juspay.godel.core.WebLabService;
import in.juspay.godel.ui.AcsInterface;
import in.juspay.godel.ui.JuspayBrowserFragment;
import in.juspay.godel.ui.JuspayWebView;
import in.juspay.godel.ui.uber.SlidingLayer;
import in.juspay.godel.util.EncryptionHelper;
import in.juspay.godel.util.JuspayLogger;
import in.juspay.godel.util.KeyValueStore;
import in.juspay.godel.util.SessionInfo;
import org.json.JSONObject;
public class UberController implements View.OnClickListener {
private static final String c = UberController.class.getName();
SlidingLayer.OnInteractListener a = new SlidingLayer.OnInteractListener() {
@Override
public void a() {
if (UberController.this.f != null && UberController.this.b != null && UberController.this.b.e() != null) {
if (UberController.this.b.e().equals("translucent")) {
UberController.this.f.setBackgroundResource(R.drawable.juspay_black_translucent);
} else if (UberController.this.b.e().equals("transparent")) {
UberController.this.f.setBackgroundResource(android.R.color.transparent);
}
}
}
@Override
public void b() {
if (UberController.this.f != null) {
UberController.this.f.setBackgroundResource(android.R.color.transparent);
}
if (UberController.this.b != null) {
if (UberController.this.i != null) {
String format = String.format("try { GK.onUberDismiss('%s') } catch(err) {}", UberController.this.b.s());
UberController.this.d.a(format, UberController.this.i);
if (UberController.this.d != null && UberController.this.d.getWebView() != null) {
UberController.this.d.a(format, UberController.this.d.getWebView());
}
}
if (UberController.this.b.j()) {
UberController uberController = UberController.this;
uberController.e(uberController.b);
}
}
}
@Override
public void c() {
}
@Override
public void d() {
if (UberController.this.f != null) {
UberController.this.f.setBackgroundResource(android.R.color.transparent);
}
}
};
private Uber b;
private JuspayBrowserFragment d;
private Dialog e;
private SlidingLayer f;
private FloatingActionButton g;
private ProgressBar h;
private JuspayWebView i;
private class JuspayDialogInterface implements DialogInterface.OnDismissListener {
private String b;
JuspayDialogInterface(String id) {
this.b = id;
}
@Override
public void onDismiss(DialogInterface dialog) {
char c;
String str = this.b;
switch (str.hashCode()) {
case -407955862:
if (str.equals("CREATE_UBER_DIALOG")) {
c = 0;
break;
}
default:
c = 65535;
break;
}
switch (c) {
case 0:
if (UberController.this.b != null) {
String format = String.format("try { GK.onUberDismiss('%s') } catch(err){}", UberController.this.b.s());
if (UberController.this.i != null) {
UberController.this.d.a(format, UberController.this.i);
}
if (UberController.this.d != null && UberController.this.d.getWebView() != null) {
UberController.this.d.a(format, UberController.this.d.getWebView());
UberController.this.d.a(true);
}
if (UberController.this.b.j()) {
UberController uberController = UberController.this;
uberController.e(uberController.b);
break;
}
}
break;
}
}
}
@Override
public void onClick(View v) {
SlidingLayer slidingLayer;
Dialog dialog;
if (v.getId() == R.id.uber_float_btn) {
GodelTracker.getInstance().a(new Event().a(Event.Category.UI).a(Event.Action.INFO).c(this.b.p()).d("uber_float_button_clicked"));
this.d.j("uber");
Uber uber = this.b;
if (uber != null) {
if (uber.q() == UberType.DIALOG && (dialog = this.e) != null) {
dialog.show();
} else if (this.b.q() == UberType.SLIDING_UBER && (slidingLayer = this.f) != null && !slidingLayer.b()) {
h();
}
}
n();
}
}
private class JuspayWebViewSetup implements View.OnTouchListener {
private String b;
JuspayWebViewSetup(String id) {
this.b = "";
this.b = id;
}
@Override
public boolean onTouch(View __v, MotionEvent __event) {
boolean z;
String str = this.b;
switch (str.hashCode()) {
case -210870542:
if (str.equals("UBER_WEBVIEW_SETUP")) {
z = false;
break;
}
default:
z = -1;
break;
}
switch (z) {
case false:
if (__event.getAction() == 0) {
UberController.this.a(__v, (Boolean) true);
break;
} else if (__event.getAction() == 1 || __event.getAction() == 3) {
UberController.this.a(__v, (Boolean) false);
break;
} else if (__event.getAction() == 2) {
UberController.this.a(__v, Boolean.valueOf(__v.canScrollHorizontally(-1)));
break;
}
break;
}
return false;
}
}
public UberController(JuspayBrowserFragment browserFragment) {
this.d = browserFragment;
if (!SessionInfo.getInstance().j() && WebLabService.getInstance().isEnabled("init_uber_on_start")) {
j();
}
l();
}
private void j() {
GodelTracker.getInstance().h("uber_initialized");
if (this.i == null) {
this.i = new JuspayWebView(this.d.c());
}
a(this.i);
}
private void k() {
if (this.e == null) {
Dialog dialog = new Dialog(this.d.c());
this.e = dialog;
dialog.requestWindowFeature(1);
this.e.setCancelable(true);
if (this.i.getParent() != null) {
((ViewGroup) this.i.getParent()).removeView(this.i);
}
this.e.setContentView(this.i);
this.e.setOnDismissListener(new JuspayDialogInterface("CREATE_UBER_DIALOG"));
}
}
private void l() {
this.g = (FloatingActionButton) this.d.j().findViewById(R.id.uber_float_btn);
}
public JuspayWebView a() {
Uber uber = this.b;
if (uber != null) {
return uber.a();
}
return null;
}
public Uber b() {
return this.b;
}
private void m() {
SlidingLayer slidingLayer = new SlidingLayer(this.d.c());
this.f = slidingLayer;
a(slidingLayer, -1, -1);
if (this.i.getParent() != null) {
((ViewGroup) this.i.getParent()).removeView(this.i);
}
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
layoutParams.addRule(3, R.id.uber_progressbar);
this.i.setLayoutParams(layoutParams);
((RelativeLayout) this.f.getContent().findViewById(R.id.uber_view)).addView(this.i);
this.h = (ProgressBar) this.f.getContent().findViewById(R.id.uber_progressbar);
}
public void a(String str, JSONObject jSONObject, String str2) {
d();
if (this.i == null) {
j();
}
try {
if (jSONObject != null) {
String optString = jSONObject.optString(WebViewManager.EVENT_TYPE_KEY, null);
UberType a = UberType.a(optString);
if (a == null) {
GodelTracker.getInstance().h("Illegal uberType " + optString);
return;
}
this.b = new Uber(str, a(a), jSONObject, str2);
a(this.i, this.d);
a(this.b);
return;
}
GodelTracker.getInstance().h("Empty properties in showUber");
} catch (Exception e) {
JuspayLogger.b(c, "Illegal uber type " + ((String) null), e);
}
}
public static void a(WebView webView, JuspayBrowserFragment juspayBrowserFragment) {
juspayBrowserFragment.a("if(document.body){document.body.scrollTop=1;document.body.scrollTop=0;}", webView);
if (webView.getContext() != null) {
String readFromFile = AssetService.getInstance().readFromFile(webView.getContext().getString(R.string.uber_filename), webView.getContext());
if (GodelTracker.getInstance().l() == null) {
GodelTracker.getInstance().d(EncryptionHelper.a().b(readFromFile));
}
JuspayLogger.f(c, "Hash of inserted uber min script : " + GodelTracker.getInstance().l());
juspayBrowserFragment.a(readFromFile, webView);
}
}
public JuspayWebView a(UberType uberType) {
return this.i;
}
static class AnonymousClass3 {
static final int[] a;
static {
int[] iArr = new int[UberType.values().length];
a = iArr;
try {
iArr[UberType.SLIDING_UBER.ordinal()] = 1;
} catch (NoSuchFieldError e) {
}
try {
a[UberType.DIALOG.ordinal()] = 2;
} catch (NoSuchFieldError e2) {
}
}
}
public void a(Uber uber) {
if (uber != null) {
switch (AnonymousClass3.a[uber.q().ordinal()]) {
case 1:
m();
b(uber);
break;
case 2:
k();
c(uber);
break;
default:
GodelTracker.getInstance().h("invalid uberType " + uber.q());
break;
}
}
}
public void b(Uber uber) {
if (uber.q() == UberType.SLIDING_UBER) {
if (this.i != null) {
SlidingLayer slidingLayer = this.f;
if (slidingLayer != null) {
View findViewById = slidingLayer.getContent().findViewById(R.id.uber_view);
if (findViewById != null) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) findViewById.getLayoutParams();
layoutParams.width = (int) uber.m();
layoutParams.height = (int) uber.n();
layoutParams.gravity = uber.r();
findViewById.setLayoutParams(layoutParams);
}
this.f.setStickTo(uber.c());
if (uber.l()) {
e(uber);
return;
} else {
if (uber.k() && !this.f.b()) {
h();
return;
}
return;
}
}
GodelTracker.getInstance().h("slidingUber-null");
return;
}
GodelTracker.getInstance().h("slidingUberWebView-null");
}
}
public void a(boolean z) {
Dialog dialog;
SlidingLayer slidingLayer;
Uber uber = this.b;
if (uber != null) {
if (z) {
e(uber);
return;
}
if (uber.q() == UberType.SLIDING_UBER && (slidingLayer = this.f) != null) {
View findViewById = slidingLayer.getContent().findViewById(R.id.uber_view);
if (findViewById != null) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) findViewById.getLayoutParams();
layoutParams.width = (int) this.b.m();
layoutParams.height = (int) this.b.n();
layoutParams.gravity = this.b.r();
findViewById.setLayoutParams(layoutParams);
}
this.f.setStickTo(this.b.c());
if (!this.f.b()) {
h();
return;
}
return;
}
if (this.b.q() != UberType.DIALOG || (dialog = this.e) == null) {
return;
}
try {
dialog.getWindow().setLayout((int) this.b.b, (int) this.b.c);
this.e.show();
} catch (Exception e) {
JuspayLogger.b(c, "Error in showUberDialog ", e);
}
}
}
private void d(Uber uber) {
this.g.setOnClickListener(this);
}
public void e(Uber uber) {
if (this.g.getVisibility() == 8) {
this.g.setVisibility(0);
GodelTracker.getInstance().a(new Event().a(Event.Category.UBER).a(Event.Action.INFO).c(uber.p()).d("uber_float_button_shown"));
}
d(uber);
}
private void n() {
FloatingActionButton floatingActionButton = this.g;
if (floatingActionButton != null && floatingActionButton.getVisibility() == 0) {
this.g.setVisibility(8);
GodelTracker.getInstance().a(new Event().a(Event.Category.UBER).a(Event.Action.INFO).c(this.b.p()).d("uber_float_button_hidden"));
}
}
public void c(Uber uber) {
if (uber.q() == UberType.DIALOG && JuspayBrowserFragment.h != JuspayBrowserFragment.state.FINISHING) {
if (this.i != null) {
Dialog dialog = this.e;
if (dialog == null) {
GodelTracker.getInstance().h("slidingUber-null");
return;
}
try {
dialog.getWindow().setLayout((int) uber.b, (int) uber.c);
if (uber.l()) {
e(uber);
} else if (uber.k()) {
this.e.show();
}
return;
} catch (Exception e) {
GodelTracker.getInstance().h("Unable to set dimensions of dialog");
return;
}
}
GodelTracker.getInstance().h("slidingUberWebView-null");
}
}
public void c() {
JuspayWebView juspayWebView = this.i;
if (juspayWebView != null) {
new KeyValueStore(juspayWebView.getContext());
}
Uber uber = this.b;
if (uber != null) {
b(uber.q());
}
}
public void d() {
Uber uber = this.b;
if (uber != null) {
b(uber.q());
n();
}
Dialog dialog = this.e;
if (dialog != null) {
if (dialog.isShowing()) {
this.e.dismiss();
}
this.e.cancel();
}
}
public void e() {
d();
this.d = null;
JuspayWebView juspayWebView = this.i;
if (juspayWebView != null) {
juspayWebView.stopLoading();
this.i.removeAllViews();
this.i.clearHistory();
this.i.destroy();
this.i = null;
}
Dialog dialog = this.e;
if (dialog != null) {
if (dialog.isShowing()) {
this.e.dismiss();
}
this.e.cancel();
this.e = null;
}
}
public void b(UberType uberType) {
switch (AnonymousClass3.a[uberType.ordinal()]) {
case 1:
o();
break;
case 2:
p();
break;
default:
GodelTracker.getInstance().h("No uber match - dismissUber");
break;
}
}
public boolean a(String str) {
char c2;
switch (str.hashCode()) {
case -1332085432:
if (str.equals("dialog")) {
c2 = 0;
break;
}
c2 = 65535;
break;
case 1550049909:
if (str.equals("float_button")) {
c2 = 2;
break;
}
c2 = 65535;
break;
case 1839259499:
if (str.equals("sliding_uber")) {
c2 = 1;
break;
}
c2 = 65535;
break;
default:
c2 = 65535;
break;
}
switch (c2) {
case 0:
Dialog dialog = this.e;
if (dialog == null || !dialog.isShowing()) {
break;
}
break;
case 1:
SlidingLayer slidingLayer = this.f;
if (slidingLayer == null || !slidingLayer.b()) {
break;
}
break;
case 2:
FloatingActionButton floatingActionButton = this.g;
if (floatingActionButton == null || floatingActionButton.getVisibility() != 0) {
break;
}
break;
}
return false;
}
public boolean f() {
Dialog dialog = this.e;
if (dialog != null && dialog.isShowing()) {
return true;
}
SlidingLayer slidingLayer = this.f;
if (slidingLayer != null && slidingLayer.b()) {
return true;
}
FloatingActionButton floatingActionButton = this.g;
return floatingActionButton != null && floatingActionButton.getVisibility() == 0;
}
public String g() {
JSONObject s;
Uber uber = this.b;
if (uber != null && (s = uber.s()) != null) {
return s.toString();
}
return null;
}
private void o() {
SlidingLayer slidingLayer = this.f;
if (slidingLayer != null && slidingLayer.b()) {
h();
}
}
private void p() {
Dialog dialog = this.e;
if (dialog != null && dialog.isShowing()) {
this.e.dismiss();
GodelTracker.getInstance().a(new Event().a(Event.Category.UBER).a(Event.Action.INFO).c(this.b.p()).d("uber_dialog_hidden"));
}
}
public void h() {
if (this.f != null) {
Event c2 = new Event().a(Event.Category.UBER).a(Event.Action.INFO).c(this.b.p());
if (this.f.b()) {
c2.d("sliding_uber_hidden");
} else {
c2.d("sliding_uber_shown");
}
GodelTracker.getInstance().a(c2);
this.f.a();
}
}
private void a(SlidingLayer slidingLayer, int i, int i2) {
slidingLayer.setStickTo(-1);
slidingLayer.setShadowDrawable(R.drawable.juspay_uber_sliding_menu_shadow);
slidingLayer.a(R.layout.juspay_uber_menu, this.d.j());
slidingLayer.setOnInteractListener(this.a);
slidingLayer.a(this.d.c());
}
public void a(JuspayWebView juspayWebView) {
juspayWebView.getSettings().setJavaScriptEnabled(true);
juspayWebView.getSettings().setBuiltInZoomControls(false);
juspayWebView.getSettings().setDomStorageEnabled(true);
juspayWebView.addJavascriptInterface(new AcsInterface(this.d), "Gatekeeper");
juspayWebView.setWebViewClient(new UberWebViewClient(this.d));
juspayWebView.setLayerType(1, null);
juspayWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int progress) {
if (UberController.this.h == null) {
return;
}
if (!WebLabService.getInstance().isEnabled("uber_pbar")) {
if (UberController.this.h.getVisibility() == 0) {
UberController.this.h.setVisibility(8);
return;
}
return;
}
if (progress < 100 && UberController.this.h.getVisibility() == 8) {
UberController.this.h.setVisibility(0);
}
UberController.this.h.setProgress(progress);
if (progress == 100) {
UberController.this.h.setVisibility(8);
}
}
});
juspayWebView.loadDataWithBaseURL("file:///android_asset/juspay/", AssetService.getInstance().readFromFile(juspayWebView.getContext().getString(R.string.uber_html_filename), juspayWebView.getContext()), "text/html", "UTF-8", "load_home");
juspayWebView.setOnTouchListener(new JuspayWebViewSetup("UBER_WEBVIEW_SETUP"));
}
public void a(View view, Boolean bool) {
while (view.getParent() != null && (view.getParent() instanceof View)) {
if (view.getParent() instanceof SlidingLayer) {
view.getParent().requestDisallowInterceptTouchEvent(bool.booleanValue());
}
view = (View) view.getParent();
}
}
public void b(String str) {
if (str != null) {
if (str.equals("dismiss")) {
c();
} else if (str.equals("destroy")) {
d();
}
}
}
public void a(int i, int i2) {
JuspayBrowserFragment juspayBrowserFragment;
Uber uber = this.b;
if (uber != null && (juspayBrowserFragment = this.d) != null) {
uber.a(juspayBrowserFragment.a(i, false));
this.b.b(this.d.a(i2, true));
}
}
public void a(int i) {
Uber uber = this.b;
if (uber != null && this.d != null) {
uber.a(i);
}
}
public void b(int i) {
Uber uber = this.b;
if (uber != null && this.d != null) {
uber.b(i);
}
}
public class Uber {
private double b;
private double c;
private UberType d;
private String e;
private JuspayWebView q;
private String r;
private String f = UpiConstant.NONE;
private boolean g = false;
private boolean h = false;
private boolean i = false;
private String j = UpiConstant.NONE;
private String k = UpiConstant.NONE;
private String l = UpiConstant.NONE;
private String m = "dismiss";
private JSONObject n = null;
private String o = "transparent";
private int p = -1;
private int s = 48;
Uber(String eventName, JuspayWebView uberWebView, JSONObject properties, String data) {
this.e = eventName;
this.q = uberWebView;
this.r = data;
a(properties);
}
public JuspayWebView a() {
return this.q;
}
public String b() {
return this.j;
}
public int c() {
return this.p;
}
public void a(int i) {
this.p = i;
}
public String d() {
return this.m;
}
public String a(String str) {
JSONObject jSONObject = this.n;
return jSONObject != null ? jSONObject.optString(str, "dismiss") : "dismiss";
}
public String e() {
return this.o;
}
public void b(String str) {
this.o = str;
}
public String f() {
return this.r;
}
public JSONObject g() {
return this.n;
}
public String h() {
return this.k;
}
public String i() {
return this.l;
}
private void a(JSONObject jSONObject) {
if (jSONObject != null) {
try {
this.f = jSONObject.optString("onPageLoad", UpiConstant.NONE);
this.g = jSONObject.optBoolean("showFButtonOnDismiss", false);
this.h = jSONObject.optBoolean("showFButtonOnLoad", false);
this.i = jSONObject.optBoolean("showOnLoad", false);
this.d = UberType.a(jSONObject.optString(WebViewManager.EVENT_TYPE_KEY, null));
this.j = jSONObject.optString("onJsAlert", UpiConstant.NONE);
this.k = jSONObject.optString("onJsConfirm", UpiConstant.NONE);
this.l = jSONObject.optString("onJsPrompt", UpiConstant.NONE);
this.m = jSONObject.optString("onRetryOptionShown", "dismiss");
this.n = jSONObject.optJSONObject("onLoadFragment");
this.p = jSONObject.optInt("stickTo", -1);
b(jSONObject.optInt("gravity", 1));
b(jSONObject.optString("background", "transparent"));
} catch (Exception e) {
JuspayLogger.b(UberController.c, "Error while parsing uber properties", e);
return;
}
}
b(jSONObject);
}
private void b(JSONObject jSONObject) {
if (jSONObject == null) {
if (this.d == UberType.SLIDING_UBER) {
this.b = -1.0d;
this.c = -1.0d;
return;
} else {
if (this.d == UberType.DIALOG) {
this.b = 360.0d;
this.c = 220.0d;
return;
}
return;
}
}
if (this.d == UberType.SLIDING_UBER) {
this.b = UberController.this.d.a(jSONObject.optInt("width", -1), false);
this.c = UberController.this.d.a(jSONObject.optInt("height", -1), true);
} else if (this.d == UberType.DIALOG) {
this.b = UberController.this.d.a(jSONObject.optInt("width", 360), false);
this.c = UberController.this.d.a(jSONObject.optInt("height", 220), true);
}
}
public boolean j() {
return this.g;
}
public boolean k() {
return this.i;
}
public boolean l() {
return this.h;
}
public void a(double d) {
this.b = d;
}
public void b(double d) {
this.c = d;
}
public double m() {
return this.b;
}
public double n() {
return this.c;
}
public String o() {
return this.f;
}
public String p() {
return this.e;
}
public UberType q() {
return this.d;
}
public int r() {
return this.s;
}
public void b(int i) {
switch (i) {
case 1:
this.s = 48;
break;
case 2:
this.s = 5;
break;
case 3:
this.s = 80;
break;
case 4:
this.s = 3;
break;
}
}
public JSONObject s() {
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("showOnLoad", k());
jSONObject.put(WebViewManager.EVENT_TYPE_KEY, this.d.a());
jSONObject.put("showFButtonOnLoad", l());
jSONObject.put("showFButtonOnDismiss", j());
jSONObject.put("width", m());
jSONObject.put("height", n());
jSONObject.put("isShowing", UberController.this.a(q().c));
jSONObject.put("isShowingFButton", UberController.this.a("float_button"));
jSONObject.put("onPageLoad", o());
jSONObject.put("onJsAlert", b());
jSONObject.put("onJsConfirm", h());
jSONObject.put("onJsPrompt", i());
jSONObject.put("onRetryOptionShown", d());
jSONObject.put("onLoadFragment", g());
jSONObject.put("gravity", r());
jSONObject.put("stickTo", c());
jSONObject.put("background", UberController.this.b.e());
jSONObject.put("name", UberController.this.b.p());
jSONObject.put("data", UberController.this.b.f());
return jSONObject;
} catch (Exception e) {
JuspayLogger.b(UberController.c, "Error in getCurrentProperties ", e);
return null;
}
}
}
public enum UberType {
DIALOG("dialog"),
SLIDING_UBER("sliding_uber");
private final String c;
public String a() {
return this.c;
}
public static UberType a(String str) {
if (str != null) {
for (UberType uberType : values()) {
if (str.equalsIgnoreCase(uberType.c)) {
return uberType;
}
}
return null;
}
return null;
}
UberType(String uberType) {
this.c = uberType;
}
}
}