Friday, March 21, 2014

Installing MODx CMS on XAMPP

Steps to install MODx on XAMPP

  1. Download MODx Revolutions Traditional package.
  2. Unzip and extract contents into htdocs folder.
  3. Make user all the required modules are enabled and settings configured in php.ini settings (refer MODx site for requirements)
  4. Rename ht.access file to .htaccess in root, core and manager folder.
    1. Problem with windows is, files can not exist without file name. So ht.access can not be renamed using windows GUI.  Switch to command line mode and do a rename using "rename ht.access .htaccess" command.
  5. Now, browse MODx using your favorite browser.
    1. It  is common to browse to root level index.php page. When browsed to index page, you may encounter "503 Error : Could not load MODx config file" error. eg: if you have extracted contents into "modxdemo" folder, your url would be "localhost/modxdemo".
    2. Instead of navigating to "localhost/modxdemo", navigate to "setup" folder, i.e., "localhost/modxdemo/setup" and follow the setup instruction. 
      1. MODx will show a welcome message, click next.
      2. Leave the default selection of "new installation" and click next.
      3. Provide you DB type and DB connection details, click on "Test database server connection and view collations." link.
      4. If connection is successful, you will be prompted to select collation and character set for the tables.
      5. After selection , click on "Create or test selection of your database".
      6. Provide site admin details and click next.
      7. MODx displays installation summary, and may ask you to correct somethings if it is not right. If every requirement is in green, click install button.
      8. This will install MODx CMS, basically it creates all the necessary tables for content management.
      9. After installation, click next in the summary page.
      10. A final Thanking message is displayed with login button.
      11. Clicking on login button will ensure the setup directory is deleted from the root folder.
      12. Now login with admin credentials and start creating content, installing extensions and templates etc.
      13. Try navigating to root page i.e., "localhost/modxdemo" now, you'll see a blank page. Don't panic here, nothing went wrong. Blank page is displayed because no content is added yet. 
      14. Add some content to home page (Resource) from the admin panel and refresh the page.
       voila...! there you go, you see the content and your site is ready to publish contents using MODx CMS.

There are some workarounds over internet to fix "503 Error : Could not load MODx config file" error. This includes creating "config.inc.php" inside "core/config" folder. This is surely resolve 503 error but results in another error "XPODdriver_ not found", I have no idea of fixing this error by doing any workaround. Instead of getting into some cumbersome techniques and wasting time, follow the steps described above to install MODx and get it up and running smoothly.

Thursday, March 20, 2014

Open Source PHP CMS

There are plenty of CMS out there, some are paid and some are open source. In spite of dozens of framework only few are success in becoming a development choice. Here is the small list of frameworks which are popular.

Wordpress
      Wordpress has a huge developer community with plenty of documentation and tutorials available.
Provide flexibility to create any kind of site with its collection of free and paid plugins. Major drawback with wordpress is, Security issues and no direct support except user forums and community.

Joomla
     Joomla is an award-winning content management system (CMS), which enables you to build Web sites and powerful online applications.Joomla! has a long development history and a very active developer community (with over 200,000 users and contributors), so finding information and tutorials is easy.

Drupal
Drupal has a very active community, with a number of IRC channels, forums, and even face-to-face Drupal events. Drupal is used by many high-profile companies.There are more than 6,000 add-ons (“modules”) available for Drupal, making it easy to extend Drupal’s functionality to do just about anything you want. 

SilverStripe
SilverStripe is good for developers and designers who are comfortable with code. It is a flexible open source Content Management System that gives everyone involved in a web project the tools they need to do their jobs. Users can get official support from SilverStrip LTD.

Cushy CMS
It is free for unlimited users, unlimited changes, unlimited pages and unlimited sites but doesn’t let you use your own logo or your own domain name for the admin panel, or customize the admin experience. Because of the nature of CushyCMS, there are no plugins or pre-defined themes.

Concrete5
Concrete 5 comes with the tag "A CMS made for Marketing, but strong enough for Geeks!". It is  very user-friendly for non-technical users, who may be the ones managing the site’s content. According to the 2010 Open Source CMS Market Share Report, concrete5′s developer community is the fastest growing among any open source CMS.

