Android :: Implementing A Robust Persistent Undo/redo Feature

Oct 27, 2010

I'm writing a bitmap editor where I use the Command Pattern to represent actions that will transform the document. I keep all the commands executed so far in a list and, to implement undo, I restore the document to its initial state and then replay all but the last command.

I would like my undo/redo system to have the following feature: When the user closes the editor and returns, the document, including the available undo and redo commands, should be restored to the state it was in when the user left.

I'm implementing this for Android where your application can be given very little notice before it will be cleared from memory if e.g. the user gets a phone call. Also, some of my commands are e.g. a list of all the x,y co-ord the user painted on so these might take a few moments to save to disk.

My current idea is as follows:

When a new action is performed, the command object is added to a list S for commands that need to be saved to disk.

A background thread is used that will continually take commands from list S and save them to disk. The postfix of the filenames used will be numbered in sequence. For example, if the user filled the screen then drew 2 circles, the command files might be called FillCommand1.cmd, DrawCircleCommand2.cmd, DrawCircleCommand3.cmd.

Periodically, we save a "checkpoint" command whose purpose is to store the full document state so that, even if one of the .cmd files is corrupted, we can restore a recent version of the document.
When the user exits the app, the background thread attempts to finish up saving all the commands it can (but it might get killed).

On startup, we look for the most recent .cmd file that represents a checkpoint that we can load successfully. All the .cmd files we can load after this (i.e. some files might be corrupt) go in the redo command list, all the .cmd files we can load between the first checkpoint loaded and the oldest checkpoint we can load go in the undo list.


I want the undo limit to be about 20 or 30 commands back so I need extra logic for discarding commands, deleting .cmd files and I've got to worry about multi-threading behaviour. This system seems pretty complex and will need a lot of testing to make sure it doesn't go wrong.

Is there anything in Java or Android than can help make this easier? Am I reinventing the wheel anywhere? Maybe a database would be better?

Android :: Implementing a robust persistent undo/redo feature


Android :: Fast Undo - Redo With Memento - Command Pattern

Jul 14, 2010

I'm writing a painting/graphics Java application for a mobile phone (so memory is limited). The application state is essentially three 1000x500 bitmaps (i.e. layers of a painting). Loading three bitmaps takes about 2 or 3 seconds.

I'm trying to write an undo engine but I just cannot work out a good way to do it. The typical approaches are:

Use the command pattern: When you undo, you reload the state of the initial file and then playback all the commands processed so far except for the final one. Doing this naively though means waiting 2 or 3 seconds to load the initial state which is too slow. There isn't enough memory to store the initial state in memory either.

Use the memento pattern: When you undo, you replace the part of the current state that was changed with the old state. This means every action needs to save bitmaps of the old state to disk because there just isn't enough memory on a mobile device to store this in memory. As saving bitmaps takes time, how do I cope if the user decides to e.g. paint many brush strokes in quick succession? I cannot make them wait.

View 1 Replies View Related

General :: Adding Undo / Redo Function To Text Editing

Oct 27, 2012

Would it be (easily) possible (for a dev, so not me) to add undo/redo buttons to text editing? This is a HUGE feature missing in Android, soon 2013, five years of android, and still not there...

View 2 Replies View Related

General :: Text Edit Copy Cut Paste - But Undo / Redo Missing?

Sep 1, 2012

On galaxy phone you can, like on iPhone, copy cut and paste text. However, undo and two is badly missing. So I'm searching for an add-on or app that would fix this.

View 9 Replies View Related

Android :: Robust RSS/Atom Reader

Oct 13, 2010

I am trying to implement a robust RSS/Atom reader for android, and since Xerces won't compile I am struggling to find an alternative. I am using org.xmlpull.v1.sax2.Driver(), however this just wraps a DOM parser with SAX callbacks. Is there anything comparable to Xerces on Android?

View 1 Replies View Related

Android :: Need Most Robust Way To Get User's Current Location?

Jun 29, 2010

The LocationManager API in android seems like it's a bit of a pain to use for an application that only needs an occasional and rough approximation of the user's location.The app I'm working on isn't really a location app per se, but it does need to get the user's location in order to display a list of nearby businesses. It doesn't need to worry about if the user is moving around or anything like that.Show the user a list of nearby locations.Preload the user's location so that by the time I need it in Activity X, it will be available. Don't particularly care about accuracy or frequency of update. Just grabbing one location is sufficient as long as it's not way off. Maybe if I want to be fancy I'll update the location once every few mins or so, but it's not a huge priority.
Work for any device as long as it has either a GPS or a Network Location provider.

View 5 Replies View Related

Android :: Robust + Easy Way To Save / Restore Droid App Instance State?

