Skip to content

Commit

Permalink
faq page added
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunal committed Jan 20, 2020
1 parent 8fe143b commit 3ea1fb6
Show file tree
Hide file tree
Showing 11 changed files with 311 additions and 18 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ dependencies {
exclude group: "commons-logging", module: "commons-logging"
}
// Test
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation "junit:junit:$rootProject.junitVersion"
androidTestImplementation "com.android.support.test:runner:$rootProject.testRunnerRulesVersion"
androidTestImplementation "com.android.support.test.espresso:espresso-core:$rootProject.espressoVersion"
Expand Down
37 changes: 19 additions & 18 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@
xmlns:tools="http://schemas.android.com/tools"
package="io.neurolab">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<uses-feature android:name="android.hardware.usb.host" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

<application
android:allowBackup="true"
android:hardwareAccelerated="true"
Expand All @@ -23,8 +13,10 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup">
<activity android:name=".activities.ShareDataActivity"
android:label="Share"/>
<activity android:name=".activities.FAQActivity"></activity>
<activity
android:name=".activities.ShareDataActivity"
android:label="Share" />
<activity android:name=".activities.RelaxParentActivity" />
<activity android:name=".activities.PinLayoutActivity" />
<activity android:name=".activities.MeditationListActivity" />
Expand Down Expand Up @@ -62,8 +54,8 @@
</activity>
<activity
android:name=".activities.SettingsActivity"
android:parentActivityName=".main.NeuroLab"
android:configChanges="orientation|keyboardHidden"/>
android:configChanges="orientation|keyboardHidden"
android:parentActivityName=".main.NeuroLab" />
<activity
android:name=".activities.OnBoardingActivity"
android:theme="@style/AppTheme.NoActionBar" />
Expand All @@ -77,6 +69,10 @@
<activity android:name=".activities.DataLoggerActivity" />
<activity android:name=".activities.DeviceInstructionsActivity" />

<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />

<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="io.neurolab.fileprovider"
Expand All @@ -86,10 +82,15 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>

<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>

<uses-feature android:name="android.hardware.usb.host" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

</manifest>
139 changes: 139 additions & 0 deletions app/src/main/java/io/neurolab/activities/FAQActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package io.neurolab.activities;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.TextView;

import io.neurolab.R;

public class FAQActivity extends AppCompatActivity {

private String[] questions;
private String[][] answers;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_faq);

questions = getResources().getStringArray(R.array.faq_questions);

String[] ans = getResources().getStringArray(R.array.faq_answers);
answers = new String[ans.length][];
for (int i = 0; i < ans.length; i++) {
answers[i] = new String[]{ans[i]};
}

ExpandableListView listView;

listView = findViewById(R.id.expListView);
listView.setAdapter(new ExpandableListAdapter(questions, answers));
listView.setGroupIndicator(null);
}

