Release 2.0.1Beta

This commit is contained in:
hyb1996
2017-03-19 16:21:07 +08:00
parent 85affed538
commit dd787236e7
110 changed files with 2428 additions and 4710 deletions

View File

@@ -81,7 +81,7 @@ public class AccessibilityWatchDogService extends AccessibilityService {
Log.v(TAG, "onAccessibilityEvent: " + event);
synchronized (mDelegates) {
for (Map.Entry<Integer, AccessibilityDelegate> entry : mDelegates.entrySet()) {
Log.v(TAG, "delegate: " + entry.getValue().getClass().getName());
//Log.v(TAG, "delegate: " + entry.getValue().getClass().getName());
if (entry.getValue().onAccessibilityEvent(this, event))
break;
}

View File

@@ -8,34 +8,35 @@ import android.content.IntentFilter;
import android.os.IBinder;
import android.support.annotation.Nullable;
import com.stardust.scriptdroid.external.notification.record.ActionRecordSwitchHandleService;
import com.stardust.scriptdroid.record.AccessibilityRecorderDelegate;
import com.stardust.scriptdroid.external.notification.record.AccessibilityActionRecordNotification;
import com.stardust.scriptdroid.record.Recorder;
import com.stardust.scriptdroid.record.accessibility.AccessibilityActionRecorder;
import com.stardust.scriptdroid.Pref;
import java.lang.ref.WeakReference;
import static com.stardust.scriptdroid.external.notification.record.ActionRecordSwitchView.STOPPED;
/**
* Created by Stardust on 2017/2/16.
*/
public class VolumeChangeListenService extends Service {
public class VolumeChangeObverseService extends Service {
private static final String ACTION_VOLUME_CHANGE = "android.media.VOLUME_CHANGED_ACTION";
private VolumeChangeReceiver mVolumeChangeReceiver;
private static WeakReference<VolumeChangeListenService> instance;
private static VolumeChangeObverseService instance;
public static void stopServiceIfNeeded() {
if (instance != null && instance.get() != null) {
instance.get().stopSelf();
if (instance != null) {
instance.stopSelf();
instance = null;
}
}
public static void startServiceIfNeeded(Context context) {
if (Pref.isRecordVolumeControlEnable() && (instance == null || instance.get() == null)) {
context.startService(new Intent(context, VolumeChangeListenService.class));
if (Pref.isRecordVolumeControlEnable() && instance == null) {
context.startService(new Intent(context, VolumeChangeObverseService.class));
}
}
@@ -43,10 +44,10 @@ public class VolumeChangeListenService extends Service {
@Override
public void onCreate() {
super.onCreate();
if (instance != null && instance.get() != null) {
instance.get().stopSelf();
if (instance != null) {
instance.stopSelf();
}
instance = new WeakReference<>(this);
instance = this;
mVolumeChangeReceiver = new VolumeChangeReceiver();
registerReceiver(mVolumeChangeReceiver, new IntentFilter(ACTION_VOLUME_CHANGE));
}
@@ -60,6 +61,7 @@ public class VolumeChangeListenService extends Service {
@Override
public void onDestroy() {
super.onDestroy();
instance = null;
unregisterReceiver(mVolumeChangeReceiver);
}
@@ -74,10 +76,10 @@ public class VolumeChangeListenService extends Service {
return;
}
mLastChangeMillis = System.currentTimeMillis();
if (AccessibilityRecorderDelegate.getInstance().getState() == STOPPED) {
ActionRecordSwitchHandleService.startRecord(VolumeChangeListenService.this);
if (AccessibilityActionRecorder.getInstance().getState() == Recorder.STATE_STOPPED) {
AccessibilityActionRecordNotification.startRecord(VolumeChangeObverseService.this);
} else {
ActionRecordSwitchHandleService.stopRecord(VolumeChangeListenService.this);
AccessibilityActionRecordNotification.stopRecord(VolumeChangeObverseService.this);
}
}
}