Spaces:
Paused
Paused
ML Intern deploy
Deploy httpSMS gateway to Hugging Face Spaces (Docker SDK): nginx :7860 -> Go API :8000, Nuxt SPA, Android APK, bootstrap-mode entrypoint
83a59ca Download android/app/src/main/java/com/httpsms/SettingsActivity.kt from red-kit/httpsms-gateway: direct link, hf CLI and curl.
- Browser
- Download file 2.14 kB
-
https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/6917738ca6db1603dee9e07994b4e42d5e1ae9b2/android/app/src/main/java/com/httpsms/SettingsActivity.kt
- Command line
-
hf download hf://spaces/red-kit/httpsms-gateway@6917738ca6db1603dee9e07994b4e42d5e1ae9b2/android/app/src/main/java/com/httpsms/SettingsActivity.kt
-
curl -L -o SettingsActivity.kt https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/6917738ca6db1603dee9e07994b4e42d5e1ae9b2/android/app/src/main/java/com/httpsms/SettingsActivity.kt
2.14 kB
| package com.httpsms | |
| import android.content.Intent | |
| import android.os.Bundle | |
| import androidx.activity.compose.setContent | |
| import androidx.activity.viewModels | |
| import androidx.appcompat.app.AppCompatActivity | |
| import com.google.android.material.dialog.MaterialAlertDialogBuilder | |
| import com.httpsms.ui.settings.SettingsScreen | |
| import com.httpsms.ui.settings.SettingsViewModel | |
| import com.httpsms.ui.theme.HttpSmsTheme | |
| import timber.log.Timber | |
| class SettingsActivity : AppCompatActivity() { | |
| private val viewModel: SettingsViewModel by viewModels() | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| viewModel.initialize(this) | |
| setContent { | |
| HttpSmsTheme { | |
| SettingsScreen( | |
| viewModel = viewModel, | |
| onBackClick = { onBackClicked() }, | |
| onLogoutClick = { onLogoutClick() } | |
| ) | |
| } | |
| } | |
| } | |
| private fun onBackClicked() { | |
| Timber.d("back button clicked") | |
| redirectToMain() | |
| } | |
| private fun redirectToMain() { | |
| finish() | |
| val switchActivityIntent = Intent(this, MainActivity::class.java) | |
| startActivity(switchActivityIntent) | |
| } | |
| private fun onLogoutClick() { | |
| Timber.d("logout button clicked") | |
| MaterialAlertDialogBuilder(this) | |
| .setTitle("Confirm") | |
| .setMessage("Are you sure you want to logout of the httpSMS App?") | |
| .setNeutralButton("Cancel"){ _, _ -> Timber.d("logout dialog canceled") } | |
| .setPositiveButton("Logout"){_, _ -> | |
| Timber.d("logging out user") | |
| viewModel.logout(this) { | |
| redirectToLogin() | |
| } | |
| } | |
| .show() | |
| } | |
| private fun redirectToLogin():Boolean { | |
| if (Settings.isLoggedIn(this)) { | |
| return false | |
| } | |
| val switchActivityIntent = Intent(this, LoginActivity::class.java) | |
| startActivity(switchActivityIntent) | |
| return true | |
| } | |
| } | |