-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from lucasnlm/add-themes-feature
Add themes feature
- Loading branch information
Showing
59 changed files
with
973 additions
and
437 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 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
43 changes: 43 additions & 0 deletions
43
app/src/main/java/dev/lucasnlm/antimine/ThematicActivity.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,43 @@ | ||
package dev.lucasnlm.antimine | ||
|
||
import android.os.Bundle | ||
import androidx.annotation.LayoutRes | ||
import androidx.appcompat.app.AppCompatActivity | ||
import dev.lucasnlm.antimine.core.themes.model.AppTheme | ||
import dev.lucasnlm.antimine.core.themes.repository.IThemeRepository | ||
import javax.inject.Inject | ||
|
||
open class ThematicActivity : AppCompatActivity { | ||
constructor() : super() | ||
constructor(@LayoutRes contentLayoutId: Int) : super(contentLayoutId) | ||
|
||
@Inject | ||
lateinit var themeRepository: IThemeRepository | ||
|
||
protected open val noActionBar: Boolean = false | ||
|
||
protected val usingTheme: AppTheme by lazy { | ||
currentTheme() | ||
} | ||
|
||
private fun currentTheme() = themeRepository.getTheme() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
themeRepository.getCustomTheme()?.let { | ||
if (noActionBar) { | ||
setTheme(it.themeNoActionBar) | ||
} else { | ||
setTheme(it.theme) | ||
} | ||
} | ||
super.onCreate(savedInstanceState) | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
|
||
if (usingTheme.id != currentTheme().id) { | ||
recreate() | ||
} | ||
} | ||
} |
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
Oops, something went wrong.