Wednesday, 22 June 2016

Custom Font in Android

In this post we will be learning how to use custom fonts in your project. First i will mention all the necessary steps to do it and then we will check code explanation for complex methods.

Step 1: Download below files and integrate them in your project:
  1. TypeFaceHelper.java
  2. CustomTextView.java
Step 2: Create attrs.xml (if not present) under your res/values folder. Place below code
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <declare-styleable name="CustomTextView">
        <attr name="fontFace" format="string" />
    </declare-styleable>
</resources>
Step 3: Download Custom Fonts. You can use any custom font which you need I have used arial.ttf fonts you can download it from below links
  1. arial.ttf
  2. arial_bold.ttf

Step 4: Place Custom fonts under your assets folder like this
              
Step 5: Refer them in your strings.xml like
      <!-- Fonts -->
          <string name="fonts_normal">arial.ttf</string>
          <string name="fonts_bold">arial_bold.ttf</string>
Step 6: You can use above custom type face in your layout xmls like below:
 <package.name.CustomTextView

        xmlns:coop="http://schemas.android.com/apk/res-auto"
        style="@style/title_font_gray"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        coop:fontFace="@string/fonts_normal" />
 Its Done, Hopefully you can easily integerate this in your projects.

Explainations:
  • TypeFaceHelper- This class allows you to load fonts from your assets directory.
  • CustomTextView- This class takes care to set typeface on your custom textviews. This class also set default typeface or normal font if fontface is not provided in your layout xml. Below lines of code take care of it.

  String fontFace = typedArray.getString(R.styleable.CustomTextView_fontFace);
            if (fontFace == null) {
                fontFace = context.getString(R.string.fonts_normal);
            }
  • CustomTextView class also has some helper methods like- 
    public void useBoldFont(){
        String fontFace = getContext().getString(R.string.fonts_bold);
        setTypeface(TypefaceHelper.getTypeface(getContext(), fontFace));
    }

    public void useNormalFont(){
        String fontFace = getContext().getString(R.string.fonts_normal);
        setTypeface(TypefaceHelper.getTypeface(getContext(), fontFace));
    }
 You can use above methods directly from your code without updating layout xml file.


Happy Coding ...




Custom Font in Android

In this post we will be learning how to use custom fonts in your project. First i will mention all the necessary steps to do it and then we will check code explanation for complex methods.

Step 1: Download below files and integrate them in your project:
  1. TypeFaceHelper.java
  2. CustomTextView.java
Step 2: Create attrs.xml (if not present) under your res/values folder. Place below code
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <declare-styleable name="CustomTextView">
        <attr name="fontFace" format="string" />
    </declare-styleable>
</resources>
Step 3: Download Custom Fonts. You can use any custom font which you need I have used arial.ttf fonts you can download it from below links
  1. arial.ttf
  2. arial_bold.ttf

Step 4: Place Custom fonts under your assets folder like this
              
Step 5: Refer them in your strings.xml like
      <!-- Fonts -->
          <string name="fonts_normal">arial.ttf</string>
          <string name="fonts_bold">arial_bold.ttf</string>
Step 6: You can use above custom type face in your layout xmls like below:
 <package.name.CustomTextView

        xmlns:coop="http://schemas.android.com/apk/res-auto"
        style="@style/title_font_gray"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        coop:fontFace="@string/fonts_normal" />
 Its Done, Hopefully you can easily integerate this in your projects.

Explainations:
  • TypeFaceHelper- This class allows you to load fonts from your assets directory.
  • CustomTextView- This class takes care to set typeface on your custom textviews. This class also set default typeface or normal font if fontface is not provided in your layout xml. Below lines of code take care of it.

  String fontFace = typedArray.getString(R.styleable.CustomTextView_fontFace);
            if (fontFace == null) {
                fontFace = context.getString(R.string.fonts_normal);
            }
  • CustomTextView class also has some helper methods like- 
    public void useBoldFont(){
        String fontFace = getContext().getString(R.string.fonts_bold);
        setTypeface(TypefaceHelper.getTypeface(getContext(), fontFace));
    }

    public void useNormalFont(){
        String fontFace = getContext().getString(R.string.fonts_normal);
        setTypeface(TypefaceHelper.getTypeface(getContext(), fontFace));
    }
 You can use above methods directly from your code without updating layout xml file.


Happy Coding ...




Friday, 17 June 2016

Basic Questions for Mobile Project KT




This Post is basically tell us on which questions or points we need to focus on when we are taking KT from someone for any Mobile project. In IT organizations It happens very frequently that you need to switch to some new project which was already in complete state and the guy who is handling that project is leaving the company. So below are the some of the points that I can thought about, that we can ask to the owner developer regarding the project. 

  1. What is the repository path for Project/POCs and step by step instructions for its setup?
  2. What are the supported OS versions and devices (Retina/Non-Retina/iPhone/iPod Touch/iPad/HDPI/Tablet etc.)?
  3. What are business requirements for Project/POCs. Is there any future planning for any existing Pocs/Change Request? Also, Is there any other POC in pipeline? 
  4. What are the steps needed to create and release build? Is there any way to create build in non-VPN network? (Existing Certificates/Provisioning/Developer Account information).
  5. What are the necessary steps to update/commit code on Gerrit?
  6. Is there any third party framework used in project? (User account information and point of contact for this.) 
  7. In future if, there is a need for new third party framework then who will be the approver for this? Also, what are the steps to add third party libraries in Central repository? 
  8. Is there any encryption tools/methodology used? (Sending a PSI(Personal Sensitive Information)/BSI(Business Sensitive Information) over the network). 
  9. Is there any offline support provided by application? Also, what are the data stored by application in its local storage? (Any user prefs and local DB/Core Data) 
  10. Is there any open requirement/un-tested feature/open bug remaining in the current implementation? 
  11. What are the environments and webservices used by application? Document stating expected parameters and expected response? (Error codes/ mandatory params/optional params/expected response/staging environments / production environments)
  12. What are the common frequent issues and their work-arounds?
  13. Reference path(s) for all necessary documents for project? (Requirement docs/test plans/ UI wire-frames/Visual Design Document/DFD etc.)
  14. What are the different tools used e.g Jira/Appium? Any automated Unit Testing Framework?
  15.   Who are Point of Contact for following:
       Environment Setup Team
       Developement Team (If any)
       Designing Team
       Testing Team
I hope I have covered majority of points that need to be taken care of. If you still think that there are some points that can be helpful to readers, Please add them in comments. Will update my blog with that point along with your name.