From 13453ff7e48ed39aef5e24b903450d8ca4b94902 Mon Sep 17 00:00:00 2001 From: jacques Date: Tue, 10 Jan 2023 12:09:21 +0100 Subject: [PATCH] Move askForComprehensive from DrugListActivity.java to WelcomeActivity.java --- .../net/foucry/pilldroid/WelcomeActivity.java | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/net/foucry/pilldroid/WelcomeActivity.java b/app/src/main/java/net/foucry/pilldroid/WelcomeActivity.java index 9cc4f3a..81deed7 100644 --- a/app/src/main/java/net/foucry/pilldroid/WelcomeActivity.java +++ b/app/src/main/java/net/foucry/pilldroid/WelcomeActivity.java @@ -16,6 +16,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.ContextCompat; import androidx.viewpager.widget.PagerAdapter; @@ -74,6 +75,12 @@ public class WelcomeActivity extends AppCompatActivity { } prefManager.setFirstTimeLaunch(false); + + if (!prefManager.isUnderstood()) { + askForComprehensive(); + prefManager.setUnderstood(true); + } + setContentView(R.layout.welcome_activity); setFullScreen(); @@ -110,28 +117,31 @@ public class WelcomeActivity extends AppCompatActivity { viewPager.setAdapter(myViewPagerAdapter); viewPager.addOnPageChangeListener(viewPagerPageChangeListener); - btnSkip.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { + btnSkip.setOnClickListener(v -> launchHomeScreen()); + + btnNext.setOnClickListener(v -> { + // checking for last page + // if last page home screen will be launched + int current = getItem(); + if (current < layouts.length) { + // move to next screen + viewPager.setCurrentItem(current); + overridePendingTransition(R.anim.slide_from_left, R.anim.slide_to_right); + } else { launchHomeScreen(); } }); + } - btnNext.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - // checking for last page - // if last page home screen will be launched - int current = getItem(); - if (current < layouts.length) { - // move to next screen - viewPager.setCurrentItem(current); - overridePendingTransition(R.anim.slide_from_left, R.anim.slide_to_right); - } else { - launchHomeScreen(); - } - } + private void askForComprehensive() { + AlertDialog.Builder dlg = new AlertDialog.Builder(this); + dlg.setTitle(getString(R.string.app_name)); + + dlg.setMessage(R.string.understood); + dlg.setPositiveButton(R.string.Yes, (dialog, which) -> { + // Nothing to do just dismiss dialog }); + dlg.show(); } private void addBottomDots(int currentPage) { @@ -220,7 +230,7 @@ public class WelcomeActivity extends AppCompatActivity { @Override - public void destroyItem(ViewGroup container, int position, @NonNull Object object) { + public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { View view = (View) object; container.removeView(view); }