Skip to content

Commit

Permalink
Add base stuff for self check
Browse files Browse the repository at this point in the history
  • Loading branch information
mar-v-in committed Jan 2, 2016
1 parent 51bbf1e commit a775593
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 0 deletions.
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);
}
}
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);
}
}
37 changes: 37 additions & 0 deletions unifiednlp-base/src/main/res/layout/self_check.xml
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>
46 changes: 46 additions & 0 deletions unifiednlp-base/src/main/res/layout/self_check_entry.xml
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>

0 comments on commit a775593

Please sign in to comment.