Frog CMS
It simplifies content management by offering an elegant user interface, flexible templating per page, simple user management and permissions, as well as the tools necessary for file management. Frog CMS is a PHP version of Radiant CMS, a well known Ruby on Rails application.

MODx
MODX Revolution is the web content management system that gives you complete control over your site and content, with the flexibility and scalability to grow with your business.

List of more CMS

PHP Nuke Free
Post Nuke Free
Open Effect Free
Uber PHP CMS Free (German)
Fire Site Free
EZ Publish Free (You can pay to recieve it on a cd with documentation etc) 
Site Box Free
Bee Hive Free version and Paid version (didn't have a price)
Mambo Server Free and Paid versions
Typo3 Free (thanks mjames)
Harpia Free
PHP Portal Project Free/Pay (thanks galt)

Some more CMS

APC ActionApps - http://www.apc.org/actionapps/
Ariadne - http://www.muze.nl/ariadne/
Back-End - http://www.back-end.org
Bitflux - http://www.bitflux.ch/developer/
Bricolage - http://www.bricolage.cc/
C-Arbre - http://realink.org/c-arbre/doc/
CAMPSITE - http://www.campware.org/campsite/
Cocoon - http://xml.apache.org
Cofax - http://www.cofax.org
Coranto - http://coranto.gweilo.org/
DaCode - http://www.dacode.org
DCP-Portal - http://www.dcp-portal.com
Easy Publisher - http://www.easypublisher.com
Edit-X - http://www.edit-x.com/
Geeklog - http://www.geeklog.org
Krysalis - http://www.interakt.ro/products/Krysalis/index.php
Mambo - http://sourceforge.net/projects/mambo/
Mason - http://www.masonhq.com/
mCubes - http://www.mCubes.com/
Metadot - http://www.metadot.net
Midgard - http://www.midgard-project.org/
MMBase - http://www.mmbase.org
MySource - http://mysource.squiz.net/
N/X - http://nxwcms.sourceforge.net/
OpenACS - http://openacs.org/
OpenCMS - http://www.opencms.org
Pagetool - http://www.pagetool.org
phpCMS - http://phpcms.de/homepage/phpcms/index.htm
PHPNuke - http://www.phpnuke.org
PHProjekt - http://www.phprojekt.com/
phpSlash - http://www.phpslash.org
phpWebSite - http://phpwebsite.appstate.edu/
Redhat CCM - http://www.redhat.com/software/ccm/
Scoop - http://scoop.kur5hin.org
Slash - http://www.slashcode.com
Squishdot - http://www.squishdot.org
SSR - http://www.ssrtech.com/
TeaServlet - http://opensource.go.com/
thatware - http://www.atthat.com/
ttCMS - http://www.ttcms.com
Webgenerator-X - http://webgenerator-x.com
WebGUI - http://plainblack.com/webgui
WebMake - http://webmake.taint.org/
WebTop - http://webtop.newfangled.com
Wyona - http://www.wyona.org/
Xinity - http://www.xinity.org/
Xoops - http://xoops.sourceforge.net/
Zope - http://www.zope.org
EZ Contents - http://www.visualshapers.com
SiteWorksPro - http://www.siteworkspro.com/
VirtuaNews - http://www.virtuanews.co.uk/

Let me know if i have missed out some of your favorite CMS in this list.

Javascript array find() and forEach()

This is a interesting error i found when developing a simple feature in javascript. Requirement was very simple, loop through every object in an array and match their ids. I implemented the solution using array.find() method.

javascript array.find() takes a function as an argument and passes "element, index, array" as parameters. I thought this is very handy and can be used. I completed the feature, tested in Firefox browser. Everything worked well.

But an issue was reported saying, feature not working. Then i inspected, everything looked fine until i asked this question "which browser?" to my tester. He replied "Chrome", Ah..... gotcha!! When i tested in chrome, there was a javascript error saying no method "find()" found in object array.

After doing a little bit search and research in google, it was clear to my understanding that "find()" is supported only in Firefox, if we have to support different browser then i have to use "forEach()" method.

Interesting fact is, "forEach()" and "find()" are similar in functionality. They both have same method signatures and does same job. Below is the details of both the functions.

forEach()
 
Syntax : 
arr.forEach(callback[, thisArg])

Parameters :
callback : Function to execute for each element.
thisArg : Value to use as this when executing callback.

Usage eg :

function logArrayElements(element, index, array) {
    console.log("a[" + index + "] = " + element);
}
[2, 5, 9].forEach(logArrayElements);
// logs:
// a[0] = 2
// a[1] = 5
// a[2] = 9

find()

Syntax : 
arr.find(callback[, thisArg])

Parameters :
callback : Function to execute for each element.
thisArg : Value to use as this when executing callback.

Usage eg :

function logArrayElements(element, index, array) {
    console.log("a[" + index + "] = " + element);
}
[2, 5, 9].find(logArrayElements);
// logs:
// a[0] = 2
// a[1] = 5
// a[2] = 9

Wednesday, March 19, 2014

WCF REST Service with clean customized urls

Annoying thing with WCF service is its ".svc" extension. Most of us , developers, think of having clean neat urls like in ASP.Net MVC, while there are lot of workarounds to create custom url, here is the simple one as described in the blog

http://geekswithblogs.net/michelotti/archive/2010/08/21/restful-wcf-services-with-no-svc-file-and-no-config.aspx

Here is a overview of the article published in the above link

Building a RESTful WCF service in this way is quite easy and you don’t need rely on any item templates.  Just start with a blank asp.net web application project in Visual Studio. The web.config file is virtually empty:

     <configuration>
         <system.web>
             <compilation debug="true" targetFramework="4.0" />
         </system.web>
     </configuration>
 
Next just add a regular C# class - for this example, I call mine PersonService and it will have basic CRUD operations. Typically we create interfaces in WCF to define our ServiceContract and operations like this:
     [ServiceContract]
     interface IPersonService
     {
         [OperationContract]
         Person GetPerson(string id);
      
         [OperationContract]
         Person InsertPerson(Person person);
      
        [OperationContract]
        Person UpdatePerson(string id, Person person);
     
        [OperationContract]
        void DeletePerson(string id);
    }
Keep in mind, this step is *not* required. You *could* decorate your service class directly with these attributes and not even have the interface at all. However, in this case, it’s a nice convenience to encapsulate all the WCF attributes on the interface rather than your implementation class. The implementation of our PersonService class looks like this.

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class PersonService : IPersonService
    {
        [WebGet(UriTemplate = "Person({id})")]
        public Person GetPerson(string id)
        {
        }
     
        [WebInvoke(UriTemplate = "Person", Method = "POST")]
        public Person InsertPerson(Person person)
        {
        }
     
        [WebInvoke(UriTemplate = "Person({id})", Method = "PUT")]
        public Person UpdatePerson(string id, Person person)
        {
        }
     
        [WebInvoke(UriTemplate = "Person({id})", Method = "DELETE")]
        public void DeletePerson(string id)
        {
        }
   }
This is just a normal C# class that implement an interface. It’s also decorated with the typical WebGet/WebInvoke attributes (in the System.ServiceModel.Web namespace) that we use for RESTful services. Also notice that 3 of the 4 methods have the same UriTemplate but they are differentiated by the HTTP method (i.e., GET/PUT/DELETE). Also notice the AspNetCompatibilityRequirements attribute – this is needed for RESTful services that are processed in the ASP.NET pipeline as described here. You also have to add this to the config file (I know, I know – I said “no config” but I meant “no ugly WCF endpoint config”!):
     <system.serviceModel>
       <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
     </system.serviceModel>
So how do we take this regular C# class and make it into a service without an *.svc file?  The System.Web.Routing infrastructure has now been incorporated into WCF 4 to make this possible.  Just add the line of code (line #5) to your global.asax:
     public class Global : System.Web.HttpApplication
     {
         protected void Application_Start(object sender, EventArgs e)
         {
             RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHostFactory(), typeof(PersonService)));
         }
     }
