From 9d34f9906cf44bd12023e768efdbc34f0f3b1049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nat=C3=A1lia=20Cond=C3=AA?= Date: Wed, 27 Feb 2019 10:35:29 -0300 Subject: [PATCH] [Back4App] - API 28 + Parse Server Android SDK 1.19.0 --- .gitignore | 13 ++ .idea/codeStyles/Project.xml | 29 +++ .idea/gradle.xml | 15 ++ .idea/misc.xml | 9 + .idea/runConfigurations.xml | 12 ++ README.md | 9 + app/.gitignore | 1 + app/build.gradle | 36 ++++ app/proguard-rules.pro | 21 +++ .../ExampleInstrumentedTest.java | 27 +++ app/src/main/AndroidManifest.xml | 35 ++++ .../com/back4app/back4appandroid9/App.java | 20 ++ .../back4appandroid9/MainActivity.java | 67 +++++++ .../drawable-v24/ic_launcher_foreground.xml | 34 ++++ .../res/drawable/ic_launcher_background.xml | 170 +++++++++++++++++ app/src/main/res/layout/activity_main.xml | 47 +++++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 2963 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 4905 bytes app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2060 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2783 bytes app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4490 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 6895 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6387 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10413 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9128 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 15132 bytes app/src/main/res/values/colors.xml | 6 + app/src/main/res/values/strings.xml | 10 + app/src/main/res/values/styles.xml | 11 ++ .../back4appandroid9/ExampleUnitTest.java | 17 ++ build.gradle | 27 +++ gradle.properties | 20 ++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54329 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 172 ++++++++++++++++++ gradlew.bat | 84 +++++++++ settings.gradle | 1 + 39 files changed, 909 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/runConfigurations.xml create mode 100644 README.md create mode 100644 app/.gitignore create mode 100644 app/build.gradle create mode 100644 app/proguard-rules.pro create mode 100644 app/src/androidTest/java/com/back4app/back4appandroid9/ExampleInstrumentedTest.java create mode 100644 app/src/main/AndroidManifest.xml create mode 100644 app/src/main/java/com/back4app/back4appandroid9/App.java create mode 100644 app/src/main/java/com/back4app/back4appandroid9/MainActivity.java create mode 100644 app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 app/src/main/res/layout/activity_main.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/values/colors.xml create mode 100644 app/src/main/res/values/strings.xml create mode 100644 app/src/main/res/values/styles.xml create mode 100644 app/src/test/java/com/back4app/back4appandroid9/ExampleUnitTest.java create mode 100644 build.gradle create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b75303 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..30aa626 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..2996d53 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..37a7509 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..74cba16 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# [Back4App] - Android (API 28) + +Don't forget to paste your Back4App App ID, Client Key and GCMSenderId in the `strings.xml` file and `App.class`. + +## (Optional) + +Go to Back4App Dashboard and import the ./Cars.json file following the guide below: + +[Back4App - Import class](https://help.back4app.com/hc/en-us/articles/115003438951-How-can-I-import-to-my-Database-) diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..d7ceef3 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,36 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "com.back4app.back4appandroid9" + minSdkVersion 28 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'androidx.appcompat:appcompat:1.0.0-beta01' + implementation 'androidx.constraintlayout:constraintlayout:1.1.2' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.1.0-alpha4' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4' + + implementation "com.github.parse-community.Parse-SDK-Android:parse:1.19.0" +} + +repositories { + mavenCentral() + jcenter() + maven { url 'https://jitpack.io' } +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/back4app/back4appandroid9/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/back4app/back4appandroid9/ExampleInstrumentedTest.java new file mode 100644 index 0000000..6d474f4 --- /dev/null +++ b/app/src/androidTest/java/com/back4app/back4appandroid9/ExampleInstrumentedTest.java @@ -0,0 +1,27 @@ +package com.back4app.back4appandroid9; + +import android.content.Context; + +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.back4app.back4appandroid9", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..156ad4a --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/back4app/back4appandroid9/App.java b/app/src/main/java/com/back4app/back4appandroid9/App.java new file mode 100644 index 0000000..4261c32 --- /dev/null +++ b/app/src/main/java/com/back4app/back4appandroid9/App.java @@ -0,0 +1,20 @@ +package com.back4app.back4appandroid9; + +import android.app.Application; + +import com.parse.Parse; + +public class App extends Application { + @Override + public void onCreate() { + super.onCreate(); + + Parse.initialize(new Parse.Configuration.Builder(this) + .applicationId(getString(R.string.back4app_app_id)) + // if desired + .clientKey(getString(R.string.back4app_client_key)) + .server(getString(R.string.back4app_server_url)) + .build() + ); + } +} diff --git a/app/src/main/java/com/back4app/back4appandroid9/MainActivity.java b/app/src/main/java/com/back4app/back4appandroid9/MainActivity.java new file mode 100644 index 0000000..19aa5ab --- /dev/null +++ b/app/src/main/java/com/back4app/back4appandroid9/MainActivity.java @@ -0,0 +1,67 @@ +package com.back4app.back4appandroid9; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.ListView; +import android.widget.Toast; + +import com.parse.FindCallback; +import com.parse.GetCallback; +import com.parse.ParseException; +import com.parse.ParseObject; +import com.parse.ParseQuery; + +import java.util.ArrayList; +import java.util.List; + +public class MainActivity extends AppCompatActivity { + public ArrayList dataList = new ArrayList(); + public String[] myArray = {}; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + final Button retrieve_data = findViewById(R.id.btnRetrieveData); + + retrieve_data.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + myArray = new String[]{}; + final ListView listView = (ListView) findViewById(R.id.listviewA); + + ParseQuery query = ParseQuery.getQuery("Cars"); + query.findInBackground(new FindCallback() { + public void done(List results, ParseException e) { + if (e == null) { + for(int i = 0; i < results.size(); i++) { + String carName = results.get(i).getString("name"); + dataList.add(carName.toString()); + } + } else { + // results have all the Posts the current user liked. + final Toast toast = Toast.makeText( + MainActivity.this, + String.valueOf("Error =>" + e.getMessage()), + Toast.LENGTH_LONG + ); + toast.show(); + } + } + }); + + myArray = dataList.toArray(new String[dataList.size()]); + ArrayAdapter adapterList + = new ArrayAdapter(MainActivity.this, android.R.layout.simple_list_item_single_choice, myArray); + + listView.setAdapter(adapterList); + } + }); + + } +} diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..1f6bb29 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..0d025f9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..88502c2 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,47 @@ + + + + + +