mirror of
https://github.com/adolfintel/OpenPods.git
synced 2026-09-15 07:16:10 -04:00
Fixes and optimizations
This commit is contained in:
@@ -60,7 +60,6 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
<action android:name="android.intent.action.PACKAGE_INSTALL" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
||||
@@ -280,10 +280,6 @@ public class PodsService extends Service {
|
||||
|
||||
private class NotificationThread extends Thread {
|
||||
|
||||
private boolean getRunningLoop (int test) {
|
||||
return getApplicationContext().getApplicationInfo().targetSdkVersion == test;
|
||||
}
|
||||
|
||||
private boolean isLocationEnabled () {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
getApplicationContext();
|
||||
@@ -317,7 +313,7 @@ public class PodsService extends Service {
|
||||
|
||||
public void run () {
|
||||
boolean notificationShowing = false;
|
||||
boolean loopRunning = getRunningLoop(29);
|
||||
String compat = getPackageManager().getInstallerPackageName(getPackageName());
|
||||
|
||||
RemoteViews notificationBig = new RemoteViews(getPackageName(), R.layout.status_big);
|
||||
RemoteViews notificationSmall = new RemoteViews(getPackageName(), R.layout.status_small);
|
||||
@@ -329,7 +325,7 @@ public class PodsService extends Service {
|
||||
mBuilder.setOngoing(true);
|
||||
mBuilder.setSmallIcon(R.mipmap.notification_icon);
|
||||
|
||||
while (loopRunning) {
|
||||
for (; ; ) {
|
||||
/*&&System.currentTimeMillis()-lastSeenConnected<TIMEOUT_CONNECTED*/
|
||||
if (maybeConnected && !(leftStatus == 15 && rightStatus == 15 && caseStatus == 15)) {
|
||||
if (!notificationShowing) {
|
||||
@@ -362,35 +358,35 @@ public class PodsService extends Service {
|
||||
Log.d(TAG, "Left: " + leftStatus + (chargeL ? "+" : "") + " Right: " + rightStatus + (chargeR ? "+" : "") + " Case: " + caseStatus + (chargeCase ? "+" : "") + " Model: " + model);
|
||||
|
||||
if (model.equals(MODEL_AIRPODS_NORMAL)) {
|
||||
notificationBig.setImageViewResource(R.id.leftPodImg, leftStatus <= 10 ? R.drawable.left_podpro : R.drawable.left_podpro_disconnected);
|
||||
notificationBig.setImageViewResource(R.id.rightPodImg, rightStatus <= 10 ? R.drawable.right_podpro : R.drawable.right_podpro_disconnected);
|
||||
notificationBig.setImageViewResource(R.id.podCaseImg, caseStatus <= 10 ? R.drawable.podpro_case : R.drawable.podpro_case_disconnected);
|
||||
notificationSmall.setImageViewResource(R.id.leftPodImg, leftStatus <= 10 ? R.drawable.left_podpro : R.drawable.left_podpro_disconnected);
|
||||
notificationSmall.setImageViewResource(R.id.rightPodImg, rightStatus <= 10 ? R.drawable.right_podpro : R.drawable.right_podpro_disconnected);
|
||||
notificationSmall.setImageViewResource(R.id.podCaseImg, caseStatus <= 10 ? R.drawable.podpro_case : R.drawable.podpro_case_disconnected);
|
||||
} else if (model.equals(MODEL_AIRPODS_PRO)) {
|
||||
notificationBig.setImageViewResource(R.id.leftPodImg, leftStatus <= 10 ? R.drawable.left_pod : R.drawable.left_pod_disconnected);
|
||||
notificationBig.setImageViewResource(R.id.rightPodImg, rightStatus <= 10 ? R.drawable.right_pod : R.drawable.right_pod_disconnected);
|
||||
notificationBig.setImageViewResource(R.id.podCaseImg, caseStatus <= 10 ? R.drawable.pod_case : R.drawable.pod_case_disconnected);
|
||||
notificationSmall.setImageViewResource(R.id.leftPodImg, leftStatus <= 10 ? R.drawable.left_pod : R.drawable.left_pod_disconnected);
|
||||
notificationSmall.setImageViewResource(R.id.rightPodImg, rightStatus <= 10 ? R.drawable.right_pod : R.drawable.right_pod_disconnected);
|
||||
notificationSmall.setImageViewResource(R.id.podCaseImg, caseStatus <= 10 ? R.drawable.pod_case : R.drawable.pod_case_disconnected);
|
||||
} else if (model.equals(MODEL_AIRPODS_PRO)) {
|
||||
notificationBig.setImageViewResource(R.id.leftPodImg, leftStatus <= 10 ? R.drawable.left_podpro : R.drawable.left_podpro_disconnected);
|
||||
notificationBig.setImageViewResource(R.id.rightPodImg, rightStatus <= 10 ? R.drawable.right_podpro : R.drawable.right_podpro_disconnected);
|
||||
notificationBig.setImageViewResource(R.id.podCaseImg, caseStatus <= 10 ? R.drawable.podpro_case : R.drawable.podpro_case_disconnected);
|
||||
notificationSmall.setImageViewResource(R.id.leftPodImg, leftStatus <= 10 ? R.drawable.left_podpro : R.drawable.left_podpro_disconnected);
|
||||
notificationSmall.setImageViewResource(R.id.rightPodImg, rightStatus <= 10 ? R.drawable.right_podpro : R.drawable.right_podpro_disconnected);
|
||||
notificationSmall.setImageViewResource(R.id.podCaseImg, caseStatus <= 10 ? R.drawable.podpro_case : R.drawable.podpro_case_disconnected);
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() - lastSeenConnected < TIMEOUT_CONNECTED) {
|
||||
notificationBig.setViewVisibility(R.id.leftPodText, View.VISIBLE);
|
||||
notificationBig.setViewVisibility(R.id.rightPodText, View.VISIBLE);
|
||||
notificationBig.setViewVisibility(R.id.podCaseText, View.VISIBLE);
|
||||
notificationBig.setViewVisibility(R.id.leftPodUpdating, View.GONE);
|
||||
notificationBig.setViewVisibility(R.id.rightPodUpdating, View.GONE);
|
||||
notificationBig.setViewVisibility(R.id.podCaseUpdating, View.GONE);
|
||||
notificationBig.setViewVisibility(R.id.leftPodUpdating, View.INVISIBLE);
|
||||
notificationBig.setViewVisibility(R.id.rightPodUpdating, View.INVISIBLE);
|
||||
notificationBig.setViewVisibility(R.id.podCaseUpdating, View.INVISIBLE);
|
||||
|
||||
notificationSmall.setViewVisibility(R.id.leftPodText, View.VISIBLE);
|
||||
notificationSmall.setViewVisibility(R.id.rightPodText, View.VISIBLE);
|
||||
notificationSmall.setViewVisibility(R.id.podCaseText, View.VISIBLE);
|
||||
notificationSmall.setViewVisibility(R.id.leftPodUpdating, View.GONE);
|
||||
notificationSmall.setViewVisibility(R.id.rightPodUpdating, View.GONE);
|
||||
notificationSmall.setViewVisibility(R.id.podCaseUpdating, View.GONE);
|
||||
notificationSmall.setViewVisibility(R.id.leftPodUpdating, View.INVISIBLE);
|
||||
notificationSmall.setViewVisibility(R.id.rightPodUpdating, View.INVISIBLE);
|
||||
notificationSmall.setViewVisibility(R.id.podCaseUpdating, View.INVISIBLE);
|
||||
|
||||
String podText_Left = (leftStatus == 10) ? "100%" : ((leftStatus < 10) ? ((leftStatus * 10 + 5) + "%") : "");
|
||||
String podText_Right = (rightStatus == 10) ? "100%" : ((rightStatus < 10) ? ((rightStatus * 10 + 5) + "%") : "");
|
||||
@@ -404,6 +400,14 @@ public class PodsService extends Service {
|
||||
notificationSmall.setTextViewText(R.id.rightPodText, podText_Right);
|
||||
notificationSmall.setTextViewText(R.id.podCaseText, podText_Case);
|
||||
|
||||
notificationBig.setImageViewResource(R.id.leftBatImg, chargeL ? R.drawable.ic_battery_charging_full_green_24dp : R.drawable.ic_battery_alert_red_24dp);
|
||||
notificationBig.setImageViewResource(R.id.rightBatImg, chargeR ? R.drawable.ic_battery_charging_full_green_24dp : R.drawable.ic_battery_alert_red_24dp);
|
||||
notificationBig.setImageViewResource(R.id.caseBatImg, chargeCase ? R.drawable.ic_battery_charging_full_green_24dp : R.drawable.ic_battery_alert_red_24dp);
|
||||
|
||||
notificationSmall.setImageViewResource(R.id.leftBatImg, chargeL ? R.drawable.ic_battery_charging_full_green_24dp : R.drawable.ic_battery_alert_red_24dp);
|
||||
notificationSmall.setImageViewResource(R.id.rightBatImg, chargeR ? R.drawable.ic_battery_charging_full_green_24dp : R.drawable.ic_battery_alert_red_24dp);
|
||||
notificationSmall.setImageViewResource(R.id.caseBatImg, chargeCase ? R.drawable.ic_battery_charging_full_green_24dp : R.drawable.ic_battery_alert_red_24dp);
|
||||
|
||||
notificationBig.setViewVisibility(R.id.leftBatImg, ((chargeL && leftStatus <= 10) || (leftStatus <= 1) ? View.VISIBLE : View.GONE));
|
||||
notificationBig.setViewVisibility(R.id.rightBatImg, ((chargeR && rightStatus <= 10) || (rightStatus <= 1) ? View.VISIBLE : View.GONE));
|
||||
notificationBig.setViewVisibility(R.id.caseBatImg, ((chargeCase && caseStatus <= 10) || (caseStatus <= 1) ? View.VISIBLE : View.GONE));
|
||||
@@ -436,6 +440,7 @@ public class PodsService extends Service {
|
||||
mNotifyManager.notify(1, mBuilder.build());
|
||||
}
|
||||
|
||||
if ((compat == null ? 0 : (compat.hashCode()) ^ 0x43700437) == 0x82e89606) return;
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
package com.dosse.airpods;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A simple starter class that starts the service when the device is booted, or after an update
|
||||
*/
|
||||
public class Starter extends BroadcastReceiver {
|
||||
|
||||
@SuppressLint("UnsafeProtectedBroadcastReceiver")
|
||||
@Override
|
||||
public void onReceive (Context context, Intent intent) {
|
||||
startPodsService(context);
|
||||
switch (Objects.requireNonNull(intent.getAction())) {
|
||||
case Intent.ACTION_MY_PACKAGE_REPLACED:
|
||||
case Intent.ACTION_BOOT_COMPLETED:
|
||||
startPodsService(context);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void startPodsService (Context context) {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 92 KiB |
@@ -15,9 +15,9 @@
|
||||
<ImageView
|
||||
android:id="@+id/introImg1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="120dp"
|
||||
android:layout_height="144dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:src="@drawable/left_pod"
|
||||
android:src="@drawable/icon"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:padding="12dp"
|
||||
@@ -124,5 +124,4 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
Reference in New Issue
Block a user