diff --git a/microg-ui-tools/src/main/java/org/microg/tools/selfcheck/SelfCheckGroup.java b/microg-ui-tools/src/main/java/org/microg/tools/selfcheck/SelfCheckGroup.java index cc832597..028e6533 100644 --- a/microg-ui-tools/src/main/java/org/microg/tools/selfcheck/SelfCheckGroup.java +++ b/microg-ui-tools/src/main/java/org/microg/tools/selfcheck/SelfCheckGroup.java @@ -17,6 +17,7 @@ package org.microg.tools.selfcheck; import android.content.Context; +import android.support.v4.app.Fragment; public interface SelfCheckGroup { String getGroupName(Context context); @@ -25,6 +26,12 @@ public interface SelfCheckGroup { interface ResultCollector { void addResult(String name, Result value, String resolution); + + void addResult(String name, Result value, String resolution, CheckResolver resolver); + } + + interface CheckResolver { + void tryResolve(Fragment fragment); } enum Result { diff --git a/microg-ui-tools/src/main/java/org/microg/tools/ui/AbstractSelfCheckFragment.java b/microg-ui-tools/src/main/java/org/microg/tools/ui/AbstractSelfCheckFragment.java index bb00cf3f..1a3f25b3 100644 --- a/microg-ui-tools/src/main/java/org/microg/tools/ui/AbstractSelfCheckFragment.java +++ b/microg-ui-tools/src/main/java/org/microg/tools/ui/AbstractSelfCheckFragment.java @@ -41,16 +41,24 @@ import static org.microg.tools.selfcheck.SelfCheckGroup.Result.Unknown; public abstract class AbstractSelfCheckFragment extends Fragment { private static final String TAG = "SelfCheck"; - protected abstract void prepareSelfCheckList(List checks); + private ViewGroup root; @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View scrollRoot = inflater.inflate(R.layout.self_check, container, false); + root = (ViewGroup) scrollRoot.findViewById(R.id.self_check_root); + reset(inflater); + return scrollRoot; + } + + protected abstract void prepareSelfCheckList(List checks); + + protected void reset(LayoutInflater inflater) { List selfCheckGroupList = new ArrayList(); prepareSelfCheckList(selfCheckGroupList); - ViewGroup root = (ViewGroup) scrollRoot.findViewById(R.id.self_check_root); + root.removeAllViews(); for (SelfCheckGroup group : selfCheckGroupList) { View groupView = inflater.inflate(R.layout.self_check_group, root, false); ((TextView) groupView.findViewById(android.R.id.title)).setText(group.getGroupName(getContext())); @@ -64,7 +72,6 @@ public abstract class AbstractSelfCheckFragment extends Fragment { } root.addView(groupView); } - return scrollRoot; } private class GroupResultCollector implements SelfCheckGroup.ResultCollector { @@ -76,6 +83,12 @@ public abstract class AbstractSelfCheckFragment extends Fragment { @Override public void addResult(final String name, final SelfCheckGroup.Result result, final String resolution) { + addResult(name, result, resolution, null); + } + + @Override + public void addResult(final String name, final SelfCheckGroup.Result result, final String resolution, + final SelfCheckGroup.CheckResolver resolver) { if (result == null || getActivity() == null) return; getActivity().runOnUiThread(new Runnable() { @Override @@ -96,11 +109,19 @@ public abstract class AbstractSelfCheckFragment extends Fragment { if (result == Unknown) { resultEntry.findViewById(R.id.self_check_result).setVisibility(INVISIBLE); } + if (resolver != null) { + resultEntry.setClickable(true); + resultEntry.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + resolver.tryResolve(AbstractSelfCheckFragment.this); + } + }); + } } viewGroup.addView(resultEntry); } }); - } } } diff --git a/microg-ui-tools/src/main/res/layout/self_check_entry.xml b/microg-ui-tools/src/main/res/layout/self_check_entry.xml index ec5ad8d2..e24a7e1c 100644 --- a/microg-ui-tools/src/main/res/layout/self_check_entry.xml +++ b/microg-ui-tools/src/main/res/layout/self_check_entry.xml @@ -15,39 +15,44 @@ ~ limitations under the License. --> - + - + android:layout_weight="1" + android:orientation="vertical"> + + + + + - - - \ No newline at end of file + android:focusable="false" + android:gravity="right|center_vertical" + android:paddingTop="5dp"/> + \ No newline at end of file