Move askForComprehensive from DrugListActivity.java to WelcomeActivity.java

This commit is contained in:
jacques 2023-01-10 12:09:21 +01:00
parent e9f5a373bb
commit 13453ff7e4

View file

@ -16,6 +16,7 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.PagerAdapter;
@ -74,6 +75,12 @@ public class WelcomeActivity extends AppCompatActivity {
} }
prefManager.setFirstTimeLaunch(false); prefManager.setFirstTimeLaunch(false);
if (!prefManager.isUnderstood()) {
askForComprehensive();
prefManager.setUnderstood(true);
}
setContentView(R.layout.welcome_activity); setContentView(R.layout.welcome_activity);
setFullScreen(); setFullScreen();
@ -110,16 +117,9 @@ public class WelcomeActivity extends AppCompatActivity {
viewPager.setAdapter(myViewPagerAdapter); viewPager.setAdapter(myViewPagerAdapter);
viewPager.addOnPageChangeListener(viewPagerPageChangeListener); viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
btnSkip.setOnClickListener(new View.OnClickListener() { btnSkip.setOnClickListener(v -> launchHomeScreen());
@Override
public void onClick(View v) {
launchHomeScreen();
}
});
btnNext.setOnClickListener(new View.OnClickListener() { btnNext.setOnClickListener(v -> {
@Override
public void onClick(View v) {
// checking for last page // checking for last page
// if last page home screen will be launched // if last page home screen will be launched
int current = getItem(); int current = getItem();
@ -130,10 +130,20 @@ public class WelcomeActivity extends AppCompatActivity {
} else { } else {
launchHomeScreen(); 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) { private void addBottomDots(int currentPage) {
TextView[] dots = new TextView[layouts.length]; TextView[] dots = new TextView[layouts.length];
@ -220,7 +230,7 @@ public class WelcomeActivity extends AppCompatActivity {
@Override @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; View view = (View) object;
container.removeView(view); container.removeView(view);
} }