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.

Android :: Fast undo - redo with memento - command pattern


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?

View 2 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 :: 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 :: Enabling Pattern Lock Without Set Pattern

May 1, 2010

What happens if I enabled the pattern lock by updating the setting LOCK_PATTERN_ENABLED, but have never set a pattern? I would check, but I don't want to reset my phone (I don't see a way to clear the lock pattern). Does anyone know?

View 3 Replies View Related

Sprint HTC Hero :: Pattern Lock Security - Must Enter Pattern B4 Pickup Call?

Dec 11, 2009

The subject is pretty much it. With pattern lock security enabled, what happens during an incoming call? Must you enter the pattern to pick up the call, or can you simply press "Send"?

View 2 Replies View Related

Samsung Captivate :: Wifi - Error 'mmc1 Got Command Interrupt 0x00060001 Even Though No Command Operation Was In Progress

Sep 6, 2010

I have a rooted samsung captivate with sideloading enabled. After experimenting with different wifi tethering apps from the unofficial market, I began experiencing difficulties with my wifi connection. Even after uninstalling every app that I thought was changing the wifi state, the problem still persists. I can turn on the wifi and it will act normally for about 30 seconds before turning off without user intervention. In dmesg, the error is as follows: 'mmc1: Got command interrupt 0x00060001 even though no command operation was in progress.' Is this caused by an app or is this a more complicated problem?

View 15 Replies View Related

HTC Desire HD :: Lock Pattern - Swipe In Certain Pattern

Nov 29, 2010

Is there a lock pattern on the DHD, the one where you swipe it in a certain pattern like I saw on the original desire?

View 4 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 :: 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

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

HTC Desire :: PC Sync Undo

Sep 15, 2010

Well for work purposes silly ol me decided to do a PC Sync of my Calendar with my Desire.

Well what happened was, the calendar on my phone got cluttered cause there were too many appointments and the worst thing is my phone calendar items got transferred to my work calendar on my PC also.

Which I would rather not have....Is there a way to Undo PC Sync?

View 2 Replies View Related

Samsung Vibrant :: How To Undo Root

Jul 18, 2010

How to unroot the vibrant and go back to normal for warranty purposes?

View 10 Replies View Related

Samsung Captivate :: How To Undo The Update

Sep 22, 2010

The update did not fix GPS and did not improve Media Scan. It DID remove the PC Internet option. How does a complete newbe undo the update? I read that ODIN3 would restore factory settings; but, several people that used ODIN3 warned against using it unless there was no other option.

View 3 Replies View Related

Motorola Droid :: Can Undo Froyo 2.2

Oct 8, 2010

I manually installed Froyo on a Motorola Droid from one of the available sites prior to the OTA update. I've experienced some slowness and my phone locking up. Can I revert back to the last good update and then reinstall Froyo via the OTA update option on my phone?

View 4 Replies View Related

Samsung Vibrant :: Undo Metamorph

Oct 26, 2010

I used metamorph to change my battery&signal icons but I wanted to go back to the stock vibrant battery/signal icons...I didnt do a back up,silly me =( anyone have a working metamorph zip of those stock icons?

View 1 Replies View Related

HTC Eris :: Undo Metamorph Theme

Sep 6, 2010

How do I turn off or undo a theme I applied with metamorph.

View 4 Replies View Related

Samsung Fascinate :: Undo One Click Lag Fix V1+

Sep 21, 2010

I looked in the market this morning, and saw an update for the OCLF. I installed the update, then opened the app and selected "Undo OneClickLagFix V1+". Afterwards, for good measure, I removed then reinstalled "EXT2 Tools." Every time I've tried to install the V2 lag fix, I get an error (redoing OCLF V1+, however, appears to work fine).

View 7 Replies View Related

HTC Incredible :: Undo Clockworkmod Custom Recovery

Jun 23, 2010

Is it possible to undo all of this via one of the RUU files or something? No problems yet, just curious in case I ever have a warranty issue or something.

View 9 Replies View Related

HTC Incredible :: Undo OTA Froyo Update - Not Rooted

Sep 2, 2010

I received my Froyo update today and it is wreaking havoc on the apps I use most. ESPN radio and MLB atbat. The streaming audio is very choppy. I did not back up and my phone is not rooted. Can I undo this update?

View 3 Replies View Related

HTC Hero :: How To Undo Facebook Profile To Contact?

Jun 4, 2010

I've seen this feature on my Hero, but, have never used it. What happens when I do this. How do you UNDO this if you don't like what it does?

View 1 Replies View Related

Motorola Droid X :: Undo Email Default Selection

Jul 17, 2010

I mistakenly selected one of two email accounts on my X -- as being the "Default"

This was a mistake, as I really should have kept the setting dynamic -- so I could chose to send from either account.

Now I can't undo that default setting -- nor can I even switch the default to the other email account.

Here's how I got to the menu in question:

GUI Messaging Icon > Left Menu Button > Messaging Settings > Email > Default Email Account

Anyone know how I can undo this default setting -- and put myself back in the position of being able to select which account to use dynamically?

View 4 Replies View Related

HTC EVO 4G :: Device Trying Toast's Root Method - Undo Damage

Sep 23, 2010

Here's what I've figured out. I tried doing Toast's root method for linux and the directions weren't idiot proof because I screwed them up. I've explained how far I've gotten in other threads. If that's relevant just ask and I'll explain exactly what I did.

Anyway my phone does the basics. It allows me to make phone calls, text, and look at the internet on the phone so this isn't an emergency but it I am worse off than I was before I tried to root because I can no longer use easytether.

I had no problem with easytether prior to the root attempt, and it still works when I hook it up with my wifes untampered evo. with my phone but with my wife's evo, I've never messed with that one, I have no trouble connecting with easy tether.

Some of the things I've noticed about the device since the attmept...
-I can't update to 2.2 via the OTA or any other method, my device says no updates are available.

-Simple root wasn't so simple, the phone never shut off and rebooted into boot screen like the red screen said it would in step 1.

How do I reset the device to the way it was the day it was purchased. I've got everything I need backed up. I'm ready to reset just tell me how.

View 9 Replies View Related

Samsung Galaxy S :: How To Undo Ryans OCLF In Shell Only

Oct 10, 2010

I installed OCLF V2+ and all is great. However, one day I turned on the phone and I think it's physically broken. The symptoms are:

- Only half screen image
- Other half screen has strange stripes
- The phone doesn't go past the spash screen
- It will boot in recovery and download mode. Here there's still only half a screen

So what I want to do is undo the lag fix, remove ext2 tools and unroot the phone before I go back to the store. Can anybody help me with this?

I CAN start in recovery mode and use adb shell to go to the phone shell! So I suppose I have to do the above steps from the shell!

View 3 Replies View Related

Sprint HTC Hero :: Undo Vanilla Lockscreen Fresh 2.1.2

Jun 4, 2010

Icouldnt find anything specific on this...i loaded fresh 2.1.2 then loaded this: Quote:

View 7 Replies View Related

Motorola Droid :: Easier Way To Undo Delete Mail?

Nov 9, 2009

I accidentally deleted an email I wanted, but couldn't figure out how to "undelete" it. I can see if in the Trash folder, but don't see any menu options to move it back to the Inbox.

I was able to open the message and Forward it to myself, but that seemed overly difficult. Is there any easier way to undo the delete?

View 7 Replies View Related

Sony Ericsson Xperia X10 Mini/pro :: How To Undo - Little E Sometimes G With Two Arrows Appear On Top Line Of Screen

Oct 18, 2010

I went on settings>basic phone settings>settings download>tesco mobile. not alot changed, well until i realised a little E sometimes G with two arrows appear on the top line of the screen, did not pay much attention to it until i have just gone to use my phone and i have no credit left and i am sure that has something to do wtih it why is this and how do i stop it from running without resetting the phone?

View 2 Replies View Related







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