Skip to content

Commit

Permalink
Merge pull request #3 from Bangkit-Capstone-Project-Team/dev
Browse files Browse the repository at this point in the history
update alpha version
  • Loading branch information
furqoncreative authored Jun 3, 2021
2 parents 738ae30 + f94244c commit e486b44
Show file tree
Hide file tree
Showing 47 changed files with 216 additions and 574 deletions.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Gamastik-Android



## Structure

* `build.gradle` - root gradle config file
* `settings.gradle` - root gradle settings file
* `app` - our only project in this repo
* `app/build.gradle` - project gradle config file
* `app/src` - main project source directory
* `app/src/main` - main project flavour
* `app/src/main/AndroidManifest.xml` - manifest file
* `app/src/main/java` - java source directory
* `app/src/main/res` - resources directory

## Building

It is recommended that you run Gradle with the `--daemon` option, as starting
up the tool from scratch often takes at least a few seconds. You can kill the
java process that it leaves running once you are done running your commands.

Tasks work much like Make targets, so you may concatenate them. Tasks are not
re-done if multiple targets in a single command require them. For example,
running `assemble install` will not compile the apk twice even though
`install` depends on `assemble`.

#### Clean

gradle clean

#### Debug

This compiles a debugging apk in `build/outputs/apk/` signed with a debug key,
ready to be installed for testing purposes.

gradle assembleDebug

You can also install it on your attached device:

gradle installDebug

#### Release

This compiles an unsigned release (non-debugging) apk in `build/outputs/apk/`.
It's not signed, you must sign it before it can be installed by any users.

gradle assembleRelease

#### Test

Were you to add automated java tests, you could configure them in your
`build.gradle` file and run them within gradle as well.

gradle test

#### Lint

This analyses the code and produces reports containing warnings about your
application in `build/outputs/lint/`.

