Thanks for your suggestion, Daniel. Actually it appears to me like a new input method would need to be implemented (by Google...? :) at least for soft-keyboard, so the user just sees the allowed keys (just the forbidden ones are not shown). And, with a flag to enable or disable the path-separator char (fun read: http://blogs.msdn.com/b/oldnewthing/archive/2005/10/14/481044.aspx ) On the other hand your suggestion seems like a good (the only?) option for an hardware keyboard.
I'll go hunting for an 'official' list of locale-specific path separators... Maybe it's just Yen, Won and slashes-backslashes... best -- Mathieu On Aug 24, 6:39 pm, Daniel Drozdzewski <[email protected]> wrote: > On 24 August 2011 17:05, bdk <[email protected]> wrote: > > > > > Hi > > > I'm showing the user a "Save as..." dialog to save files, and I'd like > > to disable a set of 'reserved characters' into a related EditText > > field. > > > Let's say, something like: > > > private static final String ReservedChars = "|\\?*<\":>+/'¥"; > > > (useful read:http://en.wikipedia.org/wiki/Filename) > > > I have to be careful not to use chars not compatible with other > > filesystems like Windows (for instance: ? or " would make the file > > unusable in a Win* filesystem) > > > Moreover, I don't want the user to be able to put sequences like "../" > > or "/foo/bar/filename.xxx" to access other paths. > > > This also brings up another point: _all_ possible filepath separators > > should be forbidden (for instance, ¥ is the filepath separator on > > Japanese locale computers). > > > So, what would be the most elegant solution to filter out these > > characters from user input? > > I'm also thinking about automatically replacing the forbidden chars > > with underscores, but it's not really user-friendly. > > > I looked > > intohttp://developer.android.com/reference/android/text/InputType.html > > but something like InputType.TYPE_CLASS_FILE_NAME is missing... > > > TYPE_TEXT_VARIATION_URI does not seem an option since apparently the > > soft keyboard ends up containing chars like: / * " ? ¥ and... smileys? > > > For now I've tried with: > > > EditText myEditText = new EditText(activity); > > myEditText.setSingleLine(); > > myEditText.setInputType(InputType.TYPE_CLASS_TEXT | > > InputType.TYPE_TEXT_VARIATION_URI); > > > to no luck. > > > Now I'm reading > > across:http://stackoverflow.com/questions/6626283/how-to-use-inputconnection... > > ... > > > best > > Just add a listener to EditText. > > In the listener you capture the text change event and filter through > only allowed characters. > -- > Daniel Drozdzewski -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