public class ExpandableListAdapter extends BaseExpandableListAdapter {

private final LayoutInflater inf;
private String[] questions;
private String[][] answers;

public ExpandableListAdapter(String[] questions, String[][] answers) {
this.questions = questions;
this.answers = answers;
inf = LayoutInflater.from(getApplication());
}

@Override
public int getGroupCount() {
return questions.length;
}

@Override
public int getChildrenCount(int questionPosition) {
return answers[questionPosition].length;
}

@Override
public Object getGroup(int questionPosition) {
return questions[questionPosition];
}

@Override
public Object getChild(int questionPosition, int answerPosition) {
return answers[questionPosition][answerPosition];
}

@Override
public long getGroupId(int questionPosition) {
return questionPosition;
}

@Override
public long getChildId(int questionPosition, int answerPosition) {
return answerPosition;
}

@Override
public boolean hasStableIds() {
return true;
}

@Override
public View getChildView(int questionPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {

ViewHolder holder;
View v = convertView;
if (v == null) {
v = inf.inflate(R.layout.list_item, parent, false);
holder = new ViewHolder();

holder.text = (TextView) v.findViewById(R.id.lblListItem);
v.setTag(holder);
} else {
holder = (ViewHolder) v.getTag();
}

holder.text.setClickable(true);
holder.text.setMovementMethod(LinkMovementMethod.getInstance());
holder.text.setText(Html.fromHtml(getChild(questionPosition, childPosition).toString()));

return v;
}

@Override
public View getGroupView(int questionPosition, boolean isExpanded, View convertView, ViewGroup parent) {
ViewHolder holder;
View v = convertView;
if (v == null) {
v = inf.inflate(R.layout.list_group, parent, false);

holder = new ViewHolder();
holder.text = (TextView) v.findViewById(R.id.lblListHeader);
v.setTag(holder);
} else {
holder = (ViewHolder) v.getTag();
}

holder.text.setText(getGroup(questionPosition).toString());

return v;
}

@Override
public boolean isChildSelectable(int questionPosition, int answerPosition) {
return true;
}

private class ViewHolder {
private TextView text;
}
}
}
3 changes: 3 additions & 0 deletions app/src/main/java/io/neurolab/main/NeuroLab.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import io.neurolab.activities.AboutUsActivity;
import io.neurolab.activities.DataLoggerActivity;
import io.neurolab.activities.DeviceInstructionsActivity;
import io.neurolab.activities.FAQActivity;
import io.neurolab.activities.FocusParentActivity;
import io.neurolab.activities.MeditationHome;
import io.neurolab.activities.MemoryGraphParent;
Expand Down Expand Up @@ -368,6 +369,8 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
startActivity(new Intent(this, SettingsActivity.class));
} else if (id == R.id.nav_about_us) {
startActivity(new Intent(this, AboutUsActivity.class));
} else if (id == R.id.nav_faq) {
startActivity(new Intent(this, FAQActivity.class));
} else if (id == R.id.nav_share) {
startActivity(new Intent(this, ShareDataActivity.class));
} else if (id == R.id.nav_data_logger) {
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_feedback_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM13,14h-2v-2h2v2zM13,10h-2L11,6h2v4z"/>
</vector>
18 changes: 18 additions & 0 deletions app/src/main/res/layout/activity_faq.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/faq"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical">

<ExpandableListView
android:id="@+id/expListView"
android:layout_margin="@dimen/faq_answer_margin_start"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen_zero_dp"
android:layout_weight="0.14"
android:childDivider="@android:color/transparent">
</ExpandableListView>

</LinearLayout>
45 changes: 45 additions & 0 deletions app/src/main/res/layout/list_group.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="horizontal">

<LinearLayout
android:layout_width="@dimen/list_group_layout_width"
android:layout_height="@dimen/list_group_layout_height"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/faq_question_margin_top"
android:text="@string/question"
android:textAlignment="center"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/faq_question_text_size" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/lblListHeader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:justificationMode="inter_word"
android:paddingBottom="@dimen/text_padding_top"
android:paddingLeft="@dimen/text_padding_top"
android:paddingTop="@dimen/text_padding_top"
android:textColor="@color/colorPrimaryDark"
android:textSize="@dimen/text_size"
tools:ignore="SpUsage" />

</LinearLayout>

</LinearLayout>
35 changes: 35 additions & 0 deletions app/src/main/res/layout/list_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/faq_answer_margin_start"
android:layout_marginTop="@dimen/faq_question_margin_top"
android:text="@string/answer"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="@dimen/faq_question_text_size" />

<TextView
android:id="@+id/lblListItem"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/faq_answer_margin"
android:paddingBottom="@dimen/list_item_padding"
android:paddingLeft="@dimen/text_padding_top"
android:paddingRight="@dimen/text_padding_top"
android:paddingTop="@dimen/list_item_padding"
android:textSize="@dimen/text_size_wavegen" />

</LinearLayout>

</LinearLayout>
5 changes: 5 additions & 0 deletions app/src/main/res/menu/activity_main_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
android:icon="@drawable/ic_info"
android:title="@string/about_us" />

<item
android:id="@+id/nav_faq"
android:icon="@drawable/ic_feedback_black_24dp"
android:title="@string/faq" />

<item
android:id="@+id/nav_share"
android:icon="@drawable/ic_menu_share"
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,16 @@
<dimen name="card_main_layout_padding">16dp</dimen>
<dimen name="image_main_layout_margin">8dp</dimen>
<dimen name="main_content_padding_textview">12dp</dimen>
<dimen name="faq_answer_margin_start">15dp</dimen>
<dimen name="dimen_zero_dp">0dp</dimen>
<dimen name="text_size_wavegen">14sp</dimen>
<dimen name="list_item_padding">5dp</dimen>
<dimen name="text_padding_top">10dp</dimen>
<dimen name="faq_answer_margin">20dp</dimen>
<dimen name="faq_question_text_size">20dp</dimen>
<dimen name="faq_question_margin_top">10dp</dimen>
<dimen name="text_size">17sp</dimen>
<dimen name="list_group_layout_height">52dp</dimen>
<dimen name="list_group_layout_width">52dp</dimen>

</resources>
Loading

0 comments on commit 3ea1fb6

Please sign in to comment.