Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
kosratdev committed Sep 26, 2022
2 parents d8e94af + f6d858b commit 1cbecab
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 20 deletions.
13 changes: 7 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 32
compileSdkVersion 33

defaultConfig {
applicationId "dev.kosrat.muslimdataexample"
minSdkVersion 16
targetSdkVersion 32
targetSdkVersion 33
versionCode 1
versionName "1.0"

Expand All @@ -25,17 +25,18 @@ android {
buildFeatures {
dataBinding = true
}
namespace 'dev.kosrat.muslimdataexample'
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(':muslim-data')

// Androidx
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'

// Tests
testImplementation 'junit:junit:4.13.2'
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.kosrat.muslimdataexample">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MainActivity : AppCompatActivity() {
val locationList = repository.searchLocation("erb")
Log.i("searchLocation", "$locationList")

val location = repository.geocoder("iq", "erbil")
val location = repository.geocoder("iq", "shaqlawa")
Log.i("geocoder", "$location")

val location2 = repository.reverseGeocoder(36.0901, 43.0930)
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.6.21'
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -32,8 +32,8 @@ task clean(type: Delete) {

// Dependency versions.
ext {
room_version = '2.4.2'
androidx_version = '1.7.0'
room_version = '2.4.3'
androidx_version = '1.9.0'
}

apply from: "${rootDir}/scripts/publish-root.gradle"
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
5 changes: 3 additions & 2 deletions muslim-data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ ext {
apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"

android {
compileSdkVersion 32
compileSdkVersion 33

defaultConfig {
minSdkVersion 16
targetSdkVersion 32
targetSdkVersion 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand All @@ -32,6 +32,7 @@ android {
buildFeatures {
dataBinding = true
}
namespace 'dev.kosrat.muslimdata'
}

dependencies {
Expand Down
3 changes: 1 addition & 2 deletions muslim-data/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.kosrat.muslimdata">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
Binary file modified muslim-data/src/main/assets/database/muslim_db_v1.0.0.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ internal interface MuslimDataDao {
AzkarReferenceTable::class,
AzkarReferenceTranslationTable::class
],
version = 1
version = 2
)
abstract class MuslimDataDatabase : RoomDatabase() {
internal abstract val muslimDataDao: MuslimDataDao
Expand All @@ -170,6 +170,7 @@ abstract class MuslimDataDatabase : RoomDatabase() {
"muslim_db.db"
)
.createFromAsset("database/muslim_db_v1.0.0.db")
.fallbackToDestructiveMigration()
.build()

INSTANCE = instance
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
package dev.kosrat.muslimdata.extensions

class CityMapper {
companion object {
fun map(city: String, countryCode: String): String {
val countries: MutableMap<String, MutableMap<String, List<String>>> = HashMap()
countries["IQ"] = getIQCities()
countries["IR"] = getIRCities()
countries["KW"] = getKWCities()

val cities = countries[countryCode]
cities?.forEach {
if (it.value.contains(city)) {
return it.key
}
}
return city
}

private fun getIQCities(): MutableMap<String, List<String>> {
val akre = listOf(
"Amedi",
"Sulav",
"Kani",
"Sheladiz",
"Barzan",
"Bele",
"Shanidar",
"Bujal",
"Mergin",
"Susna",
"Sersink"
)
val bardarash = listOf("Mamuzin")
val darbandikhan = listOf("Zarayan")
val duhok = listOf("Sumel", "Zawita", "Atrish", "Sharya", "Mrebah")
val erbil = listOf(
"Kalak",
"Pirmam",
"Shaqlawa",
"Harir",
"Khalifan",
"Rawanduz",
"Soran",
"Mergasur",
"Galala",
"Choman",
"Hiran",
"Makhmur",
"Qushtapa",
"Kasnazan"
)
val halabja = listOf("Khurmal", "Sirwan", "Byara", "Tawella")
val kifri = listOf("Hajiawa", "Chwarqurna", "Ranya")
val kirkuk = listOf("Taza Khurmatu")
val koysinjaq = listOf("Taqtaq", "Khalakan")
val qalatDizah = listOf("Sangasar", "Zharawa")
val sulaymaniyah = listOf(
"Dokan",
"Bazian",
"Chamchamal",
"Qaran Dagh",
"Arbat",
"Penjwen",
"Said Sadiq",
"Kalar",
"Takiya",
"Shorsh"
)
return mutableMapOf(
"Akre" to akre,
"Bardarash" to bardarash,
"Darbandikhan" to darbandikhan,
"Duhok" to duhok,
"Erbil" to erbil,
"Halabja" to halabja,
"Kifri" to kifri,
"Kirkuk" to kirkuk,
"Koysinjaq" to koysinjaq,
"Qalat itoah" to qalatDizah,
"Sulaymaniyah" to sulaymaniyah
)
}

private fun getIRCities(): MutableMap<String, List<String>> {
val sanandaj = listOf("Kamyaran", "Divandarreh", "Dehgolan", "Qorveh")
val urmia = listOf("Orumiyeh")
return mutableMapOf(
"Sanandaj" to sanandaj,
"Urmia" to urmia
)
}

private fun getKWCities(): MutableMap<String, List<String>> {
val alAsimah = listOf(
"Kuwait City",
"Dasman Palace",
"Sharq",
"Mirqab",
"Jibla",
"Dasma",
"Daiya",
"Salhia",
"Bneid Al Qar",
"Kaifan",
"Mansouriya",
"Abdullah al-Salem",
"Nuzha",
"Faiha",
"Shamiya",
"Rawda",
"Adailiya",
"Khaldiya",
"Qadsiya",
"Qortuba",
"Surra",
"Yarmouk",
"Shuwaikh Industrial",
"Rai",
"Granada",
"Sulaibikhat",
"Doha",
"Nahdha",
"Jaber Al Ahmad",
"Qairawan",
"Ahmadi",
"Al Wafrah",
"Sabah Al Salem",
"Messila",
"Al-Masayel",
"Adan",
"Fnaitees",
"Qusor",
"Qurain",
"Abu Fatira",
"Mubarak Al Kabeer",
"Jeleeb Al-Shuyoukh",
"Eqaila",
"Fintas",
"Dahar",
"Mahboula",
"Hadiya",
"Al-Riqqa",
"Abu Halifa",
"Fahad Al Ahmad",
"Assabahiyah",
"Mangaf",
"Fahaheel",
"South Sabahiya",
"Ali Sabah Al Salem",
"Shalayhat Mina Abdullah",
"Zour",
"Al Khiran"
)
val failaka = listOf("Zoor", "Kubbar Island", "Al-Nuwaiseeb")
val abdali = listOf("Jahra")
return mutableMapOf(
"Al Asimah" to alAsimah,
"Failaka Island" to failaka,
"Abdali" to abdali
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dev.kosrat.muslimdata.repository
import android.content.Context
import dev.kosrat.muslimdata.database.MuslimDataDatabase
import dev.kosrat.muslimdata.database.tables.prayertimes.CalculatedPrayerTime
import dev.kosrat.muslimdata.extensions.CityMapper
import dev.kosrat.muslimdata.extensions.formatToDBDate
import dev.kosrat.muslimdata.extensions.toDate
import dev.kosrat.muslimdata.models.*
Expand Down Expand Up @@ -54,7 +55,7 @@ class MuslimRepository(context: Context) {
if (location.hasFixedPrayerTime) {
val fixedPrayer = muslimDb.muslimDataDao.getPrayerTimes(
location.countryCode,
location.cityName,
CityMapper.map(location.cityName, location.countryCode),
date.formatToDBDate()
)
prayerTime = PrayerTime(
Expand Down

0 comments on commit 1cbecab

Please sign in to comment.