Fix NPE in PunctuationSuggestions.

The NPE happens when the keyboard doesn't specify any punctuation suggestions.

Bug 18047927.

Change-Id: I9f8aa35df4f163b527dc6580a99afc6da45a96b8
diff --git a/java/src/com/android/inputmethod/latin/PunctuationSuggestions.java b/java/src/com/android/inputmethod/latin/PunctuationSuggestions.java
index 555bbc7..c9b6d6b 100644
--- a/java/src/com/android/inputmethod/latin/PunctuationSuggestions.java
+++ b/java/src/com/android/inputmethod/latin/PunctuationSuggestions.java
@@ -23,6 +23,8 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 
+import javax.annotation.Nullable;
+
 /**
  * The extended {@link SuggestedWords} class to represent punctuation suggestions.
  *
@@ -49,12 +51,16 @@
      * @return The {@link PunctuationSuggestions} object.
      */
     public static PunctuationSuggestions newPunctuationSuggestions(
-            final String[] punctuationSpecs) {
-        final ArrayList<SuggestedWordInfo> puncuationsList = new ArrayList<>();
-        for (final String puncSpec : punctuationSpecs) {
-            puncuationsList.add(newHardCodedWordInfo(puncSpec));
+            @Nullable final String[] punctuationSpecs) {
+        if (punctuationSpecs == null || punctuationSpecs.length == 0) {
+            return new PunctuationSuggestions(new ArrayList<SuggestedWordInfo>(0));
         }
-        return new PunctuationSuggestions(puncuationsList);
+        final ArrayList<SuggestedWordInfo> punctuationList =
+                new ArrayList<>(punctuationSpecs.length);
+        for (String spec : punctuationSpecs) {
+            punctuationList.add(newHardCodedWordInfo(spec));
+        }
+        return new PunctuationSuggestions(punctuationList);
     }
 
     /**