2020-01-09 10:44:32 +01:00
|
|
|
/* Copyright (C) 2019-2020 Andreas Shimokawa
|
2019-04-21 21:18:08 +02:00
|
|
|
|
|
|
|
This file is part of Gadgetbridge.
|
|
|
|
|
|
|
|
Gadgetbridge is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Gadgetbridge is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
package nodomain.freeyourgadget.gadgetbridge.activities.devicesettings;
|
|
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
2019-05-22 00:42:22 +02:00
|
|
|
import androidx.fragment.app.Fragment;
|
2019-04-21 21:18:08 +02:00
|
|
|
import androidx.preference.PreferenceFragmentCompat;
|
2019-05-22 00:42:22 +02:00
|
|
|
import androidx.preference.PreferenceScreen;
|
2019-04-21 21:18:08 +02:00
|
|
|
|
2020-11-26 21:09:05 +01:00
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
2019-04-21 21:18:08 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBActivity;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
|
|
|
|
|
|
|
|
2019-05-22 00:42:22 +02:00
|
|
|
public class DeviceSettingsActivity extends AbstractGBActivity implements
|
|
|
|
PreferenceFragmentCompat.OnPreferenceStartScreenCallback {
|
2019-04-21 21:18:08 +02:00
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(DeviceSettingsActivity.class);
|
|
|
|
|
2019-05-22 00:42:22 +02:00
|
|
|
GBDevice device;
|
|
|
|
|
2019-04-21 21:18:08 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
device = getIntent().getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_device_settings);
|
2019-05-22 00:42:22 +02:00
|
|
|
if (savedInstanceState == null) {
|
|
|
|
Fragment fragment = getSupportFragmentManager().findFragmentByTag(DeviceSpecificSettingsFragment.FRAGMENT_TAG);
|
|
|
|
if (fragment == null) {
|
2022-05-09 20:47:08 +02:00
|
|
|
fragment = DeviceSpecificSettingsFragment.newInstance(device);
|
2019-05-22 00:42:22 +02:00
|
|
|
}
|
|
|
|
getSupportFragmentManager()
|
|
|
|
.beginTransaction()
|
|
|
|
.replace(R.id.settings_container, fragment, DeviceSpecificSettingsFragment.FRAGMENT_TAG)
|
|
|
|
.commit();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2019-04-21 21:18:08 +02:00
|
|
|
|
2019-05-22 00:42:22 +02:00
|
|
|
@Override
|
|
|
|
public boolean onPreferenceStartScreen(PreferenceFragmentCompat caller, PreferenceScreen preferenceScreen) {
|
2022-05-09 20:47:08 +02:00
|
|
|
final PreferenceFragmentCompat fragment = DeviceSpecificSettingsFragment.newInstance(device);
|
2019-05-22 00:42:22 +02:00
|
|
|
Bundle args = fragment.getArguments();
|
|
|
|
args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, preferenceScreen.getKey());
|
|
|
|
fragment.setArguments(args);
|
2019-04-21 21:18:08 +02:00
|
|
|
|
|
|
|
getSupportFragmentManager()
|
|
|
|
.beginTransaction()
|
2019-05-22 00:42:22 +02:00
|
|
|
.replace(R.id.settings_container, fragment, preferenceScreen.getKey())
|
|
|
|
.addToBackStack(preferenceScreen.getKey())
|
2019-04-21 21:18:08 +02:00
|
|
|
.commit();
|
2019-05-22 00:42:22 +02:00
|
|
|
return true;
|
2019-04-21 21:18:08 +02:00
|
|
|
}
|
2019-05-22 00:42:22 +02:00
|
|
|
}
|