正在查看: xDrip+ v04633772025.07.16 应用的 XDripDreamService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: xDrip+ v04633772025.07.16 应用的 XDripDreamService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.eveningoutpost.dexdrip.utilitymodels;
import android.animation.TimeAnimator;
import android.content.Context;
import android.graphics.PointF;
import android.hardware.Sensor;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Handler;
import android.service.dreams.DreamService;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.eveningoutpost.dexdrip.BestGlucose;
import com.eveningoutpost.dexdrip.utilitymodels.ColorCache;
import com.eveningoutpost.dexdrip.utils.DexCollectionType;
public class XDripDreamService extends DreamService implements SensorEventListener {
private int graph_height;
private int graph_width;
private ImageView graphimage;
private Sensor gravitySensor;
private ImageView image;
private View inflatedLayout;
private boolean keep_running;
private Bouncer mBouncer;
private SensorManager mSensorManager;
private Handler mainHandler;
private boolean updated;
private boolean use_gravity;
private TextView widgetArrow;
private TextView widgetDelta;
private TextView widgetReadingAge;
private TextView widgetStatusLine;
private TextView widgetbg;
private float last_rotation = -1.0f;
private final Runnable mRunnable = new Runnable() {
@Override
public void run() {
if (!XDripDreamService.this.keep_running) {
Log.d("xDripDreamService", "Keep running false: exiting");
} else {
Log.d("xDripDreamService", "Runnable executing");
XDripDreamService.this.mainHandler.postDelayed(XDripDreamService.this.mRunnable, XDripDreamService.this.updateData());
}
}
};
@Override
public void onCreate() {
this.use_gravity = Pref.getBooleanDefaultFalse("daydream_use_gravity_sensor");
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
this.mainHandler = new Handler(getApplicationContext().getMainLooper());
setInteractive(false);
setScreenBright(false);
if (this.use_gravity) {
SensorManager sensorManager = (SensorManager) getSystemService("sensor");
this.mSensorManager = sensorManager;
this.gravitySensor = sensorManager.getDefaultSensor(9);
}
}
@Override
public void onDreamingStarted() {
super.onDreamingStarted();
if (this.use_gravity) {
this.mSensorManager.registerListener(this, this.gravitySensor, 3);
}
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int i = displayMetrics.widthPixels;
int i2 = displayMetrics.heightPixels;
double d = displayMetrics.densityDpi / 160.0f;
this.graph_width = (int) (230.0d * d);
this.graph_height = (int) (128.0d * d);
int i3 = (int) (180.0d * d);
int i4 = (int) (d * 100.0d);
Log.d("xDripDreamService", "Width: " + this.graph_width + " Height: " + this.graph_height);
if (this.graph_height >= i2) {
this.graph_height = i2 - 20;
}
if (this.graph_width >= i) {
this.graph_width = i - 20;
}
if (i4 >= i2) {
i4 = i2 - 20;
}
if (i3 >= i) {
i3 = i - 20;
}
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(this.graph_width, this.graph_height);
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(150, 150);
Bouncer bouncer = new Bouncer(this, this);
this.mBouncer = bouncer;
bouncer.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
this.mBouncer.setSpeed(0.1f);
this.graphimage = new ImageView(this);
updateGraph();
this.mBouncer.addView(this.graphimage, layoutParams);
ImageView imageView = new ImageView(this);
this.image = imageView;
imageView.setImageResource(2131230915);
this.image.setAlpha(0.3f);
this.mBouncer.addView(this.image, layoutParams2);
View inflate = LayoutInflater.from(this).inflate(2131493097, (ViewGroup) null, false);
this.inflatedLayout = inflate;
inflate.setBackgroundColor(0);
this.widgetbg = (TextView) this.inflatedLayout.findViewById(2131297200);
this.widgetArrow = (TextView) this.inflatedLayout.findViewById(2131297199);
this.widgetDelta = (TextView) this.inflatedLayout.findViewById(2131297201);
this.widgetStatusLine = (TextView) this.inflatedLayout.findViewById(2131297204);
this.widgetReadingAge = (TextView) this.inflatedLayout.findViewById(2131296883);
this.widgetbg.setAlpha(0.6f);
this.widgetArrow.setAlpha(0.6f);
this.widgetDelta.setAlpha(0.6f);
this.widgetReadingAge.setAlpha(0.6f);
this.keep_running = true;
if (!this.updated) {
this.mainHandler.post(this.mRunnable);
}
this.mBouncer.addView(this.inflatedLayout, new FrameLayout.LayoutParams(i3, i4));
setContentView(this.mBouncer);
try {
getWindow().setNavigationBarColor(-16777216);
getWindow().setStatusBarColor(-16777216);
} catch (Exception unused) {
}
}
@Override
public void onDreamingStopped() {
this.keep_running = false;
super.onDreamingStopped();
if (this.use_gravity) {
unregister_sensor_receiver();
}
}
private void unregister_sensor_receiver() {
try {
this.mSensorManager.unregisterListener(this);
} catch (Exception unused) {
Log.e("xDripDreamService", "Could not unregister gravity listener");
}
}
public long updateData() {
this.updated = true;
BestGlucose.DisplayGlucose displayGlucose = BestGlucose.getDisplayGlucose();
if (displayGlucose != null) {
this.widgetbg.setText(displayGlucose.spannableString(displayGlucose.unitized, true));
this.widgetArrow.setText(displayGlucose.isStale() ? "" : displayGlucose.spannableString(displayGlucose.delta_arrow, true));
this.widgetDelta.setText(displayGlucose.spannableString(displayGlucose.unitized_delta));
this.widgetReadingAge.setText(displayGlucose.minutesAgo(true));
this.widgetStatusLine.setText("");
long j = ((300000 - displayGlucose.mssince) % 60000) + 10000;
Log.d("xDripDreamService", "Time mod: " + j);
r2 = j > 1000 ? j : 60000L;
updateGraph();
}
return r2;
}
private void updateGraph() {
long currentTimeMillis = System.currentTimeMillis() + 300000;
this.graphimage.setImageBitmap(new BgSparklineBuilder(this).setBgGraphBuilder(new BgGraphBuilder(this, (currentTimeMillis - 10800000) - 600000, currentTimeMillis)).setWidthPx(this.graph_width).setHeightPx(this.graph_height).showHighLine().showLowLine().setStart(System.currentTimeMillis() - 10800000).showAxes(true).setBackgroundColor(ColorCache.getCol(ColorCache.X.color_notification_chart_background)).setShowFiltered(DexCollectionType.hasFiltered() && Pref.getBooleanDefaultFalse("show_filtered_curve")).build());
}
@Override
public void onSensorChanged(android.hardware.SensorEvent r7) {
throw new UnsupportedOperationException("Method not decompiled: com.eveningoutpost.dexdrip.utilitymodels.XDripDreamService.onSensorChanged(android.hardware.SensorEvent):void");
}
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
Log.d("xDripDreamService", "Accuracy: " + i);
}
public class Bouncer extends FrameLayout implements TimeAnimator.TimeListener {
private final TimeAnimator mAnimator;
private int mHeight;
private float mMaxSpeed;
private int mWidth;
public Bouncer(XDripDreamService xDripDreamService, Context context) {
this(xDripDreamService, context, null);
}
public Bouncer(XDripDreamService xDripDreamService, Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public Bouncer(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
TimeAnimator timeAnimator = new TimeAnimator();
this.mAnimator = timeAnimator;
timeAnimator.setTimeListener(this);
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
this.mAnimator.start();
}
@Override
public void onDetachedFromWindow() {
this.mAnimator.cancel();
super.onDetachedFromWindow();
}
@Override
public void addView(View view, ViewGroup.LayoutParams layoutParams) {
super.addView(view, layoutParams);
setupView(view);
}
@Override
protected void onSizeChanged(int i, int i2, int i3, int i4) {
super.onSizeChanged(i, i2, i3, i4);
this.mWidth = i - (i / 10);
this.mHeight = i2 - (i2 / 10);
for (int i5 = 0; i5 < getChildCount(); i5++) {
setupView(getChildAt(i5));
}
}
private void setupView(View view) {
PointF pointF = new PointF();
double random = (float) (Math.random() * 360.0d);
pointF.x = this.mMaxSpeed * ((float) Math.cos(random));
pointF.y = this.mMaxSpeed * ((float) Math.sin(random));
view.setTag(pointF);
view.setX((float) (Math.random() * (this.mWidth - Math.max(view.getWidth(), view.getHeight()))));
view.setY((float) (Math.random() * (this.mHeight - Math.max(view.getHeight(), view.getWidth()))));
}
@Override
public void onTimeUpdate(android.animation.TimeAnimator r9, long r10, long r12) {
throw new UnsupportedOperationException("Method not decompiled: com.eveningoutpost.dexdrip.utilitymodels.XDripDreamService.Bouncer.onTimeUpdate(android.animation.TimeAnimator, long, long):void");
}
public void setSpeed(float f) {
this.mMaxSpeed = f;
}
}
}