The WebServiceHostFactory makes RESTful services possible in WCF. The first parameter of my ServiceRoute constructor is an empty string which means that my URI of my service will hang right off of the root – this get combined with the UriTemplate defined in the WebGet/WebInvoke attributes.  So to get a person from my service, a URI would look like this:  http://mydomain.com/Person(21).  If I had specified “foo” instead of an empty string in the first parameters of the ServiceRoute constructor, then my URI would look like this:  http://mydomain.cmo/foo/Person(21).
That’s it!  You now have a fully functioning RESTful WCF service that you can fully test with Fidder for all HTTP verbs.
One interesting aspect to all this is that you can do all this in MVC as well. In fact, I typically do use MVC to return JSON to views for AJAX calls in my MVC apps. However, if you were building stand-alone services for this, would MVC be easier than the example of above? Keep in mind, we could simplify the example above even further by eliminating the IPersonService interface all together. I daresay that setting up RESTful routes like the ones shown above is easier with WCF than MVC (this, coming from an “MVC guy”) because we can apply the UriTemplates directly to the methods. To accomplish the same in MVC, you have to create custom route constraints to avoid the name of the C# methods from showing up in the URL (and honoring the REST HTTP verbs).  If you are going to do this, I really like the approach shown here. It’s a cool approach, but it’s *more* work than just doing it with RESTful WCF – no svc file and no configuration.
In fact, using the WCF infrastructure gets you even more features for free.  For example, if we add 1 more line of configuration (check out line #5 below) we get a help page and automatic format selection for free! Now our entire configuration just looks like this (and still no WCF endpoint configuration needed):
     <system.serviceModel>
       <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
      <standardEndpoints>
         <webHttpEndpoint>
           <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
         </webHttpEndpoint>
       </standardEndpoints>
    </system.serviceModel>
Notice all we had to do to get the help page was the request “/help”:

Tuesday, July 23, 2013

Amazon S3 Console Application!!!!

Project Description
This project is an initiative to create shell like interactive console application to administer amazon s3 using c#.net.
we aim at providing easy to use features through console commands by which users are already familiar with. Commands are similar to dos or shell commands and perform similar action when executed in S3.

visit the official site of the application s3console.

Features

Releasing beta version of the app with the following feature set.
1. create, delete bucket
2. create , rename, copy, move , delete folders
3. create, rename, copy , move , delete files
4. upload files to s3
5. download files from s3

all these features are easy to use and commands are similar to shell commands.
Many more feature in the list.

To know more about the application visit the official site of the application s3console.

Thursday, May 9, 2013

Useful "Run" (windows+R) commands for windows lovers.

1. Accessibility Controls - access.cpl
2. Accessibility Wizard - accwiz
3. Add Hardware Wizard - hdwwiz.cpl
4. Add/Remove Programs - appwiz.cpl
5. Administrative Tools - control admintools
6. Automatic Updates - wuaucpl.cpl
7. Bluetooth Transfer Wizard - fsquirt
8. Calculator - calc
9. Certificate Manager - certmgr.msc
10. Character Map - charmap
11. Check Disk Utility - chkdsk
12. Clipboard Viewer - clipbrd
13. Command Prompt - cmd
14. Component Services - dcomcnfg
15. Computer Management - compmgmt.msc
16. Control Panel - control
17. Date and Time Properties - timedate.cpl
18. DDE Shares - ddeshare
19. Device Manager - devmgmt.msc
20. Direct X Troubleshooter - dxdiag
21. Disk Cleanup Utility - cleanmgr
22. Disk Defragment - dfrg.msc
23. Disk Management - diskmgmt.msc
24. Disk Partition Manager - diskpart
25. Display Properties - control desktop
26. Display Properties - desk.cpl
27. Dr. Watson System Troubleshooting­ Utility - drwtsn32
28. Driver Verifier Utility - verifier
29. Event Viewer - eventvwr.msc
30. Files and Settings Transfer Tool - migwiz
31. File Signature Verification Tool - sigverif
32. Findfast - findfast.cpl
33. Firefox - firefox
34. Folders Properties - control folders
35. Fonts - control fonts
36. Fonts Folder - fonts
37. Free Cell Card Game - freecell
38. Game Controllers - joy.cpl
39. Group Policy Editor (for xp professional) - gpedit.msc
40. Hearts Card Game - mshearts
41. Help and Support - helpctr
42. HyperTerminal - hypertrm
43. Iexpress Wizard - iexpress
44. Indexing Service - ciadv.msc
45. Internet Connection Wizard - icwconn1
46. Internet Explorer - iexplore
47. Internet Properties - inetcpl.cpl
48. Keyboard Properties - control keyboard
49. Local Security Settings - secpol.msc
50. Local Users and Groups - lusrmgr.msc
51. Logs You Out Of Windows - logoff
52. Malicious Software Removal Tool - mrt
53. Microsoft Chat - winchat
54. Microsoft Movie Maker - moviemk
55. Microsoft Paint - mspaint
56. Microsoft Syncronization Tool - mobsync
57. Minesweeper Game - winmine
58. Mouse Properties - control mouse
59. Mouse Properties - main.cpl
60. Netmeeting - conf
61. Network Connections - control netconnections
62. Network Connections - ncpa.cpl
63. Network Setup Wizard - netsetup.cpl
64. Notepad - notepad
65. Object Packager - packager
66. ODBC Data Source Administrator - odbccp32.cpl
67. On Screen Keyboard - osk
68. Outlook Express - msimn
69. Paint - pbrush
70. Password Properties - password.cpl
71. Performance Monitor - perfmon.msc
72. Performance Monitor - perfmon
73. Phone and Modem Options - telephon.cpl
74. Phone Dialer - dialer
75. Pinball Game - pinball
76. Power Configuration - powercfg.cpl
77. Printers and Faxes - control printers
78. Printers Folder - printers
79. Regional Settings - intl.cpl
80. Registry Editor - regedit
81. Registry Editor - regedit32
82. Remote Access Phonebook - rasphone
83. Remote Desktop - mstsc
84. Removable Storage - ntmsmgr.msc
85. Removable Storage Operator Requests - ntmsoprq.msc
86. Resultant Set of Policy (for xp professional) - rsop.msc
87. Scanners and Cameras - sticpl.cpl
88. Scheduled Tasks - control schedtasks
89. Security Center - wscui.cpl
90. Services - services.msc
91. Shared Folders - fsmgmt.msc
92. Shuts Down Windows - shutdown
93. Sounds and Audio - mmsys.cpl
94. Spider Solitare Card Game - spider
95. SQL Client Configuration - cliconfg
96. System Configuration Editor - sysedit
97. System Configuration Utility - msconfig
98. System Information - msinfo32
99. System Properties - sysdm.cpl
100. Task Manager - taskmgr
101. TCP Tester - tcptest
102. Telnet Client - telnet
103. User Account Management - nusrmgr.cpl
104. Utility Manager - utilman
105. Windows Address Book - wab
106. Windows Address Book Import Utility - wabmig
107. Windows Explorer - explorer
108. Windows Firewall - firewall.cpl
109. Windows Magnifier - magnify
110. Windows Management Infrastructure - wmimgmt.msc
111. Windows Media Player - wmplayer
112. Windows Messenger - msmsgs
113. Windows System Security Tool - syskey
114. Windows Update Launches - wupdmgr
115. Windows Version - winver
116. Wordpad - write

Tuesday, January 3, 2012

Android Views – TextView



Text view is most commonly used control across applications. It is used to display texts. In android, not only text, you can also display html text in text view. Texts in Text views can be modified and formatted easily.  

There are two ways how you can add text view into a layout,

1.       Through designer, by drag and drop onto layout or just edit xml file and type it manually.
2.       Add text view on the fly through code.

What all you can do with text view? Well, here is the list of few important things.

1.       Change font type – use built-in font types (limited) or refer to external font file. To use external font file, add font file (.ttf) into assets folder and import into text view using TypeFace object.            
      ex:  Typeface newtypeface = Typeface.createFromAsset(getAssets(), "Amazone BT.ttf");

2.       Change font style – bold, normal, italic (anyone at a time, multiple style only through text as html).

3.       Change font size – using a float value and unit to use.When no unit is specified, android defaults to pixels. Preferred units are dp/dip and sp. (pixels are not preferred in android as it varies across devices).

4.       Change text color – you can change text color and text background color. Text color attribute accepts only hexadecimal values when assigned in layout file. If you are adding color from code, it’s better to use Color class of android or manually create your color using hexadecimal values and add it. Text background accepts both color values and images.

5.       Text appearances – create your own style and refer it or use android built-in text appearances.

6.       Modify text dynamically through code.

7.       Bind events and act accordingly. Ex: click event, touch event, focus event etc...

Text appearance defines how your text should look to user. There are few ways how you can modify your text.

1.       Styled and formatted in layout file.
2.       If needs are simple, android’s built-in styles can be used.
3.       If you want to make some really attractive formatting and re-use it, then define the style by yourself in style.xml file and refer it either in layout file or through code using resource id. Ex: R.style.yourstyle 

Here is an example of how you can use text view in android.

TextViewDemoActivity.java

package com.coffeewithtechie.textviewdemo;

import android.app.Activity;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Html;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;

public class TextViewDemoActivity extends Activity {

                TextView tv4;
                TextView tv5;
                TextView tv6;
               
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
         tv4 = (TextView)findViewById(R.id.textView4);       
        Typeface newtypeface = Typeface.createFromAsset(getAssets(), "Amazone BT.ttf"); // font file referred from assests folder
         tv4 .setTypeface(newtypeface);
       
         tv5 = (TextView)findViewById(R.id.textView5);
         tv5 .setText(Html.fromHtml("
this is html string
")); // html text, only basic html tags works, styles doesn't work
       
         tv6 = (TextView)findViewById(R.id.textView6);
//        tv6.setOnClickListener(new OnClickListener() {
//                                           
//                                            @Override
//                                            public void onClick(View v) {
//                                                            // TODO Auto-generated method stub
//                                                            String text = tv6.getText().toString(); // get textview text value
//                                                            text = "you clicked me!";
//                                                            tv6.setText(text); // modify text dynamically
//                                            }
//                            });
       
         tv6.setOnTouchListener(new OnTouchListener() {
                                               
                                                @Override
                                                public boolean onTouch(View v, MotionEvent event) {                                                                
                                                                String text =  tv6.getText().toString(); // get textview text value
                                                                text = "you touched me! at x:"+ event.getX()+" y:"+ event.getY()+" positions";
                                                                 tv6.setText(text); // modify text dynamically
                                                                return true;
                                                }
                                });
       
        //dynamic textview
        TextView tvDynamic = new TextView(this);
        tvDynamic.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        tvDynamic.setText("Dynamic text view, styled from code");
        tvDynamic.setTextColor(Color.MAGENTA);      
        tvDynamic.setTextSize(TypedValue.COMPLEX_UNIT_MM, 5f); // font size in millimeter
       
        LinearLayout layoutparent = (LinearLayout)findViewById(R.id.layoutparent);
        layoutparent.addView(tvDynamic); //adding newly created text view to layout
       
        tvDynamic.setTextAppearance(this, R.style.CustomTextViewStyle);
       
    }
}

Main.xml

xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/layoutparent"
    android:orientation="vertical" >

    <TextView android:background="#aaaaaa"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello"  />

    <TextView
        android:background="@drawable/backgroun"
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="styled in xml"
        android:textColor="#887722"
        android:textSize="30dp"  
        android:textStyle="italic"
        android:typeface="serif"  
         />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Styled with built in android styles"
        android:textAppearance="@android:style/TextAppearance.Widget.TextView.PopupMenu" />
       
       <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Styled with custom styles"
        android:textAppearance="@style/CustomTextViewStyle" />
           
       <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Text with font type from external source"
        android:textSize="25dp"
        /> 

       <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"       
        /> 
       <TextView
        android:id="@+id/textView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"     
        android:text="Touch me!"        
        />
</LinearLayout>

Values/styles.xml

create a style.xml file under values folder and the below code

xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomTextViewStyle">
    <item name="android:textColor">#ff0000<item>
    <item name="android:textSize">26sp<item>  
    <item name="android:textStyle">bold<item>        
style>   
resources>

This is how it looks when executed.
output - before touch event

Text modifies dynamically after touching “Touch me!” text view.

output - after executing touch event