This repository was archived by the owner on Nov 8, 2018. It is now read-only.
forked from peacecorps/PCSA
-
Notifications
You must be signed in to change notification settings - Fork 103
Justified Text Across Whole App #423
Open
ashu-dadhich
wants to merge
1
commit into
systers:develop
Choose a base branch
from
ashu-dadhich:just_final
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
80 changes: 80 additions & 0 deletions
80
app/src/main/java/com/peacecorps/pcsa/FormattedSingleTextViewFragment.java
This file contains hidden or 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,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
75
app/src/main/java/com/peacecorps/pcsa/JustificationUtil.java
This file contains hidden or 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,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); | ||
| // } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you remove configChanges?
There was a problem hiding this comment.
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.