11
11
import android .content .Context ;
12
12
import android .content .pm .PackageManager ;
13
13
import android .content .pm .ResolveInfo ;
14
- import android .os . Bundle ;
14
+ import android .support . annotation . NonNull ;
15
15
import android .util .Log ;
16
16
17
17
import java .io .File ;
@@ -59,59 +59,15 @@ public static final class Builder {
59
59
* <p>
60
60
* This context will then be passed through to the rest of the Parse SDK for use during
61
61
* initialization.
62
- * <p>
63
- * <p/>
64
- * You may define {@code com.parse.SERVER_URL}, {@code com.parse.APPLICATION_ID} and (optional) {@code com.parse.CLIENT_KEY}
65
- * {@code meta-data} in your {@code AndroidManifest.xml}:
66
- * <pre>
67
- * <manifest ...>
68
- *
69
- * ...
70
- *
71
- * <application ...>
72
- * <meta-data
73
- * android:name="com.parse.SERVER_URL"
74
- * android:value="@string/parse_server_url" />
75
- * <meta-data
76
- * android:name="com.parse.APPLICATION_ID"
77
- * android:value="@string/parse_app_id" />
78
- * <meta-data
79
- * android:name="com.parse.CLIENT_KEY"
80
- * android:value="@string/parse_client_key" />
81
- *
82
- * ...
83
- *
84
- * </application>
85
- * </manifest>
86
- * </pre>
87
- * <p/>
88
- * <p>
89
- * This will cause the values for {@code server}, {@code applicationId} and {@code clientKey} to be set to
90
- * those defined in your manifest.
91
62
*
92
63
* @param context The active {@link Context} for your application. Cannot be null.
93
64
*/
94
- public Builder (Context context ) {
65
+ public Builder (@ NonNull Context context ) {
95
66
this .context = context ;
96
-
97
- // Yes, our public API states we cannot be null. But for unit tests, it's easier just to
98
- // support null here.
99
- if (context != null ) {
100
- Context applicationContext = context .getApplicationContext ();
101
- Bundle metaData = ManifestInfo .getApplicationMetadata (applicationContext );
102
- if (metaData != null ) {
103
- server (metaData .getString (PARSE_SERVER_URL ));
104
- applicationId = metaData .getString (PARSE_APPLICATION_ID );
105
- clientKey = metaData .getString (PARSE_CLIENT_KEY );
106
- }
107
- }
108
67
}
109
68
110
69
/**
111
70
* Set the application id to be used by Parse.
112
- * <p>
113
- * This method is only required if you intend to use a different {@code applicationId} than
114
- * is defined by {@code com.parse.APPLICATION_ID} in your {@code AndroidManifest.xml}.
115
71
*
116
72
* @param applicationId The application id to set.
117
73
* @return The same builder, for easy chaining.
@@ -123,9 +79,6 @@ public Builder applicationId(String applicationId) {
123
79
124
80
/**
125
81
* Set the client key to be used by Parse.
126
- * <p>
127
- * This method is only required if you intend to use a different {@code clientKey} than
128
- * is defined by {@code com.parse.CLIENT_KEY} in your {@code AndroidManifest.xml}.
129
82
*
130
83
* @param clientKey The client key to set.
131
84
* @return The same builder, for easy chaining.
@@ -224,10 +177,6 @@ private Configuration(Builder builder) {
224
177
}
225
178
}
226
179
227
- private static final String PARSE_SERVER_URL = "com.parse.SERVER_URL" ;
228
- private static final String PARSE_APPLICATION_ID = "com.parse.APPLICATION_ID" ;
229
- private static final String PARSE_CLIENT_KEY = "com.parse.CLIENT_KEY" ;
230
-
231
180
private static final Object MUTEX = new Object ();
232
181
static ParseEventuallyQueue eventuallyQueue = null ;
233
182
@@ -239,7 +188,7 @@ private Configuration(Builder builder) {
239
188
/**
240
189
* Enable pinning in your application. This must be called before your application can use
241
190
* pinning. You must invoke {@code enableLocalDatastore(Context)} before
242
- * {@link #initialize(Context)} :
191
+ * {@link #initialize(Configuration)} :
243
192
* <p/>
244
193
* <pre>
245
194
* public class MyApplication extends Application {
@@ -284,99 +233,20 @@ public static boolean isLocalDatastoreEnabled() {
284
233
285
234
/**
286
235
* Authenticates this client as belonging to your application.
287
- * <p/>
288
- * You may define {@code com.parse.SERVER_URL}, {@code com.parse.APPLICATION_ID} and (optional) {@code com.parse.CLIENT_KEY}
289
- * {@code meta-data} in your {@code AndroidManifest.xml}:
290
- * <pre>
291
- * <manifest ...>
292
- *
293
- * ...
294
- *
295
- * <application ...>
296
- * <meta-data
297
- * android:name="com.parse.SERVER_URL"
298
- * android:value="@string/parse_server_url" />
299
- * <meta-data
300
- * android:name="com.parse.APPLICATION_ID"
301
- * android:value="@string/parse_app_id" />
302
- * <meta-data
303
- * android:name="com.parse.CLIENT_KEY"
304
- * android:value="@string/parse_client_key" />
305
- *
306
- * ...
307
- *
308
- * </application>
309
- * </manifest>
310
- * </pre>
311
- * <p/>
312
- * This must be called before your application can use the Parse library.
313
- * The recommended way is to put a call to {@code Parse.initialize}
314
- * in your {@code Application}'s {@code onCreate} method:
315
- * <p/>
316
- * <pre>
317
- * public class MyApplication extends Application {
318
- * public void onCreate() {
319
- * Parse.initialize(this);
320
- * }
321
- * }
322
- * </pre>
323
- *
324
- * @param context The active {@link Context} for your application.
325
- */
326
- public static void initialize (Context context ) {
327
- Configuration .Builder builder = new Configuration .Builder (context );
328
- if (builder .server == null ) {
329
- throw new RuntimeException ("ServerUrl not defined. " +
330
- "You must provide ServerUrl in AndroidManifest.xml.\n " +
331
- "<meta-data\n " +
332
- " android:name=\" com.parse.SERVER_URL\" \n " +
333
- " android:value=\" <Your Server Url>\" />" );
334
- }
335
- if (builder .applicationId == null ) {
336
- throw new RuntimeException ("ApplicationId not defined. " +
337
- "You must provide ApplicationId in AndroidManifest.xml.\n " +
338
- "<meta-data\n " +
339
- " android:name=\" com.parse.APPLICATION_ID\" \n " +
340
- " android:value=\" <Your Application Id>\" />" );
341
- }
342
- initialize (builder
343
- .setLocalDatastoreEnabled (isLocalDatastoreEnabled )
344
- .build ()
345
- );
346
- }
347
-
348
- /**
349
- * Authenticates this client as belonging to your application.
350
- * <p/>
351
- * This method is only required if you intend to use a different {@code applicationId} or
352
- * {@code clientKey} than is defined by {@code com.parse.APPLICATION_ID} or
353
- * {@code com.parse.CLIENT_KEY} in your {@code AndroidManifest.xml}.
354
- * <p/>
355
236
* This must be called before your
356
237
* application can use the Parse library. The recommended way is to put a call to
357
238
* {@code Parse.initialize} in your {@code Application}'s {@code onCreate} method:
358
239
* <p/>
359
240
* <pre>
360
241
* public class MyApplication extends Application {
361
242
* public void onCreate() {
362
- * Parse.initialize(this, "your application id", "your client key" );
243
+ * Parse.initialize(configuration );
363
244
* }
364
245
* }
365
246
* </pre>
366
247
*
367
- * @param context The active {@link Context} for your application.
368
- * @param applicationId The application id provided in the Parse dashboard.
369
- * @param clientKey The client key provided in the Parse dashboard.
248
+ * @param configuration The configuration for your application.
370
249
*/
371
- public static void initialize (Context context , String applicationId , String clientKey ) {
372
- initialize (new Configuration .Builder (context )
373
- .applicationId (applicationId )
374
- .clientKey (clientKey )
375
- .setLocalDatastoreEnabled (isLocalDatastoreEnabled )
376
- .build ()
377
- );
378
- }
379
-
380
250
public static void initialize (Configuration configuration ) {
381
251
if (isInitialized ()) {
382
252
PLog .w (TAG , "Parse is already initialized" );
0 commit comments