Merge pull request #49 from AdrianLxM/disableLoopLongpress
Disable loop on Longpress on Loop-Status in Overview
This commit is contained in:
commit
925b5612fc
5 changed files with 40 additions and 6 deletions
|
@ -76,7 +76,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
LocaleHelper.setLocale(getApplicationContext(), lang);
|
||||
recreate();
|
||||
try { // activity may be destroyed
|
||||
setUpTabs(true);
|
||||
setUpTabs(ev.isSwitchToLast());
|
||||
} catch (IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
|||
String lang = sharedPreferences.getString("language", "en");
|
||||
LocaleHelper.setLocale(getApplicationContext(), lang);
|
||||
recreate();
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
MainApp.bus().post(new EventRefreshGui(true));
|
||||
}
|
||||
updatePrefSummary(myPreferenceFragment.getPreference(key));
|
||||
}
|
||||
|
@ -105,4 +105,4 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
|||
return findPreference(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,4 +4,15 @@ package info.nightscout.androidaps.events;
|
|||
* Created by mike on 13.06.2016.
|
||||
*/
|
||||
public class EventRefreshGui {
|
||||
|
||||
public boolean isSwitchToLast() {
|
||||
return switchToLast;
|
||||
}
|
||||
|
||||
private final boolean switchToLast;
|
||||
|
||||
public EventRefreshGui(boolean switchToLast){
|
||||
this.switchToLast = switchToLast;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
|
|||
plugin.setFragmentVisible(type, cb.isChecked());
|
||||
onEnabledCategoryChanged(plugin, type);
|
||||
configBuilderPlugin.storeSettings();
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
MainApp.bus().post(new EventRefreshGui(true));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -188,7 +188,7 @@ public class ConfigBuilderFragment extends Fragment implements FragmentBase {
|
|||
PluginBase plugin = (PluginBase) cb.getTag();
|
||||
plugin.setFragmentVisible(type, cb.isChecked());
|
||||
configBuilderPlugin.storeSettings();
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
MainApp.bus().post(new EventRefreshGui(true));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -53,6 +53,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
|
|||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
|
@ -404,7 +405,7 @@ public class OverviewFragment extends Fragment {
|
|||
if (Config.APS) {
|
||||
apsModeView.setVisibility(View.VISIBLE);
|
||||
apsModeView.setBackgroundResource(R.drawable.loopmodeborder);
|
||||
LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
|
||||
final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
|
||||
if(activeloop != null && activeloop.isEnabled(activeloop.getType())) {
|
||||
if (MainApp.getConfigBuilder().isClosedModeEnabled()) {
|
||||
apsModeView.setText(MainApp.sResources.getString(R.string.closedloop));
|
||||
|
@ -415,6 +416,28 @@ public class OverviewFragment extends Fragment {
|
|||
apsModeView.setBackgroundResource(R.drawable.loopmodedisabledborder);
|
||||
apsModeView.setText(MainApp.sResources.getString(R.string.disabledloop));
|
||||
}
|
||||
|
||||
|
||||
apsModeView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
if (activeloop == null){
|
||||
log.error("no active loop?");
|
||||
return true;
|
||||
} else if (activeloop.isEnabled(PluginBase.LOOP)){
|
||||
activeloop.setFragmentEnabled(PluginBase.LOOP, false);
|
||||
activeloop.setFragmentVisible(PluginBase.LOOP, false);
|
||||
} else {
|
||||
activeloop.setFragmentEnabled(PluginBase.LOOP, true);
|
||||
activeloop.setFragmentVisible(PluginBase.LOOP, true);
|
||||
}
|
||||
MainApp.getConfigBuilder().storeSettings();
|
||||
MainApp.bus().post(new EventRefreshGui(false));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
apsModeView.setLongClickable(true);
|
||||
|
||||
} else {
|
||||
apsModeView.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue