-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
223 changed files
with
9,333 additions
and
2,007 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
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
Binary file not shown.
Binary file not shown.
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
41 changes: 41 additions & 0 deletions
41
app/src/main/java/com/dede/android_eggs/main/AppBarExpandedState.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,41 @@ | ||
package com.dede.android_eggs.main | ||
|
||
import android.app.Activity | ||
import android.os.Bundle | ||
import androidx.annotation.IdRes | ||
import com.google.android.material.appbar.AppBarLayout | ||
|
||
/** | ||
* Fix AppBarLayout Expanded state error | ||
*/ | ||
class AppBarExpandedState( | ||
private val activity: Activity, | ||
@IdRes private val id: Int, | ||
private val animate: Boolean = false, | ||
private val default: Boolean = true, | ||
) : AppBarLayout.OnOffsetChangedListener { | ||
|
||
companion object { | ||
private const val STATE_KEY = "appbar_expanded_state" | ||
} | ||
|
||
private lateinit var appBarLayout: AppBarLayout | ||
private var isExpanded: Boolean = default | ||
|
||
fun restore(savedInstanceState: Bundle?) { | ||
appBarLayout = activity.findViewById(id) | ||
appBarLayout.addOnOffsetChangedListener(this) | ||
if (savedInstanceState != null) { | ||
isExpanded = savedInstanceState.getBoolean(STATE_KEY, default) | ||
} | ||
appBarLayout.setExpanded(isExpanded, animate) | ||
} | ||
|
||
fun saveState(outState: Bundle) { | ||
outState.putBoolean(STATE_KEY, isExpanded) | ||
} | ||
|
||
override fun onOffsetChanged(appBarLayout: AppBarLayout?, verticalOffset: Int) { | ||
isExpanded = verticalOffset >= 0 | ||
} | ||
} |
71 changes: 20 additions & 51 deletions
71
app/src/main/java/com/dede/android_eggs/main/EasterEggsActivity.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,71 +1,40 @@ | ||
package com.dede.android_eggs.main | ||
|
||
import android.animation.ObjectAnimator | ||
import android.content.res.Configuration | ||
import android.os.Build | ||
import android.os.Bundle | ||
import android.view.Menu | ||
import android.view.MenuInflater | ||
import android.view.MenuItem | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.view.MenuProvider | ||
import by.kirich1409.viewbindingdelegate.viewBinding | ||
import com.dede.android_eggs.R | ||
import com.dede.android_eggs.settings.SettingsFragment | ||
import com.dede.android_eggs.ui.FontIconsDrawable | ||
import com.dede.android_eggs.util.WindowEdgeUtilsAccessor | ||
import com.google.android.material.color.DynamicColors | ||
import com.google.android.material.R as M3R | ||
import com.dede.android_eggs.databinding.ActivityEasterEggsBinding | ||
import com.dede.android_eggs.settings.EdgePref | ||
import com.dede.android_eggs.settings.SettingsPageController | ||
|
||
/** | ||
* Easter Egg Collection | ||
*/ | ||
class EasterEggsActivity : AppCompatActivity(), MenuProvider { | ||
class EasterEggsActivity : AppCompatActivity(R.layout.activity_easter_eggs) { | ||
|
||
private val navigationViewController = NavigationViewController(this) | ||
private val settingsPageController = SettingsPageController(this) | ||
private val binding: ActivityEasterEggsBinding by viewBinding(ActivityEasterEggsBinding::bind) | ||
|
||
private val appBarExpandedState = AppBarExpandedState(this, R.id.app_bar) | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
EdgePref.applyEdge(this, window) | ||
|
||
DynamicColors.applyToActivityIfAvailable(this) | ||
WindowEdgeUtilsAccessor.applyEdgeToEdge(window, true) | ||
|
||
navigationViewController.setContentView() | ||
|
||
addMenuProvider(this, this) | ||
} | ||
|
||
override fun onConfigurationChanged(newConfig: Configuration) { | ||
super.onConfigurationChanged(newConfig) | ||
navigationViewController.onConfigurationChanged(newConfig) | ||
} | ||
|
||
override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
return navigationViewController.onOptionsItemSelected(item) || | ||
super.onOptionsItemSelected(item) | ||
} | ||
setSupportActionBar(binding.toolbar) | ||
|
||
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { | ||
menuInflater.inflate(R.menu.menu_settings, menu) | ||
menu.findItem(R.id.menu_settings).icon = | ||
FontIconsDrawable(this, "\ue8b8", M3R.attr.actionMenuTextColor, 24f) | ||
settingsPageController.onCreate(savedInstanceState) | ||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { | ||
EasterEggsSplash(this).welcome() | ||
} | ||
appBarExpandedState.restore(savedInstanceState) | ||
} | ||
|
||
override fun onMenuItemSelected(menuItem: MenuItem): Boolean { | ||
when (menuItem.itemId) { | ||
R.id.menu_settings -> { | ||
val icon = menuItem.icon as FontIconsDrawable | ||
SettingsFragment().apply { | ||
onSlide = { | ||
icon.setRotate(360f * it) | ||
} | ||
show(supportFragmentManager, "Settings") | ||
} | ||
ObjectAnimator.ofFloat(icon, "rotate", 0f, 360f) | ||
.setDuration(500) | ||
.start() | ||
} | ||
else -> return false | ||
} | ||
return true | ||
override fun onSaveInstanceState(outState: Bundle) { | ||
appBarExpandedState.saveState(outState) | ||
super.onSaveInstanceState(outState) | ||
} | ||
|
||
} |
88 changes: 0 additions & 88 deletions
88
app/src/main/java/com/dede/android_eggs/main/EasterEggsFragment.kt
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
Oops, something went wrong.