gradle lint
10 changes: 7 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ android {
versionCode 1
versionName "1.0.0-alpha"
buildConfigField "String", "DEBUG_URL", "\"https://capstone-b21-cap026.herokuapp.com/api/\""
buildConfigField "String", "BASE_URL", "\"http://35.187.255.90/api/\""
buildConfigField "String", "BASE_URL", "\"https://batik-api-qs6wradroq-et.a.run.app/api/\""
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Expand Down Expand Up @@ -103,7 +107,7 @@ dependencies {
implementation "androidx.camera:camera-lifecycle:$camerax_version"
implementation "androidx.camera:camera-view:1.0.0-alpha24"

testImplementation 'junit:junit:4.+'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
Binary file not shown.
75 changes: 74 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,77 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { <fields>; }

# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}

##---------------Begin: proguard configuration for Retrofit ----------
# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod

# Retrofit does reflection on method and parameter annotations.
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations

# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}

# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**

# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit

# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*

# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>

-dontwarn kotlinx.**

##---------------Begin: proguard configuration for Glide ----------
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep class * extends com.bumptech.glide.module.AppGlideModule {
<init>(...);
}
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
*** rewind();
}
Binary file removed app/release/app-release.apk
Binary file not shown.
7 changes: 5 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.bangkit.gamastik">

<uses-permission android:name="android.permission.CAMERA" />
Expand All @@ -16,8 +17,10 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Gamastik"
android:usesCleartextTraffic="true">
<activity android:name=".ui.feature.discovery.byregion.BatikByRegionActivity"></activity>
android:usesCleartextTraffic="true"
android:fullBackupContent="@xml/backup_descriptor"
tools:ignore="UnusedAttribute">
<activity android:name=".ui.feature.discovery.byregion.BatikByRegionActivity" />
<activity android:name=".ui.feature.batik.scanner.BatikScannerActivity" />
<activity android:name=".ui.feature.batik.result.ScannerResultActivity" />
<activity android:name=".ui.feature.recomendation.ProductRecomendationActivity" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ constructor(@ApplicationContext context: Context) {
}

fun getUserName(): String? {
return preferences.getString(NAME, "")
return preferences.getString(NAME, null)
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bangkit.gamastik.data.model.batik
package com.bangkit.gamastik.data.model.batik.byregion

import android.os.Parcelable
import com.google.gson.annotations.SerializedName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.bangkit.gamastik.data.model.auth.logout.LogoutResponse
import com.bangkit.gamastik.data.model.auth.profile.ProfileResponse
import com.bangkit.gamastik.data.model.auth.register.RegisterRequest
import com.bangkit.gamastik.data.model.auth.register.RegisterResponse
import com.bangkit.gamastik.data.model.batik.BatikByRegionResponse
import com.bangkit.gamastik.data.model.batik.byregion.BatikByRegionResponse
import com.bangkit.gamastik.data.model.batik.byregion.BatikByRegionRequest
import com.bangkit.gamastik.data.model.batik.detail.BatikDetailResponse
import com.bangkit.gamastik.data.model.batik.discovery.BatikDiscoveryResponseItem
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/bangkit/gamastik/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.bangkit.gamastik.di

import android.content.Context
import com.bangkit.gamastik.BuildConfig.BASE_URL
import com.bangkit.gamastik.BuildConfig.DEBUG_URL
import com.bangkit.gamastik.data.local.PreferencesHelper
import com.bangkit.gamastik.data.remote.AppService
import com.bangkit.gamastik.data.remote.RemoteDataSource
Expand Down Expand Up @@ -32,7 +31,7 @@ object AppModule {
@Singleton
@Provides
fun provideRetrofit(gson: Gson, client: OkHttpClient): Retrofit = Retrofit.Builder()
.baseUrl(DEBUG_URL)
.baseUrl(BASE_URL)
.client(client)
.addConverterFactory(GsonConverterFactory.create(gson))
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@ open class BaseActivity : AppCompatActivity() {

fun getToken() = preferencesHelper.getUserToken()

fun getUserName() = preferencesHelper.getUserName()

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.bangkit.gamastik.ui.base

import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.bangkit.gamastik.data.local.PreferencesHelper
import dagger.hilt.android.AndroidEntryPoint
Expand All @@ -11,16 +10,14 @@ open class BaseFragment : Fragment() {
@Inject
lateinit var preferencesHelper: PreferencesHelper

fun setToken(token: String?){
fun setToken(token: String?) {
preferencesHelper.setUserToken(token)
}

fun setUserName(name: String?){
preferencesHelper.setUserName(name)
}

fun getToken() = preferencesHelper.getUserToken()

fun getUserName() = preferencesHelper.getUserName()
fun getUsername() = preferencesHelper.getUserName()

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import android.widget.Toast
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.GridLayoutManager
import com.bangkit.gamastik.data.model.batik.BatikByRegion
import com.bangkit.gamastik.data.model.batik.byregion.BatikByRegion
import com.bangkit.gamastik.data.model.batik.byregion.BatikByRegionRequest
import com.bangkit.gamastik.databinding.ActivityBatikByRegionBinding
import com.bangkit.gamastik.ui.feature.discovery.batikdetail.BatikDetailActivity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bangkit.gamastik.R
import com.bangkit.gamastik.data.model.batik.BatikByRegion
import com.bangkit.gamastik.data.model.batik.byregion.BatikByRegion
import com.bangkit.gamastik.databinding.ItemListBatikBinding
import com.bumptech.glide.Glide

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ package com.bangkit.gamastik.ui.feature.discovery.byregion

import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import com.bangkit.gamastik.data.model.batik.BatikByRegionResponse
import com.bangkit.gamastik.data.model.batik.byregion.BatikByRegionResponse
import com.bangkit.gamastik.data.model.batik.byregion.BatikByRegionRequest
import com.bangkit.gamastik.data.model.batik.detail.BatikDetailResponse
import com.bangkit.gamastik.data.model.batik.search.BatikSearchRequest
import com.bangkit.gamastik.data.model.batik.search.BatikSearchResponseItem
import com.bangkit.gamastik.data.repository.AppRepository
import com.bangkit.gamastik.utils.Resource
import dagger.hilt.android.lifecycle.HiltViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SearchResultActivity : BaseActivity(), SearchResultAdapter.ResultItemListe
binding.progressBar.visibility = View.GONE
val data = it.data
if (data != null) {
it.data.let { it -> adapter.setItems(ArrayList(it)) }
it.data.let { it1 -> adapter.setItems(ArrayList(it1)) }
}
}
Resource.Status.ERROR -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.bangkit.gamastik.ui.feature.discovery.searchresult

import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import com.bangkit.gamastik.data.model.batik.detail.BatikDetailResponse
import com.bangkit.gamastik.data.model.batik.search.BatikSearchRequest
import com.bangkit.gamastik.data.model.batik.search.BatikSearchResponseItem
import com.bangkit.gamastik.data.repository.AppRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.bangkit.gamastik.ui.feature.quiz.quiztest
import android.content.Intent
import android.graphics.Typeface
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.TextView
import android.widget.Toast
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import javax.inject.Inject

@HiltViewModel
class QuizTestViewModel @Inject constructor(
private val repository: AppRepository
repository: AppRepository
): ViewModel() {

val quizQuestion = repository.getQuizQuestion()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import com.bangkit.gamastik.utils.Resource
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class HomeFragment : BaseFragment(), HomeAdapter.DiscoveryItemListener, RegionAdapter.RegionItemListener {
class HomeFragment : BaseFragment(), HomeAdapter.DiscoveryItemListener,
RegionAdapter.RegionItemListener {

private val homeViewModel: HomeViewModel by viewModels()
lateinit var binding: FragmentHomeBinding
Expand All @@ -43,11 +44,15 @@ class HomeFragment : BaseFragment(), HomeAdapter.DiscoveryItemListener, RegionAd
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(activity as AppCompatActivity?)?.supportActionBar?.hide()
getUserId()
setRecyclerView()
getRegionList()
getDiscoveryBatik()

if (getUsername().isNullOrBlank()) {
getUserId()
} else {
binding.tvUserName.text = StringBuilder("Hello, ${getUsername()}")
}
binding.ivLogout.setOnClickListener {
logout()
}
Expand All @@ -73,7 +78,8 @@ class HomeFragment : BaseFragment(), HomeAdapter.DiscoveryItemListener, RegionAd
binding.rvBatik.adapter = adapter

regionAdapter = RegionAdapter(this)
binding.rvRegion.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
binding.rvRegion.layoutManager =
LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
binding.rvRegion.setHasFixedSize(true)
binding.rvRegion.adapter = regionAdapter
}
Expand Down Expand Up @@ -104,6 +110,7 @@ class HomeFragment : BaseFragment(), HomeAdapter.DiscoveryItemListener, RegionAd
binding.progressBar.visibility = View.GONE
val data = it.data
if (data != null) {
setUserName(data.data?.name)
binding.tvUserName.text = StringBuilder("Hello, ${data.data?.name}")
}
}
Expand All @@ -124,7 +131,7 @@ class HomeFragment : BaseFragment(), HomeAdapter.DiscoveryItemListener, RegionAd
binding.progressBar.visibility = View.GONE
val data = it.data
if (data != null) {
it.data.let { it -> adapter.setItems(ArrayList(it)) }
it.data.let { it1 -> adapter.setItems(ArrayList(it1)) }
}
}
Resource.Status.ERROR -> {
Expand Down Expand Up @@ -182,7 +189,7 @@ class HomeFragment : BaseFragment(), HomeAdapter.DiscoveryItemListener, RegionAd

override fun onClicked(item: String?) {
val intent = Intent(requireContext(), BatikByRegionActivity::class.java)
intent.putExtra(BatikDetailActivity.EXTRA_DATA, item)
intent.putExtra(BatikByRegionActivity.EXTRA_DATA, item)
startActivity(intent)
}
}
Loading

0 comments on commit e486b44

Please sign in to comment.