-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
1 parent
dbf1ff5
commit ab74947
Showing
32 changed files
with
157 additions
and
625 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
24 changes: 24 additions & 0 deletions
24
.../ui/src/main/java/info/nightscout/core/ui/activities/TranslatedDaggerAppCompatActivity.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 |
---|---|---|
@@ -1,11 +1,35 @@ | ||
package info.nightscout.core.ui.activities | ||
|
||
import android.content.Context | ||
import android.os.Bundle | ||
import android.view.Menu | ||
import android.view.MenuInflater | ||
import android.view.MenuItem | ||
import androidx.core.view.MenuProvider | ||
import dagger.android.support.DaggerAppCompatActivity | ||
import info.nightscout.core.ui.locale.LocaleHelper | ||
|
||
open class TranslatedDaggerAppCompatActivity : DaggerAppCompatActivity() { | ||
override fun attachBaseContext(newBase: Context) { | ||
super.attachBaseContext(LocaleHelper.wrap(newBase)) | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
// Add menu items without overriding methods in the Activity | ||
addMenuProvider(object : MenuProvider { | ||
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {} | ||
|
||
override fun onMenuItemSelected(menuItem: MenuItem): Boolean = | ||
when (menuItem.itemId) { | ||
android.R.id.home -> { | ||
onBackPressedDispatcher.onBackPressed() | ||
true | ||
} | ||
|
||
else -> false | ||
} | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.