Closed zezung27 closed 1 year ago
if(listActions != null && listActions.size() > 0 && !template.equals("") && template.equals("MediaStyle")) { priorityMode = 3; } window.setCurrentProrityMode(priorityMode); if(priorityMode == 1 && !window.isExpandMedia() && priorityMode != 6) { // check if isexpandmedia -> not show window.updateList(notificationModal, priorityMode); window.handleIdleToMiniAnim(); } if(priorityMode == 3) { window.setCurrentMediaNoti(notificationModal); if(window.isExpandMedia()) { //update view window.addViewActionsToLayout(window.getLayoutListActionMedia(), notificationModal, true); } else { window.setUpMediaNoti(notificationModal); } } if(priorityMode == 4) { window.handleShowMiniCall(notificationModal); } if(priorityMode == 5) { window.showChronometerCall(notificationModal); } } @Override protected void onServiceConnected() { window = WindowPopup.getInstance(this); window.open(); }
@Override
public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
Log.d("DlAccessibilityService", "onAccessibilityEvent: " + accessibilityEvent);
}
@Override
public void onInterrupt() {
}
@Override
public void onCreate() {
super.onCreate();
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
lbm.registerReceiver(notiReceiver, new IntentFilter(Contanst.NOTI_INTENT_LOCAL_BROADCAST));
lbm.registerReceiver(notiReceiver, new IntentFilter(Contanst.REMOVE_NOTIFICATIONS));
lbm.registerReceiver(notiReceiver, new IntentFilter(Contanst.MINI_TO_EXPAND_MEDIA_LOCAL_BROADCAST));
lbm.registerReceiver(notiReceiver, new IntentFilter(Contanst.EXPAND_TO_MINI_MEDIA_LOCAL_BROADCAST));
}
@Override
public void onDestroy() {
super.onDestroy();
stopSelf();
if (this.notiReceiver != null) {
LocalBroadcastManager.getInstance(this).unregisterReceiver(this.notiReceiver);
}
}
// media
public long getMediaDuration() {
try {
long l = ((MediaController)((MediaSessionManager)this.getSystemService(Context.MEDIA_SESSION_SERVICE)).getActiveSessions(new ComponentName(this.getApplicationContext(), NotificationService.class)).get(0)).getMetadata().getLong(MediaMetadata.METADATA_KEY_DURATION);
return l;
}
catch (Exception exception) {
return 1L;
}
}
public long getMediaPosition() {
try {
long l = ((MediaController)((MediaSessionManager)this.getSystemService(Context.MEDIA_SESSION_SERVICE)).getActiveSessions(new ComponentName(this.getApplicationContext(), NotificationService.class)).get(0)).getPlaybackState().getPosition();
return l;
}
catch (Exception exception) {
return 0L;
}
}
}
package com.matcos.dynamicislandlight.core.service;
import android.accessibilityservice.AccessibilityService; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.media.MediaMetadata; import android.media.session.MediaController; import android.media.session.MediaSessionManager; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Parcelable; import android.util.Log; import android.view.accessibility.AccessibilityEvent;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.airbnb.lottie.L; import com.matcos.dynamicislandlight.core.service.modal.NotificationModal; import com.matcos.dynamicislandlight.utils.Contanst; import com.matcos.dynamicislandlight.utils.Utils;
import java.util.ArrayList;
public class MainAccessibilityService extends AccessibilityService { private WindowPopup window; private Handler mediaHandler = new Handler(); private Runnable mediaUpdateRunnable; int priorityMode = 0; BroadcastReceiver notiReceiver = new BroadcastReceiver(){ public void onReceive(Context context, Intent intent) { if (intent != null) { if(intent.getAction().equals(Contanst.NOTI_INTENT_LOCAL_BROADCAST)) { convertNotiData(intent); } if(intent.getAction().equals(Contanst.MINI_TO_EXPAND_MEDIA_LOCAL_BROADCAST)) { setUpProgressMedia(window.getCurrentMediaNoti()); } if(intent.getAction().equals(Contanst.EXPAND_TO_MINI_MEDIA_LOCAL_BROADCAST)) { mediaHandler.removeCallbacksAndMessages(null); } if(intent.getAction().equals(Contanst.REMOVE_NOTIFICATIONS)) { handleRemoveNotiData(intent); } } } };