SlideShare a Scribd company logo
1 of 21
Download to read offline
Rich Text
Editing... And
   Beyond
    Copyright © 2012CommonsWare, LLC
Whadaya Mean, Rich?
●   Things Like Bold, Italics, Underline, Etc.
●   Other Terms
    –   Styled Text
    –   Formatted Text
    –   WYSIWYG




                      Copyright © 2012CommonsWare, LLC
Is Android Rich?
●   Native Rich Text Rendering in TextView
    –   Available to all subclasses of TextView (e.g.,
        Button)
    –   Reasonable (but not immense) range of available
        styles to apply
         ●   Differing fonts, colors
         ●   Vertical & horizontal alignments
         ●   Bullets
         ●   Etc.
                           Copyright © 2012CommonsWare, LLC
Where Did All the Strings Go?
●   CharSequence
    –   In traditional Java, an inheritance artifact
         ●   Mostly the superclass of StringBuilder
    –   In Android, used as basis for rich text
         ●   Hence, lots of CharSequence parameters and
             return values, in places where Android supports rich
             text



                           Copyright © 2012CommonsWare, LLC
Spanning the Globe
●   Spanned
    –   Interface for CharSequences with inline
        formatting
●   Spannable
    –   Sub-interface where the spans can be modified
●   Editable
    –   Sub-sub-interface where the text can be
        modified
                      Copyright © 2012CommonsWare, LLC
Getting More Concrete
●   SpannedString
    –   String with markup
●   SpannableString
    –   String with mutable markup
●   SpannableStringBuilder
    –   String with mutable text and markup


                      Copyright © 2012CommonsWare, LLC
We Are Stylin'
●   CharacterStyle
    –   Base class for all styles that can be applied to a
        portion of a Spanned
    –   21 total subclasses, each applying some effect
         ● BackgroundColorSpan
         ● StyleSpan


         ● TypefaceSpan


         ● StrikethroughSpan




                       Copyright © 2012CommonsWare, LLC
Our Resources Are Low
●   String Resources
    –   Can have inline markup (<b>, <i>, <u>)
    –   Retrieving the SpannedString
         ●   getText() (as opposed to getString())
         ●   Applying the resource directly to a widget in a layout
             via @string/...




                           Copyright © 2012CommonsWare, LLC
Oh, Those Angle Brackets
●   HTML
    –   Use Html.fromHtml() to convert into
        SpannedString
         ●   Modest, undocumented set of tags supported
         ●   Optional, largely undocumented TagHandler for
             trying to add support for other tags
    –   Put the resulting SpannedString in a
        TextView (or subclass)

                         Copyright © 2012CommonsWare, LLC
Tag! You're It?
●   <a href="...">                                                            ●   <h4>
●   <b>                                                                       ●   <h5>
●   <big>                                                                     ●   <h6>
●   <blockquote>                                                              ●   <i>
●   <br>                                                                      ●   <img src="...">
●   <cite>                                                                    ●   <p>
●   <dfn>                                                                     ●   <small>
●   <div align="...">                                                         ●   <strike>
●   <em>                                                                      ●   <strong>
●   <font size="..." color="..." face="...">                                  ●   <sub>
●   <h1>                                                                      ●   <sup>
●   <h2>                                                                      ●   <tt>
●   <h3>                                   Copyright © 2012CommonsWare, LLC   ●   <u>
Mark It Down
●   Anything You Can Convert to HTML
●   Example: Markdown
    –   Popular wikitext format
    –   Used by StackOverflow, GitHub, etc.
    –   Various parsers available
    –   Example: AndDown
         ●   Wrapper around sundown C parser

                         Copyright © 2012CommonsWare, LLC
Format This, Buddy
●   Step #1: Get a SpannableString (or
    subclass)
●   Step #2: Manipulate the Formatting
    –   setSpan() applies formatting to a particular
        region
    –   removeSpan() removes a particular span
    –   getSpans() retrieves applied spans for a given
        region
                      Copyright © 2012CommonsWare, LLC
The End of Style
●   SPAN_EXCLUSIVE_EXCLUSIVE
    –   Anything added at either end is considered
        outside the span
●   SPAN_INCLUSIVE_INCLUSIVE
    –   Anything added at either end is considered
        inside the span
●   SPAN_EXCLUSIVE_INCLUSIVE
●   SPAN_INCLUSIVE_EXCLUSIVE
                      Copyright © 2012CommonsWare, LLC
CharSequence: Rich Yet Not
●   Most Utility Methods On String, Not
    CharSequence
    –   Example: indexOf()
●   TextUtils
    –   Offers a subset of those utility methods as static
        methods that can be applied to a
        CharSequence


                       Copyright © 2012CommonsWare, LLC
Hello? Didn't You Say “Editing”?
●   EditText
    –   Supports Editable
         ●   Reason why you keep calling toString() to get the
             plain text back
    –   Users Edit Prose in Existing Spans
         ●   You supply something with spans, and user types in
             the middle of one, gets formatted
    –   No UI for Users to Set Own Spans

                          Copyright © 2012CommonsWare, LLC
RichEditText
●   Open Source Component
●   Easy: Automatic FORMAT Action Mode
    –   One method to enable
    –   Works on Android 2.1+ (ActionBarSherlock!)
    –   Works great on tablets (and not so hot on phones...)
●   Harder: Roll Your Own UI
    –   E.g., toolbar
                             Copyright © 2012CommonsWare, LLC
RichEditText: Innards
●   Action Mode Items Set or Toggle “Effects”
    –   Effect = Wrapper Around CharacterStyle
         ●   Awareness of current selection
         ●   Manages idiosyncrasies of different style classes
    –   Toggle Logic
         ●   See what's in the selection now of this particular
             effect
         ●   Invert current setting

                           Copyright © 2012CommonsWare, LLC
RichEditText: The Future!
●   Better Support for Phones
    –   ...somehow...
●   Full Range of CharacterStyle Support
    –   Colors (foreground/background)
    –   Line alignment
    –   Bullets
    –   Links
●   Ragnarök            Copyright © 2012CommonsWare, LLC
A Little Bit Persistent
●   SpannableString Not Serializable
●   Best Native Bet: Convert into HTML
    –   Need to test that the formatting you apply will
        survive the round-trip conversion
●   Alternative: DIY
    –   More complete HTML conversion
    –   Convert into something else (byte array?
        Markdown?)
                      Copyright © 2012CommonsWare, LLC
What Would Be Handy...
●   More In, More Out
    –   Better HTML Conversion
    –   More wikitext support
         ●   Other flavors
         ●   Bi-directional
    –   Word processing formats (ODT, DOC/DOCX)
    –   Legacy formats
         ●   RTF
                              Copyright © 2012CommonsWare, LLC
What Would Be Handy...
●   More CharacterStyles?
    –   Theoretically an extensible system, based on
        interfaces
●   More Reusable Editing Widgets
    –   EditStyledText?




                      Copyright © 2012CommonsWare, LLC

More Related Content

What's hot

Effective Spring on Kubernetes
Effective Spring on KubernetesEffective Spring on Kubernetes
Effective Spring on KubernetesNeven Cvetković
 
The unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in AndroidThe unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in AndroidAlessandro Martellucci
 
Running Spring Boot Applications as GraalVM Native Images
Running Spring Boot Applications as GraalVM Native ImagesRunning Spring Boot Applications as GraalVM Native Images
Running Spring Boot Applications as GraalVM Native ImagesVMware Tanzu
 
IPhone Web Development With Grails from CodeMash 2009
IPhone Web Development With Grails from CodeMash 2009IPhone Web Development With Grails from CodeMash 2009
IPhone Web Development With Grails from CodeMash 2009Christopher Judd
 
Why companies like Google, Alibaba and UOL choose Flutter
Why companies like Google, Alibaba and UOL choose FlutterWhy companies like Google, Alibaba and UOL choose Flutter
Why companies like Google, Alibaba and UOL choose FlutterGeison Goes
 
[Android] DI in multimodule application
[Android] DI in multimodule application[Android] DI in multimodule application
[Android] DI in multimodule applicationOleg Mazhukin
 
Best Practices in Media Playback
Best Practices in Media PlaybackBest Practices in Media Playback
Best Practices in Media PlaybackGDG Korea
 
Flutter not yet another mobile cross-platform framework - i ox-kl19
Flutter   not yet another mobile cross-platform framework - i ox-kl19Flutter   not yet another mobile cross-platform framework - i ox-kl19
Flutter not yet another mobile cross-platform framework - i ox-kl19oradoe
 
Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3Opersys inc.
 
Intro to Flutter
Intro to FlutterIntro to Flutter
Intro to FlutterEason Pai
 
Reactive declarative UI as code - DroidCon Vietnam 2019
Reactive declarative UI as code - DroidCon Vietnam 2019Reactive declarative UI as code - DroidCon Vietnam 2019
Reactive declarative UI as code - DroidCon Vietnam 2019oradoe
 
Introduction to android studio 2.0 and data binding library
Introduction to android studio 2.0 and data binding libraryIntroduction to android studio 2.0 and data binding library
Introduction to android studio 2.0 and data binding libraryKaushal Dhruw
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureVijay Rastogi
 
Gradle and Android Studio : Best of Friends
Gradle and Android Studio : Best of FriendsGradle and Android Studio : Best of Friends
Gradle and Android Studio : Best of FriendsRomin Irani
 
Counterclockwise past present future
Counterclockwise  past present futureCounterclockwise  past present future
Counterclockwise past present futurelolopetit
 
Building GPE: What We Learned
Building GPE: What We LearnedBuilding GPE: What We Learned
Building GPE: What We Learnedrajeevdayal
 
Gradle & Android Studio - Introduction
Gradle & Android Studio - IntroductionGradle & Android Studio - Introduction
Gradle & Android Studio - IntroductionKevin Pelgrims
 
Migrating to Angular 5 for Spring Developers
Migrating to Angular 5 for Spring DevelopersMigrating to Angular 5 for Spring Developers
Migrating to Angular 5 for Spring DevelopersGunnar Hillert
 

What's hot (20)

Effective Spring on Kubernetes
Effective Spring on KubernetesEffective Spring on Kubernetes
Effective Spring on Kubernetes
 
The unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in AndroidThe unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in Android
 
Running Spring Boot Applications as GraalVM Native Images
Running Spring Boot Applications as GraalVM Native ImagesRunning Spring Boot Applications as GraalVM Native Images
Running Spring Boot Applications as GraalVM Native Images
 
IPhone Web Development With Grails from CodeMash 2009
IPhone Web Development With Grails from CodeMash 2009IPhone Web Development With Grails from CodeMash 2009
IPhone Web Development With Grails from CodeMash 2009
 
Why companies like Google, Alibaba and UOL choose Flutter
Why companies like Google, Alibaba and UOL choose FlutterWhy companies like Google, Alibaba and UOL choose Flutter
Why companies like Google, Alibaba and UOL choose Flutter
 
[Android] DI in multimodule application
[Android] DI in multimodule application[Android] DI in multimodule application
[Android] DI in multimodule application
 
Best Practices in Media Playback
Best Practices in Media PlaybackBest Practices in Media Playback
Best Practices in Media Playback
 
Flutter not yet another mobile cross-platform framework - i ox-kl19
Flutter   not yet another mobile cross-platform framework - i ox-kl19Flutter   not yet another mobile cross-platform framework - i ox-kl19
Flutter not yet another mobile cross-platform framework - i ox-kl19
 
Flutter101
Flutter101Flutter101
Flutter101
 
Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3
 
Intro to Flutter
Intro to FlutterIntro to Flutter
Intro to Flutter
 
Reactive declarative UI as code - DroidCon Vietnam 2019
Reactive declarative UI as code - DroidCon Vietnam 2019Reactive declarative UI as code - DroidCon Vietnam 2019
Reactive declarative UI as code - DroidCon Vietnam 2019
 
Introduction to android studio 2.0 and data binding library
Introduction to android studio 2.0 and data binding libraryIntroduction to android studio 2.0 and data binding library
Introduction to android studio 2.0 and data binding library
 
UI Automation Using Flutter
UI Automation Using FlutterUI Automation Using Flutter
UI Automation Using Flutter
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structure
 
Gradle and Android Studio : Best of Friends
Gradle and Android Studio : Best of FriendsGradle and Android Studio : Best of Friends
Gradle and Android Studio : Best of Friends
 
Counterclockwise past present future
Counterclockwise  past present futureCounterclockwise  past present future
Counterclockwise past present future
 
Building GPE: What We Learned
Building GPE: What We LearnedBuilding GPE: What We Learned
Building GPE: What We Learned
 
Gradle & Android Studio - Introduction
Gradle & Android Studio - IntroductionGradle & Android Studio - Introduction
Gradle & Android Studio - Introduction
 
Migrating to Angular 5 for Spring Developers
Migrating to Angular 5 for Spring DevelopersMigrating to Angular 5 for Spring Developers
Migrating to Angular 5 for Spring Developers
 

Similar to Rich Text Editing and Beyond

Advanced EPUB creation for iPad with Adobe InDesign CC - Digital Book World 2014
Advanced EPUB creation for iPad with Adobe InDesign CC - Digital Book World 2014Advanced EPUB creation for iPad with Adobe InDesign CC - Digital Book World 2014
Advanced EPUB creation for iPad with Adobe InDesign CC - Digital Book World 2014DouglasWaterfall
 
Mongo NYC PHP Development
Mongo NYC PHP Development Mongo NYC PHP Development
Mongo NYC PHP Development Fitz Agard
 
“Startup - it’s not just an IT project” - a random sampling of problems we’ve...
“Startup - it’s not just an IT project” - a random sampling of problems we’ve...“Startup - it’s not just an IT project” - a random sampling of problems we’ve...
“Startup - it’s not just an IT project” - a random sampling of problems we’ve...MobileMonday Estonia
 
Tim Klein's talk on making websites with SilverStripe in no time
Tim Klein's talk on making websites with SilverStripe in no timeTim Klein's talk on making websites with SilverStripe in no time
Tim Klein's talk on making websites with SilverStripe in no timeJoannaTMcLeod
 
Html 5 mobile - nitty gritty
Html 5 mobile - nitty grittyHtml 5 mobile - nitty gritty
Html 5 mobile - nitty grittyMario Noble
 
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCRDrupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCRGaurav Mishra
 
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.Chris Laning
 
From Android to the Mobile Web
From Android to the Mobile WebFrom Android to the Mobile Web
From Android to the Mobile WebCommonsWare
 
Solution Challenge GDSC GHRCE WEB DEVELOPMENT.pdf
Solution Challenge GDSC GHRCE WEB DEVELOPMENT.pdfSolution Challenge GDSC GHRCE WEB DEVELOPMENT.pdf
Solution Challenge GDSC GHRCE WEB DEVELOPMENT.pdfGoogleDeveloperStude22
 
Comps into pages 102
Comps into pages 102Comps into pages 102
Comps into pages 102Edward Meehan
 
Let's Build a Custom Theme
Let's Build a Custom ThemeLet's Build a Custom Theme
Let's Build a Custom ThemeAndy Stratton
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Modelchomas kandar
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Modelchomas kandar
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScriptJorg Janke
 
Implementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyImplementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyMarcos Labad
 
PodsCMS Framework by Tom Hermans (WordCampNL)
PodsCMS Framework by Tom Hermans (WordCampNL)PodsCMS Framework by Tom Hermans (WordCampNL)
PodsCMS Framework by Tom Hermans (WordCampNL)Tom Hermans
 

Similar to Rich Text Editing and Beyond (20)

Advanced EPUB creation for iPad with Adobe InDesign CC - Digital Book World 2014
Advanced EPUB creation for iPad with Adobe InDesign CC - Digital Book World 2014Advanced EPUB creation for iPad with Adobe InDesign CC - Digital Book World 2014
Advanced EPUB creation for iPad with Adobe InDesign CC - Digital Book World 2014
 
Dust.js
Dust.jsDust.js
Dust.js
 
Mongo NYC PHP Development
Mongo NYC PHP Development Mongo NYC PHP Development
Mongo NYC PHP Development
 
“Startup - it’s not just an IT project” - a random sampling of problems we’ve...
“Startup - it’s not just an IT project” - a random sampling of problems we’ve...“Startup - it’s not just an IT project” - a random sampling of problems we’ve...
“Startup - it’s not just an IT project” - a random sampling of problems we’ve...
 
Tim Klein's talk on making websites with SilverStripe in no time
Tim Klein's talk on making websites with SilverStripe in no timeTim Klein's talk on making websites with SilverStripe in no time
Tim Klein's talk on making websites with SilverStripe in no time
 
Html 5 mobile - nitty gritty
Html 5 mobile - nitty grittyHtml 5 mobile - nitty gritty
Html 5 mobile - nitty gritty
 
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCRDrupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCR
 
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
 
From Android to the Mobile Web
From Android to the Mobile WebFrom Android to the Mobile Web
From Android to the Mobile Web
 
Web Information Systems Html and css
Web Information Systems Html and cssWeb Information Systems Html and css
Web Information Systems Html and css
 
Crucible
CrucibleCrucible
Crucible
 
Solution Challenge GDSC GHRCE WEB DEVELOPMENT.pdf
Solution Challenge GDSC GHRCE WEB DEVELOPMENT.pdfSolution Challenge GDSC GHRCE WEB DEVELOPMENT.pdf
Solution Challenge GDSC GHRCE WEB DEVELOPMENT.pdf
 
Comps into pages 102
Comps into pages 102Comps into pages 102
Comps into pages 102
 
Let's Build a Custom Theme
Let's Build a Custom ThemeLet's Build a Custom Theme
Let's Build a Custom Theme
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
Dig into the omega theme
Dig into the omega themeDig into the omega theme
Dig into the omega theme
 
Implementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyImplementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing Company
 
PodsCMS Framework by Tom Hermans (WordCampNL)
PodsCMS Framework by Tom Hermans (WordCampNL)PodsCMS Framework by Tom Hermans (WordCampNL)
PodsCMS Framework by Tom Hermans (WordCampNL)
 

More from CommonsWare

The Action Bar: Front to Back
The Action Bar: Front to BackThe Action Bar: Front to Back
The Action Bar: Front to BackCommonsWare
 
Secondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManagerSecondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManagerCommonsWare
 
Mastering the Master Detail Pattern
Mastering the Master Detail PatternMastering the Master Detail Pattern
Mastering the Master Detail PatternCommonsWare
 
Not Quite As Painful Threading
Not Quite As Painful ThreadingNot Quite As Painful Threading
Not Quite As Painful ThreadingCommonsWare
 
Android Development: The 20,000-Foot View
Android Development: The 20,000-Foot ViewAndroid Development: The 20,000-Foot View
Android Development: The 20,000-Foot ViewCommonsWare
 
Maps V2... And You!
Maps V2... And You!Maps V2... And You!
Maps V2... And You!CommonsWare
 
A Deep Dive Into ViewPager
A Deep Dive Into ViewPagerA Deep Dive Into ViewPager
A Deep Dive Into ViewPagerCommonsWare
 
Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2CommonsWare
 
Integrate Android Apps and Web Apps
Integrate Android Apps and Web AppsIntegrate Android Apps and Web Apps
Integrate Android Apps and Web AppsCommonsWare
 
The Wonderful World of Wearables
The Wonderful World of WearablesThe Wonderful World of Wearables
The Wonderful World of WearablesCommonsWare
 
Securing User Data with SQLCipher
Securing User Data with SQLCipherSecuring User Data with SQLCipher
Securing User Data with SQLCipherCommonsWare
 
Beaming Data to Devices with NFC
Beaming Data to Devices with NFCBeaming Data to Devices with NFC
Beaming Data to Devices with NFCCommonsWare
 
What's New in Jelly Bean
What's New in Jelly BeanWhat's New in Jelly Bean
What's New in Jelly BeanCommonsWare
 
Making Money at Mobile: 60 Business Models
Making Money at Mobile: 60 Business ModelsMaking Money at Mobile: 60 Business Models
Making Money at Mobile: 60 Business ModelsCommonsWare
 
AppsWorld Keynote
AppsWorld KeynoteAppsWorld Keynote
AppsWorld KeynoteCommonsWare
 
Backwards Compatibility: Strategies and Tactics
Backwards Compatibility: Strategies and TacticsBackwards Compatibility: Strategies and Tactics
Backwards Compatibility: Strategies and TacticsCommonsWare
 
Android Hardware That's A Little Bit... Odd
Android Hardware That's A Little Bit... OddAndroid Hardware That's A Little Bit... Odd
Android Hardware That's A Little Bit... OddCommonsWare
 
Google TV For Fun
Google TV For FunGoogle TV For Fun
Google TV For FunCommonsWare
 
If I Were Starting Now
If I Were Starting NowIf I Were Starting Now
If I Were Starting NowCommonsWare
 

More from CommonsWare (20)

The Action Bar: Front to Back
The Action Bar: Front to BackThe Action Bar: Front to Back
The Action Bar: Front to Back
 
Secondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManagerSecondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManager
 
Mastering the Master Detail Pattern
Mastering the Master Detail PatternMastering the Master Detail Pattern
Mastering the Master Detail Pattern
 
Not Quite As Painful Threading
Not Quite As Painful ThreadingNot Quite As Painful Threading
Not Quite As Painful Threading
 
Android Development: The 20,000-Foot View
Android Development: The 20,000-Foot ViewAndroid Development: The 20,000-Foot View
Android Development: The 20,000-Foot View
 
Maps V2... And You!
Maps V2... And You!Maps V2... And You!
Maps V2... And You!
 
A Deep Dive Into ViewPager
A Deep Dive Into ViewPagerA Deep Dive Into ViewPager
A Deep Dive Into ViewPager
 
Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2
 
Integrate Android Apps and Web Apps
Integrate Android Apps and Web AppsIntegrate Android Apps and Web Apps
Integrate Android Apps and Web Apps
 
X Means Y
X Means YX Means Y
X Means Y
 
The Wonderful World of Wearables
The Wonderful World of WearablesThe Wonderful World of Wearables
The Wonderful World of Wearables
 
Securing User Data with SQLCipher
Securing User Data with SQLCipherSecuring User Data with SQLCipher
Securing User Data with SQLCipher
 
Beaming Data to Devices with NFC
Beaming Data to Devices with NFCBeaming Data to Devices with NFC
Beaming Data to Devices with NFC
 
What's New in Jelly Bean
What's New in Jelly BeanWhat's New in Jelly Bean
What's New in Jelly Bean
 
Making Money at Mobile: 60 Business Models
Making Money at Mobile: 60 Business ModelsMaking Money at Mobile: 60 Business Models
Making Money at Mobile: 60 Business Models
 
AppsWorld Keynote
AppsWorld KeynoteAppsWorld Keynote
AppsWorld Keynote
 
Backwards Compatibility: Strategies and Tactics
Backwards Compatibility: Strategies and TacticsBackwards Compatibility: Strategies and Tactics
Backwards Compatibility: Strategies and Tactics
 
Android Hardware That's A Little Bit... Odd
Android Hardware That's A Little Bit... OddAndroid Hardware That's A Little Bit... Odd
Android Hardware That's A Little Bit... Odd
 
Google TV For Fun
Google TV For FunGoogle TV For Fun
Google TV For Fun
 
If I Were Starting Now
If I Were Starting NowIf I Were Starting Now
If I Were Starting Now
 

Recently uploaded

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Recently uploaded (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

Rich Text Editing and Beyond

  • 1. Rich Text Editing... And Beyond Copyright © 2012CommonsWare, LLC
  • 2. Whadaya Mean, Rich? ● Things Like Bold, Italics, Underline, Etc. ● Other Terms – Styled Text – Formatted Text – WYSIWYG Copyright © 2012CommonsWare, LLC
  • 3. Is Android Rich? ● Native Rich Text Rendering in TextView – Available to all subclasses of TextView (e.g., Button) – Reasonable (but not immense) range of available styles to apply ● Differing fonts, colors ● Vertical & horizontal alignments ● Bullets ● Etc. Copyright © 2012CommonsWare, LLC
  • 4. Where Did All the Strings Go? ● CharSequence – In traditional Java, an inheritance artifact ● Mostly the superclass of StringBuilder – In Android, used as basis for rich text ● Hence, lots of CharSequence parameters and return values, in places where Android supports rich text Copyright © 2012CommonsWare, LLC
  • 5. Spanning the Globe ● Spanned – Interface for CharSequences with inline formatting ● Spannable – Sub-interface where the spans can be modified ● Editable – Sub-sub-interface where the text can be modified Copyright © 2012CommonsWare, LLC
  • 6. Getting More Concrete ● SpannedString – String with markup ● SpannableString – String with mutable markup ● SpannableStringBuilder – String with mutable text and markup Copyright © 2012CommonsWare, LLC
  • 7. We Are Stylin' ● CharacterStyle – Base class for all styles that can be applied to a portion of a Spanned – 21 total subclasses, each applying some effect ● BackgroundColorSpan ● StyleSpan ● TypefaceSpan ● StrikethroughSpan Copyright © 2012CommonsWare, LLC
  • 8. Our Resources Are Low ● String Resources – Can have inline markup (<b>, <i>, <u>) – Retrieving the SpannedString ● getText() (as opposed to getString()) ● Applying the resource directly to a widget in a layout via @string/... Copyright © 2012CommonsWare, LLC
  • 9. Oh, Those Angle Brackets ● HTML – Use Html.fromHtml() to convert into SpannedString ● Modest, undocumented set of tags supported ● Optional, largely undocumented TagHandler for trying to add support for other tags – Put the resulting SpannedString in a TextView (or subclass) Copyright © 2012CommonsWare, LLC
  • 10. Tag! You're It? ● <a href="..."> ● <h4> ● <b> ● <h5> ● <big> ● <h6> ● <blockquote> ● <i> ● <br> ● <img src="..."> ● <cite> ● <p> ● <dfn> ● <small> ● <div align="..."> ● <strike> ● <em> ● <strong> ● <font size="..." color="..." face="..."> ● <sub> ● <h1> ● <sup> ● <h2> ● <tt> ● <h3> Copyright © 2012CommonsWare, LLC ● <u>
  • 11. Mark It Down ● Anything You Can Convert to HTML ● Example: Markdown – Popular wikitext format – Used by StackOverflow, GitHub, etc. – Various parsers available – Example: AndDown ● Wrapper around sundown C parser Copyright © 2012CommonsWare, LLC
  • 12. Format This, Buddy ● Step #1: Get a SpannableString (or subclass) ● Step #2: Manipulate the Formatting – setSpan() applies formatting to a particular region – removeSpan() removes a particular span – getSpans() retrieves applied spans for a given region Copyright © 2012CommonsWare, LLC
  • 13. The End of Style ● SPAN_EXCLUSIVE_EXCLUSIVE – Anything added at either end is considered outside the span ● SPAN_INCLUSIVE_INCLUSIVE – Anything added at either end is considered inside the span ● SPAN_EXCLUSIVE_INCLUSIVE ● SPAN_INCLUSIVE_EXCLUSIVE Copyright © 2012CommonsWare, LLC
  • 14. CharSequence: Rich Yet Not ● Most Utility Methods On String, Not CharSequence – Example: indexOf() ● TextUtils – Offers a subset of those utility methods as static methods that can be applied to a CharSequence Copyright © 2012CommonsWare, LLC
  • 15. Hello? Didn't You Say “Editing”? ● EditText – Supports Editable ● Reason why you keep calling toString() to get the plain text back – Users Edit Prose in Existing Spans ● You supply something with spans, and user types in the middle of one, gets formatted – No UI for Users to Set Own Spans Copyright © 2012CommonsWare, LLC
  • 16. RichEditText ● Open Source Component ● Easy: Automatic FORMAT Action Mode – One method to enable – Works on Android 2.1+ (ActionBarSherlock!) – Works great on tablets (and not so hot on phones...) ● Harder: Roll Your Own UI – E.g., toolbar Copyright © 2012CommonsWare, LLC
  • 17. RichEditText: Innards ● Action Mode Items Set or Toggle “Effects” – Effect = Wrapper Around CharacterStyle ● Awareness of current selection ● Manages idiosyncrasies of different style classes – Toggle Logic ● See what's in the selection now of this particular effect ● Invert current setting Copyright © 2012CommonsWare, LLC
  • 18. RichEditText: The Future! ● Better Support for Phones – ...somehow... ● Full Range of CharacterStyle Support – Colors (foreground/background) – Line alignment – Bullets – Links ● Ragnarök Copyright © 2012CommonsWare, LLC
  • 19. A Little Bit Persistent ● SpannableString Not Serializable ● Best Native Bet: Convert into HTML – Need to test that the formatting you apply will survive the round-trip conversion ● Alternative: DIY – More complete HTML conversion – Convert into something else (byte array? Markdown?) Copyright © 2012CommonsWare, LLC
  • 20. What Would Be Handy... ● More In, More Out – Better HTML Conversion – More wikitext support ● Other flavors ● Bi-directional – Word processing formats (ODT, DOC/DOCX) – Legacy formats ● RTF Copyright © 2012CommonsWare, LLC
  • 21. What Would Be Handy... ● More CharacterStyles? – Theoretically an extensible system, based on interfaces ● More Reusable Editing Widgets – EditStyledText? Copyright © 2012CommonsWare, LLC