Skip to content

Commit ab56ba3

Browse files
authored
Merge pull request #211 from appwrite/android-template-refactor
feat: android template changes
2 parents fbedd71 + eea80a6 commit ab56ba3

File tree

69 files changed

+2160
-469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2160
-469
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ The following checklist aims to balance consistency among languages, and follow
139139
- [ ] Default Headers
140140
- [ ] 'appwrite-sdk-version' header
141141
- [ ] Add 'User-Agent' header with device/server name and version + platform name and version (ubuntu-20.04-php-7.0.1 / android-20.0-flutter-3.0)
142+
- [ ] Add 'origin' header with the following syntax `<scheme>://<identifier>` where scheme is one of `http`, `https`, `appwrite-android`, `appwrite-ios`, `appwrite-macos`, `appwrite-windows`, `appwrite-linux` and identifier is the host name is case of web apps and the package name in case of ios, android and other platforms.
142143
- [ ] All Global headers available in spec
143144
- [ ] Methods
144145
- [ ] addHeader(key, value)
@@ -184,6 +185,8 @@ After you finish initializing, make a series of HTTP calls using your new genera
184185
1. tests/languages/tests-for-php.js
185186
2. tests/languages/tests-for-node.js
186187

188+
> Note: In your test files, make sure that you begin the test with the following string "\nTest Started\n". We use this string to filter output from the build tool you're using.
189+
187190
Once done, add a Docker command that can execute your test file to the SDK test algorithm `$containers` array in this location: `./tests/SDKTest.php:17`. Make sure to add one command for each language version you wish to support.
188191

189192
A good example is the PHP test for 5 different PHP versions:
@@ -201,5 +204,5 @@ protected $containers = [
201204

202205
Finally, you can run the tests using
203206
```sh
204-
docker run --rm -v $(pwd):/app:rw -w /app -v /var/run/docker.sock:/var/run/docker.sock php:7.4-cli-alpine sh -c "apk add docker-cli && vendor/bin/phpunit tests/SDKTest.php"
207+
docker run --rm -v $(pwd):$(pwd):rw -w $(pwd) -v /var/run/docker.sock:/var/run/docker.sock php:7.4-cli-alpine sh -c "apk add docker-cli && vendor/bin/phpunit tests/SDKTest.php"
205208
```

composer.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example.php

Lines changed: 8 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Appwrite\SDK\Language\Swift;
1818
use Appwrite\SDK\Language\DotNet;
1919
use Appwrite\SDK\Language\Flutter;
20-
use Appwrite\SDK\Language\Kotlin;
20+
use Appwrite\SDK\Language\Android;
2121

2222
try {
2323

@@ -369,110 +369,30 @@ function getSSLPage($url) {
369369
;
370370
$sdk->generate(__DIR__ . '/examples/CLI');
371371

372-
// Kotlin
372+
// Android
373373

374-
$sdk = new SDK(new Kotlin(), new Swagger2($spec));
374+
$sdk = new SDK(new Android(), new Swagger2($spec));
375375

376376
$sdk
377-
->setName('Kotlin')
377+
->setName('Android')
378378
->setNamespace('io appwrite')
379379
->setDescription('Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Flutter SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to https://appwrite.io/docs')
380-
->setShortDescription('Appwrite Kotlin SDK')
380+
->setShortDescription('Appwrite Android SDK')
381381
->setURL('https://example.com')
382382
->setGitUserName('appwrite')
383-
->setGitRepoName('sdk-for-kotlin')
383+
->setGitRepoName('sdk-for-android')
384384
->setLogo('https://appwrite.io/v1/images/console.png')
385385
->setLicenseContent('test test test')
386386
->setWarning('**This SDK is compatible with Appwrite server version 0.7.x. For older versions, please check previous releases.**')
387-
->setGettingStarted("
388-
### Add your Android Platform
389-
To init your SDK and start interacting with Appwrite services, you need to add a new Flutter platform to your project. To add a new platform, go to your Appwrite console, choose the project you created in the step before, and click the 'Add Platform' button.
390-
391-
From the options, choose to add a new **Flutter** platform and add your app credentials, ignoring iOS.
392-
393-
Add your app <u>name</u> and <u>package name</u>, Your package name is generally the applicationId in your app-level build.gradle file. By registering your new app platform, you are allowing your app to communicate with the Appwrite API.
394-
395-
### OAuth
396-
In order to capture the Appwrite OAuth callback url, the following activity needs to be added to your [AndroidManifest.xml](https://github.com/appwrite/playground-for-flutter/blob/master/android/app/src/main/AndroidManifest.xml). Be sure to relpace the **[PROJECT_ID]** string with your actual Appwrite project ID. You can find your Appwrite project ID in you project settings screen in your Appwrite console.
397-
398-
```xml
399-
<manifest>
400-
<application>
401-
<activity android:name=\"io.appwrite.views.CallbackActivity\" >
402-
<intent-filter android:label=\"android_web_auth\">
403-
<action android:name=\"android.intent.action.VIEW\" />
404-
<category android:name=\"android.intent.category.DEFAULT\" />
405-
<category android:name=\"android.intent.category.BROWSABLE\" />
406-
<data android:scheme=\"appwrite-callback-[PROJECT_ID]\" />
407-
</intent-filter>
408-
</activity>
409-
</application>
410-
</manifest>
411-
```
412-
413-
### Init your SDK
414-
415-
<p>Initialize your SDK code with your project ID, which can be found in your project settings page.
416-
417-
```kotlin
418-
import io.appwrite.Client
419-
import io.appwrite.services.Account
420-
421-
val client = Client(context)
422-
.setEndpoint(\"https://[HOSTNAME_OR_IP]/v1\") // Your API Endpoint
423-
.setProject(\"5df5acd0d48c2\") // Your project ID
424-
.setSelfSigned(true) // Remove in production
425-
```
426-
427-
Before starting to send any API calls to your new Appwrite instance, make sure your Android emulators has network access to the Appwrite server hostname or IP address.
428-
429-
When trying to connect to Appwrite from an emulator or a mobile device, localhost is the hostname for the device or emulator and not your local Appwrite instance. You should replace localhost with your private IP as the Appwrite endpoint's hostname. You can also use a service like [ngrok](https://ngrok.com/) to proxy the Appwrite API.
430-
431-
### Make Your First Request
432-
433-
<p>Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.
434-
435-
```kotlin
436-
// Register User
437-
val accountService = Account(client)
438-
val user = accountService.create(
439-
440-
\"password\"
441-
)
442-
```
443-
444-
### Full Example
445-
446-
```kotlin
447-
import io.appwrite.Client
448-
import io.appwrite.services.Account
449-
450-
val client = Client(context)
451-
.setEndpoint(\"https://[HOSTNAME_OR_IP]/v1\") // Your API Endpoint
452-
.setProject(\"5df5acd0d48c2\") // Your project ID
453-
.setSelfSigned(true) // Remove in production
454-
455-
val accountService = Account(client)
456-
val user = accountService.create(
457-
458-
\"password\"
459-
)
460-
```
461-
462-
### Learn more
463-
You can use following resources to learn more and get help
464-
- 📜 [Appwrite Docs](https://appwrite.io/docs)
465-
- 💬 [Discord Community](https://appwrite.io/discord)
466-
")
467387
->setChangelog('**CHANGELOG**')
468-
->setVersion('0.7.0')
388+
->setVersion('0.0.0-SNAPSHOT')
469389
->setTwitter('appwrite_io')
470390
->setDiscord('564160730845151244', 'https://appwrite.io/discord')
471391
->setDefaultHeaders([
472392
'x-appwrite-response-format' => '0.7.0',
473393
])
474394
;
475-
$sdk->generate(__DIR__ . '/examples/kotlin-android');
395+
$sdk->generate(__DIR__ . '/examples/android');
476396
}
477397
catch (Exception $exception) {
478398
echo 'Error: ' . $exception->getMessage() . ' on ' . $exception->getFile() . ':' . $exception->getLine() . "\n";

0 commit comments

Comments
 (0)