Loading microg-ui-tools/src/main/java/org/microg/tools/selfcheck/SelfCheckGroup.java +7 −0 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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 { Loading microg-ui-tools/src/main/java/org/microg/tools/ui/AbstractSelfCheckFragment.java +25 −4 Original line number Diff line number Diff line Loading @@ -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<SelfCheckGroup> 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<SelfCheckGroup> checks); protected void reset(LayoutInflater inflater) { List<SelfCheckGroup> selfCheckGroupList = new ArrayList<SelfCheckGroup>(); 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())); Loading @@ -64,7 +72,6 @@ public abstract class AbstractSelfCheckFragment extends Fragment { } root.addView(groupView); } return scrollRoot; } private class GroupResultCollector implements SelfCheckGroup.ResultCollector { Loading @@ -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 Loading @@ -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); } }); } } } microg-ui-tools/src/main/res/layout/self_check_entry.xml +34 −29 Original line number Diff line number Diff line Loading @@ -15,39 +15,44 @@ ~ limitations under the License. --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" android:gravity="center_vertical" android:orientation="horizontal" android:paddingBottom="5dp" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:paddingLeft="?attr/listPreferredItemPaddingLeft" android:paddingRight="?attr/listPreferredItemPaddingRight" android:paddingStart="?android:attr/listPreferredItemPaddingStart"> <LinearLayout android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:paddingTop="5dp" android:id="@+id/self_check_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?attr/textAppearanceListItem" android:textColor="?android:textColorPrimary"/> <CheckBox android:id="@+id/self_check_result" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:focusable="false"/> <TextView android:id="@+id/self_check_resolution" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@id/self_check_name" android:layout_below="@id/self_check_name" android:layout_toLeftOf="@id/self_check_result" android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textColor="?android:textColorSecondary"/> </RelativeLayout> No newline at end of file </LinearLayout> <CheckBox android:id="@+id/self_check_result" android:layout_width="wrap_content" android:layout_height="wrap_content" android:focusable="false" android:gravity="right|center_vertical" android:paddingTop="5dp"/> </LinearLayout> No newline at end of file Loading
microg-ui-tools/src/main/java/org/microg/tools/selfcheck/SelfCheckGroup.java +7 −0 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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 { Loading
microg-ui-tools/src/main/java/org/microg/tools/ui/AbstractSelfCheckFragment.java +25 −4 Original line number Diff line number Diff line Loading @@ -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<SelfCheckGroup> 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<SelfCheckGroup> checks); protected void reset(LayoutInflater inflater) { List<SelfCheckGroup> selfCheckGroupList = new ArrayList<SelfCheckGroup>(); 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())); Loading @@ -64,7 +72,6 @@ public abstract class AbstractSelfCheckFragment extends Fragment { } root.addView(groupView); } return scrollRoot; } private class GroupResultCollector implements SelfCheckGroup.ResultCollector { Loading @@ -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 Loading @@ -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); } }); } } }
microg-ui-tools/src/main/res/layout/self_check_entry.xml +34 −29 Original line number Diff line number Diff line Loading @@ -15,39 +15,44 @@ ~ limitations under the License. --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" android:gravity="center_vertical" android:orientation="horizontal" android:paddingBottom="5dp" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:paddingLeft="?attr/listPreferredItemPaddingLeft" android:paddingRight="?attr/listPreferredItemPaddingRight" android:paddingStart="?android:attr/listPreferredItemPaddingStart"> <LinearLayout android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:paddingTop="5dp" android:id="@+id/self_check_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?attr/textAppearanceListItem" android:textColor="?android:textColorPrimary"/> <CheckBox android:id="@+id/self_check_result" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:focusable="false"/> <TextView android:id="@+id/self_check_resolution" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@id/self_check_name" android:layout_below="@id/self_check_name" android:layout_toLeftOf="@id/self_check_result" android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textColor="?android:textColorSecondary"/> </RelativeLayout> No newline at end of file </LinearLayout> <CheckBox android:id="@+id/self_check_result" android:layout_width="wrap_content" android:layout_height="wrap_content" android:focusable="false" android:gravity="right|center_vertical" android:paddingTop="5dp"/> </LinearLayout> No newline at end of file