Skip to content

Commit

Permalink
Updated pro support
Browse files Browse the repository at this point in the history
  • Loading branch information
adolfintel committed Dec 27, 2019
1 parent 9a86e8f commit 2712033
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
25 changes: 13 additions & 12 deletions OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ public class PodsService extends Service {

private static BluetoothLeScanner btScanner;
private static int leftStatus=15, rightStatus=15, caseStatus=15;
private static boolean chargeL=false, chargeR=false, chargeCase=false,
pro=false; //todo: replace boolean switch for support of multiple models
private static boolean chargeL=false, chargeR=false, chargeCase=false;
private static final String MODEL_AIRPODS_NORMAL="airpods12", MODEL_AIRPODS_PRO="airpodspro";
private static String model=MODEL_AIRPODS_NORMAL;

/**
* The following method (startAirPodsScanner) creates a bluetoth LE scanner.
Expand Down Expand Up @@ -153,7 +154,7 @@ public void onScanResult(int callbackType, ScanResult result) {
chargeL = (chargeStatus & 0b00000001) != 0;
chargeR = (chargeStatus & 0b00000010) != 0;
chargeCase = (chargeStatus & 0b00000100) != 0;
pro = a.charAt(7)=='E'; //detect if these are AirPods pro or regular ones
if(a.charAt(7)=='E') model = MODEL_AIRPODS_PRO; else model = MODEL_AIRPODS_NORMAL; //detect if these are AirPods pro or regular ones
lastSeenConnected = System.currentTimeMillis();
} catch (Throwable t) {
if(ENABLE_LOGGING) Log.d(TAG, "" + t);
Expand Down Expand Up @@ -279,21 +280,21 @@ public void run(){
mBuilder.setCustomBigContentView(locationDisabledBig);
}
if(notificationShowing){
if(ENABLE_LOGGING) Log.d(TAG,"Left: "+leftStatus+(chargeL?"+":"")+" "+"Right: "+rightStatus+(chargeR?"+":"")+" "+"Case: "+caseStatus+(chargeCase?"+":"")+" "+"Pro: "+pro);
if(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);
}else {
if(ENABLE_LOGGING) 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_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);
Expand Down
Binary file modified OpenPods/app/src/main/res/drawable/left_podpro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OpenPods/app/src/main/res/drawable/right_podpro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 10 additions & 5 deletions OpenPods/app/src/main/res/layout/status_big.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
>

<ImageView
android:layout_width="30dp"
android:layout_width="40dp"
android:layout_height="90dp"
android:src="@drawable/left_pod"
android:id="@+id/leftPodImg"
android:layout_centerHorizontal="true"
android:layout_marginBottom="6dp"
/>

<TextView
Expand Down Expand Up @@ -55,10 +56,12 @@

<ImageView
android:id="@+id/rightPodImg"
android:layout_width="30dp"
android:layout_width="40dp"
android:layout_height="90dp"
android:layout_centerHorizontal="true"
android:src="@drawable/right_pod" />
android:src="@drawable/right_pod"
android:layout_marginBottom="6dp"
/>

<TextView
android:layout_width="match_parent"
Expand Down Expand Up @@ -91,10 +94,12 @@

<ImageView
android:id="@+id/podCaseImg"
android:layout_width="60dp"
android:layout_width="80dp"
android:layout_height="90dp"
android:layout_centerHorizontal="true"
android:src="@drawable/pod_case" />
android:src="@drawable/pod_case"
android:layout_marginBottom="6dp"
/>

<TextView
android:layout_width="match_parent"
Expand Down
6 changes: 3 additions & 3 deletions OpenPods/app/src/main/res/layout/status_small.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
>

<ImageView
android:layout_width="15dp"
android:layout_width="18dp"
android:layout_height="30dp"
android:src="@drawable/left_pod"
android:id="@+id/leftPodImg"
Expand Down Expand Up @@ -53,7 +53,7 @@
>

<ImageView
android:layout_width="15dp"
android:layout_width="18dp"
android:layout_height="30dp"
android:src="@drawable/right_pod"
android:id="@+id/rightPodImg"
Expand Down Expand Up @@ -90,7 +90,7 @@
>

<ImageView
android:layout_width="20dp"
android:layout_width="25dp"
android:layout_height="30dp"
android:src="@drawable/pod_case"
android:id="@+id/podCaseImg"
Expand Down

0 comments on commit 2712033

Please sign in to comment.