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

Justified Text Across Whole App #423

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ashu-dadhich
Copy link

PR for issue #337.
Summary
Used bluejamesbond/TextJustify-Android(https://github.com/bluejamesbond/TextJustify-Android) in order to justify text across whole app.

Changes:

  • Moved Redundant Code to JustificationUtil.
  • Corrected naming conventions in both java and xml code.

Issue Video link(youtube):

@ashu-dadhich
Copy link
Author

ashu-dadhich commented Apr 5, 2017

@sandarumk please review.
Thank you

@sandarumk sandarumk requested review from Buddhiprabha and removed request for Buddhiprabha April 11, 2017 18:36
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.

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

public class FormattedSafetyPlanBasicsContentFragment extends DialogFragment {
Copy link

Choose a reason for hiding this comment

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

No need to create a formatted fragment. Is there any dependency for not changing the original fragment?


public DocumentView addDocumentView(CharSequence article, int type, boolean rtl) {
final DocumentView documentView = new DocumentView(mContext, type);
documentView.getDocumentLayoutParams().setTextColor(mContext.getResources().getColor(R.color.primary_text_default_material_dark));
Copy link

Choose a reason for hiding this comment

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

Can't you use JustificationUtil

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for telling me about it will correct this by tomorrow.


public DocumentView addDocumentView(CharSequence article, int type, boolean rtl) {
final DocumentView documentView = new DocumentView(getActivity(), type);
documentView.getDocumentLayoutParams().setTextColor(getResources().getColor(R.color.primary_text_default_material_dark));
Copy link

Choose a reason for hiding this comment

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

Can't you use JustificationUtil

Copy link
Author

Choose a reason for hiding this comment

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

Will correct it by tomorrow.

true, new RelativeSizeSpan(1f), new JustifiedSpan());
DocumentView reporting_step1 = util.addDocumentView(Html.toHtml(articleBuilder1),
DocumentView.FORMATTED_TEXT, false, getActivity());
reporting_step1.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
Copy link

Choose a reason for hiding this comment

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

So many code duplicates here. Move the common part to a single method

Copy link
Author

Choose a reason for hiding this comment

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

Same reason as StepsFragment.java

View rootView = inflater.inflate(R.layout.fragment_reporting_steps, container, false);
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.after_assault);

ArticleBuilder articleBuilder1 = new ArticleBuilder();
Copy link

Choose a reason for hiding this comment

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

Remove code duplicates

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 for that but I was forced to do that since in this library it is required to create new instance of every-time we are justifying a new block of text in the same screen.

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link

Choose a reason for hiding this comment

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

If possible update the original one instead of creating new one

@ashu-dadhich
Copy link
Author

ashu-dadhich commented Apr 11, 2017

@chamika the library has a slight problem since it been made over scroll view. It treats both the formatted(bold/hyperlinked etx) and plain text in the same. i.e. when we try to justify the formatted text it is justified but its formatting goes away.

So after numerous trail and errors and contacting with its maintainer I found out that in order to make the formatted text justified I had to do it programmatically using article builder instead of the conventional method i.e. using XML.

Reason for creating new layouts instead of creating new ones?
Some portions of the app share the same xml layout. But as I have mentioned before the formatted and the plain text needed to be treated differently. Thats why a formatted variant of the layout was created so that it could be used to justify formatted text.

Why not change the library?
Because this gives more control over the justified text and due to this word spacing remains uniform which is not the case with other libraries.

AND

thank you for reviewing it!

@ashu-dadhich
Copy link
Author

ashu-dadhich commented Apr 13, 2017

@sandarumk @chamika changes done.
Changes:

  • now the javaUtil function supports all three adapter/activity/fragment classes.

Please review.
Thank you

@ashu-dadhich
Copy link
Author

@sandarumk is this PR approved? if not what other changes do I have to do please tell.

@sandarumk
Copy link

@top-gun007 can you have a look at Codecy errors and fix them as well?

@ashu-dadhich
Copy link
Author

will fix them @sandarumk

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants