Text Editor

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 56

COMPANY PROFILE

Name of the Company : FOCUSLOGIC SOLUTIONS LLP

Year of Establishment : 2011

CEO Name : Mr.Kishore Kumar

Address : 4th Street, NSK Nagar,

Arumbakkam, Chennai,

Tamil Nadu 600106

ABOUT FOCUSLOGIC SOLUTION

Focuslogic is one of the leading organizations providing enterprise solutions and


integrated services for our clients, we are specialized in E-commerce, HRMS, Vehicle
management and Invoice management software with more than 40 clients.

We develop software to solve business problems. We have a highly successful track


record in designing, developing and deploying industry-specific management applications for
leading companies.

Our team of people who focus on emerging technology, their combined intelligence
and creativity make focuslogic a great place to work, learn and grow.

Our Philosophy
Our vision

Our Vision Statement

Our Mission

Our Activities
ABSTRACT

This application operates by manipulating plain text files on your phone's SD card. By
default, these files are stored in the SD Card. This is both to make the files more accessible.
If we want to save these files anywhere inside the SD Card or internal memory. Text Editor
supports reading plaintext files with either windows (\r\n) or UNIX (\n) line endings. File is
saved as UNIX formatted plaintext. Text Editor does not require a .txt file extension when
naming a new file. For stability reasons, files larger than 102400 characters can not be shared.
Text Editor will attempt to open any file it is instructed to, regardless of the size. Larger files
slow the responsiveness of the application. The extent of this depends on hardware
configurations. Use common sense when editing large files on a mobile device.
2.1 EXISTING SYSTEM:

We cannot send email in the existing one.


We cannot save the file as pdf.
Same set fonts are there and we cant able to change the font size in the existing one.

2.2 PROPOSED SYSTEM:

Widget supports
Can able to send email [After installing in android phones]
We can able to save as the file as pdf.
Support Install-shortcut feature.
RGB color picker and change the size of the fonts
Support Android 2.2 or later. (Recommended high-tier device)
2.3 FEASIBILITY STUDY

The feasibility of the project is analyzed in this phase and business proposal is put
forth with a very general plan for the project and some cost estimates. During system analysis
the feasibility study of the proposed system is to be carried out. This is to ensure that the
proposed system is not a burden to the company. For feasibility analysis, some understanding
of the major requirements for the system is essential.

Three key considerations involved in the feasibility analysis are

ECONOMICAL FEASIBILITY
OPERATIONAL FEASIBILITY
TECHNICAL FEASIBILITY
SOCIAL FEASIBILITY

2.3.1 ECONOMICAL FEASIBILITY:

This study is carried out to check the economic impact that the system will have on
the organization. The amount of fund that the company can pour into the research and
development of the system is limited. The expenditures must be justified. Thus the developed
system as well within the budget and this was achieved because most of the technologies
used are freely available. Only the customized products had to be purchased.

2.3.2 OPERATIONAL FEASIBILITY :

This study is carried out to check the operational feasibility that is to an evaluation
which analyses how well a system operates. Part of operational feasibility is how well it is
received by workers. It is also important to analyse how any new changes or plans will fit
into the existing systemic framework. An evaluation to determine whether the system is
operationally acceptable. it also. Determines how the proposed system will fit with current
operational system.
2.3.3 TECHNICAL FEASIBILITY:

This study is carried out to check the technical feasibility, that is, the technical
requirements of the system. Any system developed must not have a high demand on the
available technical resources. This will lead to high demands on the available technical
resources. This will lead to high demands being placed on the client. The developed system
must have a modest requirement, as only minimal or null changes are required for
implementing this system.

2.3.4 SOCIAL FEASIBILITY:

The aspect of study is to check the level of acceptance of the system by the user. This
includes the process of training the user to use the system efficiently. The user must not feel
threatened by the system, instead must accept it as a necessity. The level of acceptance by the
users solely depends on the methods that are employed to educate the user about the system
and to make him familiar with it. His level of confidence must be raised so that he is also able
to make some constructive criticism, which is welcomed, as he is the final user of the system.
3. SYSTEM SPECIFICATION

3.1 Hardware Configuration

Processor - Dual Core


Speed - 1.1 GHz
RAM - 512 MB(min)
Hard Disk - 20 GB
Key Board - Standard Windows Keyboard
Mouse - Two or Three Button Mouse
Monitor - SVG

3.2 Software Configuration

Operating System : Windows XP/7/8.


Front End : Java, Android
IDE : Eclipse JEE Mars, Android SDK tools,
AVD manager
Java Technology

Java technology is both a programming language and a platform. The Java


programming language is a high-level language.

With most programming languages, you either compile or interpret a program so that
you can run it on your computer. The Java programming language is unusual in that a
program is both compiled and interpreted. With the compiler, first you translate a program
into an intermediate language called Java byte codes the platform-independent codes
interpreted by the interpreter on the Java platform. The interpreter parses and runs each Java
byte code instruction on the computer. Compilation happens just once; interpretation occurs
each time the program is executed. The following figure illustrates how this works.

You can think of Java byte codes as the machine code instructions for the Java Virtual
Machine (Java VM). Every Java interpreter, whether its a development tool or a Web
browser that can run applets, is an implementation of the Java VM. Java byte codes help
make write once, run anywhere possible. You can compile your program into byte codes on
any platform that has a Java compiler. The byte codes can then be run on any implementation
of the Java VM. That means that as long as a computer has a Java VM, the same program
written in the Java programming language can run on Windows 2000, a Solaris workstation,
or on an iMac.
The Java Platform
A platform is the hardware or software environment in which a program runs. Weve already
mentioned some of the most popular platforms like Windows 2000, Linux, Solaris, and
MacOS. Most platforms can be described as a combination of the operating system and
hardware. The Java platform differs from most other platforms in that its a software-only
platform that runs on top of other hardware-based platforms.

The Java platform has two components:


The Java Virtual Machine (Java VM)
The Java Application Programming Interface (Java API)
Youve already been introduced to the Java VM. Its the base for the Java platform and is
ported onto various hardware-based platforms.

The Java API is a large collection of ready-made software components that provide many
useful capabilities, such as graphical user interface (GUI) widgets. The Java API is grouped
into libraries of related classes and interfaces; these libraries are known as packages. The next
section, What Can Java Technology Do? Highlights what functionality some of the packages
in the Java API provide.
The following figure depicts a program thats running on the Java platform. As the figure
shows, the Java API and the virtual machine insulate the program from the hardware.
Native code is code that after you compile it, the compiled code runs on a specific hardware
platform. As a platform-independent environment, the Java platform can be a bit slower than
native code. However, smart compilers, well-tuned interpreters, and just-in-time byte code
compilers can bring performance close to that of native code without threatening portability.

What Can Java Technology Do?

The most common types of programs written in the Java programming language are
applets and applications. If youve surfed the Web, youre probably already familiar with
applets. An applet is a program that adheres to certain conventions that allow it to run within
a Java-enabled browser.

However, the Java programming language is not just for writing cute, entertaining
applets for the Web. The general-purpose, high-level Java programming language is also a
powerful software platform. Using the generous API, you can write many types of programs.

An application is a standalone program that runs directly on the Java platform. A


special kind of application known as a server serves and supports clients on a network.
Examples of servers are Web servers, proxy servers, mail servers, and print servers. Another
specialized program is a servlet. A servlet can almost be thought of as an applet that runs on
the server side. Java Servlets are a popular choice for building interactive web applications,
replacing the use of CGI scripts. Servlets are similar to applets in that they are runtime
extensions of applications. Instead of working in browsers, though, servlets run within Java
Web servers, configuring or tailoring the server.
How does the API support all these kinds of programs? It does so with packages of software
components that provides a wide range of functionality. Every full implementation of the
Java platform gives you the following features:

