Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3 from BlueBubblesApp/zach/commit-mimes
Browse files Browse the repository at this point in the history
content commit MIME types
  • Loading branch information
zlshames authored Jan 15, 2022
2 parents 9d0eb17 + 0c1dbbd commit a933522
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.json.JSONArray;
Expand Down Expand Up @@ -460,6 +461,19 @@ public static Configuration fromJson(@NonNull JSONObject json)
}
}
final Integer inputAction = inputActionFromTextInputAction(inputActionName);

// Build list of content commit mime types from the passed in JSON list
List<String> contentList = new ArrayList<String>();
JSONArray contentCommitMimeTypes =
json.isNull("contentCommitMimeTypes")
? null
: json.getJSONArray("contentCommitMimeTypes");
if (contentCommitMimeTypes != null) {
for (int i = 0; i < contentCommitMimeTypes.length(); i++) {
contentList.add(contentCommitMimeTypes.optString(i));
}
}

return new Configuration(
json.optBoolean("obscureText"),
json.optBoolean("autocorrect", true),
Expand All @@ -471,6 +485,7 @@ public static Configuration fromJson(@NonNull JSONObject json)
inputAction,
json.isNull("actionLabel") ? null : json.getString("actionLabel"),
json.isNull("autofill") ? null : Autofill.fromJson(json.getJSONObject("autofill")),
contentList.toArray(new String[contentList.size()]),
fields);
}

Expand Down Expand Up @@ -627,6 +642,7 @@ public Autofill(
@Nullable public final Integer inputAction;
@Nullable public final String actionLabel;
@Nullable public final Autofill autofill;
@Nullable public final String[] contentCommitMimeTypes;
@Nullable public final Configuration[] fields;

public Configuration(
Expand All @@ -640,6 +656,7 @@ public Configuration(
@Nullable Integer inputAction,
@Nullable String actionLabel,
@Nullable Autofill autofill,
@Nullable String[] contentCommitMimeTypes,
@Nullable Configuration[] fields) {
this.obscureText = obscureText;
this.autocorrect = autocorrect;
Expand All @@ -651,6 +668,7 @@ public Configuration(
this.inputAction = inputAction;
this.actionLabel = actionLabel;
this.autofill = autofill;
this.contentCommitMimeTypes = contentCommitMimeTypes;
this.fields = fields;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,17 +340,10 @@ public InputConnection createInputConnection(
}
outAttrs.imeOptions |= enterAction;

String[] imgTypeString =
new String[] {
"image/png",
"image/bmp",
"image/jpg",
"image/tiff",
"image/gif",
"image/jpeg",
"image/webp"
};
EditorInfoCompat.setContentMimeTypes(outAttrs, imgTypeString);
if (configuration.contentCommitMimeTypes != null) {
String[] imgTypeString = configuration.contentCommitMimeTypes;
EditorInfoCompat.setContentMimeTypes(outAttrs, imgTypeString);
}

InputConnectionAdaptor connection =
new InputConnectionAdaptor(
Expand Down

0 comments on commit a933522

Please sign in to comment.