正在查看: xDrip+ v04633772025.07.16 应用的 MegaStatus.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: xDrip+ v04633772025.07.16 应用的 MegaStatus.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.eveningoutpost.dexdrip;
import android.R;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import androidx.appcompat.R$id;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.viewpager.widget.ViewPager;
import com.eveningoutpost.dexdrip.insulin.inpen.InPenEntry;
import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.services.DexCollectionService;
import com.eveningoutpost.dexdrip.services.G5BaseService;
import com.eveningoutpost.dexdrip.ui.helpers.FloatingLocaleActivityWithScreenshot;
import com.eveningoutpost.dexdrip.utilitymodels.JamorhamShowcaseDrawer;
import com.eveningoutpost.dexdrip.utilitymodels.PersistentStore;
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
import com.eveningoutpost.dexdrip.utilitymodels.ShotStateStore;
import com.eveningoutpost.dexdrip.utilitymodels.StatusItem;
import com.eveningoutpost.dexdrip.utils.DexCollectionType;
import com.eveningoutpost.dexdrip.watch.lefun.LeFunEntry;
import com.eveningoutpost.dexdrip.watch.miband.MiBandEntry;
import com.eveningoutpost.dexdrip.watch.thinjam.BlueJayEntry;
import com.eveningoutpost.dexdrip.wearintegration.WatchUpdaterService;
import com.github.amlcurran.showcaseview.ShowcaseView;
import com.github.amlcurran.showcaseview.targets.ViewTarget;
import com.google.android.gms.wearable.DataMap;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
public class MegaStatus extends FloatingLocaleActivityWithScreenshot {
private static ArrayList<MegaStatusListAdapter> MegaStatusAdapters = null;
private static boolean activityVisible = false;
private static boolean autoFreshRunning = false;
private static Runnable autoRunnable;
private static int currentPage;
private static Activity mActivity;
public static View runnableView;
private static final HashSet<String> sectionAlwaysOn;
private static final ArrayList<String> sectionList = new ArrayList<>();
private static final ArrayList<String> sectionTitles = new ArrayList<>();
private boolean autoStart = false;
private Integer color_store1;
private int gravity_store_1;
private SectionsPagerAdapter mSectionsPagerAdapter;
private ViewPager mViewPager;
private int padding_store_bottom_1;
private int padding_store_left_1;
private int padding_store_right_1;
private int padding_store_top_1;
private BroadcastReceiver serviceDataReceiver;
@Override
public String getMenuName() {
return "Mega Status";
}
static {
HashSet<String> hashSet = new HashSet<>();
sectionAlwaysOn = hashSet;
MegaStatusAdapters = new ArrayList<>();
hashSet.add("Dex Status");
}
private void addAsection(String str, String str2) {
sectionList.add(str);
sectionTitles.add(str2);
MegaStatusAdapters.add(new MegaStatusListAdapter());
}
public static PendingIntent getStatusPendingIntent(String str) {
Intent intent = new Intent(xdrip.getAppContext(), (Class<?>) MegaStatus.class);
intent.setAction(str);
return PendingIntent.getActivity(xdrip.getAppContext(), 0, intent, 134217728);
}
public static void startStatus(String str) {
try {
getStatusPendingIntent(str).send();
} catch (PendingIntent.CanceledException e) {
UserError.Log.e("MegaStatus", "Unable to start status: " + e);
}
}
private void populateSectionList() {
if (sectionList.isEmpty()) {
addAsection("Classic Status Page", "Legacy System Status");
DexCollectionType dexCollectionType = DexCollectionType.getDexCollectionType();
if (DexCollectionType.usesDexCollectionService(dexCollectionType)) {
addAsection("BT Device", "Bluetooth Collector Status");
}
if (dexCollectionType.equals(DexCollectionType.DexcomG5)) {
addAsection("Dex Status", "Dex Collector/Transmitter Status");
} else if (dexCollectionType.equals(DexCollectionType.Medtrum)) {
addAsection("Medtrum Status", "Medtrum A6 Status");
}
if (BlueJayEntry.isEnabled()) {
addAsection("BlueJay", "BlueJay Watch Status");
}
if (DexCollectionType.getDexCollectionType() == DexCollectionType.LibreReceiver) {
addAsection("Libre2", "Libre Patched App Status");
}
if (DexCollectionType.hasWifi()) {
addAsection("IP Collector", dexCollectionType == DexCollectionType.Mock ? "FAKE / MOCK DATA SOURCE" : "Wifi Wixel / Parakeet Status");
}
if (InPenEntry.isEnabled()) {
addAsection("InPen", "InPen Status");
}
if (Home.get_master_or_follower()) {
addAsection("Followers", "xDrip+ Sync Group");
}
if (Pref.getBooleanDefaultFalse("cloud_storage_mongodb_enable") || Pref.getBooleanDefaultFalse("cloud_storage_api_enable") || Pref.getBooleanDefaultFalse("share_upload") || (Pref.getBooleanDefaultFalse("wear_sync") && Home.get_engineering_mode())) {
addAsection("Uploaders", "Cloud Uploader Queues");
}
if (LeFunEntry.isEnabled()) {
addAsection("Lefun", "Lefun Watch Status");
}
if (MiBandEntry.isEnabled()) {
addAsection("MiBand", "MiBand Watch Status");
}
if (dexCollectionType.equals(DexCollectionType.NSFollow)) {
addAsection("Nightscout Follow", "Nightscout Follow Status");
}
if (dexCollectionType.equals(DexCollectionType.SHFollow)) {
addAsection("Dex Share Follow", "Dex Share Follow Status");
}
if (dexCollectionType.equals(DexCollectionType.WebFollow)) {
addAsection("Web Follower", "Web Follower Status");
}
if (dexCollectionType.equals(DexCollectionType.CLFollow)) {
addAsection("CareLink Follow", "CareLink Follow Status");
return;
}
return;
}
UserError.Log.d("MegaStatus", "Section list already populated");
}
public static void populate(com.eveningoutpost.dexdrip.MegaStatus.MegaStatusListAdapter r3, java.lang.String r4) {
throw new UnsupportedOperationException("Method not decompiled: com.eveningoutpost.dexdrip.MegaStatus.populate(com.eveningoutpost.dexdrip.MegaStatus$MegaStatusListAdapter, java.lang.String):void");
}
@Override
protected void onCreate(Bundle bundle) {
int indexOf;
super.onCreate(bundle);
mActivity = this;
setContentView(2131492925);
JoH.fixActionBar(this);
ArrayList<String> arrayList = sectionList;
arrayList.clear();
sectionTitles.clear();
populateSectionList();
this.mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
ViewPager viewPager = (ViewPager) findViewById(2131296520);
this.mViewPager = viewPager;
viewPager.setAdapter(this.mSectionsPagerAdapter);
int i = (int) PersistentStore.getLong("mega-status-last-page");
String action = getIntent().getAction();
if (action != null && action.length() > 0 && (indexOf = arrayList.indexOf(action)) > -1) {
i = indexOf;
}
if (i > 0 && i < arrayList.size()) {
currentPage = i;
this.mViewPager.setCurrentItem(i);
this.autoStart = true;
keepScreenOn(sectionAlwaysOn.contains(arrayList.get(currentPage)));
}
this.mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int i2) {
UserError.Log.d("MegaStatus", "Page selected: " + i2);
MegaStatus.runnableView = null;
int unused = MegaStatus.currentPage = i2;
MegaStatus.this.startAutoFresh();
MegaStatus.this.keepScreenOn(MegaStatus.sectionAlwaysOn.contains(MegaStatus.sectionList.get(MegaStatus.currentPage)));
PersistentStore.setLong("mega-status-last-page", MegaStatus.currentPage);
}
});
requestWearCollectorStatus();
this.serviceDataReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action2 = intent.getAction();
Bundle bundleExtra = intent.getBundleExtra("data");
if (bundleExtra != null) {
DataMap fromBundle = DataMap.fromBundle(bundleExtra);
UserError.Log.d("MegaStatus", "serviceDataReceiver onReceive:" + action2 + " :: " + fromBundle.getString("lastState", "") + " last_timestamp :: " + fromBundle.getLong("timestamp", 0L));
action2.hashCode();
if (action2.equals("com.eveningoutpost.dexdrip.BLUETOOTH_COLLECTION_SERVICE_UPDATE")) {
int i2 = AnonymousClass5.$SwitchMap$com$eveningoutpost$dexdrip$utils$DexCollectionType[DexCollectionType.getDexCollectionType().ordinal()];
if (i2 == 1) {
G5BaseService.setWatchStatus(fromBundle);
G5BaseService.setWatchStatus(fromBundle);
} else if (i2 != 2) {
DexCollectionService.setWatchStatus(fromBundle);
}
}
}
}
};
try {
getSupportActionBar().setSubtitle("0463377-2025.07.16");
fixElipsusAndSize(null);
} catch (Exception e) {
UserError.Log.e("MegaStatus", "Got exception trying to set subtitle: ", e);
}
}
static class AnonymousClass5 {
static final int[] $SwitchMap$com$eveningoutpost$dexdrip$utils$DexCollectionType;
static {
int[] iArr = new int[DexCollectionType.values().length];
$SwitchMap$com$eveningoutpost$dexdrip$utils$DexCollectionType = iArr;
try {
iArr[DexCollectionType.DexcomG5.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$eveningoutpost$dexdrip$utils$DexCollectionType[DexCollectionType.DexcomShare.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
private void fixElipsusAndSize(ViewGroup viewGroup) {
if (viewGroup == null) {
viewGroup = (ViewGroup) getWindow().getDecorView().findViewById(R.id.content).getRootView();
}
int childCount = viewGroup.getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = viewGroup.getChildAt(i);
if (childAt instanceof TextView) {
TextView textView = (TextView) childAt;
if (textView.getText().toString().contains("0463377-2025.07.16")) {
textView.setEllipsize(null);
float textSize = textView.getTextSize();
if (textSize > 10.0f) {
textView.setTextSize(Math.max(10.0f, textSize / 4.0f));
return;
}
return;
}
} else if (childAt instanceof ViewGroup) {
fixElipsusAndSize((ViewGroup) childAt);
}
}
}
public void requestWearCollectorStatus() {
if (Home.get_enable_wear()) {
if (DexCollectionType.getDexCollectionType().equals(DexCollectionType.DexcomG5)) {
Home.startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, "MegaStatus", "getBatteryStatusNow", G5BaseService.getBatteryStatusNow);
} else {
Home.startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, "MegaStatus");
}
}
}
@Override
public void onPause() {
activityVisible = false;
if (this.serviceDataReceiver != null) {
try {
LocalBroadcastManager.getInstance(xdrip.getAppContext()).unregisterReceiver(this.serviceDataReceiver);
} catch (IllegalArgumentException e) {
UserError.Log.e("MegaStatus", "broadcast receiver not registered", e);
}
}
runnableView = null;
mActivity = null;
super.onPause();
}
@Override
protected void onResume() {
mActivity = this;
super.onResume();
activityVisible = true;
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("com.eveningoutpost.dexdrip.BLUETOOTH_COLLECTION_SERVICE_UPDATE");
LocalBroadcastManager.getInstance(xdrip.getAppContext()).registerReceiver(this.serviceDataReceiver, intentFilter);
if (autoRunnable != null || this.autoStart) {
startAutoFresh();
}
if (sectionList.size() > 1) {
startupInfo();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (FloatingLocaleActivityWithScreenshot.localeString != null) {
return true;
}
getMenuInflater().inflate(2131558409, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 2131296336) {
Intent startActivityIntent = JoH.getStartActivityIntent(MegaStatus.class);
startActivityIntent.putExtra("FORCE_ACTIVITY_LANGUAGE", "en");
startActivityIntent.putExtra("SCREENSHOT_AND_EXIT", true);
FloatingLocaleActivityWithScreenshot.localeString = "en";
xdrip.getAppContext().startActivity(startActivityIntent);
return true;
}
return super.onOptionsItemSelected(menuItem);
}
private void startupInfo() {
if (ShotStateStore.hasShot(10)) {
return;
}
final ViewTarget viewTarget = new ViewTarget(2131296833, this);
JoH.runOnUiThreadDelayed(new Runnable() {
@Override
public void run() {
ShowcaseView build = new ShowcaseView.Builder(this).setTarget(viewTarget).setStyle(2131820768).setContentTitle("Swipe for Different Pages").setContentText("\nSwipe left and right to see different status tabs.\n\n").setShowcaseDrawer(new JamorhamShowcaseDrawer(MegaStatus.this.getResources(), MegaStatus.this.getTheme(), 300.0f, 130.0f, 255)).singleShot(10L).build();
build.setBackgroundColor(0);
build.show();
}
}, 1500L);
}
public void keepScreenOn(boolean z) {
try {
if (z) {
getWindow().addFlags(128);
} else {
getWindow().clearFlags(128);
}
} catch (Exception e) {
UserError.Log.d("MegaStatus", "Exception setting window flags: " + e);
}
}
public synchronized void startAutoFresh() {
if (autoFreshRunning) {
return;
}
this.autoStart = false;
if (autoRunnable == null) {
autoRunnable = new Runnable() {
@Override
public void run() {
try {
if (MegaStatus.activityVisible && MegaStatus.autoFreshRunning && MegaStatus.currentPage != 0) {
MegaStatus.populate((MegaStatusListAdapter) MegaStatus.MegaStatusAdapters.get(MegaStatus.currentPage), (String) MegaStatus.sectionList.get(MegaStatus.currentPage));
MegaStatus.this.requestWearCollectorStatus();
JoH.runOnUiThreadDelayed(MegaStatus.autoRunnable, 500L);
} else {
UserError.Log.d("MegaStatus", "AutoFresh shutting down");
boolean unused = MegaStatus.autoFreshRunning = false;
}
} catch (Exception e) {
UserError.Log.e("MegaStatus", "Exception in auto-fresh: " + e);
boolean unused2 = MegaStatus.autoFreshRunning = false;
}
}
};
}
autoFreshRunning = true;
JoH.runOnUiThreadDelayed(autoRunnable, 200L);
}
public static class PlaceholderFragment extends Fragment {
public static PlaceholderFragment newInstance(int i) {
PlaceholderFragment placeholderFragment = new PlaceholderFragment();
Bundle bundle = new Bundle();
bundle.putInt("section_number", i);
placeholderFragment.setArguments(bundle);
return placeholderFragment;
}
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
int i = getArguments().getInt("section_number");
View inflate = layoutInflater.inflate(2131492984, viewGroup, false);
TextView textView = (TextView) inflate.findViewById(2131296959);
ListView listView = (ListView) inflate.findViewById(2131296727);
UserError.Log.d("MegaStatus", "Setting Section " + i);
textView.setText((CharSequence) MegaStatus.sectionTitles.get(i));
listView.setAdapter((ListAdapter) MegaStatus.MegaStatusAdapters.get(i));
MegaStatus.populate((MegaStatusListAdapter) listView.getAdapter(), (String) MegaStatus.sectionList.get(i));
return inflate;
}
}
public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
public SectionsPagerAdapter(FragmentManager fragmentManager) {
super(fragmentManager);
}
@Override
public Fragment getItem(int i) {
if (i == 0) {
return new SystemStatusFragment();
}
return PlaceholderFragment.newInstance(i);
}
@Override
public int getCount() {
return MegaStatus.sectionList.size();
}
@Override
public CharSequence getPageTitle(int i) {
return (CharSequence) MegaStatus.sectionList.get(i);
}
}
static class ViewHolder {
LinearLayout layout;
TextView name;
TextView spacer;
TextView value;
ViewHolder() {
}
}
private class MegaStatusListAdapter extends BaseAdapter {
private LayoutInflater mInflator;
private ArrayList<StatusItem> statusRows = new ArrayList<>();
@Override
public long getItemId(int i) {
return i;
}
MegaStatusListAdapter() {
this.mInflator = MegaStatus.this.getLayoutInflater();
}
void addRow(StatusItem statusItem) {
this.statusRows.add(statusItem);
}
void addRows(List<StatusItem> list) {
Iterator<StatusItem> it = list.iterator();
while (it.hasNext()) {
addRow(it.next());
}
}
public void changed() {
notifyDataSetChanged();
}
public void clear(boolean z) {
this.statusRows.clear();
if (z) {
notifyDataSetChanged();
}
}
@Override
public int getCount() {
return this.statusRows.size();
}
@Override
public Object getItem(int i) {
return this.statusRows.get(i);
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
View view2;
ViewHolder viewHolder;
String str;
if (view == null) {
viewHolder = new ViewHolder();
view2 = this.mInflator.inflate(2131492998, (ViewGroup) null);
viewHolder.value = (TextView) view2.findViewById(2131297167);
viewHolder.name = (TextView) view2.findViewById(2131296798);
viewHolder.spacer = (TextView) view2.findViewById(R$id.spacer);
viewHolder.layout = (LinearLayout) view2.findViewById(2131296548);
view2.setTag(viewHolder);
if (MegaStatus.this.color_store1 == null) {
MegaStatus.this.color_store1 = Integer.valueOf(viewHolder.name.getCurrentTextColor());
MegaStatus.this.padding_store_bottom_1 = viewHolder.layout.getPaddingBottom();
MegaStatus.this.padding_store_top_1 = viewHolder.layout.getPaddingTop();
MegaStatus.this.padding_store_left_1 = viewHolder.layout.getPaddingLeft();
MegaStatus.this.padding_store_right_1 = viewHolder.layout.getPaddingRight();
MegaStatus.this.gravity_store_1 = viewHolder.name.getGravity();
}
} else {
ViewHolder viewHolder2 = (ViewHolder) view.getTag();
viewHolder2.spacer.setVisibility(0);
viewHolder2.name.setVisibility(0);
viewHolder2.value.setVisibility(0);
viewHolder2.name.setTextColor(MegaStatus.this.color_store1.intValue());
viewHolder2.layout.setPadding(MegaStatus.this.padding_store_left_1, MegaStatus.this.padding_store_top_1, MegaStatus.this.padding_store_right_1, MegaStatus.this.padding_store_bottom_1);
viewHolder2.name.setGravity(MegaStatus.this.gravity_store_1);
view2 = view;
viewHolder = viewHolder2;
}
final StatusItem statusItem = this.statusRows.get(i);
if (statusItem.name.equals("line-break")) {
viewHolder.spacer.setVisibility(8);
viewHolder.name.setVisibility(8);
viewHolder.value.setVisibility(8);
viewHolder.layout.setPadding(10, 10, 10, 10);
} else if (statusItem.name.equals("heading-break")) {
viewHolder.value.setVisibility(8);
viewHolder.spacer.setVisibility(8);
viewHolder.name.setText(statusItem.value);
viewHolder.name.setGravity(1);
viewHolder.name.setTextColor(Color.parseColor("#fff9c4"));
} else {
viewHolder.name.setText(statusItem.name);
viewHolder.value.setText(statusItem.value);
int color = statusItem.highlight.color();
viewHolder.value.setBackgroundColor(color);
viewHolder.spacer.setBackgroundColor(color);
viewHolder.name.setBackgroundColor(color);
view2.setOnClickListener(null);
if (statusItem.runnable != null && (str = statusItem.button_name) != null && str.equals("long-press")) {
MegaStatus.runnableView = view2;
view2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view3) {
try {
MegaStatus.this.runOnUiThread(statusItem.runnable);
} catch (Exception unused) {
}
}
});
} else {
view2.setLongClickable(false);
}
}
return view2;
}
}
}