mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
* Unused class removed * Convert BasePresenter to kotlin * Removed redundent class * Move the Utils class into the utils package * Inline the creation of a page title object * Move license utilities into their own file * Inline app rating since its only ever used in 1 place * Moved GeoCoordinates utilities into their own class * Moved Monuments related utils into their own class * Moved screen capture into its own util class * Moved handleWebUrl to its own utility class * Moved fixExtension to its own class * Moved clipboard copy into its own utility class * Renames class to match remaining utility method * Convert UnderlineUtils to kotlin * Converted the copy-to-clipboard utility to kotlin * Converted license name and url lookup to kotlin * Converted fixExtension to kotlin * Convert handleGeoCoordinates to kotlin * Monument utils converted to kotlin * Convert then inline screeen capture in kotlin * Convert handleWebUrl to kotlin
77 lines
2.5 KiB
Java
77 lines
2.5 KiB
Java
package fr.free.nrw.commons;
|
|
|
|
import static fr.free.nrw.commons.utils.UrlUtilsKt.handleWebUrl;
|
|
|
|
import android.net.Uri;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.TextView;
|
|
|
|
import androidx.viewpager.widget.PagerAdapter;
|
|
import fr.free.nrw.commons.utils.UnderlineUtils;
|
|
|
|
public class WelcomePagerAdapter extends PagerAdapter {
|
|
private static final int[] PAGE_LAYOUTS = new int[]{
|
|
R.layout.welcome_wikipedia,
|
|
R.layout.welcome_do_upload,
|
|
R.layout.welcome_dont_upload,
|
|
R.layout.welcome_image_example,
|
|
R.layout.welcome_final
|
|
};
|
|
|
|
/**
|
|
* Gets total number of layouts
|
|
* @return Number of layouts
|
|
*/
|
|
@Override
|
|
public int getCount() {
|
|
return PAGE_LAYOUTS.length;
|
|
}
|
|
|
|
/**
|
|
* Compares given view with provided object
|
|
* @param view Adapter view
|
|
* @param object Adapter object
|
|
* @return Equality between view and object
|
|
*/
|
|
@Override
|
|
public boolean isViewFromObject(View view, Object object) {
|
|
return (view == object);
|
|
}
|
|
|
|
@Override
|
|
public Object instantiateItem(ViewGroup container, int position) {
|
|
LayoutInflater inflater = LayoutInflater.from(container.getContext());
|
|
ViewGroup layout = (ViewGroup) inflater.inflate(PAGE_LAYOUTS[position], container, false);
|
|
|
|
// If final page
|
|
if (position == PAGE_LAYOUTS.length - 1) {
|
|
// Add link to more information
|
|
TextView moreInfo = layout.findViewById(R.id.welcomeInfo);
|
|
UnderlineUtils.setUnderlinedText(moreInfo, R.string.welcome_help_button_text);
|
|
moreInfo.setOnClickListener(view -> handleWebUrl(
|
|
container.getContext(),
|
|
Uri.parse("https://commons.wikimedia.org/wiki/Help:Contents")
|
|
));
|
|
|
|
// Handle click of finishTutorialButton ("YES!" button) inside layout
|
|
layout.findViewById(R.id.finishTutorialButton)
|
|
.setOnClickListener(view -> ((WelcomeActivity) container.getContext()).finishTutorial());
|
|
}
|
|
|
|
container.addView(layout);
|
|
return layout;
|
|
}
|
|
|
|
/**
|
|
* Provides a way to remove an item from container
|
|
* @param container Adapter view group container
|
|
* @param position Index of item
|
|
* @param obj Adapter object
|
|
*/
|
|
@Override
|
|
public void destroyItem(ViewGroup container, int position, Object obj) {
|
|
container.removeView((View) obj);
|
|
}
|
|
}
|