Added functionality to enable OsMo service from dashboard when it's disabled
This commit is contained in:
parent
dafddbf041
commit
d491e0ac0e
1 changed files with 32 additions and 9 deletions
|
@ -75,21 +75,26 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups
|
||||||
private void setupOsMoView() {
|
private void setupOsMoView() {
|
||||||
View mainView = getView();
|
View mainView = getView();
|
||||||
|
|
||||||
boolean show = plugin != null;
|
if (plugin == null) {
|
||||||
if (show) {
|
|
||||||
show = plugin.getService().isEnabled();
|
|
||||||
}
|
|
||||||
if (!show) {
|
|
||||||
mainView.setVisibility(View.GONE);
|
mainView.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
mainView.setVisibility(View.VISIBLE);
|
mainView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStatus();
|
updateStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupHader(final View header) {
|
private void setupHader(final View header) {
|
||||||
CompoundButton trackr = (CompoundButton) header.findViewById(R.id.check_item);
|
CompoundButton enableService = (CompoundButton)header.findViewById(R.id.header_layout).findViewById(R.id.check_item);
|
||||||
|
CompoundButton trackr = (CompoundButton) header.findViewById(R.id.card_content).findViewById(R.id.check_item);
|
||||||
|
|
||||||
|
enableService.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
plugin.getService().connect(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
final OsmandApplication app = getMyApplication();
|
final OsmandApplication app = getMyApplication();
|
||||||
trackr.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
trackr.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@ -132,6 +137,19 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups
|
||||||
if (getView() == null) {
|
if (getView() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
View cardContent = header.findViewById(R.id.card_content);
|
||||||
|
View enableOsmo = header.findViewById(R.id.header_layout).findViewById(R.id.check_item);
|
||||||
|
if (plugin.getService().isEnabled()) {
|
||||||
|
cardContent.setVisibility(View.VISIBLE);
|
||||||
|
enableOsmo.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
cardContent.setVisibility(View.GONE);
|
||||||
|
enableOsmo.setVisibility(View.VISIBLE);
|
||||||
|
getClearContentList(header);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CompoundButton trackr = (CompoundButton) header.findViewById(R.id.check_item);
|
CompoundButton trackr = (CompoundButton) header.findViewById(R.id.check_item);
|
||||||
if (plugin != null && plugin.getTracker() != null) {
|
if (plugin != null && plugin.getTracker() != null) {
|
||||||
trackr.setChecked(plugin.getTracker().isEnabledTracker());
|
trackr.setChecked(plugin.getTracker().isEnabledTracker());
|
||||||
|
@ -151,8 +169,7 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LinearLayout contentList = (LinearLayout) mainView.findViewById(R.id.items);
|
LinearLayout contentList = getClearContentList(mainView);
|
||||||
contentList.removeAllViews();
|
|
||||||
if (mainGroup == null) {
|
if (mainGroup == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -170,6 +187,12 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LinearLayout getClearContentList(View mainView) {
|
||||||
|
LinearLayout contentList = (LinearLayout) mainView.findViewById(R.id.items);
|
||||||
|
contentList.removeAllViews();
|
||||||
|
return contentList;
|
||||||
|
}
|
||||||
|
|
||||||
private void setupGroupsViews(int toAddCount, ArrayList<OsMoGroupsStorage.OsMoGroup> groups, LinearLayout contentList) {
|
private void setupGroupsViews(int toAddCount, ArrayList<OsMoGroupsStorage.OsMoGroup> groups, LinearLayout contentList) {
|
||||||
int counter = 1;
|
int counter = 1;
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
|
@ -293,7 +316,7 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups
|
||||||
getActivity().runOnUiThread(new Runnable() {
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateConnectedDevices(getView());
|
updateStatus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue