Skip to content

Commit

Permalink
Merge pull request #22 from hexley21/release
Browse files Browse the repository at this point in the history
Release 1.1.1
  • Loading branch information
hexley21 authored Sep 4, 2022
2 parents 5a61f13 + dc1c320 commit 5f1441e
Show file tree
Hide file tree
Showing 24 changed files with 644 additions and 94 deletions.
123 changes: 123 additions & 0 deletions .idea/codeStyles/Project.xml

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

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

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

22 changes: 9 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ plugins {
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'com.google.android.gms.oss-licenses-plugin'
}

android {
compileSdk 32
compileSdk 33

defaultConfig {
applicationId "com.hxl.arithmathics"
minSdk 21
targetSdk 32
versionCode 3
versionName "1.1.0"
targetSdk 33
versionCode 4
versionName "1.1.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -35,21 +34,18 @@ android {
buildFeatures {
dataBinding true
}
namespace 'com.hxl.arithmathics'
}
apply plugin: 'kotlin-kapt'
dependencies {

// Android
implementation 'androidx.core:core-ktx:1.9.0-alpha05'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation 'androidx.appcompat:appcompat:1.6.0-alpha05'
implementation 'com.google.android.material:material:1.7.0-alpha03'
implementation 'androidx.core:core-ktx:1.9.0-rc01'
implementation 'androidx.appcompat:appcompat:1.6.0-beta01'
implementation 'com.google.android.material:material:1.7.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.2.0-alpha03'
implementation 'androidx.core:core-splashscreen:1.0.0'

// Open-source notices
implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'

// Airbnb
implementation 'com.airbnb.android:paris:2.0.1'
kapt 'com.airbnb.android:paris-processor:2.0.1'
Expand All @@ -65,7 +61,7 @@ dependencies {
// Hilt
implementation 'com.google.dagger:hilt-android:2.43.1'
kapt 'com.google.dagger:hilt-compiler:2.43.1'
implementation 'androidx.fragment:fragment-ktx:1.5.1'
implementation 'androidx.fragment:fragment-ktx:1.5.2'

// RxJava
implementation 'io.reactivex.rxjava3:rxjava:3.1.5'
Expand Down
9 changes: 1 addition & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +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.hxl.arithmathics">
xmlns:tools="http://schemas.android.com/tools">

<application
android:name="com.hxl.arithmathics.app.App"
Expand All @@ -24,12 +23,6 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/Theme.Arithmathics" />
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="@style/Theme.Arithmathics" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ class GameResultFormatter {
fun getDifficultyColor(difficulty: Int, context: Context): Int {
val typedValue = TypedValue()
when (difficulty) {
in 23..149 -> context.theme.resolveAttribute(com.google.android.material.R.attr.colorPrimaryContainer, typedValue, true)
in 150..254 -> context.theme.resolveAttribute(com.google.android.material.R.attr.colorErrorContainer, typedValue, true)
else -> context.theme.resolveAttribute(com.google.android.material.R.attr.colorTertiaryContainer, typedValue, true)
in 0..200 -> context.theme.resolveAttribute(com.google.android.material.R.attr.colorTertiaryContainer, typedValue, true)
in 200..1000 -> context.theme.resolveAttribute(com.google.android.material.R.attr.colorPrimaryContainer, typedValue, true)
else -> context.theme.resolveAttribute(com.google.android.material.R.attr.colorErrorContainer, typedValue, true)
}
return typedValue.data
}

fun getDifficultyText(difficulty: Int, resources: Resources): String {
return when (difficulty) {
in 0..2 -> resources.getString(R.string.beginner)
in 3..11 -> resources.getString(R.string.easy)
in 12..22 -> resources.getString(R.string.medium)
in 23..69 -> resources.getString(R.string.hard)
in 70..149 -> resources.getString(R.string.expert)
in 150..199 -> resources.getString(R.string.extreme)
in 200..252 -> resources.getString(R.string.impossible)
in 0..100 -> resources.getString(R.string.beginner)
in 100..200 -> resources.getString(R.string.easy)
in 200..350 -> resources.getString(R.string.medium)
in 350..1000 -> resources.getString(R.string.hard)
in 1000..3000 -> resources.getString(R.string.expert)
in 3000..7000 -> resources.getString(R.string.extreme)
in 7000..10000 -> resources.getString(R.string.impossible)
else -> resources.getString(R.string.calculator)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.hxl.arithmathics.presentation.fragment.info

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.hxl.arithmathics.R
import com.hxl.arithmathics.databinding.FragmentInfoBinding
import com.hxl.arithmathics.presentation.activity.MainActivity
import com.hxl.arithmathics.presentation.fragment.info.credits.CreditFragment
import java.util.*


class InfoFragment : Fragment() {
lateinit var binding: FragmentInfoBinding

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = FragmentInfoBinding.inflate(layoutInflater, container, false)

binding.year = Calendar.getInstance().get(Calendar.YEAR).toString()
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

binding.tvEmail.setOnClickListener { openEmail() }
binding.tvGithub.setOnClickListener {
openWeb("https://" + requireContext().getString(R.string.github_page))
}
binding.tvPrivacyPolicy.setOnClickListener { openWeb(requireContext().getString(R.string.privacy_policy)) }
binding.tvCredits.setOnClickListener { (requireActivity() as MainActivity).replaceFragment(CreditFragment(), true) }

}

private fun openEmail() {
startActivity(
Intent(
Intent.ACTION_SENDTO,
Uri.parse("mailto:${requireContext().getString(R.string.developer)}")
)
)
}

private fun openWeb(url: String) {
requireActivity().startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.hxl.arithmathics.presentation.fragment.info.credits

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import com.hxl.arithmathics.databinding.FragmentCreditsBinding

class CreditFragment: Fragment() {

lateinit var binding: FragmentCreditsBinding
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = FragmentCreditsBinding.inflate(inflater, container, false)

binding.rvCredits.layoutManager = LinearLayoutManager(requireContext())
binding.rvCredits.adapter = CreditsAdapter()
binding.rvCredits.addItemDecoration(
DividerItemDecoration(requireContext() , DividerItemDecoration.VERTICAL)
)
return binding.root
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.hxl.arithmathics.presentation.fragment.info.credits

import android.content.Intent
import android.net.Uri
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.hxl.arithmathics.R
import com.hxl.arithmathics.databinding.ItemCreditBinding

class CreditsAdapter : RecyclerView.Adapter<CreditsAdapter.ViewHolder>() {
class ViewHolder(internal val binding: ItemCreditBinding) :
RecyclerView.ViewHolder(binding.root) {
init {
itemView.setOnClickListener {
binding.root.context.startActivity(
Intent(Intent.ACTION_VIEW , Uri.parse(
binding.root.context.resources.getStringArray(R.array.credits_links)[adapterPosition]
))
)
}
}
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val binding =
ItemCreditBinding.inflate(LayoutInflater.from(parent.context) , parent , false)
return ViewHolder(binding)
}

override fun onBindViewHolder(holder: ViewHolder , position: Int) {
val resources = holder.binding.root.context.resources
val titleItem = resources.getStringArray(R.array.credits_title)[position]
val descItem = resources.getStringArray(R.array.credits_desc)[position]
holder.binding.tvCreditTitle.text = titleItem
holder.binding.tvCreditDesc.text = descItem
}

override fun getItemCount(): Int {
return 8
}

}
Loading

0 comments on commit 5f1441e

Please sign in to comment.