The essentials: Objects, strings, threads, numbers, input and output, data structures,
system properties, date and time, and so on.
Applets: The set of conventions used by applets.
Networking: URLs, TCP (Transmission Control Protocol), UDP (User Data gram
Protocol) sockets, and IP (Internet Protocol) addresses.
Internationalization: Help for writing programs that can be localized for users
worldwide. Programs can automatically adapt to specific locales and be displayed in the
appropriate language.
Security: Both low level and high level, including electronic signatures, public and
private key management, access control, and certificates.
Software components: Known as JavaBeansTM, can plug into existing component
architectures.
Object serialization: Allows lightweight persistence and communication via Remote
Method Invocation (RMI).
Java Database Connectivity (JDBCTM): Provides uniform access to a wide range of
relational databases.
The Java platform also has APIs for 2D and 3D graphics, accessibility, servers, collaboration,
telephony, speech, animation, and more. The following figure depicts what is included in the
Java 2 SDK.

We cant promise you fame, fortune, or even a job if you learn the Java programming
language. Still, it is likely to make your programs better and requires less effort than other
languages. We believe that Java technology will help you do the following:
Get started quickly: Although the Java programming language is a powerful object-
oriented language, its easy to learn, especially for programmers already familiar with C or
C++.
Write less code: Comparisons of program metrics (class counts, method counts, and
so on) suggest that a program written in the Java programming language can be four times
smaller than the same program in C++.
Write better code: The Java programming language encourages good coding
practices, and its garbage collection helps you avoid memory leaks. Its object orientation, its
JavaBeans component architecture, and its wide-ranging, easily extendible API let you reuse
other peoples tested code and introduce fewer bugs.
Develop programs more quickly: Your development time may be as much as twice
as fast versus writing the same program in C++. Why? You write fewer lines of code and it is
a simpler programming language than C++.
Avoid platform dependencies with 100% Pure Java: You can keep your program
portable by avoiding the use of libraries written in other languages. The 100% Pure Java TM
Product Certification Program has a repository of historical process manuals, white papers,
brochures, and similar materials online.
Write once, run anywhere: Because 100% Pure Java programs are compiled into
machine-independent byte codes, they run consistently on any Java platform.
Distribute software more easily: You can upgrade applets easily from a central
server. Applets take advantage of the feature of allowing new classes to be loaded on the
fly, without recompiling the entire program.

4.2 FEATURES OF JAVA


Simple
Object oriented
Distributed
Interpreted
Multithreaded
Robust
Dynamic
Secure
Simple

The language itself could be considered the derivative of C and C++, so it is familiar. At
the same time, the environment takes over many of the error-prone task from the
programmer such as pointers and memory management. Java also eliminates the operator
overloading and multiple inheritance features of C++. Java also implements automatic
garbage collection.

Object Oriented

The language is object oriented at the foundation level and allows the inheritance and
reuse of code both in a static and dynamic fashion. Java comes with an extensive set of
classes, arranged in packages that can be used in programs.

Distributed

Java is designed for the distributed environment of the Internet, because it handles
TCP\IP protocols. In fact, accessing a resource using a URL is not much different from
accessing a file. The original version of Java (Oak) included features for inter-address-
space messaging. This allows objects on two different computers to execute procedures
remotely. Java has recently revived these interfaces in a package called Remote Method
Invocation (RMI). This feature brings an unparallel level of abstraction to Client/Server
programming.

Robust

The features of the language and run-time environment make sure that the code is well
behaved. This comes primarily as a result of the push for portability. Java is a strongly
typed language, which allows for extensive compile time checking for potential type
mismatch problems. Exception handling is another feature in Java that makes for more
robust programs. An exception is a signal that some sort of exceptional condition, like an
error, has occurred. The Java interpreter also performs a number of run-time checks such
as verifying that all array and string accesses are within bounds.
Multithreaded

It is easy to imagine multiple things going on at the same time in a GUI (Graphical User
Interface) based network application. Java as a multithreaded language provides support
for multiple threads of execution also called lightweight processes that can handle
different tasks. Java as a multithreaded language provides support for multiple threads of
execution also called lightweight processes that can handle different tasks. Java makes
programming with threads easier by providing built-in language support for threads

Secure

Security is an important concern, as Java is mainly used in networked environments. Java


implements several security mechanisms information to protect the user against code that
might try to create a virus or invade the file system. All of this security mechanism
information is based on the premise that nothing is to be trusted. Java's memory allocation
model is one of its main defences against malicious code. The Java compiler does not
handle memory layout decisions so that no one can guess the actual memory layout of a
class by looking at its declaration. The Java run-time system uses a byte-code verification
process to ensure that code loaded over the network does not violate any Java language
restrictions.

Dynamic
Java programs carry with them substantial amounts of run-time type information that
is used to verify and resolve accesses to objects at run-time. This makes it possible to
dynamically link code in a sate and expedient manner. This is crucial to the robustness
of the applet environment, in which small fragments of byte code may be dynamically
updated on a running system.
Android

Android is an open source and Linux-based Operating System for mobile devices
such as smartphones and tablet computers. Android was developed by the Open Handset
Alliance, led by Google, and other companies.

Android offers a unified approach to application development for mobile devices


which means developers need only develop for Android, and their applications should be able
to run on different devices powered by Android.

The first beta version of the Android Software Development Kit (SDK) was released
by Google in 2007 where as the first commercial version, Android 1.0, was released in
September 2008.

On June 27, 2012, at the Google I/O conference, Google announced the next Android
version, 4.1 Jelly Bean. Jelly Bean is an incremental update, with the primary aim of
improving the user interface, both in terms of functionality and performance.

The source code for Android is available under free and open source software
licenses. Google publishes most of the code under the Apache License version 2.0 and the
rest, Linux kernel changes, under the GNU General Public License version 2.
Feature Description

Android OS basic screen provides a beautiful and intuitive user


Beautiful UI
interface.

GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth, Wi-Fi,


Connectivity
LTE, NFC and WiMAX.

SQLite, a lightweight relational database, is used for data storage


Storage
purposes.

H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC,


Media support AAC 5.1, MP3, MIDI, Ogg Vorbis, WAV, JPEG, PNG, GIF, and
BMP

Messaging SMS and MMS

Based on the open-source WebKit layout engine, coupled with


Web browser
Chrome's V8 JavaScript engine supporting HTML5 and CSS3.

Android has native support for multi-touch which was initially


Multi-touch
made available in handsets such as the HTC Hero.

User can jump from one task to another and same time various
Multi-tasking
application can run simultaneously.

Widgets are resizable, so users can expand them to show more


Resizable widgets
content or shrink them to save space

Multi-Language Supports single direction and bi-directional text.

Google Cloud Messaging (GCM) is a service that lets developers


GCM send short message data to their users on Android devices,
without needing a proprietary sync solution.

A technology that lets apps discover and pair directly, over a


Wi-Fi Direct
high-bandwidth peer-to-peer connection.

Android Beam A popular NFC-based technology that lets users instantly share,
just by touching two NFC-enabled phones together.

Android Applications
Android applications are usually developed in the Java language using the Android
Software Development Kit.

Once developed, Android applications can be packaged easily and sold out either
through a store such as Google Play or the Amazon Appstore.

Android powers hundreds of millions of mobile devices in more than 190 countries
around the world. It's the largest installed base of any mobile platform and growing fast.
Every day more than 1 million new Android devices are activated worldwide.

This tutorial has been written with an aim to teach you how to develop and package
Android application. We will start from environment setup for Android application
programming and then drill down to look into various aspects of Android applications.
5. PROJECT DESCRIPTIONS
5.1 OVERVIEW OF THE PROJECT
Text Editor supports reading plaintext files with either windows (\r\n) or UNIX
(\n) line endings. File is saved as UNIX formatted plaintext. This application operates by
manipulating plain text files on your phone's SD card. By default, these files are stored in
the SD Card. This is both to make the files more accessible. If we want to save these files
anywhere inside the SD Card or internal memory. Text Editor does not require a .txt file
extension when naming a new file. For stability reasons, files larger than 102400
characters can not be shared. Text Editor will attempt to open any file it is instructed to,
regardless of the size. Larger files slow the responsiveness of the application. The extent
of this depends on hardware configurations. Use common sense when editing large files
on a mobile device.

5.2 Module Description:

1. Mobile version
2. Composition
3. Daedal us
4. Plain text

1. Mobile Version:
Im still trying to figure out how to make this more workable
on Android, since thats where it makes the most sense.

2. Compositions
Full screen mode - removes everything it provides
more space to text.
Plain text, Email, Text Expander, options

3. Daedalus
Plain text, Email, Open,Save,Save As and Recent
files in text editor,

Text Expander, Markdown editing features,


Appearance options

In-document text search, Full-text file search

4. Plaintext
word, line
subfolders
Full screen mode (Android)

PERMISSIONS

Network communication:

Full network access allows the app to create network


sockets and use custom network protocols. The browser
and other applications provide means to send data to the
internet, so this permission is not required to send data to
the internet.

Storage:

Modify or delete the contents of your USB storage modify


or delete the contents of your SD card. Allows the app to
write to the USB storage and app to write to the SD card
5.4 DATA FLOW DIAGRAM
Definition:

A data flow diagram is a graphical technique that depicts information flow and the
transforms that applied as data move from input to output. The Data flow diagram used to
represent a system or software at any level of abstraction. In fact DFDs may be portioned into
levels.

A level of DFD, also called a context model, represents the entire


software elements as a single bubble with input and output by arrow. A
level of DFD is portioned into several bubbles with inter connecting
arrows. Each of the process represented at level one is sub function of the
overall depicted in the context model.

The DFD Notations:

Hardware person and other program.


External Entity

Process
Information of the system to be modeled.

Data Item(s): Arrowhead indicates the direction of


flow

Stor
e Stored Information that is used by the s/w
5.4.1 DATA FLOW DIAGRAM
5.4.2 UML DIAGRAM

Use Case Diagram


5.4.3 SEQUENCE DIAGRAM FOR MODULES
5.4.4 STRUCTURE DIAGRAM

RELATIONSHIP DIAGRAM
5.7 INPUT DESIGN

Input design is the process of connecting the user-originated inputs into a


computer to used format. The goal of the input design is to make the data entry logical
& Images. Errors in the input database controlled by input design.

This application is being developed in a user-friendly manner. The Cards are


being designed in such a way that during the processing the cursor is placed in the
position where the Data must be entered. An option of selecting an appropriate input
from the values of validation is made for each of every data entered. Help managers
are also provided whenever the user entry to a new field to that he/she can understand
what is to be entered. Whenever the user enter an error data, error manager displayed
user can move to next field only after entering the correct data.
5.8 OUTPUT DESIGN

The output form of the system is either by screen or by hard copies. Output
design aims at communicating the results of the processing of the users. The reports
are generated to suit the needs of the users. The reports have to be generated with
appropriate levels.

In our project outputs are generated for final review using html Tables and
preview the output to be sent.
6. SYSTEM TESTING

Testing is the stage of implementation, which is aimed at ensuring that the system
works accurately and efficiently before live operation commences. Thus the system test
should be a confirmation that all is correct and an opportunity to show the users that the
system works. The security enhancement method is tested in this system by using various
testing techniques.

Testing steps are

1. Unit Testing

2. Acceptance testing

3. Integration Testing

4. Validation Testing

5. Security Testing

6.1 Unit Testing

Unit testing focuses verification effort on the smallest unit of S/W can be conducted
in parallel for modules. The module 'interface' is tested to ensure the information properly
flows into and out of the program unit under test. The 'local data structures' are examined to
ensure that data stored temporarily maintains its integrity during all steps in an execution.

'Boundary conditions' are tested to ensure that module operates properly at boundaries
established to limit or restrict processing. All 'independent paths' though the control structures
are exercised to ensure that all statements in a module have been executed at least once.
Finally, all 'error handling paths' are tested.

In this project each and every module of this application is tested separately. For
example message transmission between nodes is tested separately.

Test Results: All the test cases mentioned above passed successfully. No defects encountered.
6.2 Acceptance testing:

User Acceptance Testing is a critical phase of any project and requires significant
participation by the end user. It also ensures that the system meets the functional
requirements.

The customer specifies scenarios to test when a user story has been correctly
implemented. A story can have one or many acceptance tests, whatever it takes to ensure the
functionality works. Acceptance tests are black-box system tests. Each acceptance test
represents some expected result from the system. Customers are responsible for verifying the
correctness of the acceptance tests and reviewing test scores to decide which failed tests are
of highest priority. Acceptance tests are also used as regression tests prior to a production
release. A user story is not considered complete until it has passed its acceptance tests. This
means that new acceptance tests must be created in iteration or the development team will
report zero progress

Test Results: All the test cases mentioned above passed successfully. No defects
encountered.

6.3 Integration Testing

After completing the Unit test the modules are integrated and tested with sample data.
Integration testing addresses the issues associated with the dual problems of verification and
program construction. After the 8/W has been integrated a set of high-order tests are
conducted.

Integration testing is a systematic technique for constructing the program structure


while at the same time conducting tests to uncover errors associated with interfacing. The
objective has been dictated by design. They are two types:

Top down integration.


Bottom up integration.
Test Results: All the test cases mentioned above passed successfully. No defects encountered.
6.4 Validation Testing

At the end of integration testing, software is completely assembled as a package,


interfacing errors have been uncovered and correction testing begins. Every column should
be filled with data. If the user skips any column provided or enters a wrong data an alert
message will be displayed. It will reduce the workload of the Server.

S/W testing and validation is achieved through a series of black box tests that
demonstrate conformity with the requirements. A rest plan outlines the classes of tests to be
conducted and a test procedure defines specific test cases that will be used to demonstrate
conformity with requirements. Both, the plan and the procedure are designed to ensure that
all functional requirements are achieved, documentation is correct and other requirements are
met. After each validation test case has been conducted, one of the two possible conditions
exist, they are,

1. The function or performance characteristics confirm to specification and are


accepted.

2. A division from specification is uncovered and a deficiency list is created.

The deviation or error discovered at this stage in a project can rarely be corrected prior to
scheduled completion. It is necessary to negotiate with the customer to establish methods.

Test Results: All the test cases mentioned above passed successfully. No defects encountered.

6.5 Security Testing

During this testing, the tester plays the role of the individual who desires to penetrate
the system. The tester may attempt to acquire passwords through external clerical means and
attack the system with customs 8/W designed to breakdown any defenses that have been
constructed.
The tester may also overwhelm the system thereby denying service to others and may
purposely cause system errors to penetrate during recovery and may browse though insecure
hoping to find key to system entry.

Test Results: All the test cases mentioned above passed successfully. No defects encountered.

7. SYSTEM IMPLEMENTATION

After proper testing and validation, the question arises whether the system can
be implemented or not. Implementation includes all those activities that take place to
convert from the old system to the new. The new system may be totally new; replacing an
existing module or automated system, or it may be major modification to an existing
system. In either case proper implementation is essential to provide a reliable to provide a
reliable system to meet organization requirements.

All planning has now, be completed and the transformation to a fully


operational system can commence. The first job will be writing, debugging documenting
of all computer programs and their integration into a total system. The master and
transaction files are decided, and this general processing of the system is established.
Programming is complete when the programs conformed to the detailed specification.

When the system is ready for implementation, emphasis switches to


communicate with the finance department staff. Open discussion with the staff is
important form the beginning of the project. Staff can be expected to the concerned about
the effect of the automation on their jobs and the fear of redundancy or loss of status must
be allayed immediately. During the implementation phase it is important that all staff
concerned be apprised of the objectives of overall operation of the system. They will need
shinning on how computerization will change their duties and need to understand how
their role relates to the system as a whole. An organization-training program is advisable;
this can include demonstrations, newsletters, seminars etc.
The department should allocate a member of staff, who understands the system and
the equipment, and should be made responsible for the smooth operation of the system.
An administrator should coordinate the users to the system.

In existing the major issue that faces client cache management concerns the
maintenance of data consistency between the cache client and the data source. All cache
consistency algorithms seek to increase the probability of serving from the cache data
items that are identical to those on the server.
In proposed we use pull based approach and TTL algorithms are also completely
client based and require minimal server functionality. From this perspective, TTL-based
algorithms are more practical to deploy and are more scalable.
This is the first complete client side approach employing adaptive TTL and achieving
superior availability, delay, and traffic performance.
8. CONCLUSION & FUTURE ENHANCEMENT

8.1CONCLUSION
8.2 FUTURE ENHANCEMENTS
9. APPENDIX

9.1 SOURCE CODE

ClearRecentFileListPreference.java

package org.paulmach.textedit;

import android.content.Context;

import android.content.SharedPreferences;

import android.preference.Preference;

import android.preference.PreferenceManager;

import android.util.AttributeSet;

import android.widget.Toast;

/* ClearListPreference

* The Special clear recent file list preference

* Needs it's own special class so you can just click on it */

public class ClearRecentFileListPreference extends Preference

// This is the constructor called by the inflater

public ClearRecentFileListPreference(Context context, AttributeSet attrs) {

super(context, attrs);
}

@Override

protected void onClick() {

// Data has changed, notify so UI can be refreshed!

SharedPreferences.Editor editor =

PreferenceManager.getDefaultSharedPreferences(getContext()).edit();

editor.putInt("rf_numfiles", 0);

editor.commit();

Toast.makeText(getContext(), R.string.onListCleared,

Toast.LENGTH_SHORT).show();

notifyChanged();

} // end class ClearListPreference

ClearSearchSuggestion.java

package org.paulmach.textedit;

import android.content.Context;

import android.preference.Preference;
import android.provider.SearchRecentSuggestions;

import android.util.AttributeSet;

import android.widget.Toast;

/* ClearSearchSuggestions

* The Special clear recent search suggestions

* Needs its own special class so you can just click on it */

public class ClearSearchSuggestions extends Preference

// This is the constructor called by the inflater

public ClearSearchSuggestions(Context context, AttributeSet attrs) {

super(context, attrs);

@Override

protected void onClick() {

// Data has changed, notify so UI can be refreshed!

SearchRecentSuggestions suggestions = new

SearchRecentSuggestions(getContext(),

SearchSuggestions.AUTHORITY, SearchSuggestions.MODE);

suggestions.clearHistory();

Toast.makeText(getContext(), R.string.onSuggestionsCleared,

Toast.LENGTH_SHORT).show();

notifyChanged();
}

} // end class ClearSearchSuggestions

ColorPreference.java

package org.paulmach.textedit;

import android.app.AlertDialog;

import android.content.Context;

import android.content.DialogInterface;

import android.content.SharedPreferences;

import android.content.SharedPreferences.Editor;

import android.graphics.Bitmap;

import android.graphics.drawable.BitmapDrawable;

import android.preference.DialogPreference;

import android.preference.PreferenceManager;

import android.util.AttributeSet;

import android.view.LayoutInflater;

import android.view.MotionEvent;

import android.view.View;

import android.view.View.OnTouchListener;

import android.widget.ImageView;

/* ColorPreference
* Lets you pick a color

*/

public class ColorPreference extends DialogPreference

protected int color;

protected int defcolor;

protected String attribute;

// This is the constructor called by the inflater

public ColorPreference(Context context, AttributeSet attrs) {

super(context, attrs);

attribute = attrs.getAttributeValue(1);

// set the layout so we can see the preview color

setWidgetLayoutResource(R.layout.prefcolor);

// figure out what the current color is

SharedPreferences sharedPref =

PreferenceManager.getDefaultSharedPreferences(getContext());

if (attribute.equals("fontcolor"))

defcolor = 0xFFCCCCCC;

else

defcolor = 0xFF000000;
color = sharedPref.getInt(attribute, defcolor);

@Override

protected void onBindView(View view) {

super.onBindView(view);

// Set our custom views inside the layout

final View myView = (View) view.findViewById(R.id.currentcolor);

if (myView != null) {

myView.setBackgroundColor(color);

@Override

protected void onPrepareDialogBuilder(AlertDialog.Builder builder){

// Data has changed, notify so UI can be refreshed!

builder.setTitle("Choose a color");

builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int whichButton) {

// save the color

Editor editor =

PreferenceManager.getDefaultSharedPreferences(getContext()).edit();

editor.putInt(attribute, color);
editor.commit();

notifyChanged();

});

builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int whichButton) {

// set it back to original

SharedPreferences sharedPref =

PreferenceManager.getDefaultSharedPreferences(getContext());

color = sharedPref.getInt(attribute, defcolor);

});

// setup the view

LayoutInflater factory = LayoutInflater.from(getContext());

