• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007-2008 Esmertec AG.
3  * Copyright (C) 2007-2008 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 package com.example.android.mmslib;
19 
20 import java.util.ArrayList;
21 
22 public class ContentType {
23     public static final String MMS_MESSAGE       = "application/vnd.wap.mms-message";
24     // The phony content type for generic PDUs (e.g. ReadOrig.ind,
25     // Notification.ind, Delivery.ind).
26     public static final String MMS_GENERIC       = "application/vnd.wap.mms-generic";
27     public static final String MULTIPART_MIXED   = "application/vnd.wap.multipart.mixed";
28     public static final String MULTIPART_RELATED = "application/vnd.wap.multipart.related";
29     public static final String MULTIPART_ALTERNATIVE = "application/vnd.wap.multipart.alternative";
30 
31     public static final String TEXT_PLAIN        = "text/plain";
32     public static final String TEXT_HTML         = "text/html";
33     public static final String TEXT_VCALENDAR    = "text/x-vCalendar";
34     public static final String TEXT_VCARD        = "text/x-vCard";
35 
36     public static final String IMAGE_UNSPECIFIED = "image/*";
37     public static final String IMAGE_JPEG        = "image/jpeg";
38     public static final String IMAGE_JPG         = "image/jpg";
39     public static final String IMAGE_GIF         = "image/gif";
40     public static final String IMAGE_WBMP        = "image/vnd.wap.wbmp";
41     public static final String IMAGE_PNG         = "image/png";
42     public static final String IMAGE_X_MS_BMP    = "image/x-ms-bmp";
43 
44     public static final String AUDIO_UNSPECIFIED = "audio/*";
45     public static final String AUDIO_AAC         = "audio/aac";
46     public static final String AUDIO_AMR         = "audio/amr";
47     public static final String AUDIO_IMELODY     = "audio/imelody";
48     public static final String AUDIO_MID         = "audio/mid";
49     public static final String AUDIO_MIDI        = "audio/midi";
50     public static final String AUDIO_MP3         = "audio/mp3";
51     public static final String AUDIO_MPEG3       = "audio/mpeg3";
52     public static final String AUDIO_MPEG        = "audio/mpeg";
53     public static final String AUDIO_MPG         = "audio/mpg";
54     public static final String AUDIO_MP4         = "audio/mp4";
55     public static final String AUDIO_X_MID       = "audio/x-mid";
56     public static final String AUDIO_X_MIDI      = "audio/x-midi";
57     public static final String AUDIO_X_MP3       = "audio/x-mp3";
58     public static final String AUDIO_X_MPEG3     = "audio/x-mpeg3";
59     public static final String AUDIO_X_MPEG      = "audio/x-mpeg";
60     public static final String AUDIO_X_MPG       = "audio/x-mpg";
61     public static final String AUDIO_3GPP        = "audio/3gpp";
62     public static final String AUDIO_X_WAV       = "audio/x-wav";
63     public static final String AUDIO_OGG         = "application/ogg";
64 
65     public static final String VIDEO_UNSPECIFIED = "video/*";
66     public static final String VIDEO_3GPP        = "video/3gpp";
67     public static final String VIDEO_3G2         = "video/3gpp2";
68     public static final String VIDEO_H263        = "video/h263";
69     public static final String VIDEO_MP4         = "video/mp4";
70 
71     public static final String APP_SMIL          = "application/smil";
72     public static final String APP_WAP_XHTML     = "application/vnd.wap.xhtml+xml";
73     public static final String APP_XHTML         = "application/xhtml+xml";
74 
75     public static final String APP_DRM_CONTENT   = "application/vnd.oma.drm.content";
76     public static final String APP_DRM_MESSAGE   = "application/vnd.oma.drm.message";
77 
78     private static final ArrayList<String> sSupportedContentTypes = new ArrayList<String>();
79     private static final ArrayList<String> sSupportedImageTypes = new ArrayList<String>();
80     private static final ArrayList<String> sSupportedAudioTypes = new ArrayList<String>();
81     private static final ArrayList<String> sSupportedVideoTypes = new ArrayList<String>();
82 
83     static {
84         sSupportedContentTypes.add(TEXT_PLAIN);
85         sSupportedContentTypes.add(TEXT_HTML);
86         sSupportedContentTypes.add(TEXT_VCALENDAR);
87         sSupportedContentTypes.add(TEXT_VCARD);
88 
89         sSupportedContentTypes.add(IMAGE_JPEG);
90         sSupportedContentTypes.add(IMAGE_GIF);
91         sSupportedContentTypes.add(IMAGE_WBMP);
92         sSupportedContentTypes.add(IMAGE_PNG);
93         sSupportedContentTypes.add(IMAGE_JPG);
94         sSupportedContentTypes.add(IMAGE_X_MS_BMP);
95         //supportedContentTypes.add(IMAGE_SVG); not yet supported.
96 
97         sSupportedContentTypes.add(AUDIO_AAC);
98         sSupportedContentTypes.add(AUDIO_AMR);
99         sSupportedContentTypes.add(AUDIO_IMELODY);
100         sSupportedContentTypes.add(AUDIO_MID);
101         sSupportedContentTypes.add(AUDIO_MIDI);
102         sSupportedContentTypes.add(AUDIO_MP3);
103         sSupportedContentTypes.add(AUDIO_MP4);
104         sSupportedContentTypes.add(AUDIO_MPEG3);
105         sSupportedContentTypes.add(AUDIO_MPEG);
106         sSupportedContentTypes.add(AUDIO_MPG);
107         sSupportedContentTypes.add(AUDIO_X_MID);
108         sSupportedContentTypes.add(AUDIO_X_MIDI);
109         sSupportedContentTypes.add(AUDIO_X_MP3);
110         sSupportedContentTypes.add(AUDIO_X_MPEG3);
111         sSupportedContentTypes.add(AUDIO_X_MPEG);
112         sSupportedContentTypes.add(AUDIO_X_MPG);
113         sSupportedContentTypes.add(AUDIO_X_WAV);
114         sSupportedContentTypes.add(AUDIO_3GPP);
115         sSupportedContentTypes.add(AUDIO_OGG);
116 
117         sSupportedContentTypes.add(VIDEO_3GPP);
118         sSupportedContentTypes.add(VIDEO_3G2);
119         sSupportedContentTypes.add(VIDEO_H263);
120         sSupportedContentTypes.add(VIDEO_MP4);
121 
122         sSupportedContentTypes.add(APP_SMIL);
123         sSupportedContentTypes.add(APP_WAP_XHTML);
124         sSupportedContentTypes.add(APP_XHTML);
125 
126         sSupportedContentTypes.add(APP_DRM_CONTENT);
127         sSupportedContentTypes.add(APP_DRM_MESSAGE);
128 
129         // add supported image types
130         sSupportedImageTypes.add(IMAGE_JPEG);
131         sSupportedImageTypes.add(IMAGE_GIF);
132         sSupportedImageTypes.add(IMAGE_WBMP);
133         sSupportedImageTypes.add(IMAGE_PNG);
134         sSupportedImageTypes.add(IMAGE_JPG);
135         sSupportedImageTypes.add(IMAGE_X_MS_BMP);
136 
137         // add supported audio types
138         sSupportedAudioTypes.add(AUDIO_AAC);
139         sSupportedAudioTypes.add(AUDIO_AMR);
140         sSupportedAudioTypes.add(AUDIO_IMELODY);
141         sSupportedAudioTypes.add(AUDIO_MID);
142         sSupportedAudioTypes.add(AUDIO_MIDI);
143         sSupportedAudioTypes.add(AUDIO_MP3);
144         sSupportedAudioTypes.add(AUDIO_MPEG3);
145         sSupportedAudioTypes.add(AUDIO_MPEG);
146         sSupportedAudioTypes.add(AUDIO_MPG);
147         sSupportedAudioTypes.add(AUDIO_MP4);
148         sSupportedAudioTypes.add(AUDIO_X_MID);
149         sSupportedAudioTypes.add(AUDIO_X_MIDI);
150         sSupportedAudioTypes.add(AUDIO_X_MP3);
151         sSupportedAudioTypes.add(AUDIO_X_MPEG3);
152         sSupportedAudioTypes.add(AUDIO_X_MPEG);
153         sSupportedAudioTypes.add(AUDIO_X_MPG);
154         sSupportedAudioTypes.add(AUDIO_X_WAV);
155         sSupportedAudioTypes.add(AUDIO_3GPP);
156         sSupportedAudioTypes.add(AUDIO_OGG);
157 
158         // add supported video types
159         sSupportedVideoTypes.add(VIDEO_3GPP);
160         sSupportedVideoTypes.add(VIDEO_3G2);
161         sSupportedVideoTypes.add(VIDEO_H263);
162         sSupportedVideoTypes.add(VIDEO_MP4);
163     }
164 
165     // This class should never be instantiated.
ContentType()166     private ContentType() {
167     }
168 
isSupportedType(String contentType)169     public static boolean isSupportedType(String contentType) {
170         return (null != contentType) && sSupportedContentTypes.contains(contentType);
171     }
172 
isSupportedImageType(String contentType)173     public static boolean isSupportedImageType(String contentType) {
174         return isImageType(contentType) && isSupportedType(contentType);
175     }
176 
isSupportedAudioType(String contentType)177     public static boolean isSupportedAudioType(String contentType) {
178         return isAudioType(contentType) && isSupportedType(contentType);
179     }
180 
isSupportedVideoType(String contentType)181     public static boolean isSupportedVideoType(String contentType) {
182         return isVideoType(contentType) && isSupportedType(contentType);
183     }
184 
isTextType(String contentType)185     public static boolean isTextType(String contentType) {
186         return (null != contentType) && contentType.startsWith("text/");
187     }
188 
isImageType(String contentType)189     public static boolean isImageType(String contentType) {
190         return (null != contentType) && contentType.startsWith("image/");
191     }
192 
isAudioType(String contentType)193     public static boolean isAudioType(String contentType) {
194         return (null != contentType) && contentType.startsWith("audio/");
195     }
196 
isVideoType(String contentType)197     public static boolean isVideoType(String contentType) {
198         return (null != contentType) && contentType.startsWith("video/");
199     }
200 
isDrmType(String contentType)201     public static boolean isDrmType(String contentType) {
202         return (null != contentType)
203                 && (contentType.equals(APP_DRM_CONTENT)
204                         || contentType.equals(APP_DRM_MESSAGE));
205     }
206 
isUnspecified(String contentType)207     public static boolean isUnspecified(String contentType) {
208         return (null != contentType) && contentType.endsWith("*");
209     }
210 
211     @SuppressWarnings("unchecked")
getImageTypes()212     public static ArrayList<String> getImageTypes() {
213         return (ArrayList<String>) sSupportedImageTypes.clone();
214     }
215 
216     @SuppressWarnings("unchecked")
getAudioTypes()217     public static ArrayList<String> getAudioTypes() {
218         return (ArrayList<String>) sSupportedAudioTypes.clone();
219     }
220 
221     @SuppressWarnings("unchecked")
getVideoTypes()222     public static ArrayList<String> getVideoTypes() {
223         return (ArrayList<String>) sSupportedVideoTypes.clone();
224     }
225 
226     @SuppressWarnings("unchecked")
getSupportedTypes()227     public static ArrayList<String> getSupportedTypes() {
228         return (ArrayList<String>) sSupportedContentTypes.clone();
229     }
230 }
231