-
-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
unifiednlp-base/src/main/java/org/microg/tools/selfcheck/AbstractSelfCheckActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2013-2015 microG Project Team | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.microg.tools.selfcheck; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import org.microg.nlp.R; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public abstract class AbstractSelfCheckActivity extends AppCompatActivity implements SelfCheckGroup.ResultCollector { | ||
|
||
protected abstract void prepareSelfCheckList(List<SelfCheckGroup> checks); | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.self_check); | ||
setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); | ||
|
||
List<SelfCheckGroup> selfCheckGroupList = new ArrayList<SelfCheckGroup>(); | ||
prepareSelfCheckList(selfCheckGroupList); | ||
|
||
for (SelfCheckGroup group : selfCheckGroupList) { | ||
group.doChecks(this, this); | ||
} | ||
} | ||
|
||
public void addResult(String name, boolean result, String resolution) { | ||
ViewGroup root = (ViewGroup) findViewById(R.id.self_check_root); | ||
View resultEntry = LayoutInflater.from(this).inflate(R.layout.self_check_entry, root, false); | ||
((TextView) resultEntry.findViewById(R.id.self_check_name)).setText(name); | ||
((ImageView) resultEntry.findViewById(R.id.self_check_result)).setImageResource(result ? android.R.drawable.presence_online : android.R.drawable.presence_busy); | ||
((TextView) resultEntry.findViewById(R.id.self_check_resolution)).setText(resolution); | ||
resultEntry.findViewById(R.id.self_check_resolution).setVisibility(result ? View.GONE : View.VISIBLE); | ||
root.addView(resultEntry); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
unifiednlp-base/src/main/java/org/microg/tools/selfcheck/SelfCheckGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2013-2015 microG Project Team | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.microg.tools.selfcheck; | ||
|
||
import android.content.Context; | ||
|
||
public interface SelfCheckGroup { | ||
String getGroupName(Context context); | ||
|
||
void doChecks(Context context, ResultCollector collector); | ||
|
||
interface ResultCollector { | ||
void addResult(String name, boolean value, String resolution); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
~ Copyright 2013-2015 microG Project Team | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<include layout="@layout/toolbar"/> | ||
|
||
<ScrollView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<LinearLayout | ||
android:id="@+id/self_check_root" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
</LinearLayout> | ||
</ScrollView> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
~ Copyright 2013-2015 microG Project Team | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:padding="10dp"> | ||
|
||
<TextView | ||
android:id="@+id/self_check_name" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="This is the title of a check: " | ||
android:textStyle="bold"/> | ||
|
||
<ImageView | ||
android:id="@+id/self_check_result" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignBottom="@id/self_check_name" | ||
android:layout_alignParentRight="true" | ||
android:layout_alignRight="@id/self_check_name" | ||
android:src="@android:drawable/presence_busy"/> | ||
|
||
<TextView | ||
android:id="@+id/self_check_resolution" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@id/self_check_name" | ||
android:layout_toLeftOf="@id/self_check_result" | ||
android:text="This is a way to solve the issue that check above failed. It can consist of multiple lines."/> | ||
</RelativeLayout> |