Feb 19, 2010

In Android, you need to implement the following Activity methods so your application can be restored to its previous state if the OS decides to destroy then recreate your activity:

public void onSaveInstanceState(Bundle savedInstanceState)
public void onRestoreInstanceState(Bundle savedInstanceState)

The examples I've seen of implementing these methods is to use put/getBoolean, put/getInt etc. on the Bundle object (i.e. primitive objects only) to save the application state. This seems hugely error prone way to save your state for a start and I cannot see how this scales to storing complex objects without writing lots of code.

What options do I have for storing/restoring state in a robust and easy to implement fashion?

In case it's important, my application (a game) needs to store about 50 objects, which each store maybe 5 float variables and some store references to other objects. I don't particularly want to have to write save/restore methods for every class and subclass (maybe about 15 of these) I use. It would be ideal if I could just stick all my state relevant objects in an object called "state" and then just call save/load on "state" to handle everything.

Is using Java serialization an option? I've heard it's very slow, but is that a problem for save/restoring? Could I just write my data to the SD card? To a database?

View 1 Replies View Related

Android :: How To Redo Application To Display Incoming Phone Number?

May 6, 2009

How would one redo the application that displays the incoming phone number. I assume it's a content provider or a service that can be replaced.

View 2 Replies View Related

Nexus :: Transfer All Settings And Installations Without Having To Redo Whole Setup?

Jun 23, 2010

I want to root but is it possible to transfer all my settings and installations etc without having to redo my whole setup?

View 1 Replies View Related

Android :: Persistent Data Even When App Uninstalled

Oct 2, 2009

My application needs to store some application specific data on the device that persist, even when the app is uninstalled. Using files or databases is not possible as they are deleted with the app when the app is uninstalled. Storing it on an SD-card is too fragile. It is my understanding Content Providers also are deleted with their parent app?

View 7 Replies View Related

Android :: Persistent Field In Service

Aug 6, 2009

I need to retain a complex object in my service, so I can reliably come back to it (it holds updates). Initially I coded it just as a class filed in my Service implementation but I'm observing that the updates object is periodically reset to null which tells me that server class itself is recreated. Can someone recommend lightweight reliable strategy to save and recreate such updates object (I can make it serializable)

View 2 Replies View Related

Android : Want To Maintain Persistent State Information?

Nov 9, 2010

This usually happens when the user hits "Home", does something else, then eventually wanders back into the app - it attempts to go back to where it was before, but the application Context has mysteriously lost all its previously-saved state information (in my case, a few integers and a few Strings). I know this is a very vague question, but are there any cases (other than the user using "back" to back completely out of the application) where the application Context gets completely destroyed even though the application is not terminated? Is there a better way to maintain persistent state information?

View 1 Replies View Related

Android :: How To Make Persistent Cookies With A DefaultHttpClient

May 18, 2010

Im using

CODE:.......

Now, since Cookie does not implement serializeable, I can't serialize that List.

specified my goal, not only the problem)

My goal is to use the DefaultHttpClient with persistent cookies.

View 1 Replies View Related

Android :: Retaining Persistent Information On Different Versions Of Software.

Aug 31, 2010

I noticed that recently any photo uploads have the caption "Uploaded via Facebook Mobile" instead of "Uploaded via Facebook for Android". This changed sometime between May 10 and 15: Sometime between May 10 and 15 the Facebook Android app has c on Twitpic.Can anyone help me with this issue? and is anybody having the same problems as I'm having?

View 1 Replies View Related

Android :: APIDemos 8 PersistenceState - Where Is The Persistent Text Saved

Jul 21, 2010

In the class PersistentState.java the prefs variable gets the saved/typed text from prior sessions here, on line 106 into restoredText.

Where does the getString method get the saved/typed text?

CODE:............

View 1 Replies View Related

Android :: Create Persistent Socket Connection On Droid?

Apr 29, 2010

First off, let me say that feel free to recommend me if long lived TCP persistent connections are the way to go or persistent HTTP connections are better.

I've also pre-read that instead of having a persistent connection, I can have a polling mechanism.

I'm just asking in the curious interest of how can I create a persistent connection from Android to a server?

View 2 Replies View Related

Android : Can I Setup A Persistent / Regular Schedule In Droid?

Nov 23, 2010

How can I execute an action (maybe an Intent) on every specified time (e.g. Every day on 5AM)? It has to stay after device reboots, similar to how cron works.

I am not sure if I can use AlarmManager for this, or can I?

View 1 Replies View Related

Android :: How To Implement - Undo For SQLite DB Changes

Nov 1, 2010

I am trying to adapt my application from a confirmation model to an undo model. For those of you who don't know, this is where you can delete something with one click but if it was a mistake you can undo it just as easily, as opposed to interrupting the user every time he/she wants to do something to ask the annoying "Are you sure you want to...?" question via dialog.

My app is backed by the Android SQLite DB and I want to be able to undo a limited set of delete and update operations. Also, I only need to be able to undo one sequential change and the information does not have to stick arround for very long.

Everything I read on undo/redo says to use a command model to store the data. My question is how can I store the database changes in a lightweight restorable way?

View 1 Replies View Related

General :: Undo Typing In Android?

Apr 30, 2013

Is it not possible to Undo Typing in Android? I cannot tell you how many times I used the auto spell checker to correct a word and it wiped-out an entire sentence instead of the word I was typing and I wanted to through my phone on the floor in frustration! At the very least, there SHOULD be an undo feature ... somewhere!!

View 3 Replies View Related

Android :: Wallpapers Persistent - Removing Application That Sets User Background?

Feb 19, 2010

I have an application that sets the user's background. Is it possible to remove the wallpaper if my app is uninstalled?

View 1 Replies View Related

HTC EVO 4G : Stop Persistent Programs

Oct 22, 2010

How do you stop persistent programs,

for instance:
when i goto manage applications -> running services, fring is always running even if i don't run the app.

I will force stop the app, then minutes later, it will be back there again. that's just one of them.

Amazon mp3 also does the same thing. it still comes back even if i use titanium backup to freeze the app.

View 2 Replies View Related

Android :: Set A Default Contact Number - How To Undo

Jan 10, 2010

So, I selected "remember this" when I was sending a text to a contact, because it was the mobile number. Turns out, that set the number as "default" for the contact and now I no longer get to choose which number to use when calling. How can I got back to not having a "default" number?

View 4 Replies View Related

General :: Mail App With Persistent Notification?

Oct 22, 2013

I'm looking for an email app with really persistent notifications, that is: instead of the single tone/vibrate notification when a new email arrives, I need it to keep notifying me periodically (say, once per minute) until I open the app and read the email, or at least clear it from the notification shade.

recommend an email app that does that, or an addon/plugin/extra app that accomplishes the same thing?

View 2 Replies View Related

General :: Hiding Persistent Notifications?

Jan 10, 2014

So, we all know that some apps that are meant to always be running have this feature to place a constant notifcation in the statusbar which keeps the app from being killed off by Android... and now we got, in Jellybean, the possibility to hide notifcations from any app. If I do this with an app that has this enhanced priority notification running, will the app still remain "protected" from being killed? Or will the hiding of this notification result in the app being reduced back to its "regular" state?

View 3 Replies View Related

General :: Persistent Notification / Status Bar?

Feb 14, 2013

Any mod or app that allows the notification/status bar be visible all the time throughout any app? I dont mind loosing that few bits of screen.

View 3 Replies View Related

Android :: Undo Remember Password On Samsung Moment

Apr 18, 2010

I'm sure this has been asked before, but how do you undo a saved password on the Samsung Moment for Facebook & Yahoo mail?

View 3 Replies View Related

Android :: Implementing In App Purchases

Jan 7, 2010

It looks like Android won't natively support in-app purchases for a while, and when it does there might be a huge user base with devices that don't support them.What's the best way to implement iPhone-like (additional content or services) in-app purchases in Android using the Android Market if possible?

View 4 Replies View Related

Android :: Implementing Action Bar

Jun 24, 2010

I am working on creating an Action Bar like the one from the new Android UI Patterns and I am running into a bit of trouble. I have a ViewSwitcher with two layouts in it. When the user taps the search button I animate between the two layouts. The problem is that the layouts are different sizes and I can't figure out how to make them take up the same amount of space. Here's what I mean. p.s. forgive the bad art, they are just place holders ;)

View 1 Replies View Related

Android :: Implementing An OnClickListener?

Nov 9, 2010

I am trying to do something similar to that of the android lock screen pattern. I have a class that extends a view that I create multiple instances of. These appear on the screen all at once.

I need to be able to click on them individually and have each one turn green individually, however only one on touch listener is listening at once and it belongs to the last dot which appeared, so if I click anywhere on the screen the last appeared dot turns green no matter where I click.

Here is the code for my dot class:

CODE:......

In the code I called newdotdraw multiple times.

View 1 Replies View Related

Android :: Implementing L2CAP

Aug 13, 2009

With reference to the current work at : http://android.git.kernel.org/?p=platform/frameworks/base.git;a=tree;...

Can you tell me how can I implement L2CAP Socket?

I need to do it ASAP for a university project. Hoping for optimistic reciprocation.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved