Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies {
compile 'com.android.support:support-v4:23.4.0'



compile 'com.github.bluejamesbond:textjustify-android:2.1.6'
compile 'com.android.support.test.espresso:espresso-core:2.2.2'
compile 'com.android.support.test:runner:0.5'
}
21 changes: 10 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name" />

<activity
android:name=".reporting.Confidentiality"
android:label="@string/title_activity_confidentiality" />
Expand All @@ -36,8 +36,7 @@
android:name=".circle_of_trust.Trustees"
android:label="@string/title_activity_trustees"
android:parentActivityName=".MainActivity"
android:windowSoftInputMode="adjustPan|stateAlwaysHidden"
>
android:windowSoftInputMode="adjustPan|stateAlwaysHidden">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.peacecorps.pcsa.MainActivity" />
Expand All @@ -60,10 +59,10 @@
</activity>
<activity
android:name=".UserSettingsActivity"
android:configChanges="orientation|screenSize"
android:label="@string/user_settings_activity"
android:parentActivityName=".MainActivity"
android:windowSoftInputMode="adjustPan|stateAlwaysHidden"
android:configChanges="orientation|screenSize">
Copy link

@chamika chamika Apr 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you remove configChanges?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologise if I misunderstood something but I think the config changes are there. I just reformatted the code of "AndroidManifest" since it was not aligned properly.

android:windowSoftInputMode="adjustPan|stateAlwaysHidden">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.peacecorps.pcsa.MainActivity" />
Expand All @@ -73,18 +72,18 @@
android:label="@string/title_activity_login"
android:parentActivityName=".SplashScreenActivity"
android:theme="@style/MyMaterialTheme"
android:windowSoftInputMode="adjustPan|stateAlwaysHidden"
>
android:windowSoftInputMode="adjustPan|stateAlwaysHidden">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.peacecorps.pcsa.SplashScreenActivity" />
</activity>
<activity android:name=".circle_of_trust.CircleIntroActivity"
<activity
android:name=".circle_of_trust.CircleIntroActivity"
android:label="@string/title_activity_circle_intro"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.peacecorps.pcsa.MainActivity" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.peacecorps.pcsa.MainActivity" />
</activity>
</application>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.peacecorps.pcsa;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.text.style.RelativeSizeSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bluejamesbond.text.DocumentView;
import com.bluejamesbond.text.hyphen.DefaultHyphenator;
import com.bluejamesbond.text.style.JustifiedSpan;
import com.bluejamesbond.text.style.TextAlignment;
import com.bluejamesbond.text.util.ArticleBuilder;

/**
* Created by ashu on 5/2/17.
*/

public class FormattedSingleTextViewFragment extends Fragment {
public static final String TAG = FormattedSingleTextViewFragment.class.getSimpleName();
public static final String TOOLBAR_KEY = "TOOLBAR";
public static final String CONTENT_KEY = "CONTENT";
public static final String SUBTITLE_KEY = "SUBTITLE";
TextView subTitle;
DocumentView content;
String toolbarTitle, subtitle, contentString;

/**
* Populates the required data for the layout which appears
*
* @param subTitle subtitle of the layout
* @param contentToShow data to be displayed
* @param toolbarString displayed on the toolbar
*/
public static void showSingleTextLayout(FragmentActivity mainActivity, String toolbarString, String subTitle, String contentToShow) {
FormattedSingleTextViewFragment singleTextViewFragment = new FormattedSingleTextViewFragment();
Bundle bundle = new Bundle();
bundle.putString(SingleTextViewFragment.TOOLBAR_KEY, toolbarString);
bundle.putString(SingleTextViewFragment.SUBTITLE_KEY, subTitle);
bundle.putString(SingleTextViewFragment.CONTENT_KEY, contentToShow);
singleTextViewFragment.setArguments(bundle);

//Swapping Single Textview Fragment into the fragment container
MainActivity.swapFragmentIn(mainActivity, singleTextViewFragment, FormattedSingleTextViewFragment.TAG, true);
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

View rootView = inflater.inflate(R.layout.fragment_formatted_single_textview, container, false);
subTitle = (TextView) rootView.findViewById(R.id.layout_subtitle);
//content = (DocumentView) rootView.findViewById(R.id.layout_content);
JustificationUtil util = new JustificationUtil(getActivity().getApplicationContext());
toolbarTitle = getArguments().getString(TOOLBAR_KEY);
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(toolbarTitle);
subtitle = getArguments().getString(SUBTITLE_KEY);
subTitle.setText(subtitle);
contentString = getArguments().getString(CONTENT_KEY);

ArticleBuilder articleBuilder = new ArticleBuilder();
articleBuilder.append(contentString, true, new RelativeSizeSpan(1f), new JustifiedSpan());
content = util.addDocumentView(Html.toHtml(articleBuilder), DocumentView.FORMATTED_TEXT, false,null,
getActivity());
content.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
content.getDocumentLayoutParams().setHyphenator(DefaultHyphenator.
getInstance(DefaultHyphenator.HyphenPattern.PT));
content.getDocumentLayoutParams().setHyphenated(true);
LinearLayout linearLayout = (LinearLayout) rootView.findViewById(R.id.layout_content);
linearLayout.addView(content);
return rootView;
}
}
75 changes: 75 additions & 0 deletions app/src/main/java/com/peacecorps/pcsa/JustificationUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.peacecorps.pcsa;

/**
* Created by ashu on 3/3/17.
*/

import android.app.Activity;
import android.content.Context;
import android.graphics.Typeface;
import android.text.Html;

import com.bluejamesbond.text.DocumentView;
import com.bluejamesbond.text.hyphen.DefaultHyphenator;
import com.bluejamesbond.text.style.TextAlignment;

public final class JustificationUtil {
private static Context context;

public JustificationUtil(Context context) {
this.context = context;
}

public static DocumentView addDocumentView(CharSequence article, int type, boolean isOtherStaffContent,Context mContext, Activity activity) {
final DocumentView documentView;
if(mContext!=null){
documentView= new DocumentView(mContext, type);
}else {
documentView = new DocumentView(activity, type);
}
documentView.getDocumentLayoutParams().setTextColor(context.getResources().getColor(R.color.primary_text_default_material_dark));
documentView.getDocumentLayoutParams().setTextTypeface(Typeface.DEFAULT);
if (isOtherStaffContent) {
documentView.getDocumentLayoutParams().setTextSize(16f);
} else {
documentView.getDocumentLayoutParams().setTextSize(17f);
}
documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
documentView.getDocumentLayoutParams().setInsetPaddingLeft(10);
documentView.getDocumentLayoutParams().setInsetPaddingRight(10);
documentView.getDocumentLayoutParams().setAntialias(true);
documentView.getDocumentLayoutParams().setInsetPaddingTop(10);
documentView.getDocumentLayoutParams().setInsetPaddingBottom(10);
documentView.getDocumentLayoutParams().setHyphenator(DefaultHyphenator.
getInstance(DefaultHyphenator.HyphenPattern.PT));
documentView.getDocumentLayoutParams().setHyphenated(true);
documentView.setText(Html.fromHtml(article.toString()));
return documentView;
}

// public static DocumentView addDocumentViewC(CharSequence article, int type, boolean isOtherStaffContent, Context activity) {
// final DocumentView documentView = new DocumentView(activity, type);
// documentView.getDocumentLayoutParams().setTextColor(context.getResources().getColor(R.color.primary_text_default_material_dark));
// documentView.getDocumentLayoutParams().setTextTypeface(Typeface.DEFAULT);
// if (isOtherStaffContent) {
// documentView.getDocumentLayoutParams().setTextSize(16f);
// } else {
// documentView.getDocumentLayoutParams().setTextSize(17f);
// }
// documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
// documentView.getDocumentLayoutParams().setInsetPaddingLeft(10);
// documentView.getDocumentLayoutParams().setInsetPaddingRight(10);
// documentView.getDocumentLayoutParams().setAntialias(true);
// documentView.getDocumentLayoutParams().setInsetPaddingTop(10);
// documentView.getDocumentLayoutParams().setInsetPaddingBottom(10);
// documentView.getDocumentLayoutParams().setHyphenator(DefaultHyphenator.
// getInstance(DefaultHyphenator.HyphenPattern.PT));
// documentView.getDocumentLayoutParams().setHyphenated(true);
// documentView.setText(Html.fromHtml(article.toString()));
// return documentView;
// }

// public static DocumentView addDocumentView(CharSequence article, int type,boolean isOtherStaffContent,Activity activity) {
// return addDocumentView(article, type, false,activity);
// }
}
4 changes: 2 additions & 2 deletions app/src/main/java/com/peacecorps/pcsa/SignupActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ protected void onCreate(Bundle savedInstanceState) {
String[] countries = getResources().getStringArray(R.array.countryArray);

ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this, R.layout.textview, countries);
adapter.setDropDownViewResource(R.layout.textview);
new ArrayAdapter<String>(this, R.layout.textview_plain, countries);
adapter.setDropDownViewResource(R.layout.textview_plain);
country.setAdapter(adapter);
country.setOnItemSelectedListener(this);
loginButton.setOnClickListener(new View.OnClickListener() {
Expand Down
59 changes: 33 additions & 26 deletions app/src/main/java/com/peacecorps/pcsa/SingleTextViewFragment.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package com.peacecorps.pcsa;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bluejamesbond.text.DocumentView;
import com.bluejamesbond.text.hyphen.DefaultHyphenator;

/**
* This class has to be instantiated for all layouts which have a single text view
*
* @author rohan
* @since 2016-07-18
*/
Expand All @@ -24,42 +26,47 @@ public class SingleTextViewFragment extends Fragment {
public static final String TOOLBAR_KEY = "TOOLBAR";
public static final String CONTENT_KEY = "CONTENT";
public static final String SUBTITLE_KEY = "SUBTITLE";
TextView subTitle, content;
TextView subTitle;
DocumentView content;
String toolbarTitle, subtitle, contentString;

/**
* Populates the required data for the layout which appears
*
* @param subTitle subtitle of the layout
* @param contentToShow data to be displayed
* @param toolbarString displayed on the toolbar
*/
public static void showSingleTextLayout(FragmentActivity mainActivity, String toolbarString, String subTitle, String contentToShow) {
SingleTextViewFragment singleTextViewFragment = new SingleTextViewFragment();
Bundle bundle = new Bundle();
bundle.putString(SingleTextViewFragment.TOOLBAR_KEY, toolbarString);
bundle.putString(SingleTextViewFragment.SUBTITLE_KEY, subTitle);
bundle.putString(SingleTextViewFragment.CONTENT_KEY, contentToShow);
singleTextViewFragment.setArguments(bundle);

//Swapping Single Textview Fragment into the fragment container
MainActivity.swapFragmentIn(mainActivity, singleTextViewFragment, SingleTextViewFragment.TAG, true);
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

View rootView = inflater.inflate(R.layout.fragment_single_textview, container, false);
subTitle = (TextView)rootView.findViewById(R.id.layout_subtitle);
content = (TextView)rootView.findViewById(R.id.layout_content);
subTitle = (TextView) rootView.findViewById(R.id.layout_subtitle);
content = (DocumentView) rootView.findViewById(R.id.layout_content);
toolbarTitle = getArguments().getString(TOOLBAR_KEY);
((AppCompatActivity)getActivity()).getSupportActionBar().setTitle(toolbarTitle);
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(toolbarTitle);
subtitle = getArguments().getString(SUBTITLE_KEY);
subTitle.setText(subtitle);
contentString = getArguments().getString(CONTENT_KEY);
content.setText(Html.fromHtml(contentString));
content.setMovementMethod(new ScrollingMovementMethod());
return rootView;
}

/**
* Populates the required data for the layout which appears
* @param subTitle subtitle of the layout
* @param contentToShow data to be displayed
* @param toolbarString displayed on the toolbar
*/
public static void showSingleTextLayout(FragmentActivity mainActivity, String toolbarString, String subTitle, String contentToShow)
{
SingleTextViewFragment singleTextViewFragment = new SingleTextViewFragment();
Bundle bundle = new Bundle();
bundle.putString(SingleTextViewFragment.TOOLBAR_KEY,toolbarString);
bundle.putString(SingleTextViewFragment.SUBTITLE_KEY,subTitle);
bundle.putString(SingleTextViewFragment.CONTENT_KEY,contentToShow);
singleTextViewFragment.setArguments(bundle);

//Swapping Single Textview Fragment into the fragment container
MainActivity.swapFragmentIn(mainActivity,singleTextViewFragment,SingleTextViewFragment.TAG,true);
content.getDocumentLayoutParams().setHyphenator(DefaultHyphenator.
getInstance(DefaultHyphenator.HyphenPattern.PT));
content.getDocumentLayoutParams().setHyphenated(true);
//content.setMovementMethod(new ScrollingMovementMethod());
return rootView;
}
}
Loading