正在查看: Namma Yatri v3.3.7 应用的 WidgetService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Namma Yatri v3.3.7 应用的 WidgetService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package in.juspay.mobility.app;
import android.animation.ValueAnimator;
import android.app.ActivityManager;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.media.MediaPlayer;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Vibrator;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.google.android.material.progressindicator.LinearProgressIndicator;
import com.google.firebase.analytics.FirebaseAnalytics;
import in.juspay.hypersdk.core.PaymentConstants;
import in.juspay.mobility.app.WidgetService;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Queue;
import java.util.TimeZone;
import org.json.JSONObject;
public class WidgetService extends Service {
private static FirebaseAnalytics mFirebaseAnalytics;
private int LAYOUT_FLAG;
private Runnable animationRunnable;
private JSONObject data;
private View dismissRequest;
private JSONObject entity_payload;
private View floatingWidget;
private Handler handler;
private float height;
private ImageView imageClose;
private float mAngleToRotate;
private LinearProgressIndicator progressBar;
private View silentRideRequest;
private String widgetMessage;
private View widgetView;
private float width;
private WindowManager windowManager;
private int calculatedTime = 0;
private boolean isRemovingInProcess = false;
private final Queue<Intent> rideRequestQueue = new LinkedList();
private final Bundle params = new Bundle();
public class AnonymousClass1 implements View.OnTouchListener {
long actionDownTime;
float initialTouchX;
float initialTouchY;
int initialX;
int initialY;
boolean isCloseEnabled = false;
final WindowManager.LayoutParams val$widgetLayoutParams;
public AnonymousClass1(WindowManager.LayoutParams layoutParams) {
this.val$widgetLayoutParams = layoutParams;
}
public void lambda$onTouch$0(WindowManager.LayoutParams layoutParams, ValueAnimator valueAnimator) {
try {
layoutParams.x = Math.round(((Float) valueAnimator.getAnimatedValue()).floatValue());
WidgetService.this.windowManager.updateViewLayout(WidgetService.this.widgetView, layoutParams);
} catch (Exception e) {
e.printStackTrace();
}
}
public void lambda$onTouch$1(View view) {
view.setVisibility(8);
WidgetService.this.openMainActivity();
}
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
SharedPreferences sharedPreferences;
int action;
try {
view.performClick();
sharedPreferences = WidgetService.this.getApplicationContext().getSharedPreferences(WidgetService.this.getApplicationContext().getString(R.string.preference_file_key), 0);
action = motionEvent.getAction();
} catch (Exception e) {
e.printStackTrace();
}
if (action == 0) {
WidgetService.this.imageClose.setVisibility(8);
this.actionDownTime = Calendar.getInstance().getTimeInMillis();
WindowManager.LayoutParams layoutParams = this.val$widgetLayoutParams;
this.initialX = layoutParams.x;
this.initialY = layoutParams.y;
this.initialTouchX = motionEvent.getRawX();
this.initialTouchY = motionEvent.getRawY();
return true;
}
if (action != 1) {
if (action == 2) {
if (Calendar.getInstance().getTimeInMillis() - this.actionDownTime > 200 && sharedPreferences.getString(Utils.DRIVER_STATUS, "null").equals(Utils.DRIVER_STATUS_OFFLINE)) {
WidgetService.this.imageClose.setVisibility(0);
}
this.val$widgetLayoutParams.x = this.initialX + ((int) (motionEvent.getRawX() - this.initialTouchX));
this.val$widgetLayoutParams.y = this.initialY + ((int) (motionEvent.getRawY() - this.initialTouchY));
WidgetService.this.windowManager.updateViewLayout(WidgetService.this.widgetView, this.val$widgetLayoutParams);
if (this.val$widgetLayoutParams.y <= WidgetService.this.height * 0.85d || this.val$widgetLayoutParams.x <= WidgetService.this.width * 0.3d || this.val$widgetLayoutParams.x >= WidgetService.this.width * 0.55d) {
WidgetService.this.imageClose.setImageResource(R.drawable.ny_ic_close_transparent);
this.isCloseEnabled = false;
} else {
WidgetService.this.imageClose.setImageResource(R.drawable.ny_ic_close_filled_round);
Vibrator vibrator = (Vibrator) WidgetService.this.getSystemService("vibrator");
if (this.isCloseEnabled) {
if (Build.VERSION.SDK_INT >= 26) {
q6.b.a(vibrator, q6.c.a(50L, -1));
} else {
vibrator.vibrate(500L);
}
}
if (sharedPreferences.getString(Utils.DRIVER_STATUS, "null").equals(Utils.DRIVER_STATUS_OFFLINE)) {
this.isCloseEnabled = true;
}
}
return true;
}
return false;
}
WidgetService.this.imageClose.setVisibility(8);
if (this.isCloseEnabled) {
WidgetService.this.stopSelf();
} else {
ValueAnimator ofFloat = ValueAnimator.ofFloat(this.val$widgetLayoutParams.x, 0.0f);
ofFloat.setDuration(WidgetService.this.getResources().getInteger(R.integer.WIDGET_CORNER_ANIMATION_DURATION));
final WindowManager.LayoutParams layoutParams2 = this.val$widgetLayoutParams;
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
WidgetService.AnonymousClass1.this.lambda$onTouch$0(layoutParams2, valueAnimator);
}
});
ofFloat.start();
if (Math.abs(this.initialTouchX - motionEvent.getRawX()) < 5.0f && Math.abs(this.initialTouchY - motionEvent.getRawY()) < 5.0f) {
long timeBasedOnRamSize = WidgetService.this.getTimeBasedOnRamSize();
boolean z = !sharedPreferences.getString("ACTIVITY_STATUS", "null").equals("onDestroy");
boolean equals = sharedPreferences.getString("IS_RIDE_ACTIVE", "null").equals("true");
boolean equals2 = sharedPreferences.getString("MAPS_OPENED", "null").equals("true");
if (z && (equals2 || equals)) {
Handler handler = new Handler(Looper.getMainLooper());
WidgetService.this.minimizeApp();
final View loaderView = WidgetService.this.getLoaderView();
handler.postDelayed(new Runnable() {
@Override
public final void run() {
WidgetService.AnonymousClass1.this.lambda$onTouch$1(loaderView);
}
}, timeBasedOnRamSize);
} else {
WidgetService.this.openMainActivity();
}
}
}
return true;
}
}
private void addMessageToWidget(Intent intent) {
String str;
if (intent != null) {
this.widgetMessage = intent.getStringExtra(getResources().getString(R.string.WIDGET_MESSAGE));
str = intent.getStringExtra("sentBy");
} else {
str = null;
}
if (this.widgetMessage == null || this.windowManager == null) {
return;
}
final LinearLayout linearLayout = (LinearLayout) this.widgetView.findViewById(R.id.message_view_right);
TextView textView = (TextView) this.widgetView.findViewById(R.id.messageTextView_right_header);
TextView textView2 = (TextView) this.widgetView.findViewById(R.id.messageTextView_right);
linearLayout.setVisibility(0);
textView2.setText(this.widgetMessage);
if (str != null && textView != null) {
textView2.setVisibility(0);
textView.setText(str);
textView.setVisibility(0);
} else if (textView != null) {
textView.setVisibility(8);
}
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public final void run() {
WidgetService.this.lambda$addMessageToWidget$11(linearLayout, handler);
}
}, getResources().getInteger(R.integer.DURATION_OF_SHOWING_MESSAGE));
}
private void addWidgetToWindowManager() {
if (Settings.canDrawOverlays(this) && !getSharedPreferences(getString(R.string.preference_file_key), 0).getString(Utils.DRIVER_STATUS, Utils.DRIVER_STATUS_OFFLINE).equals(Utils.DRIVER_STATUS_OFFLINE)) {
float f = getResources().getDisplayMetrics().density;
if (Build.VERSION.SDK_INT >= 26) {
this.LAYOUT_FLAG = 2038;
} else {
this.LAYOUT_FLAG = 2002;
}
this.windowManager = (WindowManager) getSystemService("window");
this.widgetView = LayoutInflater.from(this).inflate(R.layout.floating_widget_layout, (ViewGroup) null);
DisplayMetrics displayMetrics = new DisplayMetrics();
this.windowManager.getDefaultDisplay().getRealMetrics(displayMetrics);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(-2, -2, this.LAYOUT_FLAG, 8, -3);
layoutParams.gravity = 8388659;
layoutParams.x = 16;
layoutParams.y = displayMetrics.heightPixels / 4;
WindowManager.LayoutParams layoutParams2 = new WindowManager.LayoutParams(-1, (int) ((50.0f * f) + 0.5f), this.LAYOUT_FLAG, 8, -3);
layoutParams2.gravity = 81;
ImageView imageView = new ImageView(this);
this.imageClose = imageView;
try {
imageView.setImageResource(R.drawable.ny_ic_close_transparent);
this.imageClose.setBackground(androidx.core.content.res.h.f(getResources(), R.drawable.widget_close_gradient, (Resources.Theme) null));
} catch (Exception e) {
android.util.Log.e("Exception in rendering Image", e.toString());
}
this.imageClose.setPadding(0, 0, 0, (int) ((f * 10.0f) + 0.5f));
this.imageClose.setVisibility(4);
this.windowManager.addView(this.imageClose, layoutParams2);
this.windowManager.addView(this.widgetView, layoutParams);
this.widgetView.setVisibility(0);
this.height = displayMetrics.heightPixels;
this.width = displayMetrics.widthPixels;
this.widgetView.setOnTouchListener(new AnonymousClass1(layoutParams));
}
}
private int calculateExpireTimer(String str, String str2) {
String[] split = str.split("T");
String[] split2 = str2.split("T");
if (!split[0].equals(split2[0])) {
return -1;
}
String[] split3 = split[1].split(":");
String[] split4 = split2[1].split(":");
split3[2] = split3[2].substring(0, 2);
split4[2] = split4[2].substring(0, 2);
int i = 3600;
int i2 = 0;
int i3 = 0;
for (int i4 = 0; i4 < split4.length; i4++) {
i3 += Integer.parseInt(split4[i4]) * i;
i2 += Integer.parseInt(split3[i4]) * i;
i /= 60;
}
int i5 = i2 - i3;
if (i5 >= 5) {
return i5 - 5;
}
return 0;
}
public View getLoaderView() {
View inflate = LayoutInflater.from(getApplicationContext()).inflate(R.layout.loader_mini, (ViewGroup) null);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(-2, -2, this.LAYOUT_FLAG, 8, -3);
ProgressBar progressBar = (ProgressBar) inflate.findViewById(R.id.loader);
inflate.setVisibility(0);
this.windowManager.addView(inflate, layoutParams);
RotateAnimation rotateAnimation = new RotateAnimation(0.0f, 360.0f, 1, 0.5f, 1, 0.5f);
rotateAnimation.setInterpolator(new LinearInterpolator());
rotateAnimation.setDuration(1000L);
rotateAnimation.setRepeatCount(-1);
progressBar.startAnimation(rotateAnimation);
return inflate;
}
public long getTimeBasedOnRamSize() {
((ActivityManager) getSystemService("activity")).getMemoryInfo(new ActivityManager.MemoryInfo());
double d = ((r0.totalMem / 1024.0d) / 1024.0d) / 1024.0d;
if (d >= 7.0d) {
return 1000L;
}
return (long) (((7.0d - d) * 500.0d) + 1000.0d);
}
private void hideViewWithAnimation(View view) {
if (view != null) {
view.animate().translationX(-1500.0f).setInterpolator(new r0.a()).setDuration(600L).start();
}
}
public void lambda$addMessageToWidget$11(final LinearLayout linearLayout, Handler handler) {
linearLayout.startAnimation(AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out));
handler.postDelayed(new Runnable() {
@Override
public final void run() {
linearLayout.setVisibility(8);
}
}, getResources().getInteger(R.integer.WIDGET_MESSAGE_ANIMATION_DURATION));
}
public void lambda$removeViewAndRequest$8() {
View view = this.silentRideRequest;
if (view == null || this.progressBar == null || this.dismissRequest == null) {
return;
}
view.setVisibility(8);
this.progressBar.setVisibility(8);
this.dismissRequest.setVisibility(8);
this.silentRideRequest = null;
this.progressBar = null;
this.dismissRequest = null;
this.calculatedTime = 0;
this.isRemovingInProcess = false;
this.handler.removeCallbacksAndMessages(null);
this.animationRunnable = null;
if (this.rideRequestQueue.size() <= 0 || this.rideRequestQueue.peek() == null) {
return;
}
showSilentNotification(this.rideRequestQueue.poll());
}
public void lambda$removeViewAndRequest$9(Intent intent) {
this.isRemovingInProcess = true;
View view = this.silentRideRequest;
if (view != null) {
view.animate().translationX(-1500.0f).setInterpolator(new r0.a()).setDuration(600L).start();
}
LinearProgressIndicator linearProgressIndicator = this.progressBar;
if (linearProgressIndicator != null) {
linearProgressIndicator.animate().translationX(-1500.0f).setInterpolator(new r0.a()).setDuration(600L).start();
}
rotationAnimation(this.floatingWidget, this.mAngleToRotate, 0.0f);
this.handler.postDelayed(this.animationRunnable, 700L);
boolean equals = getApplicationContext().getSharedPreferences(getApplicationContext().getString(R.string.preference_file_key), 0).getString("ACTIVITY_STATUS", "null").equals("onResume");
if (((intent == null || !intent.hasExtra("isForwardRequest")) ? null : Boolean.valueOf(intent.getBooleanExtra("isForwardRequest", false))).booleanValue() && equals) {
stopService(intent);
}
}
public void lambda$showSilentNotification$4(Intent intent, View view) {
if (this.data == null || this.entity_payload == null) {
return;
}
NotificationUtils.showAllocationNotification(getApplicationContext(), this.data, this.entity_payload, (intent == null || !intent.hasExtra("requestSource")) ? "" : intent.getStringExtra("requestSource"));
this.silentRideRequest.setVisibility(8);
this.progressBar.setVisibility(8);
this.dismissRequest.setVisibility(8);
this.calculatedTime = 0;
}
public void lambda$showSilentNotification$5(int i, ValueAnimator valueAnimator, ValueAnimator valueAnimator2) {
if (this.progressBar == null) {
valueAnimator.removeAllUpdateListeners();
valueAnimator.end();
return;
}
int intValue = ((Integer) valueAnimator2.getAnimatedValue()).intValue();
ViewGroup.LayoutParams layoutParams = this.progressBar.getLayoutParams();
if (intValue < i / 3 && intValue > i / 5) {
this.progressBar.setIndicatorColor(new int[]{getColor(R.color.yellow900)});
} else if (intValue < i / 5) {
this.progressBar.setIndicatorColor(new int[]{getColor(R.color.red900)});
} else {
this.progressBar.setIndicatorColor(new int[]{getColor(R.color.green900)});
}
layoutParams.width = intValue;
this.progressBar.setLayoutParams(layoutParams);
}
public void lambda$showSilentNotification$6() {
try {
final int width = (this.widgetView.getWidth() / 100) * 85;
int[] iArr = new int[100];
int i = 99;
for (int i2 = 1; i >= 0 && i2 <= 100; i2++) {
iArr[i] = (width / 100) * i2;
i--;
}
final ValueAnimator ofInt = ValueAnimator.ofInt(iArr);
ofInt.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
WidgetService.this.lambda$showSilentNotification$5(width, ofInt, valueAnimator);
}
});
ofInt.setDuration((this.calculatedTime + 1) * 1000);
ofInt.start();
} catch (Exception e) {
android.util.Log.e("WidgetService", "Error in showSilentNotification " + e);
mFirebaseAnalytics.c("Exception_in_showSilentNotification", (Bundle) null);
}
}
public void lambda$showSilentNotification$7(View view) {
View view2 = this.silentRideRequest;
if (view2 != null) {
view2.setVisibility(8);
}
LinearProgressIndicator linearProgressIndicator = this.progressBar;
if (linearProgressIndicator != null) {
linearProgressIndicator.setVisibility(8);
}
View view3 = this.dismissRequest;
if (view3 != null) {
view3.setVisibility(8);
}
this.silentRideRequest = null;
this.progressBar = null;
this.handler.removeCallbacksAndMessages(null);
this.animationRunnable = null;
this.calculatedTime = 0;
}
public void lambda$specialPickupNotification$0(ValueAnimator valueAnimator, ValueAnimator valueAnimator2) {
if (this.progressBar == null) {
valueAnimator.removeAllUpdateListeners();
valueAnimator.end();
return;
}
int intValue = ((Integer) valueAnimator2.getAnimatedValue()).intValue();
ViewGroup.LayoutParams layoutParams = this.progressBar.getLayoutParams();
this.progressBar.setIndicatorColor(new int[]{getColor(R.color.green900)});
layoutParams.width = intValue;
this.progressBar.setLayoutParams(layoutParams);
}
public void lambda$specialPickupNotification$1() {
try {
int width = (this.widgetView.getWidth() / 100) * 85;
int[] iArr = new int[100];
int i = 99;
for (int i2 = 1; i >= 0 && i2 <= 100; i2++) {
iArr[i] = (width / 100) * i2;
i--;
}
final ValueAnimator ofInt = ValueAnimator.ofInt(iArr);
ofInt.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
WidgetService.this.lambda$specialPickupNotification$0(ofInt, valueAnimator);
}
});
ofInt.setDuration(5000L);
ofInt.start();
} catch (Exception e) {
android.util.Log.e("WidgetService", "Error in specialPickupNotification " + e);
mFirebaseAnalytics.c("Exception_in_specialPickupNotification", (Bundle) null);
}
}
public void lambda$specialPickupNotification$2(View view) {
hideViewWithAnimation(this.dismissRequest);
View view2 = this.silentRideRequest;
if (view2 != null) {
view2.setVisibility(8);
}
LinearProgressIndicator linearProgressIndicator = this.progressBar;
if (linearProgressIndicator != null) {
linearProgressIndicator.setVisibility(8);
}
view.setVisibility(8);
}
public void lambda$specialPickupNotification$3(ImageView imageView) {
View view = this.silentRideRequest;
if (view != null) {
hideViewWithAnimation(view);
}
View view2 = this.silentRideRequest;
if (view2 != null) {
view2.setVisibility(8);
}
LinearProgressIndicator linearProgressIndicator = this.progressBar;
if (linearProgressIndicator != null) {
linearProgressIndicator.setVisibility(8);
}
View view3 = this.dismissRequest;
if (view3 != null) {
view3.setVisibility(8);
}
if (imageView != null) {
imageView.setVisibility(0);
}
}
public void openMainActivity() {
Intent launchIntentForPackage = getPackageManager().getLaunchIntentForPackage(getPackageName());
launchIntentForPackage.addFlags(268566528);
getApplicationContext().startActivity(launchIntentForPackage);
stopSelf();
}
private void removeViewAndRequest(int i, final Intent intent) {
this.animationRunnable = new Runnable() {
@Override
public final void run() {
WidgetService.this.lambda$removeViewAndRequest$8();
}
};
this.handler.postDelayed(new Runnable() {
@Override
public final void run() {
WidgetService.this.lambda$removeViewAndRequest$9(intent);
}
}, i);
}
private void rotationAnimation(View view, float f, float f2) {
if (view != null) {
RotateAnimation rotateAnimation = new RotateAnimation(f, f2, 1, 0.5f, 1, 0.5f);
rotateAnimation.setDuration(600L);
rotateAnimation.setInterpolator(getApplicationContext(), android.R.interpolator.accelerate_decelerate);
view.startAnimation(rotateAnimation);
}
}
private void showSilentNotification(final Intent intent) {
String str;
if (this.widgetView == null) {
return;
}
this.animationRunnable = null;
mFirebaseAnalytics = FirebaseAnalytics.getInstance(getApplicationContext());
try {
TextView textView = (TextView) this.widgetView.findViewById(R.id.ride_fare);
TextView textView2 = (TextView) this.widgetView.findViewById(R.id.distance_to_pickup);
ImageView imageView = (ImageView) this.widgetView.findViewById(R.id.dot_view);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", new Locale("en"));
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
String format = simpleDateFormat.format(new Date());
if (intent != null) {
this.entity_payload = new JSONObject(intent.getStringExtra(PaymentConstants.PAYLOAD));
String stringExtra = intent.hasExtra("data") ? intent.getStringExtra("data") : null;
this.data = stringExtra != null ? new JSONObject(stringExtra) : null;
}
JSONObject jSONObject = this.entity_payload;
if (jSONObject == null || !jSONObject.has("baseFare")) {
return;
}
System.out.println("PAYLOAD + PAYLIAD " + this.entity_payload);
MediaPlayer create = MediaPlayer.create(getApplicationContext(), R.raw.silent_mode_notification_sound);
if (create != null) {
create.start();
}
int i = this.entity_payload.getInt("baseFare");
int i2 = this.entity_payload.getInt("distanceToPickup");
int calculateExpireTimer = calculateExpireTimer(this.entity_payload.getString("searchRequestValidTill"), format);
this.calculatedTime = calculateExpireTimer;
int min = Math.min(calculateExpireTimer, 30);
this.calculatedTime = min;
if (min < 0) {
min = 20;
}
this.calculatedTime = min;
DecimalFormat decimalFormat = new DecimalFormat();
decimalFormat.setMaximumFractionDigits(2);
textView.setText(getApplicationContext().getSharedPreferences(getApplicationContext().getString(R.string.preference_file_key), 0).getString("CURRENCY", "₹") + i);
textView.setTextSize(20.0f);
if (i2 > 1000) {
str = decimalFormat.format(i2 / 1000) + " km pickup";
} else {
str = i2 + " m pickup";
}
textView2.setText(str);
textView2.setVisibility(0);
imageView.setVisibility(0);
View findViewById = this.widgetView.findViewById(R.id.silent_ride_request_background);
this.silentRideRequest = findViewById;
if (findViewById != null) {
showViewWithAnimation(findViewById);
this.silentRideRequest.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WidgetService.this.lambda$showSilentNotification$4(intent, view);
}
});
}
View findViewById2 = this.widgetView.findViewById(R.id.dismiss_silent_reqID);
this.dismissRequest = findViewById2;
if (findViewById2 != null) {
showViewWithAnimation(findViewById2);
}
LinearProgressIndicator findViewById3 = this.widgetView.findViewById(R.id.silent_progress_indicator);
this.progressBar = findViewById3;
if (findViewById3 != null) {
showViewWithAnimation(findViewById3);
this.progressBar.setIndicatorColor(new int[]{getColor(R.color.green900)});
}
View findViewById4 = this.widgetView.findViewById(R.id.floating_logo);
this.floatingWidget = findViewById4;
this.mAngleToRotate = 360.0f;
rotationAnimation(findViewById4, 0.0f, 360.0f);
this.widgetView.post(new Runnable() {
@Override
public final void run() {
WidgetService.this.lambda$showSilentNotification$6();
}
});
this.handler = new Handler();
removeViewAndRequest(this.calculatedTime * 1000, intent);
this.dismissRequest.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WidgetService.this.lambda$showSilentNotification$7(view);
}
});
mFirebaseAnalytics.c("ny_silent_ride_request", this.params);
RideRequestUtils.addRideReceivedEvent(this.entity_payload, null, null, "silent_ride_request_popped", this);
} catch (Exception e) {
e.printStackTrace();
this.calculatedTime = 0;
FirebaseAnalytics firebaseAnalytics = mFirebaseAnalytics;
if (firebaseAnalytics != null) {
firebaseAnalytics.c("exception_ny_silent_ride_request", this.params);
}
}
}
private void showViewWithAnimation(View view) {
if (view != null) {
view.setVisibility(0);
view.setTranslationX(-1500.0f);
view.animate().translationX(0.0f).setInterpolator(new r0.a()).setDuration(600L).start();
}
}
private void specialPickupNotification(Intent intent, boolean z) {
View view = this.widgetView;
if (view == null || intent == null) {
return;
}
final ImageView imageView = (ImageView) view.findViewById(R.id.notification_dot);
if (!z) {
if (imageView != null) {
imageView.setVisibility(8);
return;
}
return;
}
try {
TextView textView = (TextView) this.widgetView.findViewById(R.id.ride_fare);
TextView textView2 = (TextView) this.widgetView.findViewById(R.id.distance_to_pickup);
ImageView imageView2 = (ImageView) this.widgetView.findViewById(R.id.dot_view);
MediaPlayer create = MediaPlayer.create(getApplicationContext(), R.raw.silent_mode_notification_sound);
if (create != null) {
create.start();
create.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public final void onCompletion(MediaPlayer mediaPlayer) {
mediaPlayer.release();
}
});
}
String stringExtra = intent.getStringExtra("specialPickupMessage");
if (textView != null && stringExtra != null && imageView != null) {
textView.setText(stringExtra);
textView.setVisibility(0);
textView.setTextSize(13.0f);
textView2.setVisibility(8);
imageView2.setVisibility(8);
}
View findViewById = this.widgetView.findViewById(R.id.silent_ride_request_background);
this.silentRideRequest = findViewById;
showViewWithAnimation(findViewById);
View findViewById2 = this.widgetView.findViewById(R.id.dismiss_silent_reqID);
this.dismissRequest = findViewById2;
showViewWithAnimation(findViewById2);
LinearProgressIndicator findViewById3 = this.widgetView.findViewById(R.id.silent_progress_indicator);
this.progressBar = findViewById3;
if (findViewById3 != null) {
findViewById3.setIndicatorColor(new int[]{getColor(R.color.green900)});
showViewWithAnimation(this.progressBar);
}
this.widgetView.post(new Runnable() {
@Override
public final void run() {
WidgetService.this.lambda$specialPickupNotification$1();
}
});
this.dismissRequest.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
WidgetService.this.lambda$specialPickupNotification$2(view2);
}
});
new Handler().postDelayed(new Runnable() {
@Override
public final void run() {
WidgetService.this.lambda$specialPickupNotification$3(imageView);
}
}, getResources().getInteger(R.integer.DURATION_OF_SHOWING_MESSAGE));
} catch (Exception e) {
android.util.Log.e("WidgetService", "Error in specialPickupNotification " + e);
mFirebaseAnalytics.c("Exception_in_specialPickupNotification", (Bundle) null);
}
}
public void minimizeApp() {
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.HOME");
intent.setFlags(268435456);
startActivity(intent);
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
addWidgetToWindowManager();
}
@Override
public void onDestroy() {
super.onDestroy();
View view = this.widgetView;
if (view != null) {
this.windowManager.removeView(view);
this.widgetView = null;
}
ImageView imageView = this.imageClose;
if (imageView != null) {
this.windowManager.removeView(imageView);
this.imageClose = null;
}
this.rideRequestQueue.clear();
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
if (getSharedPreferences(getString(R.string.preference_file_key), 0).getString(Utils.DRIVER_STATUS, Utils.DRIVER_STATUS_OFFLINE).equals(Utils.DRIVER_STATUS_OFFLINE)) {
return 2;
}
mFirebaseAnalytics = FirebaseAnalytics.getInstance(getApplicationContext());
getApplicationContext().getSharedPreferences(getApplicationContext().getString(R.string.preference_file_key), 0);
Boolean bool = null;
String stringExtra = (intent == null || !intent.hasExtra(getResources().getString(R.string.WIDGET_MESSAGE))) ? null : intent.getStringExtra(getResources().getString(R.string.WIDGET_MESSAGE));
if (intent != null && intent.hasExtra("showNearbySpecialPickup")) {
bool = Boolean.valueOf(intent.getBooleanExtra("showNearbySpecialPickup", false));
}
if (bool != null) {
specialPickupNotification(intent, bool.booleanValue());
return 1;
}
if (intent != null && this.calculatedTime == 0 && stringExtra == null && this.animationRunnable == null) {
showSilentNotification(intent);
return 1;
}
if (stringExtra != null && stringExtra.equals("CLEAR_FARE") && this.silentRideRequest != null && this.progressBar != null && this.dismissRequest != null && this.handler != null) {
removeViewAndRequest(0, intent);
return 1;
}
if (this.isRemovingInProcess || this.animationRunnable != null) {
this.rideRequestQueue.offer(intent);
return 1;
}
if (stringExtra == null || stringExtra.equals("CLEAR_FARE")) {
return 1;
}
addMessageToWidget(intent);
return 1;
}
}