Skip to content

Commit

Permalink
Improve sample theme and launcher icon
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavpandey committed Jun 17, 2022
1 parent 53cae7e commit 71d678f
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@

package com.pranavpandey.android.dynamic.support.sample.activity

import android.annotation.SuppressLint
import android.graphics.drawable.Animatable
import android.view.View
import androidx.appcompat.widget.AppCompatImageView
import com.pranavpandey.android.dynamic.support.Dynamic
import com.pranavpandey.android.dynamic.support.sample.R
import com.pranavpandey.android.dynamic.support.splash.activity.DynamicSplashActivity
import com.pranavpandey.android.dynamic.support.widget.base.DynamicWidget
import com.pranavpandey.android.dynamic.util.DynamicIntentUtils

/**
* Implementing a splash screen by using [DynamicSplashActivity].
*/
@SuppressLint("CustomSplashScreen")
class SplashActivity : DynamicSplashActivity() {

/**
Expand All @@ -49,6 +53,17 @@ class SplashActivity : DynamicSplashActivity() {
override fun onViewCreated(view: View) {
// TODO: Get any view reference here.
mSplash = view.findViewById(R.id.splash_image)

if (mSplash is DynamicWidget) {
// TODO: Tint views according to the background.
Dynamic.setContrastWithColor(mSplash, backgroundColor)
Dynamic.setContrastWithColor(
view.findViewById(R.id.splash_title) as DynamicWidget,
backgroundColor)
Dynamic.setContrastWithColor(
view.findViewById(R.id.splash_subtitle) as DynamicWidget,
backgroundColor)
}
}

override fun onPreSplash() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class TutorialActivity :
getString(R.string.tutorial_welcome),
getString(R.string.tutorial_welcome_subtitle),
getString(R.string.tutorial_welcome_desc),
R.drawable.ic_sample_splash, true))
R.drawable.ic_launcher_monochrome, true))

// TODO: Add another simple dynamic tutorial.
tutorials.add(DynamicTutorial(TUTORIAL_FINISH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class AboutFragment : DynamicViewPager2Fragment() {
override fun createFragment(position: Int): Fragment {
// TODO: Return view pager fragments.
return when (position) {
1 -> LicensesFragment.newInstance()
1 -> NoticeFragment.newInstance()
else -> AppInfoFragment.newInstance()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import com.pranavpandey.android.dynamic.support.sample.R
/**
* Licenses fragment to show license and by using [DynamicFragment].
*/
class LicensesFragment : DynamicFragment() {
class NoticeFragment : DynamicFragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
Expand All @@ -39,10 +39,10 @@ class LicensesFragment : DynamicFragment() {
/**
* Returns the new instance of this fragment.
*
* @return The new instance of [LicensesFragment].
* @return The new instance of [NoticeFragment].
*/
fun newInstance(): LicensesFragment {
return LicensesFragment()
fun newInstance(): NoticeFragment {
return NoticeFragment()
}
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:drawable="@drawable/ic_sample_splash"
android:drawable="@drawable/ic_launcher_monochrome"
tools:targetApi="lollipop">

<target
Expand Down
10 changes: 3 additions & 7 deletions sample/src/main/res/layout-land/activity_splash.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,17 @@
<com.pranavpandey.android.dynamic.support.widget.DynamicLinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/ads_margin_splash"
style="@style/Widget.DynamicApp.Content.Splash"
android:gravity="center"
android:orientation="horizontal"
app:adt_colorType="primary"
app:adt_backgroundAware="disable">
android:orientation="horizontal">

<com.pranavpandey.android.dynamic.support.widget.DynamicImageView
android:id="@+id/splash_image"
android:layout_width="@dimen/ads_icon_splash"
android:layout_height="@dimen/ads_icon_splash"
android:layout_margin="@dimen/ads_margin_splash_small"
android:layout_gravity="center"
app:srcCompat="@drawable/ic_sample_splash_animated"
app:srcCompat="@drawable/ic_launcher_monochrome_animated"
app:adt_colorType="tint_primary"
app:adt_contrastWithColorType="primary" />

Expand Down
8 changes: 2 additions & 6 deletions sample/src/main/res/layout/activity_splash.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
<com.pranavpandey.android.dynamic.support.widget.DynamicRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/ads_margin_splash"
app:adt_colorType="primary"
app:adt_backgroundAware="disable">
style="@style/Widget.DynamicApp.Content.Splash">

<com.pranavpandey.android.dynamic.support.widget.DynamicImageView
android:id="@+id/splash_image"
Expand All @@ -32,7 +28,7 @@
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
app:srcCompat="@drawable/ic_sample_splash_animated"
app:srcCompat="@drawable/ic_launcher_monochrome_animated"
app:adt_colorType="tint_primary"
app:adt_contrastWithColorType="primary" />

Expand Down
4 changes: 2 additions & 2 deletions sample/src/main/res/layout/layout_info_app.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
android:id="@+id/info_app"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:ads_icon="@drawable/ic_sample"
app:ads_iconBig="@drawable/ic_sample_splash"
app:ads_icon="@drawable/ic_launcher"
app:ads_iconBig="@drawable/ic_launcher_monochrome"
app:ads_title="@string/app_name"
app:ads_subtitle="@string/app_subtitle"
app:ads_description="@string/ads_info_made_in"
Expand Down
8 changes: 8 additions & 0 deletions sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@

</foreground>

<monochrome>

<inset
android:drawable="@drawable/ic_launcher_monochrome"
android:inset="@dimen/ads_inset_icon_launcher_huge" />

</monochrome>

</adaptive-icon>
3 changes: 3 additions & 0 deletions sample/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@
<!-- TODO: App theme accent color. -->
<color name="color_accent">#E91E63</color>

<!-- TODO: App theme default color. -->
<color name="app_default">@color/color_primary</color>

</resources>
8 changes: 7 additions & 1 deletion sample/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
limitations under the License.
-->

<resources>
<resources
xmlns:tools="http://schemas.android.com/tools"
tools:targetApi="s">

<!-- Dark theme -->
<style name="Sample" parent="Theme.DynamicApp">
<item name="android:windowBackground">@color/app_default</item>
<item name="android:windowSplashScreenAnimatedIcon">@mipmap/ads_ic_author_splash</item>
<item name="colorPrimary">@color/color_primary</item>
<item name="colorPrimaryDark">@color/color_primary_dark</item>
<item name="colorAccent">@color/color_accent</item>
Expand All @@ -27,6 +31,8 @@

<!-- Light theme -->
<style name="Sample.Light" parent="Theme.DynamicApp.Light">
<item name="android:windowBackground">@color/app_default</item>
<item name="android:windowSplashScreenAnimatedIcon">@mipmap/ads_ic_author_splash</item>
<item name="colorPrimary">@color/color_primary</item>
<item name="colorPrimaryDark">@color/color_primary_dark</item>
<item name="colorAccent">@color/color_accent</item>
Expand Down

0 comments on commit 71d678f

Please sign in to comment.