Phone Listener changed.
This commit is contained in:
parent
cddd8cfac5
commit
c926c85dd0
@ -220,7 +220,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
|
|
||||||
private boolean checkBeforeSaving(Context context, boolean changeExistingRule)
|
private boolean checkBeforeSaving(Context context, boolean changeExistingRule)
|
||||||
{
|
{
|
||||||
if(this.getName() == null | this.getName().length()==0)
|
if(this.getName() == null || this.getName().length()==0)
|
||||||
{
|
{
|
||||||
Toast.makeText(context, context.getResources().getString(R.string.pleaseEnterValidName), Toast.LENGTH_LONG).show();
|
Toast.makeText(context, context.getResources().getString(R.string.pleaseEnterValidName), Toast.LENGTH_LONG).show();
|
||||||
return false;
|
return false;
|
||||||
@ -415,13 +415,13 @@ public class Rule implements Comparable<Rule>
|
|||||||
&&
|
&&
|
||||||
Miscellaneous.compareTimes(nowTime, oneTrigger.getTimeFrame().getTriggerTimeStop()) > 0
|
Miscellaneous.compareTimes(nowTime, oneTrigger.getTimeFrame().getTriggerTimeStop()) > 0
|
||||||
)
|
)
|
||||||
|
|
||
|
||||||
// Other case, start time higher than end time, timeframe goes over midnight
|
// Other case, start time higher than end time, timeframe goes over midnight
|
||||||
(
|
(
|
||||||
Miscellaneous.compareTimes(oneTrigger.getTimeFrame().getTriggerTimeStart(), oneTrigger.getTimeFrame().getTriggerTimeStop()) < 0
|
Miscellaneous.compareTimes(oneTrigger.getTimeFrame().getTriggerTimeStart(), oneTrigger.getTimeFrame().getTriggerTimeStop()) < 0
|
||||||
&&
|
&&
|
||||||
(Miscellaneous.compareTimes(oneTrigger.getTimeFrame().getTriggerTimeStart(), nowTime) >= 0
|
(Miscellaneous.compareTimes(oneTrigger.getTimeFrame().getTriggerTimeStart(), nowTime) >= 0
|
||||||
|
|
||
|
||||||
Miscellaneous.compareTimes(nowTime, oneTrigger.getTimeFrame().getTriggerTimeStop()) > 0)
|
Miscellaneous.compareTimes(nowTime, oneTrigger.getTimeFrame().getTriggerTimeStop()) > 0)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -601,11 +601,11 @@ public class Rule implements Comparable<Rule>
|
|||||||
}
|
}
|
||||||
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.phoneCall))
|
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.phoneCall))
|
||||||
{
|
{
|
||||||
if(oneTrigger.getPhoneNumber().equals("any") | oneTrigger.getPhoneNumber().equals(PhoneStatusListener.getLastPhoneNumber()))
|
if(oneTrigger.getPhoneNumber().equals("any") || PhoneStatusListener.getLastPhoneNumber().matches(oneTrigger.getPhoneNumber()))
|
||||||
{
|
{
|
||||||
if(PhoneStatusListener.isInACall() == oneTrigger.getTriggerParameter())
|
if(PhoneStatusListener.isInACall() == oneTrigger.getTriggerParameter())
|
||||||
{
|
{
|
||||||
if(oneTrigger.getPhoneDirection() == 0 | (oneTrigger.getPhoneDirection() == PhoneStatusListener.getLastPhoneDirection()))
|
if(oneTrigger.getPhoneDirection() == 0 || (oneTrigger.getPhoneDirection() == PhoneStatusListener.getLastPhoneDirection()))
|
||||||
{
|
{
|
||||||
// Everything's allright
|
// Everything's allright
|
||||||
}
|
}
|
||||||
@ -622,7 +622,10 @@ public class Rule implements Comparable<Rule>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
Miscellaneous.logEvent("i", "Rule", "Rule doesn't apply. Wrong phone number. Demanded: " + oneTrigger.getPhoneNumber() + ", got: " + PhoneStatusListener.getLastPhoneNumber(), 4);
|
Miscellaneous.logEvent("i", "Rule", "Rule doesn't apply. Wrong phone number. Demanded: " + oneTrigger.getPhoneNumber() + ", got: " + PhoneStatusListener.getLastPhoneNumber(), 4);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.nfcTag))
|
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.nfcTag))
|
||||||
{
|
{
|
||||||
@ -916,7 +919,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
|
boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
|
||||||
boolean doToggle = ruleToggle && isActuallyToggable;
|
boolean doToggle = ruleToggle && isActuallyToggable;
|
||||||
|
|
||||||
if(notLastActive | force | doToggle)
|
if(notLastActive || force || doToggle)
|
||||||
{
|
{
|
||||||
String message;
|
String message;
|
||||||
if(!doToggle)
|
if(!doToggle)
|
||||||
@ -1069,7 +1072,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() > oneTrigger.getTimeFrame().getTriggerTimeStop().getTime())
|
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() > oneTrigger.getTimeFrame().getTriggerTimeStop().getTime())
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "Timeframe search", "Rule goes over midnight.", 5);
|
Miscellaneous.logEvent("i", "Timeframe search", "Rule goes over midnight.", 5);
|
||||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() | searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() || searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
||||||
{
|
{
|
||||||
ruleCandidates.add(oneRule);
|
ruleCandidates.add(oneRule);
|
||||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||||
|
@ -39,7 +39,7 @@ public class ActivityManageActionTriggerUrl extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
this.setContentView(R.layout.trigger_url_editor);
|
this.setContentView(R.layout.activity_manage_action_url_editor);
|
||||||
|
|
||||||
etTriggerUrl = (EditText)findViewById(R.id.etTriggerUrl);
|
etTriggerUrl = (EditText)findViewById(R.id.etTriggerUrl);
|
||||||
etTriggerUrlUsername = (EditText)findViewById(R.id.etTriggerUrlUsername);
|
etTriggerUrlUsername = (EditText)findViewById(R.id.etTriggerUrlUsername);
|
||||||
|
@ -47,7 +47,7 @@ public class ActivityManagePoi extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
this.setContentView(R.layout.manage_specific_poi);
|
this.setContentView(R.layout.activity_manage_specific_poi);
|
||||||
|
|
||||||
myLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
myLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||||
bGetPosition = (Button)findViewById(R.id.bGetPosition);
|
bGetPosition = (Button)findViewById(R.id.bGetPosition);
|
||||||
|
@ -82,7 +82,7 @@ public class ActivityManageProfile extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
this.setContentView(R.layout.manage_specific_profile);
|
this.setContentView(R.layout.activity_manage_specific_profile);
|
||||||
|
|
||||||
checkBoxChangeSoundMode = (CheckBox)findViewById(R.id.checkBoxChangeSoundMode);
|
checkBoxChangeSoundMode = (CheckBox)findViewById(R.id.checkBoxChangeSoundMode);
|
||||||
checkBoxChangeVolumeMusicVideoGameMedia = (CheckBox)findViewById(R.id.checkBoxChangeVolumeMusicVideoGameMedia);
|
checkBoxChangeVolumeMusicVideoGameMedia = (CheckBox)findViewById(R.id.checkBoxChangeVolumeMusicVideoGameMedia);
|
||||||
|
@ -1396,13 +1396,16 @@ public class ActivityManageRule extends Activity
|
|||||||
{
|
{
|
||||||
newAction.setAction(Action_Enum.setUsbTethering);
|
newAction.setAction(Action_Enum.setUsbTethering);
|
||||||
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1)
|
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1)
|
||||||
Toast.makeText(context, context.getResources().getString(R.string.usbTetheringFailForAboveGingerbread), Toast.LENGTH_LONG).show();
|
Miscellaneous.messageBox(context.getResources().getString(R.string.warning), context.getResources().getString(R.string.usbTetheringFailForAboveGingerbread), context).show();
|
||||||
getActionParameter1Dialog(ActivityManageRule.this).show();
|
getActionParameter1Dialog(ActivityManageRule.this).show();
|
||||||
}
|
}
|
||||||
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setWifiTethering.toString()))
|
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setWifiTethering.toString()))
|
||||||
{
|
{
|
||||||
newAction.setAction(Action_Enum.setWifiTethering);
|
newAction.setAction(Action_Enum.setWifiTethering);
|
||||||
getActionParameter1Dialog(ActivityManageRule.this).show();
|
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
|
||||||
|
Miscellaneous.messageBox(context.getResources().getString(R.string.warning), context.getResources().getString(R.string.wifiTetheringFailForAboveNougat), context).show();
|
||||||
|
else
|
||||||
|
getActionParameter1Dialog(ActivityManageRule.this).show();
|
||||||
}
|
}
|
||||||
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setDisplayRotation.toString()))
|
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setDisplayRotation.toString()))
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ public class ActivityManageTriggerBluetooth extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_bluetooth_trigger);
|
setContentView(R.layout.activity_manage_trigger_bluetooth);
|
||||||
|
|
||||||
radioAnyBluetoothDevice = (RadioButton)findViewById(R.id.radioAnyBluetoothDevice);
|
radioAnyBluetoothDevice = (RadioButton)findViewById(R.id.radioAnyBluetoothDevice);
|
||||||
radioNoDevice = (RadioButton)findViewById(R.id.radioNoDevice);
|
radioNoDevice = (RadioButton)findViewById(R.id.radioNoDevice);
|
||||||
|
@ -250,7 +250,7 @@ public class ActivityManageTriggerNotification extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.manage_trigger_notification);
|
setContentView(R.layout.activity_manage_trigger_notification);
|
||||||
|
|
||||||
etNotificationTitle = (EditText)findViewById(R.id.etNotificationTitle);
|
etNotificationTitle = (EditText)findViewById(R.id.etNotificationTitle);
|
||||||
etNotificationText = (EditText)findViewById(R.id.etNotificationText);
|
etNotificationText = (EditText)findViewById(R.id.etNotificationText);
|
||||||
|
@ -27,7 +27,7 @@ public class ActivityManageTriggerTimeFrame extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.manage_trigger_timeframe);
|
setContentView(R.layout.activity_manage_trigger_timeframe);
|
||||||
|
|
||||||
startPicker = (TimePicker)findViewById(R.id.tpTimeFrameStart);
|
startPicker = (TimePicker)findViewById(R.id.tpTimeFrameStart);
|
||||||
stopPicker = (TimePicker)findViewById(R.id.tpTimeFrameStop);
|
stopPicker = (TimePicker)findViewById(R.id.tpTimeFrameStop);
|
||||||
|
@ -225,7 +225,15 @@ public class ActivityPermissions extends Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
ActivityMainScreen.updateMainScreen();
|
ActivityMainScreen.updateMainScreen();
|
||||||
ActivityMainRules.getInstance().updateListView();
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ActivityMainRules.getInstance().updateListView();
|
||||||
|
}
|
||||||
|
catch (IllegalStateException e)
|
||||||
|
{
|
||||||
|
// Activity may not have been loaded, yet.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void addToArrayListUnique(String value, ArrayList<String> list)
|
protected static void addToArrayListUnique(String value, ArrayList<String> list)
|
||||||
@ -538,6 +546,13 @@ public class ActivityPermissions extends Activity
|
|||||||
addToArrayListUnique(writeSystemSettingsPermissionName, requiredPermissions);
|
addToArrayListUnique(writeSystemSettingsPermissionName, requiredPermissions);
|
||||||
addToArrayListUnique("android.permission.CHANGE_NETWORK_STATE", requiredPermissions);
|
addToArrayListUnique("android.permission.CHANGE_NETWORK_STATE", requiredPermissions);
|
||||||
addToArrayListUnique("android.permission.ACCESS_NETWORK_STATE", requiredPermissions);
|
addToArrayListUnique("android.permission.ACCESS_NETWORK_STATE", requiredPermissions);
|
||||||
|
|
||||||
|
/*
|
||||||
|
https://stackoverflow.com/questions/46284914/how-to-enable-android-o-wifi-hotspot-programmatically
|
||||||
|
Unfortunately when requesting this permission it will be rejected automatically.
|
||||||
|
*/
|
||||||
|
// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||||
|
// addToArrayListUnique("android.permission.TETHER_PRIVILEGED", requiredPermissions);
|
||||||
break;
|
break;
|
||||||
case speakText:
|
case speakText:
|
||||||
break;
|
break;
|
||||||
@ -1088,7 +1103,16 @@ public class ActivityPermissions extends Activity
|
|||||||
NotificationManager mNotificationManager = (NotificationManager) Miscellaneous.getAnyContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager mNotificationManager = (NotificationManager) Miscellaneous.getAnyContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
mNotificationManager.cancel(notificationIdPermissions);
|
mNotificationManager.cancel(notificationIdPermissions);
|
||||||
ActivityMainScreen.updateMainScreen();
|
ActivityMainScreen.updateMainScreen();
|
||||||
ActivityMainRules.getInstance().updateListView();
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ActivityMainRules.getInstance().updateListView();
|
||||||
|
}
|
||||||
|
catch (IllegalStateException e)
|
||||||
|
{
|
||||||
|
// Activity may not have been loaded, yet.
|
||||||
|
}
|
||||||
|
|
||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,6 @@ public class ActivityTriggerPhoneCall extends Activity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.trigger_phone_call);
|
setContentView(R.layout.activity_manage_trigger_phone_call);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.telecom.Call;
|
||||||
import android.telephony.PhoneStateListener;
|
import android.telephony.PhoneStateListener;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -128,8 +129,8 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
|||||||
// return false;
|
// return false;
|
||||||
// case 0:
|
// case 0:
|
||||||
// return false;
|
// return false;
|
||||||
// case 1:
|
case 1:
|
||||||
// return true;
|
return true;
|
||||||
case 2:
|
case 2:
|
||||||
return true;
|
return true;
|
||||||
// case 3:
|
// case 3:
|
||||||
@ -169,7 +170,7 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
|||||||
|
|
||||||
private static void setCurrentStateIncoming(int state)
|
private static void setCurrentStateIncoming(int state)
|
||||||
{
|
{
|
||||||
// Miscellaneous.logEvent("i", "Call state", "New incoming call state: " + String.valueOf(state), 4);
|
Miscellaneous.logEvent("i", "Call state", "New incoming call state: " + String.valueOf(state), 4);
|
||||||
if(currentStateIncoming != state)
|
if(currentStateIncoming != state)
|
||||||
{
|
{
|
||||||
if(lastPhoneDirection != 1)
|
if(lastPhoneDirection != 1)
|
||||||
@ -177,8 +178,10 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
|||||||
|
|
||||||
if(
|
if(
|
||||||
(state == 0 && currentStateIncoming == 2)
|
(state == 0 && currentStateIncoming == 2)
|
||||||
|
|
||
|
||||||
(state == 2 && (currentStateIncoming == 0 | currentStateIncoming == 1))
|
(state == 2 && (currentStateIncoming == 0 | currentStateIncoming == 1))
|
||||||
|
||
|
||||||
|
state == 1 // this will enable incoming calls that have not been answered, yet, so when they are still only ringing
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
currentStateIncoming = state;
|
currentStateIncoming = state;
|
||||||
|
@ -489,7 +489,8 @@
|
|||||||
<string name="errorWritingFile">Error writing settings file.</string>
|
<string name="errorWritingFile">Error writing settings file.</string>
|
||||||
<string name="unknownError">Unknown error.</string>
|
<string name="unknownError">Unknown error.</string>
|
||||||
<string name="noWritableFolderFound">No writable folder found to store config file.</string>
|
<string name="noWritableFolderFound">No writable folder found to store config file.</string>
|
||||||
<string name="usbTetheringFailForAboveGingerbread">This will most likely not work as you\'re above Android 2.3. However you could use wifi tethering instead.</string>
|
<string name="usbTetheringFailForAboveGingerbread">This will most likely not work as you\'re above Android 2.3. If you\'re below Android 7 you could use wifi tethering instead instead.</string>
|
||||||
|
<string name="wifiTetheringFailForAboveNougat">This will not work anymore as you\'re above Android 7.</string>
|
||||||
<string name="usingNewThreadForRuleExecution">Using new thread for rule activation.</string>
|
<string name="usingNewThreadForRuleExecution">Using new thread for rule activation.</string>
|
||||||
<string name="startNewThreadForRuleExecution">Start new thread for rule activation.</string>
|
<string name="startNewThreadForRuleExecution">Start new thread for rule activation.</string>
|
||||||
<string name="newThreadRules">New thread</string>
|
<string name="newThreadRules">New thread</string>
|
||||||
@ -665,5 +666,6 @@
|
|||||||
<string name="openExamplesPage">Open webpage with examples</string>
|
<string name="openExamplesPage">Open webpage with examples</string>
|
||||||
<string name="packageName">Package name</string>
|
<string name="packageName">Package name</string>
|
||||||
<string name="activityOrActionName">Activity/action name</string>
|
<string name="activityOrActionName">Activity/action name</string>
|
||||||
|
<string name="warning">Warning</string>
|
||||||
<!-- <string name="net.kollnig.missioncontrol.permission.ADMIN">Control the app Tracker Control</string>-->
|
<!-- <string name="net.kollnig.missioncontrol.permission.ADMIN">Control the app Tracker Control</string>-->
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user