-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
605 additions
and
675 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
app/src/main/java/com/vsahin/praytimes/common/RemoteActivityHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.vsahin.praytimes.common | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.net.Uri | ||
import androidx.wear.remote.interactions.RemoteActivityHelper | ||
import androidx.wear.widget.ConfirmationOverlay | ||
import com.vsahin.praytimes.R | ||
import kotlinx.coroutines.CancellationException | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.guava.await | ||
import kotlinx.coroutines.launch | ||
|
||
fun startRemoteActivity( | ||
activity: Activity, | ||
scope: CoroutineScope, | ||
data: Uri | ||
) { | ||
val remoteActivityHelper = RemoteActivityHelper(activity) | ||
val sentToYourPhoneMessage = activity.getString(R.string.sent_to_your_phone) | ||
val unknownErrorMessage = activity.getString(R.string.unknown_error) | ||
|
||
scope.launch { | ||
try { | ||
val intent = Intent(Intent.ACTION_VIEW) | ||
.addCategory(Intent.CATEGORY_BROWSABLE) | ||
.setData(data) | ||
|
||
remoteActivityHelper.startRemoteActivity(intent).await() | ||
|
||
ConfirmationOverlay() | ||
.setMessage(sentToYourPhoneMessage) | ||
.setDuration(2000) | ||
.showOn(activity) | ||
} catch (cancellationException: CancellationException) { | ||
throw cancellationException | ||
} catch (throwable: Throwable) { | ||
ConfirmationOverlay() | ||
.setType(ConfirmationOverlay.FAILURE_ANIMATION) | ||
.setMessage(unknownErrorMessage) | ||
.showOn(activity) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.vsahin.praytimes.ui | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import com.vsahin.praytimes.ui.theme.PrayTimesTheme | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class MainActivity : ComponentActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
setContent { | ||
PrayTimesTheme { | ||
Navigation() | ||
} | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
app/src/main/java/com/vsahin/praytimes/ui/NavigationGraph.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.vsahin.praytimes.ui | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import androidx.wear.compose.navigation.SwipeDismissableNavHost | ||
import androidx.wear.compose.navigation.composable | ||
import androidx.wear.compose.navigation.rememberSwipeDismissableNavController | ||
import com.vsahin.praytimes.ui.about.AboutScreen | ||
import com.vsahin.praytimes.ui.home.HomeScreen | ||
import com.vsahin.praytimes.ui.locationSelector.LocationSelectorScreen | ||
|
||
const val HOME = "home" | ||
const val LOCATION_SELECTOR = "locationSelector" | ||
const val ABOUT = "about" | ||
|
||
@Composable | ||
fun Navigation() { | ||
val navController = rememberSwipeDismissableNavController() | ||
SwipeDismissableNavHost( | ||
navController = navController, | ||
startDestination = HOME, | ||
) { | ||
composable(HOME) { | ||
HomeScreen( | ||
navController = navController, | ||
viewModel = hiltViewModel(), | ||
) | ||
} | ||
composable(LOCATION_SELECTOR) { | ||
LocationSelectorScreen( | ||
navController = navController, | ||
viewModel = hiltViewModel() | ||
) | ||
} | ||
composable(ABOUT) { | ||
AboutScreen() | ||
} | ||
} | ||
} |
56 changes: 0 additions & 56 deletions
56
app/src/main/java/com/vsahin/praytimes/ui/about/AboutActivity.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.