Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.

Commit 8ccd4b8

Browse files
committed
justificationSuggestedChangesDone
1 parent 2061d82 commit 8ccd4b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1359
-584
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies {
3333
compile 'com.android.support:support-v4:23.4.0'
3434

3535

36-
36+
compile 'com.github.bluejamesbond:textjustify-android:2.1.6'
3737
compile 'com.android.support.test.espresso:espresso-core:2.2.2'
3838
compile 'com.android.support.test:runner:0.5'
3939
}

app/src/main/AndroidManifest.xml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<activity
2626
android:name=".MainActivity"
2727
android:label="@string/app_name" />
28-
28+
2929
<activity
3030
android:name=".reporting.Confidentiality"
3131
android:label="@string/title_activity_confidentiality" />
@@ -36,8 +36,7 @@
3636
android:name=".circle_of_trust.Trustees"
3737
android:label="@string/title_activity_trustees"
3838
android:parentActivityName=".MainActivity"
39-
android:windowSoftInputMode="adjustPan|stateAlwaysHidden"
40-
>
39+
android:windowSoftInputMode="adjustPan|stateAlwaysHidden">
4140
<meta-data
4241
android:name="android.support.PARENT_ACTIVITY"
4342
android:value="com.peacecorps.pcsa.MainActivity" />
@@ -60,10 +59,10 @@
6059
</activity>
6160
<activity
6261
android:name=".UserSettingsActivity"
62+
android:configChanges="orientation|screenSize"
6363
android:label="@string/user_settings_activity"
6464
android:parentActivityName=".MainActivity"
65-
android:windowSoftInputMode="adjustPan|stateAlwaysHidden"
66-
android:configChanges="orientation|screenSize">
65+
android:windowSoftInputMode="adjustPan|stateAlwaysHidden">
6766
<meta-data
6867
android:name="android.support.PARENT_ACTIVITY"
6968
android:value="com.peacecorps.pcsa.MainActivity" />
@@ -73,18 +72,18 @@
7372
android:label="@string/title_activity_login"
7473
android:parentActivityName=".SplashScreenActivity"
7574
android:theme="@style/MyMaterialTheme"
76-
android:windowSoftInputMode="adjustPan|stateAlwaysHidden"
77-
>
75+
android:windowSoftInputMode="adjustPan|stateAlwaysHidden">
7876
<meta-data
7977
android:name="android.support.PARENT_ACTIVITY"
8078
android:value="com.peacecorps.pcsa.SplashScreenActivity" />
8179
</activity>
82-
<activity android:name=".circle_of_trust.CircleIntroActivity"
80+
<activity
81+
android:name=".circle_of_trust.CircleIntroActivity"
8382
android:label="@string/title_activity_circle_intro"
8483
android:parentActivityName=".MainActivity">
85-
<meta-data
86-
android:name="android.support.PARENT_ACTIVITY"
87-
android:value="com.peacecorps.pcsa.MainActivity" />
84+
<meta-data
85+
android:name="android.support.PARENT_ACTIVITY"
86+
android:value="com.peacecorps.pcsa.MainActivity" />
8887
</activity>
8988
</application>
9089

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.peacecorps.pcsa;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.support.v4.app.Fragment;
6+
import android.support.v4.app.FragmentActivity;
7+
import android.support.v7.app.AppCompatActivity;
8+
import android.text.Html;
9+
import android.text.style.RelativeSizeSpan;
10+
import android.view.LayoutInflater;
11+
import android.view.View;
12+
import android.view.ViewGroup;
13+
import android.widget.LinearLayout;
14+
import android.widget.TextView;
15+
16+
import com.bluejamesbond.text.DocumentView;
17+
import com.bluejamesbond.text.hyphen.DefaultHyphenator;
18+
import com.bluejamesbond.text.style.JustifiedSpan;
19+
import com.bluejamesbond.text.style.TextAlignment;
20+
import com.bluejamesbond.text.util.ArticleBuilder;
21+
22+
/**
23+
* Created by ashu on 5/2/17.
24+
*/
25+
26+
public class FormattedSingleTextViewFragment extends Fragment {
27+
public static final String TAG = FormattedSingleTextViewFragment.class.getSimpleName();
28+
public static final String TOOLBAR_KEY = "TOOLBAR";
29+
public static final String CONTENT_KEY = "CONTENT";
30+
public static final String SUBTITLE_KEY = "SUBTITLE";
31+
TextView subTitle;
32+
DocumentView content;
33+
String toolbarTitle, subtitle, contentString;
34+
35+
/**
36+
* Populates the required data for the layout which appears
37+
*
38+
* @param subTitle subtitle of the layout
39+
* @param contentToShow data to be displayed
40+
* @param toolbarString displayed on the toolbar
41+
*/
42+
public static void showSingleTextLayout(FragmentActivity mainActivity, String toolbarString, String subTitle, String contentToShow) {
43+
FormattedSingleTextViewFragment singleTextViewFragment = new FormattedSingleTextViewFragment();
44+
Bundle bundle = new Bundle();
45+
bundle.putString(SingleTextViewFragment.TOOLBAR_KEY, toolbarString);
46+
bundle.putString(SingleTextViewFragment.SUBTITLE_KEY, subTitle);
47+
bundle.putString(SingleTextViewFragment.CONTENT_KEY, contentToShow);
48+
singleTextViewFragment.setArguments(bundle);
49+
50+
//Swapping Single Textview Fragment into the fragment container
51+
MainActivity.swapFragmentIn(mainActivity, singleTextViewFragment, FormattedSingleTextViewFragment.TAG, true);
52+
}
53+
54+
@Nullable
55+
@Override
56+
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
57+
58+
View rootView = inflater.inflate(R.layout.fragment_formatted_single_textview, container, false);
59+
subTitle = (TextView) rootView.findViewById(R.id.layout_subtitle);
60+
//content = (DocumentView) rootView.findViewById(R.id.layout_content);
61+
JustificationUtil util = new JustificationUtil(getActivity().getApplicationContext());
62+
toolbarTitle = getArguments().getString(TOOLBAR_KEY);
63+
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(toolbarTitle);
64+
subtitle = getArguments().getString(SUBTITLE_KEY);
65+
subTitle.setText(subtitle);
66+
contentString = getArguments().getString(CONTENT_KEY);
67+
68+
ArticleBuilder articleBuilder = new ArticleBuilder();
69+
articleBuilder.append(contentString, true, new RelativeSizeSpan(1f), new JustifiedSpan());
70+
content = util.addDocumentView(Html.toHtml(articleBuilder), DocumentView.FORMATTED_TEXT, false,null,
71+
getActivity());
72+
content.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
73+
content.getDocumentLayoutParams().setHyphenator(DefaultHyphenator.
74+
getInstance(DefaultHyphenator.HyphenPattern.PT));
75+
content.getDocumentLayoutParams().setHyphenated(true);
76+
LinearLayout linearLayout = (LinearLayout) rootView.findViewById(R.id.layout_content);
77+
linearLayout.addView(content);
78+
return rootView;
79+
}
80+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.peacecorps.pcsa;
2+
3+
/**
4+
* Created by ashu on 3/3/17.
5+
*/
6+
7+
import android.app.Activity;
8+
import android.content.Context;
9+
import android.graphics.Typeface;
10+
import android.text.Html;
11+
12+
import com.bluejamesbond.text.DocumentView;
13+
import com.bluejamesbond.text.hyphen.DefaultHyphenator;
14+
import com.bluejamesbond.text.style.TextAlignment;
15+
16+
public final class JustificationUtil {
17+
private static Context context;
18+
19+
public JustificationUtil(Context context) {
20+
this.context = context;
21+
}
22+
23+
public static DocumentView addDocumentView(CharSequence article, int type, boolean isOtherStaffContent,Context mContext, Activity activity) {
24+
final DocumentView documentView;
25+
if(mContext!=null){
26+
documentView= new DocumentView(mContext, type);
27+
}else {
28+
documentView = new DocumentView(activity, type);
29+
}
30+
documentView.getDocumentLayoutParams().setTextColor(context.getResources().getColor(R.color.primary_text_default_material_dark));
31+
documentView.getDocumentLayoutParams().setTextTypeface(Typeface.DEFAULT);
32+
if (isOtherStaffContent) {
33+
documentView.getDocumentLayoutParams().setTextSize(16f);
34+
} else {
35+
documentView.getDocumentLayoutParams().setTextSize(17f);
36+
}
37+
documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
38+
documentView.getDocumentLayoutParams().setInsetPaddingLeft(10);
39+
documentView.getDocumentLayoutParams().setInsetPaddingRight(10);
40+
documentView.getDocumentLayoutParams().setAntialias(true);
41+
documentView.getDocumentLayoutParams().setInsetPaddingTop(10);
42+
documentView.getDocumentLayoutParams().setInsetPaddingBottom(10);
43+
documentView.getDocumentLayoutParams().setHyphenator(DefaultHyphenator.
44+
getInstance(DefaultHyphenator.HyphenPattern.PT));
45+
documentView.getDocumentLayoutParams().setHyphenated(true);
46+
documentView.setText(Html.fromHtml(article.toString()));
47+
return documentView;
48+
}
49+
50+
// public static DocumentView addDocumentViewC(CharSequence article, int type, boolean isOtherStaffContent, Context activity) {
51+
// final DocumentView documentView = new DocumentView(activity, type);
52+
// documentView.getDocumentLayoutParams().setTextColor(context.getResources().getColor(R.color.primary_text_default_material_dark));
53+
// documentView.getDocumentLayoutParams().setTextTypeface(Typeface.DEFAULT);
54+
// if (isOtherStaffContent) {
55+
// documentView.getDocumentLayoutParams().setTextSize(16f);
56+
// } else {
57+
// documentView.getDocumentLayoutParams().setTextSize(17f);
58+
// }
59+
// documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
60+
// documentView.getDocumentLayoutParams().setInsetPaddingLeft(10);
61+
// documentView.getDocumentLayoutParams().setInsetPaddingRight(10);
62+
// documentView.getDocumentLayoutParams().setAntialias(true);
63+
// documentView.getDocumentLayoutParams().setInsetPaddingTop(10);
64+
// documentView.getDocumentLayoutParams().setInsetPaddingBottom(10);
65+
// documentView.getDocumentLayoutParams().setHyphenator(DefaultHyphenator.
66+
// getInstance(DefaultHyphenator.HyphenPattern.PT));
67+
// documentView.getDocumentLayoutParams().setHyphenated(true);
68+
// documentView.setText(Html.fromHtml(article.toString()));
69+
// return documentView;
70+
// }
71+
72+
// public static DocumentView addDocumentView(CharSequence article, int type,boolean isOtherStaffContent,Activity activity) {
73+
// return addDocumentView(article, type, false,activity);
74+
// }
75+
}

