Bug 48995: Add acceptable use 'tutorial' to app

Initial port of the acceptable use tutorial from iOS app. This version uses static images and is not yet animated. Indicator circles on the pager are done using Apache-licensed https://github.com/JakeWharton/Android-ViewPagerIndicator -- imported via maven. Currently the tutorial launches when we reach the login screen (as when first installing the app or creating a new account from system settings). You can either 'back' out of it or page through and hit the 'yes' button.

GitHub: https://github.com/wikimedia/apps-android-commons/pull/20
Change-Id: Ibc444102e28a55bfa7bbae601ff0c56268a0c7dd
This commit is contained in:
Brion Vibber 2013-06-24 20:43:35 +00:00
parent d1ee62d08c
commit 6c97d3e01b
23 changed files with 429 additions and 4 deletions

View file

@ -0,0 +1,68 @@
package org.wikimedia.commons;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.viewpagerindicator.CirclePageIndicator;
public class WelcomeActivity extends Activity {
static final int PAGE_WIKIPEDIA = 0,
PAGE_COPYRIGHT = 1,
PAGE_FINAL = 2;
static final int[] pageLayouts = new int[] {
R.layout.welcome_wikipedia,
R.layout.welcome_copyright,
R.layout.welcome_final
};
private ViewPager pager;
private Button yesButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
pager = (ViewPager)findViewById(R.id.welcomePager);
pager.setAdapter(new PagerAdapter() {
@Override
public int getCount() {
return pageLayouts.length;
}
@Override
public boolean isViewFromObject(View view, Object o) {
return (view == o);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
View view = getLayoutInflater().inflate(pageLayouts[position], null);
container.addView(view);
if (position == PAGE_FINAL) {
yesButton = (Button)view.findViewById(R.id.welcomeYesButton);
yesButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
finish();
}
});
}
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object obj) {
yesButton = null;
container.removeView((View)obj);
}
});
CirclePageIndicator indicator = (CirclePageIndicator)findViewById(R.id.welcomePagerIndicator);
indicator.setViewPager(pager);
}
}

View file

@ -168,6 +168,11 @@ public class LoginActivity extends AccountAuthenticatorActivity {
that.performLogin();
}
});
if (savedInstanceState == null) {
Intent welcomeIntent = new Intent(this, WelcomeActivity.class);
startActivity(welcomeIntent);
}
}
private void performLogin() {

View file

@ -256,6 +256,7 @@ public class ContributionsListFragment extends SherlockFragment {
feedbackIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { CommonsApplication.FEEDBACK_EMAIL });
feedbackIntent.putExtra(Intent.EXTRA_SUBJECT, String.format(CommonsApplication.FEEDBACK_EMAIL_SUBJECT, CommonsApplication.APPLICATION_VERSION));
startActivity(feedbackIntent);
return true;
default:
return super.onOptionsItemSelected(item);