final View colorView = factory.inflate(R.layout.colorchooser, null);

final ImageView colormap = (ImageView)

colorView.findViewById(R.id.colormap);

// set the background to the current color

colorView.setBackgroundColor(color);

// setup the click listener

colormap.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {

BitmapDrawable bd = (BitmapDrawable)

colormap.getDrawable();

Bitmap bitmap = bd.getBitmap();

// get the color value.

// scale the touch location

int x = (int) ((event.getX()-15) * bitmap.getWidth() / (colormap.getWidth()-30));

int y = (int) ((event.getY()-15) * bitmap.getHeight() / (colormap.getHeight()-30));

if (x >= bitmap.getWidth())

x = (int) bitmap.getWidth() - 1;

if (x < 0)

x = 0;

if (y >= bitmap.getHeight())

y = (int) bitmap.getHeight() - 1;

if (y < 0)

y = 0;

// set the color

color = bitmap.getPixel(x, y);

colorView.setBackgroundColor(color);

return true;

});

builder.setView(colorView);

}
} // end class ColorPreference

DefaultDirPreference.Java

package org.paulmach.textedit;

import java.io.File;

import android.app.Activity;

import android.content.Context;

import android.content.Intent;

import android.content.SharedPreferences;

import android.preference.Preference;

import android.preference.PreferenceManager;

import android.util.AttributeSet;

/* DefaultDirPreference

* Special to show and browser for the default directory

*/

public class DefaultDirPreference extends Preference

private final static int REQUEST_FILE_BROWSER = 1;

// This is the constructor called by the inflater


public DefaultDirPreference(Context context, AttributeSet attrs) {

super(context, attrs);

// define what happens when we click the preference

setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()

public boolean onPreferenceClick(Preference arg0)

// figure out what is currently selected

SharedPreferences sharedPref =

PreferenceManager.getDefaultSharedPreferences(getContext());

String current = sharedPref.getString("defaultdir", "/sdcard/");

// figure out what to display. should just be the directory

String location = "/sdcard/";

File f = new File(current);

if (f.toString().equals("/"))

location = "/";

else if (f.isDirectory())

location = f.toString() + "/";

else if (f.getParent().toString().equals("/"))

location = "/";

else

location = f.getParent() + "/";


if (f != null)

location = f.toString();

// start the intent

Intent intent = new Intent(getContext(), FileBrowser.class);

intent.setAction(location);

((Activity) getContext()).startActivityForResult(intent,

REQUEST_FILE_BROWSER);

return false;

});

// so the summary says the current

SharedPreferences sharedPref =

PreferenceManager.getDefaultSharedPreferences(getContext());

String current = sharedPref.getString("defaultdir", "/sdcard/");

this.setSummary(current);

} // end class DefaultDirPreference

FileAutoCompleteArrayAdapter.java
package org.paulmach.textedit;

import java.io.File;

import java.util.List;

import android.content.Context;

import android.view.View;

import android.view.ViewGroup;

import android.widget.ArrayAdapter;

import android.widget.TextView;

/****************************************************************

* FileAutoCompleteArrayAdapter

* To customize what is displayed in the autocomplete

* options we use this class, getView() is where the change

* happens. */

public class FileAutoCompleteArrayAdapter extends ArrayAdapter<String>

// just a basic constructor

public FileAutoCompleteArrayAdapter(Context context, int resource, List<String>

objects) {

super(context, resource, objects);

public View getView(int position, View convertView, ViewGroup parent)


{

// get the view that would normally be returned

TextView tv = (TextView) super.getView(position, convertView, parent);

// update the text accordingly

File f = new File(tv.getText().toString());

if (f.isDirectory())

tv.setText(f.getName() + "/");

else

tv.setText(f.getName());

// change some options

tv.setPadding(10,3,3,3);

tv.setTextSize(18.0f);

return (View) tv; // return the view

// end class AutoCompleteArrayAdapter


9.2 SCREENSHOT

Main Page
Menuoptions
SDCARD
Send Email With
Change Font Size
Choose a Color
Choose Font Type
Open Existing File
Open a Recent File
Search File in Text Editor

You might also like