[android-developers] Re: IME - Main Dictionary
Hi, Very useful information, thanks! Got everything to work nicely, one quick question: I use Eclipse, not GNU make. I noticed Android.mk for LatinIME specifies a "-0 .dict" aapt flag (I'm guessing "store uncompressed"). Is there some way to do the same while using the Eclipse builder? Right now I'm manually fudging the generated APK (zip -d ime.apk res/ raw/main.dict; zip -0 ime.apk res/raw/main.dict) before signing, but I'd like to do this as part of the build process (makes testing a bit tedious). Thanks! Spiros On Jul 8, 12:23 pm, "nEx.Software" wrote: > So, in sending in a FileDescriptor, I assume I would need to modify > openNative to take a FileDescriptor... > > Presumably, I would get a FileDescriptor like this: > > AssetManager am = context.getResources().getAssets(); > AssetFileDescriptor afd = am.openNonAssetFd("mydictionaryfile"); > FileDescriptor fd = afd.getFileDescriptor(); > > Is there anything else I would need to do? I will be storing my > dictionary in raw, as it the case with the LatinIME. > > On Jul 8, 5:49 am, "nEx.Software" wrote: > > > > > Great... thanks for the info Dianne. I appreciate i. > > > On Jul 8, 12:25 am, Dianne Hackborn wrote: > > > > Oh sorry, yeah those are not part of the NDK. However you should be able > > > to > > > use the Java API to open a FileDescriptor for an asset, and hand that to > > > native code for it to use the fd. The only limitation is that the asset > > > will need to be stored uncompressed. (Alternatively, an .apk is just a > > > zip > > > file, so worst case you could compile the zip code into your app and use > > > that to extract the file you want.) > > > > On Tue, Jul 7, 2009 at 11:54 PM, nEx.Software > > > wrote: > > > > > So, I've been looking over the LatinIME in the git repository, and I > > > > am getting the feeling that this (the native dictionary piece) can't > > > > be compiled on the NDK - at least not officially? There seem to be > > > > some unsupported libraries and such being used. Specifically, Asset.h > > > > and AssetManager.h which look to be a part of the base/include/utils > > > > portion of the source tree. I assume these are not a part of the NDK > > > > scope at this point? > > > > > On Jul 7, 4:13 pm, "nEx.Software" wrote: > > > > > Awesome, thanks for the info. I had a feeling that was the case. > > > > > Thanks for confirming that for me. > > > > > > On Jul 7, 3:04 pm, Dianne Hackborn wrote: > > > > > > > The prediction dictionary is built into the IME, it is not a part of > > > > the > > > > > > platform like the user dictionary, so you will need to implement > > > > > > your > > > > own > > > > > > for your IME. The LatinIME code is open source, so to start you can > > > > just > > > > > > copy it (especially now that we have the NDK available). > > > > > > > On Tue, Jul 7, 2009 at 2:56 PM, nEx.Software < > > > > justin.shapc...@gmail.com>wrote: > > > > > > > > I am attempting to do an IME and am wondering the best way to use > > > > > > > the > > > > > > > main dictionary for the suggestions to work? Using the User > > > > Dictionary > > > > > > > is pretty straight forward, but I am not sure how to use the main > > > > > > > dictionary. The System IME appears to use BinaryDictionary and a > > > > > > > native method to do this? Can I piggy back on this or must I > > > > > > > create > > > > my > > > > > > > own implementation? Thanks in advance. > > > > > > > -- > > > > > > Dianne Hackborn > > > > > > Android framework engineer > > > > > > hack...@android.com > > > > > > > Note: please don't send private questions to me, as I don't have > > > > > > time > > > > to > > > > > > provide private support, and so won't reply to such e-mails. All > > > > > > such > > > > > > questions should be posted on public forums, where I and others can > > > > > > see > > > > and > > > > > > answer them. > > > > -- > > > Dianne Hackborn > > > Android framework engineer > > > hack...@android.com > > > > Note: please don't send private questions to me, as I don't have time to > > > provide private support, and so won't reply to such e-mails. All such > > > questions should be posted on public forums, where I and others can see > > > and > > > answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Hardware keyboard caps state
Oops, duplicate of http://groups.google.com/group/android-framework/browse_thread/thread/a656b7aa896caa7f My bad, I'll re-post there -- please ignore this. Cheers, Spiros On Jun 4, 1:12 pm, Spiros wrote: > Hi, > > I'm writing a Greek IME, which also needs to translate hardware > keypresses. I'm doing this by intercepting onKeyDown() in > InputMethodService. > > Is there some way to find out what the caps state is (as indicated by > the plain/triangle/caret cursor in the UI for lowercase/single-caps/ > all-caps, respectively), so I can accordingly output upper or lower > case characters? I checked the PinyinIME code in GIT and it tries to > track the hardware keyboard shift state by monitoring > KEYCODE_SHIFT_LEFT and KEYCODE_SHIFT_RIGHT keypresses -- and it can > get out of sync with the true state indicated by the cursor, which can > be confusing. > > So, the question is: > 1. Do I also have to track hardware shift key-down events and > duplicate the caps state logic, or is there a way to query the input > connection what that state is? > 2. If there is no way to query the caps state, then is there a way to > reset it to lowercase (since I need to know what the initial caps > state is when the IME starts). > > Thanks! > Spiros --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Hardware keyboard caps state
Hi, I'm writing a Greek IME, which also needs to translate hardware keypresses. I'm doing this by intercepting onKeyDown() in InputMethodService. Is there some way to find out what the caps state is (as indicated by the plain/triangle/caret cursor in the UI for lowercase/single-caps/ all-caps, respectively), so I can accordingly output upper or lower case characters? I checked the PinyinIME code in GIT and it tries to track the hardware keyboard shift state by monitoring KEYCODE_SHIFT_LEFT and KEYCODE_SHIFT_RIGHT keypresses -- and it can get out of sync with the true state indicated by the cursor, which can be confusing. So, the question is: 1. Do I also have to track hardware shift key-down events and duplicate the caps state logic, or is there a way to query the input connection what that state is? 2. If there is no way to query the caps state, then is there a way to reset it to lowercase (since I need to know what the initial caps state is when the IME starts). Thanks! Spiros --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Should cursors used in autocomplete adapters be managed or not?
Thanks for the quick response! That's what I also thought, but then I get these exceptions. I glanced at the Android sources, and here is what I *think* is going on if I use managed cursors: - Cursor returned by FilterQueryProvider#runQuery() is passed on to SimpleQueryAdapter#changeCursor() - changeCursor() calls close() on the *previous* cursor (which is also managed) - However, this is not reflected in any way in Activity#mManagedCursors (mReleased is still false) - If the activity is paused, then Activity#performStop() deactivates all managed cursors and sets them to be requeried on resume - When the activity resumes, Activity#performRestart() tries to requery those closed cursors and the application dies As far as I can tell, there is no hook in FilterQueryProvider (or elsewhere), where I can call Activity#stopManagingCursor() on the old cursor to avoid this. Also, it seems there is no way to iterate over the managed cursors in onPause() to perform a post-mortem cleanup (no accessor for Activity#mManagedCursors). Or am I missing something? Thanks, Spiros On Feb 10, 7:17 pm, Romain Guy wrote: > It's up to you. If you don't use managed cursors, you will have to > close/query them yourself when the activity is > destroyed/created/stopped, etc. > > > > On Tue, Feb 10, 2009 at 4:14 PM, Spiros wrote: > > > Hi, > > > I'm using an autocomplete box, with suggestions provided by a > > SimpleQueryAdapter, almost identical to the code in this thread: > > http://groups.google.com/group/android-developers/browse_thread/threa... > > Not sure if relevant, but only difference I see is that, both in the > > adapter constructor, as well as in runQuery(), I use a cursor returned > > by SQLiteDatabase#query() obtained via an SQLiteOpenHelper instance. > > > Should I be using Activity#startManagingCursor() on these cursors or > > not? > > > If I don't use managed cursors, then I get "leak found" warnings > > ("database was created [sic] but never closed"). > > > If I do then, if the application pauses (e.g., incoming call) and then > > resumes, I get an unhandled exception ("attempted to requery closed > > cursor" thrown by Activity#performRestart(), in Activity.java: -- > > SDK 1.0_r2, btw). > > > What am I missing? > > > Thanks! > > Spiros > > -- > Romain Guy > Android framework engineer > romain...@android.com > > Note: please don't send private questions to me, as I don't have time > to provide private support. All such questions should be posted on > public forums, where I and others can see and answer them --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Getting user's confirmation in OnPreferenceChangeListener
Ugh, nevermind -- a quick look at the Android sources solved this easily. For the record, this seems to be the right way to change a setting in a preference screen: CheckBoxPreference p = (CheckBoxPreference)findPreference ("foo_enable"); p.setChecked(false); Spiros. On Feb 10, 7:03 pm, Spiros wrote: > Hi, > > I have a checkbox preference which, when set for the first time, may > trigger a long-running operation. I want to get the user's explicit > consent before starting this operation. However, if the user hits > cancel, then the preference should remain unchecked. > > I'm using a preference activity and register an onPreferenceChanged() > handler for the checkbox preference in question, which shows an alert > dialog (and returns true, so the preference *will* be set before the > dialog pops up). > > I tried doing something like this in the AlertDialog that asks for > user confirmation, to revert that preference change if he clicks > cancel: > > [] > .setNegativeButton(R.string.cancel_button, new > DialogInterface.OnClickListener() { > @Override > public void onClick (DialogInterface dialog, int which) { > Editor e = getPreferenceScreen().getEditor(); > e.putBoolean("foo_enable", false); > e.commit(); > SettingsActivity.this.onContentChanged(); > } > > }) > > but it doesn't quite have the desired effect: the "foo_enabled" > preference remains checked. > > AFAIK there are no blocking modal dialogs in Android. Should I > perhaps be using something other than onPreferenceChanged() for this? > Any suggestions would be appreciated! > > Thanks, > Spiros --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Should cursors used in autocomplete adapters be managed or not?
Hi, I'm using an autocomplete box, with suggestions provided by a SimpleQueryAdapter, almost identical to the code in this thread: http://groups.google.com/group/android-developers/browse_thread/thread/8e9738ec79042f9e Not sure if relevant, but only difference I see is that, both in the adapter constructor, as well as in runQuery(), I use a cursor returned by SQLiteDatabase#query() obtained via an SQLiteOpenHelper instance. Should I be using Activity#startManagingCursor() on these cursors or not? If I don't use managed cursors, then I get "leak found" warnings ("database was created [sic] but never closed"). If I do then, if the application pauses (e.g., incoming call) and then resumes, I get an unhandled exception ("attempted to requery closed cursor" thrown by Activity#performRestart(), in Activity.java: -- SDK 1.0_r2, btw). What am I missing? Thanks! Spiros --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Getting user's confirmation in OnPreferenceChangeListener
Hi, I have a checkbox preference which, when set for the first time, may trigger a long-running operation. I want to get the user's explicit consent before starting this operation. However, if the user hits cancel, then the preference should remain unchecked. I'm using a preference activity and register an onPreferenceChanged() handler for the checkbox preference in question, which shows an alert dialog (and returns true, so the preference *will* be set before the dialog pops up). I tried doing something like this in the AlertDialog that asks for user confirmation, to revert that preference change if he clicks cancel: [] .setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { @Override public void onClick (DialogInterface dialog, int which) { Editor e = getPreferenceScreen().getEditor(); e.putBoolean("foo_enable", false); e.commit(); SettingsActivity.this.onContentChanged(); } }) but it doesn't quite have the desired effect: the "foo_enabled" preference remains checked. AFAIK there are no blocking modal dialogs in Android. Should I perhaps be using something other than onPreferenceChanged() for this? Any suggestions would be appreciated! Thanks, Spiros --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---