Skip to content

Commit

Permalink
Merge pull request #14 from binaryshrey/feat/setup-v1.2
Browse files Browse the repository at this point in the history
Feat/setup v1.2
  • Loading branch information
binaryshrey committed Mar 8, 2023
2 parents 11cb1ee + 8e976a1 commit 6d5c1a6
Show file tree
Hide file tree
Showing 48 changed files with 1,733 additions and 157 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ jobs :
with:
java-version : 11

- name: Decode google-services.json
env:
FIREBASE_GOOGLE_SERVICE: ${{ secrets.FIREBASE_GOOGLE_SERVICE }}
run: echo $FIREBASE_GOOGLE_SERVICE > app/google-services.json

- name: Change wrapper permissions
run: chmod +x ./gradlew

- name: Build Project
run : ./gradlew assemble

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
.externalNativeBuild
.cxx
local.properties
/app/google-services.json
/.idea/
17 changes: 0 additions & 17 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 21 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.gms.google-services'

}

android {
compileSdk 31
compileSdk 33

defaultConfig {
applicationId "dev.shreyansh.dice"
minSdk 21
targetSdk 31
targetSdk 33
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary true
Expand Down Expand Up @@ -37,21 +39,35 @@ android {
dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.play:core-ktx:1.8.1'


implementation 'androidx.preference:preference-ktx:1.2.0'
implementation 'androidx.preference:preference:1.2.0'

testImplementation 'junit:junit:4.13.2'

androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation 'androidx.legacy:legacy-support-v4:1.0.0'

implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'

implementation 'com.jakewharton.timber:timber:5.0.1'
implementation 'androidx.core:core-splashscreen:1.0.0'
implementation "androidx.datastore:datastore-preferences:1.0.0"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
implementation("androidx.datastore:datastore-preferences-core:1.0.0")
//firebase
implementation platform('com.google.firebase:firebase-bom:31.1.1')

//firebase-auth
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.android.gms:play-services-auth:20.4.0'
}
34 changes: 33 additions & 1 deletion app/src/main/java/dev/shreyansh/dice/SettingsFragment.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
package dev.shreyansh.dice

import android.content.SharedPreferences
import android.os.Bundle
import androidx.appcompat.app.AppCompatDelegate
import androidx.fragment.app.activityViewModels
import androidx.preference.PreferenceFragmentCompat
import dev.shreyansh.dice.viewModel.DiceViewModel

class SettingsFragment : PreferenceFragmentCompat() {
class SettingsFragment : PreferenceFragmentCompat() , SharedPreferences.OnSharedPreferenceChangeListener {

private val viewModel: DiceViewModel by activityViewModels()

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.root_preferences, rootKey)
}

override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
when(key){
"THEME_KEY" -> {
viewModel.setAppTheme(sharedPreferences.getString("THEME_KEY", "System Default") ?: "System Default")
when(sharedPreferences.getString("THEME_KEY", "System Default")){
"Light Mode" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
"Dark Mode" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
"System Default" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
}
}
"GAME_MODE" -> {
viewModel.setGameMode(sharedPreferences.getString("GAME_MODE_KEY", "one") ?: "one")
}
}
}

override fun onResume() {
super.onResume()
preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this)
}

override fun onPause() {
super.onPause()
preferenceScreen.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(this)
}
}
34 changes: 30 additions & 4 deletions app/src/main/java/dev/shreyansh/dice/ui/about/AboutFragment.kt
Original file line number Diff line number Diff line change
@@ -1,26 +1,52 @@
package dev.shreyansh.dice.ui.about

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.activityViewModels
import dev.shreyansh.dice.R
import dev.shreyansh.dice.databinding.FragmentAboutBinding
import dev.shreyansh.dice.viewModel.DiceViewModel


class AboutFragment : Fragment() {

private lateinit var binding : FragmentAboutBinding
private val viewModel: DiceViewModel by activityViewModels()

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

binding = DataBindingUtil.inflate(inflater,R.layout.fragment_about, container, false)
binding.rateAppCV.setOnClickListener {
openWebURI(viewModel.appURI)
}
binding.bugCV.setOnClickListener {
openWebURI(viewModel.issuesURI)
}
binding.devCV.setOnClickListener {
openWebURI(viewModel.developerURI)
}

binding.supportAppCV.setOnClickListener {
Toast.makeText(context,"Coming Soon!", Toast.LENGTH_SHORT).show()
}


return binding.root
}
private fun openWebURI(url: String) {
val webpage: Uri = Uri.parse(url)
val intent = Intent(Intent.ACTION_VIEW, webpage)
startActivity(intent)
if (intent.resolveActivity(requireActivity().packageManager) != null) {
startActivity(intent)
}
}

}
35 changes: 31 additions & 4 deletions app/src/main/java/dev/shreyansh/dice/ui/game/BoardFourFragment.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package dev.shreyansh.dice.ui.game

import android.os.Bundle
import android.util.Log
import android.view.*
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.ContextCompat
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Observer
import androidx.navigation.fragment.findNavController
import androidx.preference.PreferenceManager
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.firebase.auth.FirebaseAuth
import dev.shreyansh.dice.R
import dev.shreyansh.dice.databinding.FragmentBoardFourBinding
import dev.shreyansh.dice.databinding.FragmentBoardThreeBinding
Expand All @@ -22,12 +27,10 @@ class BoardFourFragment : Fragment() {
private lateinit var binding : FragmentBoardFourBinding
private val viewModel: DiceViewModel by activityViewModels()

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
(activity as AppCompatActivity).supportActionBar?.show()
requireActivity().window.statusBarColor = ContextCompat.getColor(requireContext(),R.color.black)
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_board_four, container, false)
binding.viewModel = viewModel
binding.lifecycleOwner = this
Expand All @@ -39,6 +42,16 @@ class BoardFourFragment : Fragment() {
animateDice(binding)
}
})
binding.rollButton.setOnClickListener {
binding.rollButton.isEnabled=false
binding.rollButton.isClickable=false
viewModel.rollBoardFour()
binding.rollButton.postDelayed(Runnable {
binding.rollButton.isEnabled=true
binding.rollButton.isClickable=true
} , 210)

}

return binding.root
}
Expand Down Expand Up @@ -69,10 +82,24 @@ class BoardFourFragment : Fragment() {
when (item.itemId) {
R.id.aboutFragment -> findNavController().navigate(R.id.action_boardFourFragment_to_aboutFragment)
R.id.settings -> findNavController().navigate(R.id.action_boardFourFragment_to_settingsFragment)
R.id.logout -> signOutFlow()
}
return super.onOptionsItemSelected(item)
}

private fun signOutFlow() {
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build()

val googlesSignInClient = GoogleSignIn.getClient(requireContext(),gso)
googlesSignInClient.signOut()
FirebaseAuth.getInstance().signOut()
findNavController().navigate(R.id.action_boardFourFragment_to_introFragment)
Log.d("BottomSheet", "Log Out successful!")
}

private fun animateDice(binding: FragmentBoardFourBinding) {
binding.dice1ImageView.animate().apply {
duration = 100
Expand Down
Loading

0 comments on commit 6d5c1a6

Please sign in to comment.