diff --git a/android/Lodjinha/.gitignore b/android/Lodjinha/.gitignore new file mode 100644 index 0000000..2b75303 --- /dev/null +++ b/android/Lodjinha/.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/android/Lodjinha/.idea/codeStyles/Project.xml b/android/Lodjinha/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..34dc27c --- /dev/null +++ b/android/Lodjinha/.idea/codeStyles/Project.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/.idea/codeStyles/codeStyleConfig.xml b/android/Lodjinha/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/android/Lodjinha/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/android/Lodjinha/.idea/gradle.xml b/android/Lodjinha/.idea/gradle.xml new file mode 100644 index 0000000..7ac24c7 --- /dev/null +++ b/android/Lodjinha/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/.idea/misc.xml b/android/Lodjinha/.idea/misc.xml new file mode 100644 index 0000000..37a7509 --- /dev/null +++ b/android/Lodjinha/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/.idea/runConfigurations.xml b/android/Lodjinha/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/android/Lodjinha/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/.idea/vcs.xml b/android/Lodjinha/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/android/Lodjinha/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/.gitignore b/android/Lodjinha/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/android/Lodjinha/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/Lodjinha/app/build.gradle b/android/Lodjinha/app/build.gradle new file mode 100644 index 0000000..2e1c5cd --- /dev/null +++ b/android/Lodjinha/app/build.gradle @@ -0,0 +1,61 @@ +apply plugin: 'com.android.application' + +apply plugin: 'kotlin-android' + +apply plugin: 'kotlin-android-extensions' + +apply plugin: 'kotlin-kapt' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "com.example.lodjinha" + minSdkVersion 15 + 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 "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.1.0-alpha03' + implementation 'androidx.core:core-ktx:1.1.0-alpha05' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + + //material components + implementation 'com.google.android.material:material:1.0.0' + //navigation + implementation "android.arch.navigation:navigation-fragment-ktx:1.0.0-rc02" // use -ktx for Kotlin + implementation "android.arch.navigation:navigation-ui-ktx:1.0.0-rc02" // use -ktx for Kotlin + //Viewmodel and Livedata + implementation "androidx.lifecycle:lifecycle-extensions:2.0.0" + //Room Database + implementation "androidx.room:room-runtime:2.1.0-alpha04" + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0-alpha02' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0' + kapt "androidx.room:room-compiler:2.1.0-alpha04" + //Koin + implementation 'org.koin:koin-android-viewmodel:1.0.2' + //Retrofit and Gson + implementation 'com.squareup.retrofit2:converter-gson:2.5.0' + implementation 'com.squareup.retrofit2:retrofit:2.5.0' + + implementation 'de.hdodenhof:circleimageview:2.0.0' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.1.2-alpha02' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha02' + implementation 'androidx.recyclerview:recyclerview:1.0.0' + androidTestImplementation 'androidx.test:rules:1.1.2-alpha02' +} diff --git a/android/Lodjinha/app/proguard-rules.pro b/android/Lodjinha/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/android/Lodjinha/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/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ExampleInstrumentedTest.kt b/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..7d71c24 --- /dev/null +++ b/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.lodjinha + +import androidx.test.InstrumentationRegistry +import androidx.test.runner.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getTargetContext() + assertEquals("com.example.lodjinha", appContext.packageName) + } +} diff --git a/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_AbrindoItemMaisVendidos.kt b/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_AbrindoItemMaisVendidos.kt new file mode 100644 index 0000000..d6efa6e --- /dev/null +++ b/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_AbrindoItemMaisVendidos.kt @@ -0,0 +1,90 @@ +package com.example.lodjinha.ui + + +import android.view.View +import android.view.ViewGroup +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.* +import androidx.test.filters.LargeTest +import androidx.test.rule.ActivityTestRule +import androidx.test.runner.AndroidJUnit4 +import com.example.lodjinha.R +import org.hamcrest.Description +import org.hamcrest.Matcher +import org.hamcrest.Matchers.`is` +import org.hamcrest.Matchers.allOf +import org.hamcrest.TypeSafeMatcher +import org.hamcrest.core.IsInstanceOf +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@LargeTest +@RunWith(AndroidJUnit4::class) +class Ui_Test_AbrindoItemMaisVendidos { + + @Rule + @JvmField + var mActivityTestRule = ActivityTestRule(MainActivity::class.java) + + @Test + fun ui_Test_AbrindoItemMaisVendidos() { + Thread.sleep(7000) + val cardView = onView( + allOf( + childAtPosition( + allOf( + withId(R.id.recycler_view), + childAtPosition( + withClassName(`is`("android.widget.LinearLayout")), + 5 + ) + ), + 0 + ), + isDisplayed() + ) + ) + cardView.perform(click()) + + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + Thread.sleep(700) + + val textView = onView( + allOf( + withId(R.id.tv_detail_product_name), withText("Fifa 17 com uma descrição grandona"), + childAtPosition( + childAtPosition( + IsInstanceOf.instanceOf(android.widget.RelativeLayout::class.java), + 0 + ), + 0 + ), + isDisplayed() + ) + ) + textView.check(matches(withText("Fifa 17 com uma descrição grandona"))) + } + + private fun childAtPosition( + parentMatcher: Matcher, position: Int + ): Matcher { + + return object : TypeSafeMatcher() { + override fun describeTo(description: Description) { + description.appendText("Child at position $position in parent ") + parentMatcher.describeTo(description) + } + + public override fun matchesSafely(view: View): Boolean { + val parent = view.parent + return parent is ViewGroup && parentMatcher.matches(parent) + && view == parent.getChildAt(position) + } + } + } +} diff --git a/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_AbrindoTelaSobre.kt b/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_AbrindoTelaSobre.kt new file mode 100644 index 0000000..5dc832c --- /dev/null +++ b/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_AbrindoTelaSobre.kt @@ -0,0 +1,106 @@ +package com.example.lodjinha.ui + + +import android.view.View +import android.view.ViewGroup +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.* +import androidx.test.filters.LargeTest +import androidx.test.rule.ActivityTestRule +import androidx.test.runner.AndroidJUnit4 +import com.example.lodjinha.R +import org.hamcrest.Description +import org.hamcrest.Matcher +import org.hamcrest.Matchers.`is` +import org.hamcrest.Matchers.allOf +import org.hamcrest.TypeSafeMatcher +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@LargeTest +@RunWith(AndroidJUnit4::class) +class Ui_Test_AbrindoTelaSobre { + + @Rule + @JvmField + var mActivityTestRule = ActivityTestRule(MainActivity::class.java) + + @Test + fun ui_Test_AbrindoTelaSobre() { + val appCompatImageButton = onView( + allOf( + withContentDescription("Open navigation drawer"), + childAtPosition( + allOf( + withId(R.id.wld_toolbar), + childAtPosition( + withClassName(`is`("android.widget.LinearLayout")), + 0 + ) + ), + 2 + ), + isDisplayed() + ) + ) + appCompatImageButton.perform(click()) + + val navigationMenuItemView = onView( + allOf( + childAtPosition( + allOf( + withId(R.id.design_navigation_view), + childAtPosition( + withId(R.id.nav_view), + 0 + ) + ), + 1 + ), + isDisplayed() + ) + ) + navigationMenuItemView.perform(click()) + + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + Thread.sleep(700) + + val textView = onView( + allOf( + withId(R.id.tv_aboutview_devname), withText("Lucas de Lima Martins"), + childAtPosition( + childAtPosition( + withId(android.R.id.content), + 0 + ), + 3 + ), + isDisplayed() + ) + ) + textView.check(matches(withText("Lucas de Lima Martins"))) + } + + private fun childAtPosition( + parentMatcher: Matcher, position: Int + ): Matcher { + + return object : TypeSafeMatcher() { + override fun describeTo(description: Description) { + description.appendText("Child at position $position in parent ") + parentMatcher.describeTo(description) + } + + public override fun matchesSafely(view: View): Boolean { + val parent = view.parent + return parent is ViewGroup && parentMatcher.matches(parent) + && view == parent.getChildAt(position) + } + } + } +} diff --git a/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_AbrindoTelaSobreEvoltandoParaHome.kt b/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_AbrindoTelaSobreEvoltandoParaHome.kt new file mode 100644 index 0000000..5618c6b --- /dev/null +++ b/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_AbrindoTelaSobreEvoltandoParaHome.kt @@ -0,0 +1,144 @@ +package com.example.lodjinha.ui + + +import android.view.View +import android.view.ViewGroup +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.* +import androidx.test.filters.LargeTest +import androidx.test.rule.ActivityTestRule +import androidx.test.runner.AndroidJUnit4 +import com.example.lodjinha.R +import org.hamcrest.Description +import org.hamcrest.Matcher +import org.hamcrest.Matchers.`is` +import org.hamcrest.Matchers.allOf +import org.hamcrest.TypeSafeMatcher +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@LargeTest +@RunWith(AndroidJUnit4::class) +class Ui_Test_AbrindoTelaSobreEvoltandoParaHome { + + @Rule + @JvmField + var mActivityTestRule = ActivityTestRule(MainActivity::class.java) + + @Test + fun ui_Test_AbrindoTelaSobreEvoltandoParaHome() { + val appCompatImageButton = onView( + allOf( + withContentDescription("Open navigation drawer"), + childAtPosition( + allOf( + withId(R.id.wld_toolbar), + childAtPosition( + withClassName(`is`("android.widget.LinearLayout")), + 0 + ) + ), + 2 + ), + isDisplayed() + ) + ) + appCompatImageButton.perform(click()) + + val navigationMenuItemView = onView( + allOf( + childAtPosition( + allOf( + withId(R.id.design_navigation_view), + childAtPosition( + withId(R.id.nav_view), + 0 + ) + ), + 1 + ), + isDisplayed() + ) + ) + navigationMenuItemView.perform(click()) + + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + Thread.sleep(700) + + val textView = onView( + allOf( + withId(R.id.tv_aboutview_devname), withText("Lucas de Lima Martins"), + childAtPosition( + childAtPosition( + withId(android.R.id.content), + 0 + ), + 3 + ), + isDisplayed() + ) + ) + textView.check(matches(withText("Lucas de Lima Martins"))) + + val appCompatImageButton2 = onView( + allOf( + withContentDescription("Navegar para cima"), + childAtPosition( + allOf( + withId(R.id.about_toolbar), + childAtPosition( + withClassName(`is`("android.widget.LinearLayout")), + 0 + ) + ), + 1 + ), + isDisplayed() + ) + ) + appCompatImageButton2.perform(click()) + + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + Thread.sleep(700) + + val textView2 = onView( + allOf( + withId(R.id.tv_category), withText("Categorias"), + childAtPosition( + childAtPosition( + withId(R.id.drawer_layout), + 0 + ), + 2 + ), + isDisplayed() + ) + ) + textView2.check(matches(withText("Categorias"))) + } + + private fun childAtPosition( + parentMatcher: Matcher, position: Int + ): Matcher { + + return object : TypeSafeMatcher() { + override fun describeTo(description: Description) { + description.appendText("Child at position $position in parent ") + parentMatcher.describeTo(description) + } + + public override fun matchesSafely(view: View): Boolean { + val parent = view.parent + return parent is ViewGroup && parentMatcher.matches(parent) + && view == parent.getChildAt(position) + } + } + } +} diff --git a/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_AbrindoUmaCategoria.kt b/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_AbrindoUmaCategoria.kt new file mode 100644 index 0000000..f784b16 --- /dev/null +++ b/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_AbrindoUmaCategoria.kt @@ -0,0 +1,89 @@ +package com.example.lodjinha.ui + + +import android.view.View +import android.view.ViewGroup +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.* +import androidx.test.filters.LargeTest +import androidx.test.rule.ActivityTestRule +import androidx.test.runner.AndroidJUnit4 +import com.example.lodjinha.R +import org.hamcrest.Description +import org.hamcrest.Matcher +import org.hamcrest.Matchers.`is` +import org.hamcrest.Matchers.allOf +import org.hamcrest.TypeSafeMatcher +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@LargeTest +@RunWith(AndroidJUnit4::class) +class Ui_Test_AbrindoUmaCategoria { + + @Rule + @JvmField + var mActivityTestRule = ActivityTestRule(MainActivity::class.java) + + @Test + fun ui_Test_AbrindoUmaCategoria() { + Thread.sleep(7000) + val cardView = onView( + allOf( + childAtPosition( + allOf( + withId(R.id.recycler_view_cat), + childAtPosition( + withClassName(`is`("android.widget.LinearLayout")), + 3 + ) + ), + 2 + ), + isDisplayed() + ) + ) + cardView.perform(click()) + + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + Thread.sleep(700) + + val imageView = onView( + allOf( + withId(R.id.iv_product_image), + childAtPosition( + childAtPosition( + withId(R.id.recycler_view_products), + 0 + ), + 1 + ), + isDisplayed() + ) + ) + imageView.check(matches(isDisplayed())) + } + + private fun childAtPosition( + parentMatcher: Matcher, position: Int + ): Matcher { + + return object : TypeSafeMatcher() { + override fun describeTo(description: Description) { + description.appendText("Child at position $position in parent ") + parentMatcher.describeTo(description) + } + + public override fun matchesSafely(view: View): Boolean { + val parent = view.parent + return parent is ViewGroup && parentMatcher.matches(parent) + && view == parent.getChildAt(position) + } + } + } +} diff --git a/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_NavegandoEvoltandoParaHome.kt b/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_NavegandoEvoltandoParaHome.kt new file mode 100644 index 0000000..74c382c --- /dev/null +++ b/android/Lodjinha/app/src/androidTest/java/com/example/lodjinha/ui/Ui_Test_NavegandoEvoltandoParaHome.kt @@ -0,0 +1,157 @@ +package com.example.lodjinha.ui + + +import android.view.View +import android.view.ViewGroup +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers.* +import androidx.test.filters.LargeTest +import androidx.test.rule.ActivityTestRule +import androidx.test.runner.AndroidJUnit4 +import com.example.lodjinha.R +import org.hamcrest.Description +import org.hamcrest.Matcher +import org.hamcrest.Matchers.`is` +import org.hamcrest.Matchers.allOf +import org.hamcrest.TypeSafeMatcher +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@LargeTest +@RunWith(AndroidJUnit4::class) +class Ui_Test_NavegandoEvoltandoParaHome { + + @Rule + @JvmField + var mActivityTestRule = ActivityTestRule(MainActivity::class.java) + + @Test + fun ui_Test_NavegandoEvoltandoParaHome() { + Thread.sleep(7000) + val cardView = onView( + allOf( + childAtPosition( + allOf( + withId(R.id.recycler_view_cat), + childAtPosition( + withClassName(`is`("android.widget.LinearLayout")), + 3 + ) + ), + 2 + ), + isDisplayed() + ) + ) + cardView.perform(click()) + + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + Thread.sleep(700) + + val appCompatImageButton = onView( + allOf( + withContentDescription("Navegar para cima"), + childAtPosition( + allOf( + withId(R.id.allproducts_toolbar), + childAtPosition( + withClassName(`is`("android.widget.LinearLayout")), + 0 + ) + ), + 1 + ), + isDisplayed() + ) + ) + appCompatImageButton.perform(click()) + + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + Thread.sleep(700) + + val cardView2 = onView( + allOf( + childAtPosition( + allOf( + withId(R.id.recycler_view_cat), + childAtPosition( + withClassName(`is`("android.widget.LinearLayout")), + 3 + ) + ), + 2 + ), + isDisplayed() + ) + ) + cardView2.perform(click()) + + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + Thread.sleep(700) + + val appCompatImageButton2 = onView( + allOf( + withContentDescription("Navegar para cima"), + childAtPosition( + allOf( + withId(R.id.allproducts_toolbar), + childAtPosition( + withClassName(`is`("android.widget.LinearLayout")), + 0 + ) + ), + 1 + ), + isDisplayed() + ) + ) + appCompatImageButton2.perform(click()) + + // Added a sleep statement to match the app's execution delay. + // The recommended way to handle such scenarios is to use Espresso idling resources: + // https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html + Thread.sleep(700) + + val textView = onView( + allOf( + withId(R.id.tv_category), withText("Categorias"), + childAtPosition( + childAtPosition( + withId(R.id.drawer_layout), + 0 + ), + 2 + ), + isDisplayed() + ) + ) + textView.check(matches(withText("Categorias"))) + } + + private fun childAtPosition( + parentMatcher: Matcher, position: Int + ): Matcher { + + return object : TypeSafeMatcher() { + override fun describeTo(description: Description) { + description.appendText("Child at position $position in parent ") + parentMatcher.describeTo(description) + } + + public override fun matchesSafely(view: View): Boolean { + val parent = view.parent + return parent is ViewGroup && parentMatcher.matches(parent) + && view == parent.getChildAt(position) + } + } + } +} diff --git a/android/Lodjinha/app/src/main/AndroidManifest.xml b/android/Lodjinha/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..71b1273 --- /dev/null +++ b/android/Lodjinha/app/src/main/AndroidManifest.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/assets/Roboto-Bold.ttf b/android/Lodjinha/app/src/main/assets/Roboto-Bold.ttf new file mode 100644 index 0000000..d3f01ad Binary files /dev/null and b/android/Lodjinha/app/src/main/assets/Roboto-Bold.ttf differ diff --git a/android/Lodjinha/app/src/main/assets/Roboto-Light.ttf b/android/Lodjinha/app/src/main/assets/Roboto-Light.ttf new file mode 100644 index 0000000..219063a Binary files /dev/null and b/android/Lodjinha/app/src/main/assets/Roboto-Light.ttf differ diff --git a/android/Lodjinha/app/src/main/assets/Roboto-Medium.ttf b/android/Lodjinha/app/src/main/assets/Roboto-Medium.ttf new file mode 100644 index 0000000..1a7f3b0 Binary files /dev/null and b/android/Lodjinha/app/src/main/assets/Roboto-Medium.ttf differ diff --git a/android/Lodjinha/app/src/main/assets/pacifico.ttf b/android/Lodjinha/app/src/main/assets/pacifico.ttf new file mode 100644 index 0000000..a2994c9 Binary files /dev/null and b/android/Lodjinha/app/src/main/assets/pacifico.ttf differ diff --git a/android/Lodjinha/app/src/main/assets/roboto.ttf b/android/Lodjinha/app/src/main/assets/roboto.ttf new file mode 100644 index 0000000..2c97eea Binary files /dev/null and b/android/Lodjinha/app/src/main/assets/roboto.ttf differ diff --git a/android/Lodjinha/app/src/main/ic_launcher-web.png b/android/Lodjinha/app/src/main/ic_launcher-web.png new file mode 100644 index 0000000..2f4ba18 Binary files /dev/null and b/android/Lodjinha/app/src/main/ic_launcher-web.png differ diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/MyApplication.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/MyApplication.kt new file mode 100644 index 0000000..35291f0 --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/MyApplication.kt @@ -0,0 +1,14 @@ +package com.example.lodjinha + +import android.app.Application +import com.example.alodjinha.dependencies_injection.DiModules +import org.koin.android.ext.android.startKoin + +class MyApplication: Application() { + + override fun onCreate() { + super.onCreate() + + startKoin(this, listOf(DiModules.appModule)) + } +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/api/LodjinhaInstance.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/api/LodjinhaInstance.kt new file mode 100644 index 0000000..b9891c7 --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/api/LodjinhaInstance.kt @@ -0,0 +1,20 @@ +package com.example.alodjinha.api + +import com.example.alodjinha.api.interfaces.GetLodjinhaDataService +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory + +class LodjinhaInstance { + private var retrofit: Retrofit? = null + fun getOmdbInstance(): Retrofit { + if (retrofit == null) { + retrofit = retrofit2.Retrofit.Builder() + .baseUrl("https://alodjinha.herokuapp.com/") + .addConverterFactory(GsonConverterFactory.create()) + .build() + } + return retrofit!! + } + + fun lodjinhaService() = getOmdbInstance().create(GetLodjinhaDataService::class.java) +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/api/interfaces/GetLodjinhaDataService.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/api/interfaces/GetLodjinhaDataService.kt new file mode 100644 index 0000000..943f466 --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/api/interfaces/GetLodjinhaDataService.kt @@ -0,0 +1,25 @@ +package com.example.alodjinha.api.interfaces + +import com.example.alodjinha.data.classes.BannerList +import com.example.alodjinha.data.classes.ProductList +import com.example.lodjinha.data.classes.CategoryList +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Query + +interface GetLodjinhaDataService { + + @GET("produto/maisvendidos") + fun listProduct(): Call + + @GET("banner") + fun listBanner(): Call + + @GET("categoria") + fun listCategory(): Call + + @GET("produto/") + fun listProductsAll(@Query("offset") offset: Int, + @Query("limit") limit: Int , + @Query("categoriaId") categoriaId: Int ): Call +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/Database.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/Database.kt new file mode 100644 index 0000000..f115e2f --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/Database.kt @@ -0,0 +1,82 @@ +package com.example.alodjinha.data + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.example.alodjinha.api.LodjinhaInstance +import com.example.alodjinha.data.classes.* +import com.example.lodjinha.data.classes.CategoryList +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response + +class Database { + val call = LodjinhaInstance().lodjinhaService() + + private val dataProductList: MutableLiveData> = MutableLiveData() + private val dataProductsAllList: MutableLiveData> = MutableLiveData() + private val dataCategoryList: MutableLiveData> = MutableLiveData() + private val dataBannerList: MutableLiveData> = MutableLiveData() + fun insertProducts(): MutableLiveData> { + call.listProduct().clone().enqueue(object : Callback { + + override fun onResponse(call: Call, response: Response) { + Log.d("OnResponse","RESPONSEPRODUCT") + dataProductList.postValue(response.body()?.getData()) + } + + override fun onFailure(call: Call, t: Throwable) { + Log.d("OnFail","error" + t.message) + } + }) + + return dataProductList + } + + fun insertBanners(): MutableLiveData> { + call.listBanner().clone().enqueue(object : Callback { + + override fun onResponse(call: Call, response: Response) { + Log.d("OnResponse","RESPONSEBANNER") + dataBannerList.postValue(response.body()?.getData()) + } + + override fun onFailure(call: Call, t: Throwable) { + Log.d("OnFail","error" + t.message) + } + }) + + return dataBannerList + } + + fun insertCategory(): MutableLiveData> { + call.listCategory().clone().enqueue(object : Callback { + + override fun onResponse(call: Call, response: Response) { + Log.d("OnResponse","RESPONSECATEGORY") + dataCategoryList.postValue(response.body()?.getData()) + } + + override fun onFailure(call: Call, t: Throwable) { + Log.d("OnFail","error" + t.message) + } + }) + + return dataCategoryList + } + + fun insertAllProducts(offset: Int, limit: Int, categoriaId: Int): MutableLiveData> { + call.listProductsAll(offset, limit, categoriaId).clone().enqueue(object : Callback { + + override fun onResponse(call: Call, response: Response) { + Log.d("OnResponse","RESPONSE") + dataProductsAllList.postValue(response.body()?.getData()) + } + + override fun onFailure(call: Call, t: Throwable) { + Log.d("OnFail","error" + t.message) + } + }) + + return dataProductsAllList + } +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/Banner.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/Banner.kt new file mode 100644 index 0000000..6b4a577 --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/Banner.kt @@ -0,0 +1,33 @@ +package com.example.alodjinha.data.classes + +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +class Banner { + @SerializedName("id") + @Expose + private var id: Int? = null + + @SerializedName("urlImagem") + @Expose + private var urlImage: String? = null + + @SerializedName("linkUrl") + @Expose + private var linkUrl: String? = null + + + fun setId(Id: Int){ id = Id } + + fun getId() = id + + fun setUrlImage(UrlImage: String){ urlImage = UrlImage} + + fun getUrlImage() = urlImage + + fun setLinkUrl(LinkUrl: String){ linkUrl = LinkUrl } + + fun getLinkUrl() = linkUrl + + +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/BannerList.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/BannerList.kt new file mode 100644 index 0000000..ed3f97a --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/BannerList.kt @@ -0,0 +1,17 @@ +package com.example.alodjinha.data.classes + +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +class BannerList { + + @SerializedName("data") + @Expose + private var data: List? = null + + fun setData(Data: List){ + data = Data + } + + fun getData() = data +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/Category.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/Category.kt new file mode 100644 index 0000000..7460c20 --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/Category.kt @@ -0,0 +1,32 @@ +package com.example.alodjinha.data.classes + +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + + class Category { + + @SerializedName("id") + @Expose + private var id: Int? = null + + @SerializedName("descricao") + @Expose + private var description: String? = null + + + @SerializedName("urlImagem") + @Expose + private var urlImage: String? = null + + fun setId(Id: Int){ id = Id } + + fun getId() = id + + fun setUrlImage(UrlImage: String){ urlImage = UrlImage} + + fun getUrlImage() = urlImage + + fun setDescription(Description: String){ description = Description } + + fun getDescription() = description +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/CategoryList.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/CategoryList.kt new file mode 100644 index 0000000..2932733 --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/CategoryList.kt @@ -0,0 +1,19 @@ +package com.example.lodjinha.data.classes + +import com.example.alodjinha.data.classes.Banner +import com.example.alodjinha.data.classes.Category +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +class CategoryList { + + @SerializedName("data") + @Expose + private var data: List? = null + + fun setData(Data: List){ + data = Data + } + + fun getData() = data +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/Product.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/Product.kt new file mode 100644 index 0000000..05367c7 --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/Product.kt @@ -0,0 +1,79 @@ +package com.example.alodjinha.data.classes + +import com.example.alodjinha.data.classes.Category +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +class Product { + + @SerializedName("id") + @Expose + private var id: Int? = null + + @SerializedName("nome") + @Expose + private var name: String? = null + + @SerializedName("urlImagem") + @Expose + private var urlImage: String? = null + + @SerializedName("descricao") + @Expose + private var description: String? = null + + @SerializedName("precoDe") + @Expose + private var price: Double? = null + + @SerializedName("precoPor") + @Expose + private var priceFor: Double? = null + + @SerializedName("categoria") + @Expose + private var category: Category? = null + + + fun setId(Id: Int){ id = Id } + + fun getId() = id + + fun setName(Name: String){ name = Name } + + fun getName() = name + + fun setUrlImage(UrlImage: String){ urlImage = UrlImage} + + fun getUrlImage() = urlImage + + fun setDescription(Description: String){ description = Description } + + fun getDescription() = description + + fun setPrice(Price: Double){ price = Price } + + fun getPrice() = price + + fun setPriceFor(PriceFor: Double){ priceFor = PriceFor } + + fun getPriceFor() = priceFor + + fun setCategoryId(CatId: Int){ + category?.setId(CatId) + } + fun getCategoryId() = category?.getId() + + fun setCategoryDescription(CatDesc: String){ + category?.setDescription(CatDesc) + } + fun getCategoryDescription() = category?.getDescription() + + fun setCategoryUrlImage(CatUrl: String){ + category?.setUrlImage(CatUrl) + } + fun getCategoryUrlImage() = category?.getUrlImage() + + + +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/ProductList.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/ProductList.kt new file mode 100644 index 0000000..e156b39 --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/classes/ProductList.kt @@ -0,0 +1,18 @@ +package com.example.alodjinha.data.classes + +import com.example.alodjinha.data.classes.Product +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +class ProductList { + + @SerializedName("data") + @Expose + private var data: List? = null + + fun setData(Data: List){ + data = Data + } + + fun getData() = data +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/managers/LodjinhaManager.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/managers/LodjinhaManager.kt new file mode 100644 index 0000000..decd1eb --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/data/managers/LodjinhaManager.kt @@ -0,0 +1,15 @@ +package com.example.alodjinha.data.managers + +import com.example.alodjinha.data.Database + +class LodjinhaManager(val database: Database) { + + fun getProducts() = database.insertProducts() + + fun getBanners() = database.insertBanners() + + fun getCategory() = database.insertCategory() + + fun getAllProducts(offset: Int, limit: Int, categoriaId: Int) = + database.insertAllProducts(offset,limit,categoriaId) +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/dependencies_injection/DiModules.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/dependencies_injection/DiModules.kt new file mode 100644 index 0000000..c60b565 --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/dependencies_injection/DiModules.kt @@ -0,0 +1,18 @@ +package com.example.alodjinha.dependencies_injection + +import com.example.alodjinha.data.Database +import com.example.alodjinha.data.managers.LodjinhaManager +import com.example.alodjinha.viewmodels.LodjinhaViewModel +import org.koin.android.viewmodel.ext.koin.viewModel +import org.koin.dsl.module.module + +object DiModules { + val appModule = module { + + single { Database() } + + factory { LodjinhaManager(get()) } + + viewModel { LodjinhaViewModel(get()) } + } +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/AboutActivity.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/AboutActivity.kt new file mode 100644 index 0000000..8f01581 --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/AboutActivity.kt @@ -0,0 +1,37 @@ +package com.example.lodjinha.ui + +import android.graphics.Typeface +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.view.MenuItem +import com.example.lodjinha.R +import kotlinx.android.synthetic.main.activity_about.* +import kotlinx.android.synthetic.main.app_bar_about.* +import kotlinx.android.synthetic.main.app_bar_main.* + +class AboutActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_about) + setSupportActionBar(about_toolbar) + + supportActionBar?.setDisplayHomeAsUpEnabled(true) + supportActionBar?.setHomeButtonEnabled(true) + supportActionBar?.setTitle("") + + val fontRobotoMedium = Typeface.createFromAsset(this.assets, "Roboto-Medium.ttf") + val fontRobotoLight = Typeface.createFromAsset(this.assets, "Roboto-Light.ttf") + val fontPacifico = Typeface.createFromAsset(this.assets, "pacifico.ttf") + tv_aboutview.setTypeface(fontPacifico) + tv_aboutview_devname.setTypeface(fontRobotoMedium) + tv_aboutview_date.setTypeface(fontRobotoLight) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId){ + android.R.id.home -> onBackPressed() + } + return super.onOptionsItemSelected(item) + } +} diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/DetailActivity.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/DetailActivity.kt new file mode 100644 index 0000000..385ec7d --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/DetailActivity.kt @@ -0,0 +1,47 @@ +package com.example.lodjinha.ui + +import android.graphics.Paint +import android.graphics.Typeface +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.text.Html +import android.view.MenuItem +import com.example.alodjinha.ui.DownloadImageWithURLTask +import com.example.lodjinha.R +import kotlinx.android.synthetic.main.activity_detail.* +import kotlinx.android.synthetic.main.item_product.view.* + +class DetailActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_detail) + setSupportActionBar(toolbar_collapse) + val fontRobotoMedium = Typeface.createFromAsset(this.assets, "Roboto-Medium.ttf") + val fontRobotoBold = Typeface.createFromAsset(this.assets, "Roboto-Bold.ttf") + supportActionBar?.setDisplayHomeAsUpEnabled(true) + supportActionBar?.setHomeButtonEnabled(true) + supportActionBar?.setTitle("") + tv_detail_product_name.text = intent.getStringExtra("Name") +" com uma descrição grandona" + tv_detail_product_name.setTypeface(fontRobotoBold) + tv_detail_pricebefore.text = "De: " + intent.getStringExtra("priceBefore") + tv_detail_pricebefore.setTypeface(fontRobotoMedium) + tv_detail_pricefor.text ="Por " + intent.getStringExtra("priceFor") + tv_detail_pricebefore.setPaintFlags(tv_detail_pricebefore.getPaintFlags() or Paint.STRIKE_THRU_TEXT_FLAG) + tv_detail_title.setTypeface(fontRobotoBold) + tv_detail_pricefor.setTypeface(fontRobotoBold) + tv_detail_description.text = Html.fromHtml(intent.getStringExtra("Description")) + tv_detail_description.setTypeface(fontRobotoMedium) + val downloadImage = DownloadImageWithURLTask(iv_detail) + downloadImage.execute(intent.getStringExtra("imageUrl")) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId){ + android.R.id.home -> onBackPressed() + } + return super.onOptionsItemSelected(item) + } +} + + diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/DownloadAsBitmap.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/DownloadAsBitmap.kt new file mode 100644 index 0000000..42f2c49 --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/DownloadAsBitmap.kt @@ -0,0 +1,29 @@ +package com.example.alodjinha.ui + +import android.graphics.Bitmap +import android.graphics.BitmapFactory +import android.os.AsyncTask +import android.util.Log +import android.widget.ImageView + + +class DownloadImageWithURLTaskBitmap(var bmImage: ImageView) : AsyncTask() { + + override fun doInBackground(vararg urls: String): Bitmap? { + val pathToFile = urls[0] + var bitmap: Bitmap? = null + try { + val `in` = java.net.URL(pathToFile).openStream() + + bitmap = BitmapFactory.decodeStream(`in`) + } catch (e: Exception) { + Log.e("Error", e.message) + e.printStackTrace() + } + return bitmap + } + + override fun onPostExecute(result: Bitmap) { + bmImage.setImageBitmap(result) + } +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/DownloadImage.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/DownloadImage.kt new file mode 100644 index 0000000..87f1d6e --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/DownloadImage.kt @@ -0,0 +1,28 @@ +package com.example.alodjinha.ui + +import android.graphics.Bitmap +import android.graphics.BitmapFactory +import android.os.AsyncTask +import android.util.Log +import android.widget.ImageView + +class DownloadImageWithURLTask(var bmImage: ImageView) : AsyncTask() { + + override fun doInBackground(vararg urls: String): Bitmap? { + val pathToFile = urls[0] + var bitmap: Bitmap? = null + try { + val `in` = java.net.URL(pathToFile).openStream() + bitmap = BitmapFactory.decodeStream(`in`) + + } catch (e: Exception) { + Log.e("Error", e.message) + e.printStackTrace() + } + return bitmap + } + + override fun onPostExecute(result: Bitmap?) { + bmImage.setImageBitmap(result) + } +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/MainActivity.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/MainActivity.kt new file mode 100644 index 0000000..f410a8c --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/MainActivity.kt @@ -0,0 +1,239 @@ +package com.example.lodjinha.ui + +import android.content.Intent +import android.graphics.Paint +import android.graphics.Typeface +import android.os.Bundle +import android.util.Log +import com.google.android.material.snackbar.Snackbar +import com.google.android.material.navigation.NavigationView +import androidx.core.view.GravityCompat +import androidx.appcompat.app.ActionBarDrawerToggle +import androidx.appcompat.app.AppCompatActivity +import android.view.Menu +import android.view.MenuItem +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.LinearLayout +import android.widget.TextView +import androidx.core.content.ContextCompat +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import androidx.viewpager.widget.ViewPager +import com.example.alodjinha.ui.adapters.BannerAdapter +import com.example.alodjinha.ui.adapters.ProductsAdapter +import com.example.alodjinha.viewmodels.LodjinhaViewModel +import com.example.lodjinha.R +import com.example.lodjinha.ui.adapters.CategoryAdapter +import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.content_main.* +import kotlinx.android.synthetic.main.item_product.* +import kotlinx.android.synthetic.main.main_toolbar.* +import kotlinx.android.synthetic.main.nav_header_main.* +import org.koin.android.viewmodel.ext.android.viewModel +import java.util.* + +class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener { + + private var dotsLayout: LinearLayout? = null + private var customPosition: Int = 0 + private var timer: Timer? = null + private var current_position: Int = 0 + internal lateinit var viewPager: ViewPager + private val lodjinhaViewModel: LodjinhaViewModel by viewModel() + val productsAdapter: ProductsAdapter by lazy { + ProductsAdapter() + } + + val categoryAdapter : CategoryAdapter by lazy { + CategoryAdapter() + } + var count = 0 + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setContentView(R.layout.activity_main) + setSupportActionBar(wld_toolbar) + + + val toggle = ActionBarDrawerToggle( + this, drawer_layout, wld_toolbar, + R.string.navigation_drawer_open, + R.string.navigation_drawer_close + ) + drawer_layout.addDrawerListener(toggle) + toggle.syncState() + nav_view.setNavigationItemSelectedListener(this) + val fontPacifico = Typeface.createFromAsset(assets, "pacifico.ttf") + dotsLayout = findViewById(R.id.dots_container) + recycler_view.layoutManager = LinearLayoutManager(this) + recycler_view_cat.layoutManager = LinearLayoutManager(this + , LinearLayoutManager.HORIZONTAL, false) + + viewPager = findViewById(R.id.vp_banner) as ViewPager + + lodjinhaViewModel.loadCategory() + lodjinhaViewModel.getCategorys().observe(this, androidx.lifecycle.Observer {data -> + data?.let { + + recycler_view_cat.adapter = categoryAdapter + categoryAdapter.add(it) + } + tv_name_menu.setTypeface(fontPacifico) + }) + lodjinhaViewModel.loadProducts() + lodjinhaViewModel.getProducts().observe(this, androidx.lifecycle.Observer {data -> + data?.let { + recycler_view.adapter = productsAdapter + if (it.size < 20) { + productsAdapter.add(it) + } + else{ + recycler_view.addOnScrollListener(prOnScrollListener) + while (count < 20){ + productsAdapter.add(it[count]) + count++ + } + } + + } + + }) + + lodjinhaViewModel.loadBanners() + lodjinhaViewModel.getBanners().observe(this, androidx.lifecycle.Observer {data -> + data?.let { + val adapter = BannerAdapter(this, it) + viewPager.adapter = adapter + + } + prepareDots(customPosition++) + createSlideShow() + viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { + + override fun onPageScrollStateChanged(state: Int) { + } + + override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { + + } + override fun onPageSelected(position: Int) { + if(customPosition>2) + customPosition = 0 + prepareDots(customPosition++) + } + + }) + }) + + } + + override fun onBackPressed() { + if (drawer_layout.isDrawerOpen(GravityCompat.START)) { + drawer_layout.closeDrawer(GravityCompat.START) + } else { + super.onBackPressed() + } + } + + + + override fun onNavigationItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + R.id.nav_about -> { + val intentAbout = Intent(this,AboutActivity::class.java) + this.startActivity(intentAbout) + } + R.id.nav_exit -> { + finish() + } + } + + drawer_layout.closeDrawer(GravityCompat.START) + return true + } + + private val prOnScrollListener = object : RecyclerView.OnScrollListener() { + override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { + super.onScrollStateChanged(recyclerView, newState) + + } + + override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { + super.onScrolled(recyclerView, dx, dy) + + + if (isLastItemDisplaying(recyclerView)){ + Log.d("ItemDisplaying", "LOAD MORE ITEMS") + //TODO: load remaining products + } + + } + + } + + private fun isLastItemDisplaying(recyclerView: RecyclerView): Boolean{ + if (recyclerView.adapter?.itemCount != 0){ + var lastVisiblePosition: Int + lastVisiblePosition = 20 + + if (lastVisiblePosition != RecyclerView.NO_POSITION && lastVisiblePosition == recyclerView.adapter!!.itemCount) + return true + } + + + return false + } + + fun createSlideShow() { + val handler= android.os.Handler() + val runnable = Runnable { + if (current_position == 3) + current_position = 0 + viewPager.setCurrentItem(current_position++, true) + } + + timer = Timer() + timer!!.schedule(object : TimerTask() { + override fun run() { + handler.post(runnable) + } + + }, 250, 2500) + } + + fun prepareDots(currentSlidePotion: Int){ + if (dotsLayout!!.childCount > 0) + dotsLayout!!.removeAllViews() + var i = 0 + val dots: Array = arrayOfNulls(3) + while (i<3){ + dots[i] = ImageView(this) + if (i == currentSlidePotion) + dots[i]!!.setImageDrawable(ContextCompat.getDrawable(this,R.drawable.active_dot)) + else + dots[i]!!.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.inactive_dot)) + + var layoutParams: LinearLayout.LayoutParams + layoutParams = LinearLayout.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT) + + layoutParams.setMargins(4,0,4,0) + dotsLayout!!.addView(dots[i],layoutParams) + i++ + } + } + + override fun onResume() { + super.onResume() + val fontPacifico = Typeface.createFromAsset(assets, "pacifico.ttf") + val fontRobotoBold = Typeface.createFromAsset(assets, "Roboto-Bold.ttf") + tv_category!!.setTypeface(fontRobotoBold) + tv_sold!!.setTypeface(fontRobotoBold) + tv_logo_menu!!.setTypeface(fontPacifico) + } + + + +} diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/ProductsActivity.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/ProductsActivity.kt new file mode 100644 index 0000000..5a65755 --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/ProductsActivity.kt @@ -0,0 +1,53 @@ +package com.example.lodjinha.ui + +import android.os.Bundle +import android.app.Activity +import android.view.MenuItem +import androidx.appcompat.app.AppCompatActivity +import androidx.recyclerview.widget.LinearLayoutManager +import com.example.alodjinha.ui.adapters.ProductsAdapter +import com.example.alodjinha.viewmodels.LodjinhaViewModel +import com.example.lodjinha.R + +import kotlinx.android.synthetic.main.activity_products.* +import kotlinx.android.synthetic.main.app_bar_about.* +import kotlinx.android.synthetic.main.app_bar_allproducts.* +import kotlinx.android.synthetic.main.content_main.* +import kotlinx.android.synthetic.main.nav_header_main.* +import org.koin.android.viewmodel.ext.android.viewModel + +class ProductsActivity : AppCompatActivity() { + private val lodjinhaViewModel: LodjinhaViewModel by viewModel() + val productsAdapter: ProductsAdapter by lazy { + ProductsAdapter() + } + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_products) + setSupportActionBar(allproducts_toolbar) + + supportActionBar?.setDisplayHomeAsUpEnabled(true) + supportActionBar?.setHomeButtonEnabled(true) + supportActionBar?.setTitle("") + recycler_view_products.layoutManager = LinearLayoutManager(this) + if (intent.getStringExtra("id").toInt() == 1) + lodjinhaViewModel.loadAllProducts(20,40,intent.getStringExtra("id").toInt()) + else + lodjinhaViewModel.loadAllProducts(0,20,intent.getStringExtra("id").toInt()) + lodjinhaViewModel.getAllProducts().observe(this, androidx.lifecycle.Observer {data -> + data?.let { + recycler_view_products.adapter = productsAdapter + productsAdapter.add(it) + } + + }) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId){ + android.R.id.home -> onBackPressed() + } + return super.onOptionsItemSelected(item) + } + +} diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/adapters/BannerAdapter.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/adapters/BannerAdapter.kt new file mode 100644 index 0000000..ff2d2fb --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/adapters/BannerAdapter.kt @@ -0,0 +1,56 @@ +package com.example.alodjinha.ui.adapters + +import android.content.Context +import android.graphics.Bitmap +import android.graphics.drawable.BitmapDrawable +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.LinearLayout +import androidx.viewpager.widget.PagerAdapter +import androidx.viewpager.widget.ViewPager +import com.example.alodjinha.data.classes.Banner +import com.example.alodjinha.data.classes.Product +import com.example.alodjinha.ui.DownloadImageWithURLTask +import com.example.alodjinha.ui.DownloadImageWithURLTaskBitmap +import com.example.lodjinha.R +import kotlinx.android.synthetic.main.item_product.view.* + +class BannerAdapter(private val context: Context, private val urlList: List): PagerAdapter() { + override fun getCount(): Int { + return urlList.size + } + + + private var layoutInflater: LayoutInflater? = null + + override fun isViewFromObject(view: View, `object`: Any): Boolean { + return view === `object` + + } + + override fun instantiateItem(container: ViewGroup, position: Int): Any { + layoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater + val v = layoutInflater!!.inflate(R.layout.swipe_layout, null) + val image = v.findViewById(R.id.iv_banner ) as ImageView + val downloadImage = DownloadImageWithURLTaskBitmap(image) + downloadImage.execute(urlList[position].getUrlImage()) + val vp = container as ViewPager + vp.addView(v,0) + return v + } + + override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) { + val vp = container as ViewPager + val v = `object` as View + vp.removeView(v) + } + + +} + + + + + diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/adapters/CategoryAdapter.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/adapters/CategoryAdapter.kt new file mode 100644 index 0000000..b27faa7 --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/adapters/CategoryAdapter.kt @@ -0,0 +1,69 @@ +package com.example.lodjinha.ui.adapters + +import android.content.Intent +import android.graphics.Paint +import android.graphics.Typeface +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.appcompat.app.AppCompatActivity +import androidx.recyclerview.widget.RecyclerView +import com.example.alodjinha.data.classes.Category +import com.example.alodjinha.data.classes.Product +import com.example.alodjinha.ui.DownloadImageWithURLTask +import com.example.lodjinha.R +import com.example.lodjinha.ui.DetailActivity +import com.example.lodjinha.ui.ProductsActivity +import kotlinx.android.synthetic.main.item_category.view.* +import kotlinx.android.synthetic.main.item_product.view.* + +class CategoryViewHolder(val view: View): RecyclerView.ViewHolder(view){ + fun bindView(item: Category){ + with(view){ + val fontRoboto = Typeface.createFromAsset(this.context.assets, "roboto.ttf") + val fontRobotoMedium = Typeface.createFromAsset(this.context.assets, "Roboto-Medium.ttf") + val fontRobotoBold = Typeface.createFromAsset(this.context.assets, "Roboto-Bold.ttf") + val downloadImage = DownloadImageWithURLTask(iv_category) + downloadImage.execute(item.getUrlImage()) + + tv_cat.text = item.getDescription().toString() + tv_cat.typeface = fontRoboto + } + } + +} +class CategoryAdapter(val data: MutableList = mutableListOf()): RecyclerView.Adapter(){ + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CategoryViewHolder { + val view = LayoutInflater.from(parent.context).inflate(R.layout.item_category, parent, false) + return CategoryViewHolder(view) + } + + override fun getItemCount(): Int = data.size + + override fun onBindViewHolder(holder: CategoryViewHolder, position: Int) { + holder.bindView(data[position]) + holder.view.setOnClickListener() { + val intentProduct = Intent(it.context as AppCompatActivity, ProductsActivity::class.java) + intentProduct.putExtra("id", data[position].getId().toString()) + it.context.startActivity(intentProduct) + } + } + + fun add(item: List){ + data.clear() + data.addAll(item) + notifyDataSetChanged() + } + + fun add(item: Category){ + data.add(item) + notifyDataSetChanged() + } + + fun remove (item: Category){ + data.remove(item) + notifyDataSetChanged() + } + +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/adapters/ProductsAdapter.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/adapters/ProductsAdapter.kt new file mode 100644 index 0000000..b1f94bd --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/ui/adapters/ProductsAdapter.kt @@ -0,0 +1,79 @@ +package com.example.alodjinha.ui.adapters + +import android.content.Intent +import android.graphics.Paint +import android.graphics.Typeface +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.appcompat.app.AppCompatActivity +import androidx.recyclerview.widget.RecyclerView + +import com.example.alodjinha.data.classes.Product +import com.example.alodjinha.ui.DownloadImageWithURLTask + +import com.example.lodjinha.R +import com.example.lodjinha.ui.DetailActivity +import kotlinx.android.synthetic.main.item_product.view.* + + +class ProductsViewHolder(val view: View): RecyclerView.ViewHolder(view){ + fun bindView(item: Product){ + with(view){ + val fontRoboto = Typeface.createFromAsset(this.context.assets, "roboto.ttf") + val fontRobotoMedium = Typeface.createFromAsset(this.context.assets, "Roboto-Medium.ttf") + val fontRobotoBold = Typeface.createFromAsset(this.context.assets, "Roboto-Bold.ttf") + val downloadImage = DownloadImageWithURLTask(iv_product_image) + downloadImage.execute(item.getUrlImage()) + tv_name.text = item.getName().toString() + " com uma descrição grandona" + tv_name.setTypeface(fontRobotoMedium) + tv_priceBefore.text = "De: " + item.getPrice().toString() + tv_priceBefore.setTypeface(fontRobotoMedium) + tv_priceFor.text ="Por " + item.getPriceFor().toString() + tv_priceFor.setTypeface(fontRobotoBold) + tv_priceBefore.setPaintFlags(tv_priceBefore.getPaintFlags() or Paint.STRIKE_THRU_TEXT_FLAG) + + + } + } + +} +class ProductsAdapter(val data: MutableList = mutableListOf()): RecyclerView.Adapter(){ + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProductsViewHolder { + val view = LayoutInflater.from(parent.context).inflate(R.layout.item_product, parent, false) + return ProductsViewHolder(view) + } + + override fun getItemCount(): Int = data.size + + override fun onBindViewHolder(holder: ProductsViewHolder, position: Int) { + holder.bindView(data[position]) + holder.view.setOnClickListener() { + val intent = Intent(it.context as AppCompatActivity,DetailActivity::class.java) + intent.putExtra("Name", data[position].getName()) + intent.putExtra("priceBefore", data[position].getPrice().toString()) + intent.putExtra("priceFor", data[position].getPriceFor().toString()) + intent.putExtra("Description", data[position].getDescription()) + intent.putExtra("imageUrl", data[position].getUrlImage()) + it.context.startActivity(intent) + } + } + + fun add(item: List){ + data.clear() + data.addAll(item) + notifyDataSetChanged() + } + + fun add(item: Product){ + data.add(item) + notifyDataSetChanged() + } + + fun remove (item: Product){ + data.remove(item) + notifyDataSetChanged() + } + +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/java/com/example/lodjinha/viewmodels/LodjinhaViewModel.kt b/android/Lodjinha/app/src/main/java/com/example/lodjinha/viewmodels/LodjinhaViewModel.kt new file mode 100644 index 0000000..73e4585 --- /dev/null +++ b/android/Lodjinha/app/src/main/java/com/example/lodjinha/viewmodels/LodjinhaViewModel.kt @@ -0,0 +1,40 @@ +package com.example.alodjinha.viewmodels + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import com.example.alodjinha.data.classes.Banner +import com.example.alodjinha.data.classes.Category +import com.example.alodjinha.data.classes.Product +import com.example.alodjinha.data.managers.LodjinhaManager + +class LodjinhaViewModel(val lodjinhaManager: LodjinhaManager): ViewModel() { + + private var mProducts = MutableLiveData>() + private var mBanners = MutableLiveData>() + private var mCategorys = MutableLiveData>() + private var mAllProducts = MutableLiveData>() + fun getProducts(): LiveData> = mProducts + + fun loadProducts(){ + mProducts =lodjinhaManager.getProducts() + } + + fun getBanners(): LiveData> = mBanners + + fun loadBanners(){ + mBanners = lodjinhaManager.getBanners() + } + + fun loadCategory(){ + mCategorys = lodjinhaManager.getCategory() + } + + fun getCategorys(): LiveData> = mCategorys + + fun getAllProducts(): LiveData> = mAllProducts + + fun loadAllProducts(offset: Int, limit: Int, categoriaId: Int){ + mAllProducts =lodjinhaManager.getAllProducts(offset,limit,categoriaId) + } +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/drawable-v21/ic_menu_slideshow.xml b/android/Lodjinha/app/src/main/res/drawable-v21/ic_menu_slideshow.xml new file mode 100644 index 0000000..ae51e49 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/drawable-v21/ic_menu_slideshow.xml @@ -0,0 +1,9 @@ + + + diff --git a/android/Lodjinha/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/android/Lodjinha/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..6348baa --- /dev/null +++ b/android/Lodjinha/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/android/Lodjinha/app/src/main/res/drawable/active_dot.xml b/android/Lodjinha/app/src/main/res/drawable/active_dot.xml new file mode 100644 index 0000000..ecd289c --- /dev/null +++ b/android/Lodjinha/app/src/main/res/drawable/active_dot.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/drawable/check_button.png b/android/Lodjinha/app/src/main/res/drawable/check_button.png new file mode 100644 index 0000000..4a51e5c Binary files /dev/null and b/android/Lodjinha/app/src/main/res/drawable/check_button.png differ diff --git a/android/Lodjinha/app/src/main/res/drawable/disclosure_indicator.png b/android/Lodjinha/app/src/main/res/drawable/disclosure_indicator.png new file mode 100644 index 0000000..f4b522f Binary files /dev/null and b/android/Lodjinha/app/src/main/res/drawable/disclosure_indicator.png differ diff --git a/android/Lodjinha/app/src/main/res/drawable/home_menu.png b/android/Lodjinha/app/src/main/res/drawable/home_menu.png new file mode 100644 index 0000000..6a69f66 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/drawable/home_menu.png differ diff --git a/android/Lodjinha/app/src/main/res/drawable/ic_check_black_24dp.xml b/android/Lodjinha/app/src/main/res/drawable/ic_check_black_24dp.xml new file mode 100644 index 0000000..de0b077 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/drawable/ic_check_black_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/android/Lodjinha/app/src/main/res/drawable/ic_check_white.xml b/android/Lodjinha/app/src/main/res/drawable/ic_check_white.xml new file mode 100644 index 0000000..17aca2a --- /dev/null +++ b/android/Lodjinha/app/src/main/res/drawable/ic_check_white.xml @@ -0,0 +1,5 @@ + + + diff --git a/android/Lodjinha/app/src/main/res/drawable/ic_circle.xml b/android/Lodjinha/app/src/main/res/drawable/ic_circle.xml new file mode 100644 index 0000000..d0d33e4 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/drawable/ic_circle.xml @@ -0,0 +1,5 @@ + + + diff --git a/android/Lodjinha/app/src/main/res/drawable/ic_close.xml b/android/Lodjinha/app/src/main/res/drawable/ic_close.xml new file mode 100644 index 0000000..f1563f4 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/drawable/ic_close.xml @@ -0,0 +1,5 @@ + + + diff --git a/android/Lodjinha/app/src/main/res/drawable/ic_home_menu.xml b/android/Lodjinha/app/src/main/res/drawable/ic_home_menu.xml new file mode 100644 index 0000000..5cb4d2f --- /dev/null +++ b/android/Lodjinha/app/src/main/res/drawable/ic_home_menu.xml @@ -0,0 +1,5 @@ + + + diff --git a/android/Lodjinha/app/src/main/res/drawable/ic_launcher_background.xml b/android/Lodjinha/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..2408e30 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/Lodjinha/app/src/main/res/drawable/inactive_dot.xml b/android/Lodjinha/app/src/main/res/drawable/inactive_dot.xml new file mode 100644 index 0000000..0c19f23 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/drawable/inactive_dot.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/drawable/logo_menu.png b/android/Lodjinha/app/src/main/res/drawable/logo_menu.png new file mode 100644 index 0000000..414d459 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/drawable/logo_menu.png differ diff --git a/android/Lodjinha/app/src/main/res/drawable/logo_navbar.png b/android/Lodjinha/app/src/main/res/drawable/logo_navbar.png new file mode 100644 index 0000000..6a9bc43 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/drawable/logo_navbar.png differ diff --git a/android/Lodjinha/app/src/main/res/drawable/logo_sobre.png b/android/Lodjinha/app/src/main/res/drawable/logo_sobre.png new file mode 100644 index 0000000..d6afd8c Binary files /dev/null and b/android/Lodjinha/app/src/main/res/drawable/logo_sobre.png differ diff --git a/android/Lodjinha/app/src/main/res/drawable/menu_pattern.png b/android/Lodjinha/app/src/main/res/drawable/menu_pattern.png new file mode 100644 index 0000000..bd4cb94 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/drawable/menu_pattern.png differ diff --git a/android/Lodjinha/app/src/main/res/drawable/side_nav_bar.xml b/android/Lodjinha/app/src/main/res/drawable/side_nav_bar.xml new file mode 100644 index 0000000..a33798b --- /dev/null +++ b/android/Lodjinha/app/src/main/res/drawable/side_nav_bar.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/drawable/tag_menu.png b/android/Lodjinha/app/src/main/res/drawable/tag_menu.png new file mode 100644 index 0000000..fb6c792 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/drawable/tag_menu.png differ diff --git a/android/Lodjinha/app/src/main/res/layout/activity_about.xml b/android/Lodjinha/app/src/main/res/layout/activity_about.xml new file mode 100644 index 0000000..c86ffde --- /dev/null +++ b/android/Lodjinha/app/src/main/res/layout/activity_about.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/layout/activity_detail.xml b/android/Lodjinha/app/src/main/res/layout/activity_detail.xml new file mode 100644 index 0000000..2f99061 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/layout/activity_detail.xml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/layout/activity_main.xml b/android/Lodjinha/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..cfed04a --- /dev/null +++ b/android/Lodjinha/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/android/Lodjinha/app/src/main/res/layout/activity_products.xml b/android/Lodjinha/app/src/main/res/layout/activity_products.xml new file mode 100644 index 0000000..8eb5f29 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/layout/activity_products.xml @@ -0,0 +1,19 @@ + + + + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/layout/app_bar_about.xml b/android/Lodjinha/app/src/main/res/layout/app_bar_about.xml new file mode 100644 index 0000000..25730e5 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/layout/app_bar_about.xml @@ -0,0 +1,24 @@ + + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/layout/app_bar_allproducts.xml b/android/Lodjinha/app/src/main/res/layout/app_bar_allproducts.xml new file mode 100644 index 0000000..3768aab --- /dev/null +++ b/android/Lodjinha/app/src/main/res/layout/app_bar_allproducts.xml @@ -0,0 +1,24 @@ + + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/layout/app_bar_main.xml b/android/Lodjinha/app/src/main/res/layout/app_bar_main.xml new file mode 100644 index 0000000..bbe83aa --- /dev/null +++ b/android/Lodjinha/app/src/main/res/layout/app_bar_main.xml @@ -0,0 +1,29 @@ + + + + + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/layout/content_main.xml b/android/Lodjinha/app/src/main/res/layout/content_main.xml new file mode 100644 index 0000000..4bc2952 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/layout/content_main.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/layout/item_category.xml b/android/Lodjinha/app/src/main/res/layout/item_category.xml new file mode 100644 index 0000000..83e323b --- /dev/null +++ b/android/Lodjinha/app/src/main/res/layout/item_category.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/layout/item_product.xml b/android/Lodjinha/app/src/main/res/layout/item_product.xml new file mode 100644 index 0000000..0e3ae17 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/layout/item_product.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/layout/main_toolbar.xml b/android/Lodjinha/app/src/main/res/layout/main_toolbar.xml new file mode 100644 index 0000000..43999e9 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/layout/main_toolbar.xml @@ -0,0 +1,32 @@ + + + + + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/layout/nav_header_main.xml b/android/Lodjinha/app/src/main/res/layout/nav_header_main.xml new file mode 100644 index 0000000..b53925d --- /dev/null +++ b/android/Lodjinha/app/src/main/res/layout/nav_header_main.xml @@ -0,0 +1,35 @@ + + + + + + + + diff --git a/android/Lodjinha/app/src/main/res/layout/swipe_layout.xml b/android/Lodjinha/app/src/main/res/layout/swipe_layout.xml new file mode 100644 index 0000000..42602f1 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/layout/swipe_layout.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/menu/activity_main_drawer.xml b/android/Lodjinha/app/src/main/res/menu/activity_main_drawer.xml new file mode 100644 index 0000000..bd7a776 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/menu/activity_main_drawer.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/android/Lodjinha/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/Lodjinha/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..8b1fd9b --- /dev/null +++ b/android/Lodjinha/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android/Lodjinha/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..8b1fd9b --- /dev/null +++ b/android/Lodjinha/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/mipmap-hdpi/ic_home.png b/android/Lodjinha/app/src/main/res/mipmap-hdpi/ic_home.png new file mode 100644 index 0000000..88972a1 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-hdpi/ic_home.png differ diff --git a/android/Lodjinha/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/Lodjinha/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..3e2f019 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/Lodjinha/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/android/Lodjinha/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..6753e92 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/android/Lodjinha/app/src/main/res/mipmap-mdpi/ic_home.png b/android/Lodjinha/app/src/main/res/mipmap-mdpi/ic_home.png new file mode 100644 index 0000000..1b66bd6 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-mdpi/ic_home.png differ diff --git a/android/Lodjinha/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/Lodjinha/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..e3a73ec Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/Lodjinha/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/android/Lodjinha/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..b5607fd Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/android/Lodjinha/app/src/main/res/mipmap-xhdpi/ic_home.png b/android/Lodjinha/app/src/main/res/mipmap-xhdpi/ic_home.png new file mode 100644 index 0000000..9d1491f Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-xhdpi/ic_home.png differ diff --git a/android/Lodjinha/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/Lodjinha/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..1ff22cb Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/Lodjinha/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/android/Lodjinha/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..8a627b2 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/android/Lodjinha/app/src/main/res/mipmap-xxhdpi/ic_home.png b/android/Lodjinha/app/src/main/res/mipmap-xxhdpi/ic_home.png new file mode 100644 index 0000000..de99bb0 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-xxhdpi/ic_home.png differ diff --git a/android/Lodjinha/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/Lodjinha/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..bcb6af8 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/Lodjinha/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/android/Lodjinha/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..5f89ac8 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/android/Lodjinha/app/src/main/res/mipmap-xxxhdpi/ic_home.png b/android/Lodjinha/app/src/main/res/mipmap-xxxhdpi/ic_home.png new file mode 100644 index 0000000..6a5488f Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-xxxhdpi/ic_home.png differ diff --git a/android/Lodjinha/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/Lodjinha/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..2808137 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/Lodjinha/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/android/Lodjinha/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..145f5c8 Binary files /dev/null and b/android/Lodjinha/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/android/Lodjinha/app/src/main/res/values-v21/styles.xml b/android/Lodjinha/app/src/main/res/values-v21/styles.xml new file mode 100644 index 0000000..e546804 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/values-v21/styles.xml @@ -0,0 +1,7 @@ + + + diff --git a/android/Lodjinha/app/src/main/res/values/colors.xml b/android/Lodjinha/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..aa95415 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/values/colors.xml @@ -0,0 +1,17 @@ + + + #5e2a84 + #00574B + #D81B60 + #f15025 + #aaaaaa + #2d3142 + #4a4a4a + #d5d5d5 + #fcfcfc + #5e2a84 + + + #fcfcfc + #aaaaaa + diff --git a/android/Lodjinha/app/src/main/res/values/dimens.xml b/android/Lodjinha/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..4ab4520 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/values/dimens.xml @@ -0,0 +1,8 @@ + + + 16dp + 16dp + 8dp + 176dp + 16dp + \ No newline at end of file diff --git a/android/Lodjinha/app/src/main/res/values/drawables.xml b/android/Lodjinha/app/src/main/res/values/drawables.xml new file mode 100644 index 0000000..52c6a6c --- /dev/null +++ b/android/Lodjinha/app/src/main/res/values/drawables.xml @@ -0,0 +1,8 @@ + + @android:drawable/ic_menu_camera + @android:drawable/ic_menu_gallery + @android:drawable/ic_menu_slideshow + @android:drawable/ic_menu_manage + @android:drawable/ic_menu_share + @android:drawable/ic_menu_send + diff --git a/android/Lodjinha/app/src/main/res/values/strings.xml b/android/Lodjinha/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..cb82636 --- /dev/null +++ b/android/Lodjinha/app/src/main/res/values/strings.xml @@ -0,0 +1,10 @@ + + Lodjinha + Open navigation drawer + Close navigation drawer + Android Studio + android.studio@android.com + Navigation header + Settings + ProductsActivity + diff --git a/android/Lodjinha/app/src/main/res/values/styles.xml b/android/Lodjinha/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..bbc23fd --- /dev/null +++ b/android/Lodjinha/app/src/main/res/values/styles.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/android/Lodjinha/app/src/test/java/com/example/lodjinha/BannersExibitionTest.kt b/android/Lodjinha/app/src/test/java/com/example/lodjinha/BannersExibitionTest.kt new file mode 100644 index 0000000..a864bf3 --- /dev/null +++ b/android/Lodjinha/app/src/test/java/com/example/lodjinha/BannersExibitionTest.kt @@ -0,0 +1,25 @@ +package com.example.lodjinha + +import com.example.alodjinha.data.Database +import com.example.alodjinha.data.managers.LodjinhaManager +import org.junit.Assert +import org.junit.Test + +class BannersExibitionTest { + val database = Database() + val lodjinhaManager = LodjinhaManager(database) + @Test + fun databseManager_isCorrect() { + val result = lodjinhaManager.getBanners().value + + var check = true + if (result == null) { + check = false + } + else + check = true + Assert.assertEquals(true, check) + } + +} + diff --git a/android/Lodjinha/app/src/test/java/com/example/lodjinha/CategorysExibitionTest.kt b/android/Lodjinha/app/src/test/java/com/example/lodjinha/CategorysExibitionTest.kt new file mode 100644 index 0000000..0d76479 --- /dev/null +++ b/android/Lodjinha/app/src/test/java/com/example/lodjinha/CategorysExibitionTest.kt @@ -0,0 +1,24 @@ +package com.example.lodjinha + +import com.example.alodjinha.data.Database +import com.example.alodjinha.data.managers.LodjinhaManager +import org.junit.Assert +import org.junit.Test + +class CategorysExibitionTest { + + val database = Database() + val lodjinhaManager = LodjinhaManager(database) + @Test + fun databseManager_isCorrect() { + val result = lodjinhaManager.getCategory().value + + var check = true + if (result == null) { + check = false + } + else + check = true + Assert.assertEquals(true, check) + } +} \ No newline at end of file diff --git a/android/Lodjinha/app/src/test/java/com/example/lodjinha/ExampleUnitTest.kt b/android/Lodjinha/app/src/test/java/com/example/lodjinha/ExampleUnitTest.kt new file mode 100644 index 0000000..13c0a33 --- /dev/null +++ b/android/Lodjinha/app/src/test/java/com/example/lodjinha/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.example.lodjinha + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/android/Lodjinha/app/src/test/java/com/example/lodjinha/ProductsExibitionTest.kt b/android/Lodjinha/app/src/test/java/com/example/lodjinha/ProductsExibitionTest.kt new file mode 100644 index 0000000..0ec8376 --- /dev/null +++ b/android/Lodjinha/app/src/test/java/com/example/lodjinha/ProductsExibitionTest.kt @@ -0,0 +1,27 @@ +package com.example.lodjinha + +import androidx.lifecycle.MutableLiveData +import com.example.alodjinha.data.Database +import com.example.alodjinha.data.classes.Product +import com.example.alodjinha.data.managers.LodjinhaManager +import org.junit.Assert +import org.junit.Test + +class ProductsExibitionTest { + val database = Database() + val lodjinhaManager = LodjinhaManager(database) + @Test + fun databseManager_isCorrect() { + val result = lodjinhaManager.getProducts().value + + var check = true + if (result == null) { + check = false + } + else + check = true + Assert.assertEquals(true, check) + } + + +} \ No newline at end of file diff --git a/android/Lodjinha/build.gradle b/android/Lodjinha/build.gradle new file mode 100644 index 0000000..7f692ed --- /dev/null +++ b/android/Lodjinha/build.gradle @@ -0,0 +1,28 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.3.20' + repositories { + google() + jcenter() + + } + dependencies { + classpath 'com.android.tools.build:gradle:3.3.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/android/Lodjinha/gradle.properties b/android/Lodjinha/gradle.properties new file mode 100644 index 0000000..23339e0 --- /dev/null +++ b/android/Lodjinha/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official diff --git a/android/Lodjinha/gradle/wrapper/gradle-wrapper.jar b/android/Lodjinha/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f Binary files /dev/null and b/android/Lodjinha/gradle/wrapper/gradle-wrapper.jar differ diff --git a/android/Lodjinha/gradle/wrapper/gradle-wrapper.properties b/android/Lodjinha/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..970a0ca --- /dev/null +++ b/android/Lodjinha/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Thu Mar 21 13:23:38 BRT 2019 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip diff --git a/android/Lodjinha/gradlew b/android/Lodjinha/gradlew new file mode 100644 index 0000000..cccdd3d --- /dev/null +++ b/android/Lodjinha/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/android/Lodjinha/gradlew.bat b/android/Lodjinha/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/android/Lodjinha/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/Lodjinha/settings.gradle b/android/Lodjinha/settings.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/android/Lodjinha/settings.gradle @@ -0,0 +1 @@ +include ':app'