mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-30 06:13:54 +01:00
* Quiz (#1629) * Layout inflated * Layout for mcq added * Inflated Basic Layout * Implemented basic flow * Added the basic implementation pf score * Added the result layout * Added the result layout * Added functionality to set result * Changed the launcher intent to Quiz Activity for testing purpose * Explanations of answers added * Improved the layout of quiz result a bit * Fixed some minor issues * Fixed build issues * Api Added and basic structure for calling implemented * Added intents * Added the title * Fixed image error and improved quality of pr * Made separate class for checking quiz * Added counter * Implemented back and next for quiz result * Added back functionality to quiz * Added progressBar * Fixed bugs * Improved code quality * Imporved code Quality * Updated strings * Added share screenshot function * Added checks and improved UI * Removed unused string * Removed unused string * Adding checks and improving code quality * Changed string * Improved code quality * Update strings.xml * Update MediaWikiApi.java * Fix build
71 lines
2 KiB
Java
71 lines
2 KiB
Java
package fr.free.nrw.commons;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.support.v4.view.ViewPager;
|
|
|
|
import com.viewpagerindicator.CirclePageIndicator;
|
|
|
|
import butterknife.BindView;
|
|
import butterknife.ButterKnife;
|
|
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;
|
|
|
|
private WelcomePagerAdapter adapter = new WelcomePagerAdapter();
|
|
private boolean isQuiz;
|
|
|
|
/**
|
|
* Initialises exiting fields and dependencies
|
|
*
|
|
* @param savedInstanceState WelcomeActivity bundled data
|
|
*/
|
|
@Override
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.activity_welcome);
|
|
|
|
if(getIntent() != null) {
|
|
Bundle bundle = getIntent().getExtras();
|
|
if (bundle != null) {
|
|
isQuiz = bundle.getBoolean("isQuiz");
|
|
}
|
|
} else{
|
|
isQuiz = false;
|
|
}
|
|
|
|
ButterKnife.bind(this);
|
|
|
|
pager.setAdapter(adapter);
|
|
indicator.setViewPager(pager);
|
|
adapter.setCallback(this::finish);
|
|
}
|
|
|
|
/**
|
|
* References WelcomePageAdapter to null before the activity is destroyed
|
|
*/
|
|
@Override
|
|
public void onDestroy() {
|
|
if(isQuiz){
|
|
Intent i = new Intent(WelcomeActivity.this, QuizActivity.class);
|
|
startActivity(i);
|
|
}
|
|
adapter.setCallback(null);
|
|
super.onDestroy();
|
|
}
|
|
|
|
/**
|
|
* Creates a way to change current activity to WelcomeActivity
|
|
*
|
|
* @param context Activity context
|
|
*/
|
|
public static void startYourself(Context context) {
|
|
Intent welcomeIntent = new Intent(context, WelcomeActivity.class);
|
|
context.startActivity(welcomeIntent);
|
|
}
|
|
}
|