Changeset 10097 in josm for trunk/src/org


Ignore:
Timestamp:
2016-04-02T13:04:59+02:00 (9 years ago)
Author:
Don-vip
Message:

fix #12717 - Warning about short comments when submitting Chinese comment

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java

    r10035 r10097  
    1818import java.beans.PropertyChangeEvent;
    1919import java.beans.PropertyChangeListener;
     20import java.lang.Character.UnicodeBlock;
    2021import java.util.ArrayList;
    2122import java.util.Collection;
     
    503504        }
    504505
     506        static boolean isUploadCommentTooShort(String comment) {
     507            String s = comment.trim();
     508            boolean result = true;
     509            if (!s.isEmpty()) {
     510                UnicodeBlock block = Character.UnicodeBlock.of(s.charAt(0));
     511                if (block.toString().contains("CJK")) {
     512                    result = s.length() < 4;
     513                } else {
     514                    result = s.length() < 10;
     515                }
     516            }
     517            return result;
     518        }
     519
    505520        @Override
    506521        public void actionPerformed(ActionEvent e) {
    507             if (dialog.getUploadComment().trim().length() < 10 && warnUploadComment()) {
     522            if (isUploadCommentTooShort(dialog.getUploadComment()) && warnUploadComment()) {
    508523                // abort for missing comment
    509524                dialog.handleMissingComment();
Note: See TracChangeset for help on using the changeset viewer.