"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:
Mojtaba Rahimy 2018-12-17 14:50:13 +03:30 committed by neslihanturan
parent 11e5c3c01a
commit f79456ec8e
14 changed files with 89 additions and 182 deletions

View file

@ -14,7 +14,7 @@ import butterknife.OnClick;
import butterknife.Optional;
public class WelcomePagerAdapter extends PagerAdapter {
static final int[] PAGE_LAYOUTS = new int[]{
private static final int[] PAGE_LAYOUTS = new int[]{
R.layout.welcome_wikipedia,
R.layout.welcome_do_upload,
R.layout.welcome_dont_upload,
@ -57,29 +57,31 @@ public class WelcomePagerAdapter extends PagerAdapter {
@Override
public Object instantiateItem(ViewGroup container, int position) {
this.container=container;
this.container = container;
LayoutInflater inflater = LayoutInflater.from(container.getContext());
ViewGroup layout = (ViewGroup) inflater.inflate(PAGE_LAYOUTS[position], container, false);
if (BuildConfig.FLAVOR == "beta") {
TextView textView = layout.findViewById(R.id.welcomeYesButton);
if (textView.getVisibility() != View.VISIBLE) {
textView.setVisibility(View.VISIBLE);
}
ViewHolder holder = new ViewHolder(layout);
layout.setTag(holder);
if (position == PAGE_FINAL){
TextView moreInfo = layout.findViewById(R.id.welcomeInfo);
moreInfo.setText(Html.fromHtml(WelcomeActivity.moreInformation));
ViewHolder holder1 = new ViewHolder(layout);
layout.setTag(holder1);
}
} else {
if (position == PAGE_FINAL) {
ViewHolder holder = new ViewHolder(layout);
layout.setTag(holder);
}
// If final page
if (position == PAGE_FINAL) {
// Add link to more information
TextView moreInfo = layout.findViewById(R.id.welcomeInfo);
moreInfo.setText(Html.fromHtml(WelcomeActivity.moreInformation));
moreInfo.setOnClickListener(view -> {
try {
Utils.handleWebUrl(
container.getContext(),
Uri.parse("https://commons.wikimedia.org/wiki/Help:Contents")
);
} catch (Exception e) {
e.printStackTrace();
}
});
// Handle click of finishTutorialButton ("YES!" button) inside layout
layout.findViewById(R.id.finishTutorialButton)
.setOnClickListener(view -> callback.finishTutorial());
}
container.addView(layout);
return layout;
}
@ -96,33 +98,6 @@ public class WelcomePagerAdapter extends PagerAdapter {
}
public interface Callback {
void onYesClicked();
}
class ViewHolder {
ViewHolder(View view) {
ButterKnife.bind(this, view);
}
/**
* Triggers on click callback on button click
*/
@OnClick(R.id.welcomeYesButton)
void onClicked() {
if (callback != null) {
callback.onYesClicked();
}
}
@Optional
@OnClick(R.id.welcomeInfo)
void onHelpClicked () {
try {
Utils.handleWebUrl(container.getContext(),Uri.parse("https://commons.wikimedia.org/wiki/Help:Contents" ));
} catch (Exception e) {
e.printStackTrace();
}
}
void finishTutorial();
}
}