[MOD] Add auto-correct to Samsung Keyboard and shorten long-press delay

Search This thread

eclipxe

Senior Member
Jan 14, 2007
68
84
Hey all, this is my first mod, but it was driving me crazy that the stock samsung keyboard didn't support auto-correct - and the timeout delay was way too long.

I'm working on an auto-patcher in the next couple of days.

EDIT:
I attached the APK: /system/app/
Make sure to set the proper permissions, then reboot.

The code changed is below

Here's a first stab at fixing both, would love some feedback.

1. To change the long press delay

In PointerTracker:
Code:
        ###################################################
	# Change the long press delay to 200ms from 500ms #
	###################################################
    .line 498
    const/16 v0, 0xc8

    .line 499
    .local v0, delay:I
    packed-switch p1, :pswitch_data_0

    .line 504
    const/16 v0, 0xc8

    .line 507
    :goto_0
    int-to-long v1, v0

    return-wide v1

    .line 501
    :pswitch_0
    const/16 v0, 0xc8

2. To add auto-correct

In SwiftkeyQwertyLatinInputModule
Code:
    .line 312
    :cond_3
	
	##################################################
	# Add support for auto-correct on word separator # 
	##################################################
	#check if the user has entered text
    iget-object v7, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mComposing:Ljava/lang/StringBuilder;
    invoke-virtual {v7}, Ljava/lang/StringBuilder;->length()I
    move-result v7
    if-lez v7, :cond_10
	
    iget-object v7, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mEngineManager:Lcom/diotek/ime/framework/engine/InputEngineManager;
    iget-object v8, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mComposing:Ljava/lang/StringBuilder;
    invoke-interface {v7, v8, v9}, Lcom/diotek/ime/framework/engine/InputEngineManager;->getCharSequence(Ljava/lang/StringBuilder;I)I
	invoke-virtual {p0}, Lcom/diotek/ime/framework/input/SwiftkeyQwertyLatinInputModule;->updateSuggestion()V
	invoke-virtual {p0}, Lcom/diotek/ime/framework/input/SwiftkeyQwertyLatinInputModule;->setComposingText()V
	##################################################
	# End support for auto-correct on word separator #
	##################################################

   #move clearCandidateList from beginning of processWordSeparator to after we do correct
   :cond_10
    invoke-virtual {p0}, Lcom/diotek/ime/framework/input/SwiftkeyQwertyLatinInputModule;->clearCandidateList()V
	
   #code below is not changed - just for reference	
    iget-object v7, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mEngineManager:Lcom/diotek/ime/framework/engine/InputEngineManager;

    iget-object v8, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mCandidates:Ljava/util/ArrayList;

    invoke-interface {v7, v8}, Lcom/diotek/ime/framework/engine/InputEngineManager;->getSuggestion(Ljava/util/ArrayList;)I

    .line 313
 

Attachments

  • SamsungIME.apk
    6.5 MB · Views: 2,001
Last edited:

brooon

Senior Member
May 11, 2009
852
156
Looks very promising! As I don´t know where to add the code, I´m patiently waiting for your patcher! ;)
 

zkyevolved

Senior Member
Apr 17, 2008
1,983
422
Or even an APK that can be installed as a keyboard itself for the people that aren't Rooted :$
 

eclipxe

Senior Member
Jan 14, 2007
68
84
Yeah! I actually originally started by trying Xposed - in fact, I'll send you the Xposed module I built for changing the timeout delay - it didn't work though! I might have followed an outdated tutorial, but I kept banging my head against the wall trying to get Xposed to work, when it was just a simple smali change.

For the auto-correct, I'm not entirely sure how I would do it in exposed. I don't want to necessarily replace a method, I need to hook in at a precise execution point. How would I do that?

This would be awesome as an "Xposed" framework apk. No need to bake into other roms.

Not sure if you have seen the below link.

http://xdaforums.com/showthread.php?t=1574401

Here are some other examples of "patches". I'm using this on stock rooted.

Multiwindow apk:
http://xdaforums.com/showthread.php?t=2048668

Per App DPI apk:
http://xdaforums.com/showthread.php?t=2067303
 

samevo

Senior Member
Jun 1, 2011
130
72
Boise
I cant wait to try this out. Samsung innovated so much with this phone its a shame they couldnt add this in too.
 

ultra74

Member
Feb 14, 2010
49
6
Yeah! I actually originally started by trying Xposed - in fact, I'll send you the Xposed module I built for changing the timeout delay - it didn't work though! I might have followed an outdated tutorial, but I kept banging my head against the wall trying to get Xposed to work, when it was just a simple smali change.

For the auto-correct, I'm not entirely sure how I would do it in exposed. I don't want to necessarily replace a method, I need to hook in at a precise execution point. How would I do that?

That would be cool. I'm just a noob programmer, but I would like to take a look at what you have and see what I can do.

Thanks!
 

cherylbaker

Senior Member
Jan 21, 2006
1,519
225
Samsung Galaxy S21 Ultra
I uploaded the APK - give it a try and let me know how it works for you guys. Open to suggestions. Also working on the patcher in case you wanted to customize it.

Awesome job. Seems to work well I guess. . Never understood the whole auto Correction. . But if it type rscue it will change it to rescue auto magically. .

Sent from my SPH-L900 using Xparent Purple Tapatalk 2
 
  • Like
Reactions: THEGUYRock

lehoi79

Senior Member
Mar 22, 2010
65
6
VA
failed to install for me... I guess it might be due to the fact that mine is ATT version. I wanna try this mod so bad though....

Sent from my SAMSUNG-SGH-I317 using Tapatalk 2
 

vwgti18

Senior Member
Apr 28, 2011
513
125
Sacramento
Hey all, this is my first mod, but it was driving me crazy that the stock samsung keyboard didn't support auto-correct - and the timeout delay was way too long.

I'm working on an auto-patcher in the next couple of days.

EDIT:
I attached the APK: /system/app/
Make sure to set the proper permissions, then reboot.

The code changed is below

Here's a first stab at fixing both, would love some feedback.

1. To change the long press delay

In PointerTracker:
Code:
        ###################################################
# Change the long press delay to 200ms from 500ms #
###################################################
    .line 498
    const/16 v0, 0xc8

    .line 499
    .local v0, delay:I
    packed-switch p1, :pswitch_data_0

    .line 504
    const/16 v0, 0xc8

    .line 507
    :goto_0
    int-to-long v1, v0

    return-wide v1

    .line 501
    :pswitch_0
    const/16 v0, 0xc8

2. To add auto-correct

In SwiftkeyQwertyLatinInputModule
Code:
    .line 312
    :cond_3

##################################################
# Add support for auto-correct on word separator # 
##################################################
#check if the user has entered text
    iget-object v7, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mComposing:Ljava/lang/StringBuilder;
    invoke-virtual {v7}, Ljava/lang/StringBuilder;->length()I
    move-result v7
    if-lez v7, :cond_10

    iget-object v7, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mEngineManager:Lcom/diotek/ime/framework/engine/InputEngineManager;
    iget-object v8, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mComposing:Ljava/lang/StringBuilder;
    invoke-interface {v7, v8, v9}, Lcom/diotek/ime/framework/engine/InputEngineManager;->getCharSequence(Ljava/lang/StringBuilder;I)I
invoke-virtual {p0}, Lcom/diotek/ime/framework/input/SwiftkeyQwertyLatinInputModule;->updateSuggestion()V
invoke-virtual {p0}, Lcom/diotek/ime/framework/input/SwiftkeyQwertyLatinInputModule;->setComposingText()V
##################################################
# End support for auto-correct on word separator #
##################################################

   #move clearCandidateList from beginning of processWordSeparator to after we do correct
   :cond_10
    invoke-virtual {p0}, Lcom/diotek/ime/framework/input/SwiftkeyQwertyLatinInputModule;->clearCandidateList()V

   #code below is not changed - just for reference
    iget-object v7, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mEngineManager:Lcom/diotek/ime/framework/engine/InputEngineManager;

    iget-object v8, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mCandidates:Ljava/util/ArrayList;

    invoke-interface {v7, v8}, Lcom/diotek/ime/framework/engine/InputEngineManager;->getSuggestion(Ljava/util/ArrayList;)I

    .line 313

Can u make the long press a lil shorter like 140ms ? And turn off the auto correct lol I can't type half the stuff I'm trying to. Is there a user dictionary?

Sent from my SPH-L900 using Tapatalk 2
 
Last edited:

lehoi79

Senior Member
Mar 22, 2010
65
6
VA
Did you drop into /system/app then set permissions on it? Shouldn't need to actually install, just reboot.

I guess I have to be rooted in order to do thissince this is a system app. I will try it tonight when I get home.

Thanks for the help.

Sent from my SAMSUNG-SGH-I317 using Tapatalk 2
 

lehoi79