app/src/main/java/com/peacecorps/pcsa/SignupActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ protected void onCreate(Bundle savedInstanceState) {
5151
String[] countries = getResources().getStringArray(R.array.countryArray);
5252

5353
ArrayAdapter<String> adapter =
54-
new ArrayAdapter<String>(this, R.layout.textview, countries);
55-
adapter.setDropDownViewResource(R.layout.textview);
54+
new ArrayAdapter<String>(this, R.layout.textview_plain, countries);
55+
adapter.setDropDownViewResource(R.layout.textview_plain);
5656
country.setAdapter(adapter);
5757
country.setOnItemSelectedListener(this);
5858
loginButton.setOnClickListener(new View.OnClickListener() {
Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
package com.peacecorps.pcsa;
22

3-
import android.content.Context;
43
import android.os.Bundle;
54
import android.support.annotation.Nullable;
65
import android.support.v4.app.Fragment;
76
import android.support.v4.app.FragmentActivity;
87
import android.support.v7.app.AppCompatActivity;
98
import android.text.Html;
10-
import android.text.method.ScrollingMovementMethod;
119
import android.view.LayoutInflater;
1210
import android.view.View;
1311
import android.view.ViewGroup;
1412
import android.widget.TextView;
1513

14+
import com.bluejamesbond.text.DocumentView;
15+
import com.bluejamesbond.text.hyphen.DefaultHyphenator;
16+
1617
/**
1718
* This class has to be instantiated for all layouts which have a single text view
19+
*
1820
* @author rohan
1921
* @since 2016-07-18
2022
*/
@@ -24,42 +26,47 @@ public class SingleTextViewFragment extends Fragment {
2426
public static final String TOOLBAR_KEY = "TOOLBAR";
2527
public static final String CONTENT_KEY = "CONTENT";
2628
public static final String SUBTITLE_KEY = "SUBTITLE";
27-
TextView subTitle, content;
29+
TextView subTitle;
30+
DocumentView content;
2831
String toolbarTitle, subtitle, contentString;
2932

33+
/**
34+
* Populates the required data for the layout which appears
35+
*
36+
* @param subTitle subtitle of the layout
37+
* @param contentToShow data to be displayed
38+
* @param toolbarString displayed on the toolbar
39+
*/
40+
public static void showSingleTextLayout(FragmentActivity mainActivity, String toolbarString, String subTitle, String contentToShow) {
41+
SingleTextViewFragment singleTextViewFragment = new SingleTextViewFragment();
42+
Bundle bundle = new Bundle();
43+
bundle.putString(SingleTextViewFragment.TOOLBAR_KEY, toolbarString);
44+
bundle.putString(SingleTextViewFragment.SUBTITLE_KEY, subTitle);
45+
bundle.putString(SingleTextViewFragment.CONTENT_KEY, contentToShow);
46+
singleTextViewFragment.setArguments(bundle);
47+
48+
//Swapping Single Textview Fragment into the fragment container
49+
MainActivity.swapFragmentIn(mainActivity, singleTextViewFragment, SingleTextViewFragment.TAG, true);
50+
}
51+
3052
@Nullable
3153
@Override
3254
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
3355

3456
View rootView = inflater.inflate(R.layout.fragment_single_textview, container, false);
35-
subTitle = (TextView)rootView.findViewById(R.id.layout_subtitle);
36-
content = (TextView)rootView.findViewById(R.id.layout_content);
57+
subTitle = (TextView) rootView.findViewById(R.id.layout_subtitle);
58+
content = (DocumentView) rootView.findViewById(R.id.layout_content);
3759
toolbarTitle = getArguments().getString(TOOLBAR_KEY);
38-
((AppCompatActivity)getActivity()).getSupportActionBar().setTitle(toolbarTitle);
60+
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(toolbarTitle);
3961
subtitle = getArguments().getString(SUBTITLE_KEY);
4062
subTitle.setText(subtitle);
4163
contentString = getArguments().getString(CONTENT_KEY);
4264
content.setText(Html.fromHtml(contentString));
43-
content.setMovementMethod(new ScrollingMovementMethod());
44-
return rootView;
45-
}
46-
47-
/**
48-
* Populates the required data for the layout which appears
49-
* @param subTitle subtitle of the layout
50-
* @param contentToShow data to be displayed
51-
* @param toolbarString displayed on the toolbar
52-
*/
53-
public static void showSingleTextLayout(FragmentActivity mainActivity, String toolbarString, String subTitle, String contentToShow)
54-
{
55-
SingleTextViewFragment singleTextViewFragment = new SingleTextViewFragment();
56-
Bundle bundle = new Bundle();
57-
bundle.putString(SingleTextViewFragment.TOOLBAR_KEY,toolbarString);
58-
bundle.putString(SingleTextViewFragment.SUBTITLE_KEY,subTitle);
59-
bundle.putString(SingleTextViewFragment.CONTENT_KEY,contentToShow);
60-
singleTextViewFragment.setArguments(bundle);
6165

62-
//Swapping Single Textview Fragment into the fragment container
63-
MainActivity.swapFragmentIn(mainActivity,singleTextViewFragment,SingleTextViewFragment.TAG,true);
66+
content.getDocumentLayoutParams().setHyphenator(DefaultHyphenator.
67+
getInstance(DefaultHyphenator.HyphenPattern.PT));
68+
content.getDocumentLayoutParams().setHyphenated(true);
69+
//content.setMovementMethod(new ScrollingMovementMethod());
70+
return rootView;
6471
}
6572
}

0 commit comments

Comments
 (0)