mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-28 03:25:49 +01:00
Merge remote-tracking branch 'freeyourgadget/master'
This commit is contained in:
commit
4a3b530d8f
@ -143,6 +143,8 @@ public class Widget extends AppWidgetProvider {
|
||||
|
||||
if (sleep < 1) {
|
||||
views.setViewVisibility(R.id.todaywidget_sleep_layout, View.GONE);
|
||||
} else {
|
||||
views.setViewVisibility(R.id.todaywidget_sleep_layout, View.VISIBLE);
|
||||
}
|
||||
|
||||
views.setTextViewText(R.id.todaywidget_steps, String.format("%1s", steps));
|
||||
|
@ -57,6 +57,7 @@ import android.widget.Toast;
|
||||
import androidx.core.app.NavUtils;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.RemoteInput;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@ -681,10 +682,17 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
final Uri providerUri = FileProvider.getUriForFile(
|
||||
this,
|
||||
getApplicationContext().getPackageName() + ".screenshot_provider",
|
||||
logFile
|
||||
);
|
||||
|
||||
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
emailIntent.setType("*/*");
|
||||
emailIntent.putExtra(EXTRA_SUBJECT, "Gadgetbridge log file");
|
||||
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(logFile));
|
||||
emailIntent.putExtra(Intent.EXTRA_STREAM, providerUri);
|
||||
startActivity(Intent.createChooser(emailIntent, "Share File"));
|
||||
}
|
||||
}
|
||||
|
@ -198,6 +198,8 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
}
|
||||
}
|
||||
};
|
||||
int CallbackType = android.bluetooth.le.ScanSettings.CALLBACK_TYPE_ALL_MATCHES;
|
||||
int MatchMode = android.bluetooth.le.ScanSettings.MATCH_MODE_STICKY;
|
||||
|
||||
public void logMessageContent(byte[] value) {
|
||||
if (value != null) {
|
||||
@ -654,17 +656,17 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
private ScanSettings getScanSettings() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
return new ScanSettings.Builder()
|
||||
.setCallbackType(android.bluetooth.le.ScanSettings.CALLBACK_TYPE_ALL_MATCHES)
|
||||
.setCallbackType(CallbackType)
|
||||
.setScanMode(android.bluetooth.le.ScanSettings.SCAN_MODE_LOW_LATENCY)
|
||||
.setMatchMode(android.bluetooth.le.ScanSettings.MATCH_MODE_AGGRESSIVE)
|
||||
.setMatchMode(MatchMode)
|
||||
.setPhy(android.bluetooth.le.ScanSettings.PHY_LE_ALL_SUPPORTED)
|
||||
.setNumOfMatches(android.bluetooth.le.ScanSettings.MATCH_NUM_ONE_ADVERTISEMENT)
|
||||
.build();
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
return new ScanSettings.Builder()
|
||||
.setCallbackType(android.bluetooth.le.ScanSettings.CALLBACK_TYPE_ALL_MATCHES)
|
||||
.setCallbackType(CallbackType)
|
||||
.setScanMode(android.bluetooth.le.ScanSettings.SCAN_MODE_LOW_LATENCY)
|
||||
.setMatchMode(android.bluetooth.le.ScanSettings.MATCH_MODE_AGGRESSIVE)
|
||||
.setMatchMode(MatchMode)
|
||||
.setNumOfMatches(android.bluetooth.le.ScanSettings.MATCH_NUM_ONE_ADVERTISEMENT)
|
||||
.build();
|
||||
} else {
|
||||
@ -910,6 +912,26 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
|
||||
if (oldBleScanning) {
|
||||
LOG.info("New BLE scanning disabled via settings, using old method");
|
||||
}
|
||||
int level = prefs.getInt("scanning_intensity", 1);
|
||||
switch (level) {
|
||||
case 0:
|
||||
CallbackType = android.bluetooth.le.ScanSettings.CALLBACK_TYPE_FIRST_MATCH;
|
||||
MatchMode = android.bluetooth.le.ScanSettings.MATCH_MODE_STICKY;
|
||||
break;
|
||||
case 1:
|
||||
CallbackType = android.bluetooth.le.ScanSettings.CALLBACK_TYPE_FIRST_MATCH;
|
||||
MatchMode = android.bluetooth.le.ScanSettings.MATCH_MODE_AGGRESSIVE;
|
||||
break;
|
||||
case 2:
|
||||
CallbackType = android.bluetooth.le.ScanSettings.CALLBACK_TYPE_ALL_MATCHES;
|
||||
MatchMode = android.bluetooth.le.ScanSettings.MATCH_MODE_STICKY;
|
||||
break;
|
||||
case 3:
|
||||
CallbackType = android.bluetooth.le.ScanSettings.CALLBACK_TYPE_ALL_MATCHES;
|
||||
MatchMode = android.bluetooth.le.ScanSettings.MATCH_MODE_AGGRESSIVE;
|
||||
break;
|
||||
}
|
||||
LOG.debug("Device discovery - scanning level: " + level + " " + CallbackType + " " + MatchMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,14 +18,33 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
public class DiscoveryPairingPreferenceActivity extends AbstractSettingsActivity {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractSettingsActivity.class);
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.discovery_pairing_preferences);
|
||||
|
||||
final Prefs prefs = GBApplication.getPrefs();
|
||||
final Preference pref = findPreference("scanning_intensity");
|
||||
pref.setSummary(String.valueOf(prefs.getInt("scanning_intensity", 1)));
|
||||
|
||||
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||
preference.setSummary(newVal.toString());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
|
@ -141,7 +141,7 @@ public class WidgetAlarmsActivity extends Activity implements View.OnClickListen
|
||||
this.getString(R.string.appwidget_setting_alarm, hours, minutes),
|
||||
Toast.LENGTH_SHORT, GB.INFO);
|
||||
|
||||
Alarm alarm = AlarmUtils.createSingleShot(0, true, false, calendar);
|
||||
Alarm alarm = AlarmUtils.createSingleShot(0, true, true, calendar);
|
||||
ArrayList<Alarm> alarms = new ArrayList<>(1);
|
||||
alarms.add(alarm);
|
||||
GBApplication.deviceService().onSetAlarms(alarms);
|
||||
|
@ -144,7 +144,7 @@ public class MiBand5Coordinator extends HuamiCoordinator {
|
||||
"id_ID",
|
||||
"it_IT",
|
||||
"nl_NL",
|
||||
"pt_PT",
|
||||
"pt_BR",
|
||||
"pl_PL",
|
||||
"ro_RO",
|
||||
"ru_RU",
|
||||
|
@ -956,33 +956,9 @@ public class FitProDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
// this device doesn't have concept of on-off alarm, so use the last slot for this and store
|
||||
// this alarm in the database so the user knows what is going on and can disable it
|
||||
|
||||
if (alarms.toArray().length == 1 && alarms.get(0).getRepetition() == 0) {
|
||||
if (alarms.toArray().length == 1 && alarms.get(0).getRepetition() == 0) { //single shot?
|
||||
Alarm oneshot = alarms.get(0);
|
||||
DBHandler db = null;
|
||||
try {
|
||||
db = GBApplication.acquireDB();
|
||||
DaoSession daoSession = db.getDaoSession();
|
||||
Device device = DBHelper.getDevice(gbDevice, daoSession);
|
||||
User user = DBHelper.getUser(daoSession);
|
||||
nodomain.freeyourgadget.gadgetbridge.entities.Alarm tmpAlarm =
|
||||
new nodomain.freeyourgadget.gadgetbridge.entities.Alarm(
|
||||
device.getId(),
|
||||
user.getId(),
|
||||
7,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
oneshot.getHour(),
|
||||
oneshot.getMinute(),
|
||||
true, //kind of indicate the specialty of this alarm
|
||||
"",
|
||||
"");
|
||||
daoSession.insertOrReplace(tmpAlarm);
|
||||
GBApplication.releaseDB();
|
||||
} catch (GBException e) {
|
||||
LOG.error("error storing one shot quick alarm");
|
||||
}
|
||||
alarms = (ArrayList<? extends Alarm>) AlarmUtils.mergeOneshotToDeviceAlarms(gbDevice, (nodomain.freeyourgadget.gadgetbridge.entities.Alarm) oneshot, 7);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -78,6 +78,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.mis
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.ReleaseHandsControlRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.RequestHandControlRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.SaveCalibrationRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.AlarmUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.UriHelper;
|
||||
@ -516,6 +517,16 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
|
||||
@Override
|
||||
public void onSetAlarms(ArrayList<? extends Alarm> alarms) {
|
||||
|
||||
// handle one-shot alarm from the widget:
|
||||
// this device doesn't have concept of on-off alarm, so use the last slot for this and store
|
||||
// this alarm in the database so the user knows what is going on and can disable it
|
||||
|
||||
if (alarms.toArray().length == 1 && alarms.get(0).getRepetition() == 0) { //single shot?
|
||||
Alarm oneshot = alarms.get(0);
|
||||
alarms = (ArrayList<? extends Alarm>) AlarmUtils.mergeOneshotToDeviceAlarms(getDeviceSupport().getDevice(), (nodomain.freeyourgadget.gadgetbridge.entities.Alarm) oneshot, 5);
|
||||
}
|
||||
|
||||
// throw new RuntimeException("noope");
|
||||
ArrayList<nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.alarm.Alarm> activeAlarms = new ArrayList<>();
|
||||
for (Alarm alarm : alarms) {
|
||||
|
@ -1380,7 +1380,9 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
outerLoop:
|
||||
for (ButtonConfiguration config : configs) {
|
||||
for (ApplicationInformation installedApp : installedApplications) {
|
||||
if (installedApp.getAppName().equals(config.getAction())) {
|
||||
if (installedApp.getAppName().equals(config.getAction()) ||
|
||||
config.getAction().equals("workoutApp") //workoutApp is part of internal firmware
|
||||
) {
|
||||
availableConfigs.add(config);
|
||||
continue outerLoop;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
|
||||
@ -50,7 +51,7 @@ public class AlarmUtils {
|
||||
* @return
|
||||
*/
|
||||
public static nodomain.freeyourgadget.gadgetbridge.model.Alarm createSingleShot(int index, boolean smartWakeup, boolean snooze, Calendar calendar) {
|
||||
return new Alarm(-1, -1, index, true, smartWakeup, snooze, Alarm.ALARM_ONCE, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), false, null, null);
|
||||
return new Alarm(-1, -1, index, true, smartWakeup, snooze, Alarm.ALARM_ONCE, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), false, GBApplication.getContext().getString(R.string.quick_alarm), GBApplication.getContext().getString(R.string.quick_alarm_description));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,4 +145,23 @@ public class AlarmUtils {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static List<Alarm> mergeOneshotToDeviceAlarms(GBDevice gbDevice, Alarm oneshot, int position) {
|
||||
List<Alarm> all_alarms = new ArrayList<>();
|
||||
try {
|
||||
DBHandler db = GBApplication.acquireDB();
|
||||
DaoSession daoSession = db.getDaoSession();
|
||||
Device device = DBHelper.getDevice(gbDevice, daoSession);
|
||||
User user = DBHelper.getUser(daoSession);
|
||||
oneshot.setPosition(position);
|
||||
oneshot.setDeviceId(device.getId());
|
||||
oneshot.setUserId(user.getId());
|
||||
daoSession.insertOrReplace(oneshot);
|
||||
all_alarms = DBHelper.getAlarms(gbDevice);
|
||||
GBApplication.releaseDB();
|
||||
} catch (Exception e) {
|
||||
GB.log("error storing one shot quick alarm", GB.ERROR, e);
|
||||
}
|
||||
return all_alarms;
|
||||
}
|
||||
}
|
||||
|
@ -405,6 +405,7 @@
|
||||
<item>@string/menuitem_status</item>
|
||||
<item>@string/menuitem_pai</item>
|
||||
<item>@string/menuitem_hr</item>
|
||||
<item>@string/menuitem_breathing</item>
|
||||
<item>@string/menuitem_stress</item>
|
||||
<item>@string/menuitem_eventreminder</item>
|
||||
<item>@string/menuitem_dnd</item>
|
||||
@ -427,6 +428,7 @@
|
||||
<item>@string/p_menuitem_status</item>
|
||||
<item>@string/p_menuitem_pai</item>
|
||||
<item>@string/p_menuitem_hr</item>
|
||||
<item>@string/p_menuitem_breathing</item>
|
||||
<item>@string/p_menuitem_stress</item>
|
||||
<item>@string/p_menuitem_eventreminder</item>
|
||||
<item>@string/p_menuitem_dnd</item>
|
||||
@ -726,6 +728,7 @@
|
||||
<item>@string/menuitem_pai</item>
|
||||
<item>@string/menuitem_hr</item>
|
||||
<item>@string/menuitem_spo2</item>
|
||||
<item>@string/menuitem_breathing</item>
|
||||
<item>@string/menuitem_stress</item>
|
||||
<item>@string/menuitem_eventreminder</item>
|
||||
<item>@string/menuitem_dnd</item>
|
||||
@ -749,6 +752,7 @@
|
||||
<item>@string/p_menuitem_pai</item>
|
||||
<item>@string/p_menuitem_hr</item>
|
||||
<item>@string/p_menuitem_spo2</item>
|
||||
<item>@string/p_menuitem_breathing</item>
|
||||
<item>@string/p_menuitem_stress</item>
|
||||
<item>@string/p_menuitem_eventreminder</item>
|
||||
<item>@string/p_menuitem_dnd</item>
|
||||
@ -1431,7 +1435,8 @@
|
||||
<item name="de_DE">@string/german</item>
|
||||
<item name="it_IT">@string/italian</item>
|
||||
<item name="fr_FR">@string/french</item>
|
||||
<item name="pt_BR">@string/portuguese</item>
|
||||
<item name="pt_BR">@string/portuguese_br</item>
|
||||
<item name="pt_PT">@string/portuguese_pt</item>
|
||||
<item name="nl_NL">@string/dutch</item>
|
||||
<item name="pl_PL">@string/polish</item>
|
||||
<item name="cs_CZ">@string/czesh</item>
|
||||
@ -1458,6 +1463,7 @@
|
||||
<item>it_IT</item>
|
||||
<item>fr_FR</item>
|
||||
<item>pt_BR</item>
|
||||
<item>pt_PT</item>
|
||||
<item>nl_NL</item>
|
||||
<item>pl_PL</item>
|
||||
<item>cs_CZ</item>
|
||||
|
@ -389,6 +389,8 @@
|
||||
<string name="pref_auto_fetch_limit_fetches">Minimum time between fetches</string>
|
||||
<string name="pref_auto_fetch_limit_fetches_summary">Fetches every %d minutes</string>
|
||||
<!-- developer/debug preferences-->
|
||||
<string name="discovery_scanning_intensity">Scanning intensity</string>
|
||||
<string name="discovery_scanning_intensity_warning">If you experience freezing or unresponsiveness, try to set Scanning intensity to lower level. If your device is not being discovered, try to set Scanning intensity to higher level.</string>
|
||||
<string name="pref_disable_new_ble_scanning">Disable new BLE scanning</string>
|
||||
<string name="pref_summary_disable_new_ble_scanning">Check this option if your device cannot be found during discovery</string>
|
||||
<string name="not_connected">Not connected</string>
|
||||
@ -757,6 +759,8 @@
|
||||
<string name="thai">Thai</string>
|
||||
<string name="vietnamese">Vietnamese</string>
|
||||
<string name="portuguese">Portuguese</string>
|
||||
<string name="portuguese_br">Portuguese (Brazil)</string>
|
||||
<string name="portuguese_pt">Portuguese (Portugal)</string>
|
||||
<string name="romanian">Romanian</string>
|
||||
<string name="hungarian">Hungarian</string>
|
||||
<string name="greek">Greek</string>
|
||||
@ -1133,6 +1137,8 @@
|
||||
<string name="widget_10_minutes">10 minutes</string>
|
||||
<string name="widget_20_minutes">20 minutes</string>
|
||||
<string name="widget_1_hour">1 hour</string>
|
||||
<string name="quick_alarm">Quick alarm</string>
|
||||
<string name="quick_alarm_description">Alarm from widget</string>
|
||||
<string name="icon_placeholder" translatable="false">Icon</string>
|
||||
<string name="watch_not_connected">Watch not connected</string>
|
||||
<string name="qhybrid_vibration_strength">vibration strength:</string>
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory
|
||||
android:key="pref_discovery_pairing"
|
||||
android:title="@string/activity_prefs_discovery_pairing">
|
||||
@ -27,5 +28,17 @@
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/discover_unsupported_devices_description"
|
||||
android:title="@string/discover_unsupported_devices" />
|
||||
<SeekBarPreference
|
||||
android:key="scanning_intensity"
|
||||
android:max="3"
|
||||
android:min="0"
|
||||
android:title="@string/discovery_scanning_intensity"
|
||||
android:defaultValue="1"
|
||||
app:showSeekBarValue="true" />
|
||||
<Preference
|
||||
android:selectable="false"
|
||||
android:persistent="false"
|
||||
android:summary="@string/discovery_scanning_intensity_warning" />
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
Loading…
Reference in New Issue
Block a user