/android/import-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/import-contacts

« back to all changes in this revision

Viewing changes to src/am/ed/importcontacts/VcardImporter.java

  • Committer: edam
  • Date: 2012-12-19 17:51:35 UTC
  • Revision ID: tim@ed.am-20121219175135-1cpuafp76jg1ib1p
added preliminary (buggy) ContactsContract backend

Show diffs side-by-side

added added

removed removed

681
681
                                        parseADR( name_param_parts, complete_value );
682
682
                                else if( name_param_parts[ 0 ].equals( "LABEL" ) )
683
683
                                        parseLABEL( name_param_parts, complete_value );
684
 
                                else if( name_param_parts[ 0 ].equals( "NOTE" ) )
685
 
                                        parseNOTE( name_param_parts, complete_value );
686
684
                        }
687
685
                }
688
686
 
760
758
                                in_escape = false;
761
759
                                switch( c )
762
760
                                {
763
 
                                case 'T':
764
 
                                case 't':
765
 
                                        // add tab (invalid/non-standard, but accepted)
766
 
                                        ret.append( '\t' );
767
 
                                        break;
768
761
                                case 'N':
769
762
                                case 'n':
770
763
                                        // add newline
778
771
                                        break;
779
772
                                default:
780
773
                                        // unknown escape sequence, so add it unescaped
781
 
                                        // (invalid/non-standard, but accepted)
782
774
                                        ret.append( "\\" );
783
775
                                        ret.append( Character.toChars( c ) );
784
776
                                        break;
973
965
                        addAddress( unescapeValue( value ), type );
974
966
                }
975
967
 
976
 
                private void parseNOTE( String[] params, String value )
977
 
                {
978
 
                        addNote( unescapeValue( value ) );
979
 
                }
980
 
 
981
968
                public void finaliseVcard()
982
969
                        throws ParseException, ContactNotIdentifiableException
983
970
                {
1013
1000
                        HashSet< String > ret = new HashSet< String >();
1014
1001
 
1015
1002
                        Pattern p = Pattern.compile(
1016
 
                                "^" + name + "[ \\t]*=[ \\t]*(\"?)(.*)\\1$",
1017
 
                                Pattern.CASE_INSENSITIVE );
 
1003
                                "^" + name + "[ \\t]*=[ \\t]*(\"?)(.*)\\1$" );
1018
1004
                        for( int i = 0; i < params.length; i++ ) {
1019
1005
                                Matcher m = p.matcher( params[ i ] );
1020
1006
                                if( m.matches() )
1028
1014
                 * Amongst the params, return any type values present. For v2.1 vCards,
1029
1015
                 * those types are just parameters. For v3.0, they are prefixed with
1030
1016
                 * "TYPE=". There may also be multiple type parameters.
1031
 
                 * @param params an array of params to look for types in
1032
 
                 * @param valid_types an list of upper-case type values to look for
 
1017
                 * @param params
 
1018
                 * @param a list of type values to look for
1033
1019
                 * @return a set of present type values
1034
1020
                 */
1035
1021
                private Set< String > extractTypes( String[] params,
1045
1031
                                // the specs!)
1046
1032
                                String[] parts = type_params[ a ].split( "," );
1047
1033
                                for( int i = 0; i < parts.length; i++ )
1048
 
                                        parts[ i ] = parts[ i ].toUpperCase( Locale.US );
1049
 
                                for( int i = 0; i < parts.length; i++ )
1050
1034
                                        if( valid_types.contains( parts[ i ] ) )
1051
1035
                                                types.add( parts[ i ] );
1052
1036
                        }