From 20d5602934a00ccbf4d1a570d36b146361e794ae Mon Sep 17 00:00:00 2001 From: Suryansh Prajapati Date: Sun, 11 Feb 2024 22:19:50 +0530 Subject: [PATCH] add the dialog box --- .../com/weather/weatherapp/MainActivity.kt | 21 +++++++++++++++++++ .../res/drawable/baseline_location_pin_24.xml | 5 +++++ app/src/main/res/menu/home_page_menu.xml | 6 ++++++ 3 files changed, 32 insertions(+) create mode 100644 app/src/main/res/drawable/baseline_location_pin_24.xml diff --git a/app/src/main/java/com/weather/weatherapp/MainActivity.kt b/app/src/main/java/com/weather/weatherapp/MainActivity.kt index 785d198..9c69bfb 100644 --- a/app/src/main/java/com/weather/weatherapp/MainActivity.kt +++ b/app/src/main/java/com/weather/weatherapp/MainActivity.kt @@ -36,6 +36,7 @@ import com.karumi.dexter.PermissionToken import com.karumi.dexter.listener.PermissionRequest import com.karumi.dexter.listener.multi.MultiplePermissionsListener import com.weather.Network.WeatherService +import com.weather.models.Coord import com.weather.models.WeatherResponse import kotlinx.coroutines.launch import retrofit.* @@ -174,6 +175,14 @@ class MainActivity : AppCompatActivity() { true } + R.id.coordinates -> { + + + showLocationDialog(this,mLatitude,mLongitude ) + + true + } + else -> super.onOptionsItemSelected(item) } @@ -197,6 +206,18 @@ class MainActivity : AppCompatActivity() { } + fun showLocationDialog(context: Context, latitude: Double, longitude: Double) { + val builder = AlertDialog.Builder(context) + builder.setTitle("Coordinates") + val message = "Latitude: $latitude\nLongitude: $longitude" + builder.setMessage(message) + builder.setPositiveButton("OK") { dialog, _ -> + dialog.dismiss() + } + val dialog = builder.create() + dialog.show() + } + private fun Version() { Toast.makeText(this@MainActivity,"Version of the applicationo is : 1.1.0", Toast.LENGTH_LONG).show() diff --git a/app/src/main/res/drawable/baseline_location_pin_24.xml b/app/src/main/res/drawable/baseline_location_pin_24.xml new file mode 100644 index 0000000..0b12e57 --- /dev/null +++ b/app/src/main/res/drawable/baseline_location_pin_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/menu/home_page_menu.xml b/app/src/main/res/menu/home_page_menu.xml index e76b361..3a5de13 100644 --- a/app/src/main/res/menu/home_page_menu.xml +++ b/app/src/main/res/menu/home_page_menu.xml @@ -7,4 +7,10 @@ /> + +