mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +01:00
Nothing: add option to auto-reply to incoming phone calls
The new preference to toggle the auto-reply behavior is not prefixed with the device name, as I guess it could be useful also for other bluetooth headphones
This commit is contained in:
parent
43fddd0110
commit
c4747e2e23
@ -436,4 +436,6 @@ public class DeviceSettingsPreferenceConst {
|
|||||||
public static final String PREF_CLAP_HANDS_TO_WAKEUP_DEVICE = "pref_key_clap_hands_to_wakeup_device";
|
public static final String PREF_CLAP_HANDS_TO_WAKEUP_DEVICE = "pref_key_clap_hands_to_wakeup_device";
|
||||||
public static final String PREF_POWER_SAVING = "pref_key_power_saving";
|
public static final String PREF_POWER_SAVING = "pref_key_power_saving";
|
||||||
public static final String PREF_FORCE_CONNECTION_TYPE = "pref_force_connection_type";
|
public static final String PREF_FORCE_CONNECTION_TYPE = "pref_force_connection_type";
|
||||||
|
|
||||||
|
public static final String PREF_AUTO_REPLY_INCOMING_CALL = "pref_auto_reply_phonecall";
|
||||||
}
|
}
|
||||||
|
@ -476,6 +476,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
|
|||||||
addPreferenceHandlerFor(PREF_DISPLAY_CALLER);
|
addPreferenceHandlerFor(PREF_DISPLAY_CALLER);
|
||||||
addPreferenceHandlerFor(PREF_NOTIFICATION_DELAY_CALLS);
|
addPreferenceHandlerFor(PREF_NOTIFICATION_DELAY_CALLS);
|
||||||
addPreferenceHandlerFor(PREF_CALL_REJECT_METHOD);
|
addPreferenceHandlerFor(PREF_CALL_REJECT_METHOD);
|
||||||
|
addPreferenceHandlerFor(PREF_AUTO_REPLY_INCOMING_CALL);
|
||||||
|
|
||||||
addPreferenceHandlerFor(PREF_SLEEP_MODE_SLEEP_SCREEN);
|
addPreferenceHandlerFor(PREF_SLEEP_MODE_SLEEP_SCREEN);
|
||||||
addPreferenceHandlerFor(PREF_SLEEP_MODE_SMART_ENABLE);
|
addPreferenceHandlerFor(PREF_SLEEP_MODE_SMART_ENABLE);
|
||||||
|
@ -16,15 +16,17 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.nothing;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.nothing;
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import java.util.UUID;
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.serial.AbstractSerialDeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.serial.AbstractSerialDeviceSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceIoThread;
|
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceIoThread;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
|
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
|
||||||
@ -33,6 +35,29 @@ public class Ear1Support extends AbstractSerialDeviceSupport {
|
|||||||
private static final Logger LOG = LoggerFactory.getLogger(Ear1Support.class);
|
private static final Logger LOG = LoggerFactory.getLogger(Ear1Support.class);
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSetCallState(CallSpec callSpec) {
|
||||||
|
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
|
||||||
|
|
||||||
|
if (!prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_AUTO_REPLY_INCOMING_CALL, false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(CallSpec.CALL_INCOMING != callSpec.command)
|
||||||
|
return;
|
||||||
|
|
||||||
|
LOG.debug("Incoming call, scheduling auto answer in 10 seconds.");
|
||||||
|
Looper mainLooper = Looper.getMainLooper();
|
||||||
|
new Handler(mainLooper).postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
GBDeviceEventCallControl callCmd = new GBDeviceEventCallControl();
|
||||||
|
callCmd.event = GBDeviceEventCallControl.Event.ACCEPT;
|
||||||
|
evaluateGBDeviceEvent(callCmd);
|
||||||
|
}
|
||||||
|
}, 15000); //15s
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSendConfiguration(String config) {
|
public void onSendConfiguration(String config) {
|
||||||
super.onSendConfiguration(config);
|
super.onSendConfiguration(config);
|
||||||
|
@ -2774,4 +2774,6 @@
|
|||||||
<string name="pref_dashboard_select_devices_summary">Combine activity data from specific devices for the totals on the dashboard</string>
|
<string name="pref_dashboard_select_devices_summary">Combine activity data from specific devices for the totals on the dashboard</string>
|
||||||
<string name="pref_dashboard_widget_today_hr_interval_title">Heart rate interval</string>
|
<string name="pref_dashboard_widget_today_hr_interval_title">Heart rate interval</string>
|
||||||
<string name="pref_dashboard_widget_today_hr_interval_summary">The amount of minutes the chart shows \'worn\' after each successful heart rate measurement</string>
|
<string name="pref_dashboard_widget_today_hr_interval_summary">The amount of minutes the chart shows \'worn\' after each successful heart rate measurement</string>
|
||||||
|
<string name="pref_auto_reply_calls_summary">The phone will automatically pick-up incoming phonecalls</string>
|
||||||
|
<string name="pref_auto_reply_calls_title">Automatically answer phone calls</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -14,4 +14,10 @@
|
|||||||
android:key="pref_nothing_audiomode"
|
android:key="pref_nothing_audiomode"
|
||||||
android:summary="%s"
|
android:summary="%s"
|
||||||
android:title="@string/nothing_prefs_audiomode_title" />
|
android:title="@string/nothing_prefs_audiomode_title" />
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:icon="@drawable/ic_phone"
|
||||||
|
android:key="pref_auto_reply_phonecall"
|
||||||
|
android:summary="@string/pref_auto_reply_calls_summary"
|
||||||
|
android:title="@string/pref_auto_reply_calls_title"/>
|
||||||
</androidx.preference.PreferenceScreen>
|
</androidx.preference.PreferenceScreen>
|
||||||
|
Loading…
Reference in New Issue
Block a user