diff --git a/app/build.gradle b/app/build.gradle index c844d59..35c5d74 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ android { defaultConfig { applicationId "com.islamey.wazkar" - minSdkVersion 26 + minSdkVersion 25 targetSdkVersion 33 versionCode 1 versionName "1.0.0" diff --git a/app/release/release/Wazaker.aab b/app/release/release/Wazaker.aab deleted file mode 100644 index 139b7a0..0000000 Binary files a/app/release/release/Wazaker.aab and /dev/null differ diff --git a/app/src/main/java/com/islamey/hamza/wazaker/ui/HomeFragment/HomeFragment.kt b/app/src/main/java/com/islamey/hamza/wazaker/ui/HomeFragment/HomeFragment.kt index 967a991..78e8160 100644 --- a/app/src/main/java/com/islamey/hamza/wazaker/ui/HomeFragment/HomeFragment.kt +++ b/app/src/main/java/com/islamey/hamza/wazaker/ui/HomeFragment/HomeFragment.kt @@ -1,5 +1,6 @@ package com.islamey.hamza.wazaker.ui.HomeFragment +import android.os.Build import android.os.Bundle import android.util.Log import android.view.LayoutInflater @@ -41,7 +42,9 @@ class HomeFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - hijriViewModel.getHijriDate(getCurrentDate()) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + hijriViewModel.getHijriDate(getCurrentDate()) + } initUI() diff --git a/app/src/main/java/com/islamey/hamza/wazaker/ui/MainActivity.kt b/app/src/main/java/com/islamey/hamza/wazaker/ui/MainActivity.kt index e08aa88..cbeb3cd 100644 --- a/app/src/main/java/com/islamey/hamza/wazaker/ui/MainActivity.kt +++ b/app/src/main/java/com/islamey/hamza/wazaker/ui/MainActivity.kt @@ -1,15 +1,11 @@ package com.islamey.hamza.wazaker.ui -import android.content.Intent import android.os.Bundle -import android.view.View import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatDelegate import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen -import androidx.navigation.NavController import androidx.navigation.fragment.NavHostFragment -import com.hassanjamil.hqibla.CompassActivity -import com.hassanjamil.hqibla.Constants +import androidx.navigation.ui.setupWithNavController import com.islamey.hamza.wazaker.utils.Notifications.setupNotification import com.islamey.hamza.wazaker.utils.Utils.getDarkModeState import com.islamey.wazkar.R @@ -20,13 +16,6 @@ import dagger.hilt.android.AndroidEntryPoint class MainActivity : AppCompatActivity() { private lateinit var binding: ActivityMainBinding - private val navController: NavController by lazy { - val navHostFragment = - supportFragmentManager.findFragmentById(R.id.hostFragment) as NavHostFragment - navHostFragment.navController - } - - private var lastOpenedScreenId = R.id.home_action override fun onCreate(savedInstanceState: Bundle?) { installSplashScreen() @@ -48,66 +37,9 @@ class MainActivity : AppCompatActivity() { } private fun setUpBottomViewNavigation() { - binding.bottomNavigationView.setOnItemSelectedListener { menuItem -> - when (menuItem.itemId) { - R.id.home_action -> { - doIfNotCurrent(R.id.home_action){ - navController.navigate(R.id.homeFragment) - } - true - } - - R.id.qibla_action -> { - openQiblaActivity() - // as we open another activity we should not lose current selection - false - } - - R.id.forty_action -> { - doIfNotCurrent(R.id.forty_action){ - navController.navigate(R.id.fortyHadithListFragment) - } - true - } - - R.id.settings_action -> { - doIfNotCurrent(R.id.settings_action){ - navController.navigate(R.id.settingsFragment) - } - true - } - - else -> false - } - } - } - - private fun doIfNotCurrent(actionId: Int, action : ()-> Unit) { - if (actionId != lastOpenedScreenId){ - action.invoke() - lastOpenedScreenId = actionId - } - } - - private fun openQiblaActivity() { - val intent = Intent(this, CompassActivity::class.java) - intent.putExtra(Constants.TOOLBAR_BG_COLOR, "#FFFFFF") // Toolbar Background color - intent.putExtra(Constants.COMPASS_BG_COLOR, "#FFFFFF") // Compass background color - intent.putExtra(Constants.ANGLE_TEXT_COLOR, "#000000") // Angle Text color - intent.putExtra(Constants.DRAWABLE_DIAL, R.drawable.dial) // Your dial drawable resource - intent.putExtra( - Constants.DRAWABLE_QIBLA, - R.drawable.qibla - ) // Your qibla indicator drawable resource - intent.putExtra( - Constants.FOOTER_IMAGE_VISIBLE, - View.VISIBLE or View.INVISIBLE or View.GONE - ) // Footer World Image visibility - intent.putExtra( - Constants.LOCATION_TEXT_VISIBLE, - View.VISIBLE or View.INVISIBLE or View.GONE - ) // Location Text visibility - startActivity(intent) + val navHostFragment = + supportFragmentManager.findFragmentById(R.id.hostFragment) as NavHostFragment + binding.bottomNavigationView.setupWithNavController(navHostFragment.navController) } } diff --git a/app/src/main/java/com/islamey/hamza/wazaker/ui/qibla/QiblaFragment.kt b/app/src/main/java/com/islamey/hamza/wazaker/ui/qibla/QiblaFragment.kt new file mode 100644 index 0000000..6c92a83 --- /dev/null +++ b/app/src/main/java/com/islamey/hamza/wazaker/ui/qibla/QiblaFragment.kt @@ -0,0 +1,41 @@ +package com.islamey.hamza.wazaker.ui.qibla + +import android.content.Intent +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.hassanjamil.hqibla.CompassActivity +import com.hassanjamil.hqibla.Constants +import com.islamey.wazkar.databinding.FragmentQiblaBinding +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class QiblaFragment : Fragment() { + + private var _binding: FragmentQiblaBinding? = null + private val binding get() = _binding!! + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + _binding = FragmentQiblaBinding.inflate(layoutInflater) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + openQiblaActivity() + } + + private fun openQiblaActivity() { + val intent = Intent(requireContext(), CompassActivity::class.java) + intent.putExtra(Constants.TOOLBAR_BG_COLOR, "#FFFFFF") // Toolbar Background color + intent.putExtra(Constants.COMPASS_BG_COLOR, "#FFFFFF") // Compass background color + intent.putExtra(Constants.ANGLE_TEXT_COLOR, "#000000") // Angle Text color + startActivity(intent) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/islamey/hamza/wazaker/utils/Utils.kt b/app/src/main/java/com/islamey/hamza/wazaker/utils/Utils.kt index 76f6a40..95c8be4 100644 --- a/app/src/main/java/com/islamey/hamza/wazaker/utils/Utils.kt +++ b/app/src/main/java/com/islamey/hamza/wazaker/utils/Utils.kt @@ -2,13 +2,17 @@ package com.islamey.hamza.wazaker.utils import android.content.Context import android.content.Intent +import android.os.Build +import androidx.annotation.RequiresApi import com.islamey.hamza.wazaker.domain.Models.HijriDateResponse import org.apache.commons.lang3.StringEscapeUtils import java.time.LocalDate import java.time.format.DateTimeFormatter +import java.util.* object Utils { + @RequiresApi(Build.VERSION_CODES.O) fun getCurrentDate(): String { val currentDate = LocalDate.now() val formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy") diff --git a/app/src/main/res/layout/fragment_qibla.xml b/app/src/main/res/layout/fragment_qibla.xml new file mode 100644 index 0000000..dc0f41a --- /dev/null +++ b/app/src/main/res/layout/fragment_qibla.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 864d4c8..126ea88 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -118,5 +118,10 @@ android:name="com.islamey.hamza.wazaker.ui.settings.SettingsFragment" android:label="fragment_settings" tools:layout="@layout/fragment_settings" /> + \ No newline at end of file diff --git a/build.gradle b/build.gradle index ae33325..caf837d 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ buildscript { plugins { id 'com.google.dagger.hilt.android' version '2.44' apply false + id 'org.jetbrains.kotlin.android' version '1.8.0' apply false } allprojects {