Senior Member
Mar 22, 2010
65
6
VA
dropped the apk in the system/app, rebooted (wiped cache, delvik cache)... crashed at opening the keyboard.

Im on ATT 4.1.2 stock rooted.

do I need to be on deodex ROM?

Sent from my SAMSUNG-SGH-I317 using Tapatalk 2
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 35
    Hey all, this is my first mod, but it was driving me crazy that the stock samsung keyboard didn't support auto-correct - and the timeout delay was way too long.

    I'm working on an auto-patcher in the next couple of days.

    EDIT:
    I attached the APK: /system/app/
    Make sure to set the proper permissions, then reboot.

    The code changed is below

    Here's a first stab at fixing both, would love some feedback.

    1. To change the long press delay

    In PointerTracker:
    Code:
            ###################################################
    	# Change the long press delay to 200ms from 500ms #
    	###################################################
        .line 498
        const/16 v0, 0xc8
    
        .line 499
        .local v0, delay:I
        packed-switch p1, :pswitch_data_0
    
        .line 504
        const/16 v0, 0xc8
    
        .line 507
        :goto_0
        int-to-long v1, v0
    
        return-wide v1
    
        .line 501
        :pswitch_0
        const/16 v0, 0xc8

    2. To add auto-correct

    In SwiftkeyQwertyLatinInputModule
    Code:
        .line 312
        :cond_3
    	
    	##################################################
    	# Add support for auto-correct on word separator # 
    	##################################################
    	#check if the user has entered text
        iget-object v7, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mComposing:Ljava/lang/StringBuilder;
        invoke-virtual {v7}, Ljava/lang/StringBuilder;->length()I
        move-result v7
        if-lez v7, :cond_10
    	
        iget-object v7, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mEngineManager:Lcom/diotek/ime/framework/engine/InputEngineManager;
        iget-object v8, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mComposing:Ljava/lang/StringBuilder;
        invoke-interface {v7, v8, v9}, Lcom/diotek/ime/framework/engine/InputEngineManager;->getCharSequence(Ljava/lang/StringBuilder;I)I
    	invoke-virtual {p0}, Lcom/diotek/ime/framework/input/SwiftkeyQwertyLatinInputModule;->updateSuggestion()V
    	invoke-virtual {p0}, Lcom/diotek/ime/framework/input/SwiftkeyQwertyLatinInputModule;->setComposingText()V
    	##################################################
    	# End support for auto-correct on word separator #
    	##################################################
    
       #move clearCandidateList from beginning of processWordSeparator to after we do correct
       :cond_10
        invoke-virtual {p0}, Lcom/diotek/ime/framework/input/SwiftkeyQwertyLatinInputModule;->clearCandidateList()V
    	
       #code below is not changed - just for reference	
        iget-object v7, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mEngineManager:Lcom/diotek/ime/framework/engine/InputEngineManager;
    
        iget-object v8, p0, Lcom/diotek/ime/framework/input/AbstractInputModule;->mCandidates:Ljava/util/ArrayList;
    
        invoke-interface {v7, v8}, Lcom/diotek/ime/framework/engine/InputEngineManager;->getSuggestion(Ljava/util/ArrayList;)I
    
        .line 313
    4
    Op here, glad this is still working! I should get a GS4 soon and will make a more generic version for all Galaxy variants

    Sent from my SPH-L710 using xda premium
    2
    Care to share it?

    Sent from my SPH-L900 using xda premium

    See the post a few above yours.

    Found this link to a working stock keyboard with auto correct for ma7 I've been using it all day and haven't had a single problem just loving my auto correct! =D so anyways go to
    http://xdaforums.com/showthread.php?t=2110841 and click spoiler in the op at the bottom of the list is the keyboard for sprint. It says to flash it but I just unzipped the zip file and manually moved the apk to system/app and deleted the .odex file. If I helped at all please thank me =)

    Sent from my SPH-L900 using xda app-developers app
    2
    Found this link to a working stock keyboard with auto correct for ma7 I've been using it all day and haven't had a single problem just loving my auto correct! =D so anyways go to
    http://xdaforums.com/showthread.php?t=2110841 and click spoiler in the op at the bottom of the list is the keyboard for sprint. It says to flash it but I just unzipped the zip file and manually moved the apk to system/app and deleted the .odex file. If I helped at all please thank me =)

    Sent from my SPH-L900 using xda app-developers app
    2
    This is the keyboard from deodexed international 4.1.2

    http://db.tt/Xy3xGJbk

    Hope you can make one for us.