mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
"Skip Tutorial" button moved to parent view so that it does not animate by swipes. (#1945)
* Update WelcomeActivity.java Now it starts welcome screen after not finishing the pager. Moved "Skip Tutorial" button here so it does not animate by swipe. * Update activity_welcome.xml Putting "Skip Tutorial" button here so that it does not animate by swipes. * Update LoginActivity.java Removing the set of "first run " flag from here. we set it after the buttons press or on WelcomeActivity's finish() * Update welcome_do_upload.xml removing "skip tut" button from here. * Update welcome_dont_upload.xml Removing "Skip Tutorial" button from here so that it does not animate by swipes. * Update welcome_image_details.xml Removing "Skip Tutorial" button from here so that it does not animate by swipes. * Update welcome_wikipedia.xml Removing "Skip Tutorial" button from here so that it does not animate by swipes. * Update WelcomePagerAdapter.java the "welcomyesButton" is removed from the child views in pager, so it is optional now. * Add JavaDoc to WelcomeActivity.onBackPressed() * Fix #2103: Remove welcomeYesButton from landscape layout * Refactor WelcomePagerAdapter
This commit is contained in:
parent
11e5c3c01a
commit
f79456ec8e
14 changed files with 89 additions and 182 deletions
|
|
@ -2,20 +2,33 @@ package fr.free.nrw.commons;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.View;
|
||||
|
||||
import com.viewpagerindicator.CirclePageIndicator;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.Optional;
|
||||
import fr.free.nrw.commons.quiz.QuizActivity;
|
||||
import fr.free.nrw.commons.theme.BaseActivity;
|
||||
|
||||
public class WelcomeActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.welcomePager) ViewPager pager;
|
||||
@BindView(R.id.welcomePagerIndicator) CirclePageIndicator indicator;
|
||||
@Inject
|
||||
@Named("application_preferences")
|
||||
SharedPreferences prefs;
|
||||
|
||||
@BindView(R.id.welcomePager)
|
||||
ViewPager pager;
|
||||
@BindView(R.id.welcomePagerIndicator)
|
||||
CirclePageIndicator indicator;
|
||||
|
||||
private WelcomePagerAdapter adapter = new WelcomePagerAdapter();
|
||||
private boolean isQuiz;
|
||||
|
|
@ -38,15 +51,20 @@ public class WelcomeActivity extends BaseActivity {
|
|||
if (bundle != null) {
|
||||
isQuiz = bundle.getBoolean("isQuiz");
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
isQuiz = false;
|
||||
}
|
||||
|
||||
// Enable skip button if beta flavor
|
||||
if (BuildConfig.FLAVOR == "beta") {
|
||||
findViewById(R.id.finishTutorialButton).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
ButterKnife.bind(this);
|
||||
|
||||
pager.setAdapter(adapter);
|
||||
indicator.setViewPager(pager);
|
||||
adapter.setCallback(this::finish);
|
||||
adapter.setCallback(this::finishTutorial);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -54,7 +72,7 @@ public class WelcomeActivity extends BaseActivity {
|
|||
*/
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (isQuiz){
|
||||
if (isQuiz) {
|
||||
Intent i = new Intent(WelcomeActivity.this, QuizActivity.class);
|
||||
startActivity(i);
|
||||
}
|
||||
|
|
@ -71,4 +89,22 @@ public class WelcomeActivity extends BaseActivity {
|
|||
Intent welcomeIntent = new Intent(context, WelcomeActivity.class);
|
||||
context.startActivity(welcomeIntent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override onBackPressed() to go to previous tutorial 'pages' if not on first page
|
||||
*/
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (pager.getCurrentItem() != 0) {
|
||||
pager.setCurrentItem(pager.getCurrentItem() - 1, true);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.finishTutorialButton)
|
||||
public void finishTutorial() {
|
||||
prefs.edit().putBoolean("firstrun", false).apply();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue