diff --git a/.travis.yml b/.travis.yml index 98e8172..b8166d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,26 @@ language: android -script: - - ./gradlew assembleDebug +jdk: oraclejdk7 android: components: + - build-tools-22.0.1 + - android-22 - extra-android-m2repository - - build-tools-21.1.2 + - sys-img-armeabi-v7a-android-21 + licenses: - - android-sdk-license-.+ \ No newline at end of file + - 'android-sdk-license-.+' +env: + global: + - ADB_INSTALL_TIMEOUT=8 + +# Emulator Management: Create, Start and Wait +before_script: + - echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a + - emulator -avd test -no-skin -no-audio -no-window & + - android-wait-for-emulator + - adb shell input keyevent 82 & + +script: + - android list target + - ./gradlew assembleDebug diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 24f35b7..ff8303a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -88,6 +88,16 @@ android:name="android.support.PARENT_ACTIVITY" android:value="com.kanshu.kanshu.SignupActivity" /> + + + + - + \ No newline at end of file diff --git a/app/src/main/ic_check_white-web.png b/app/src/main/ic_check_white-web.png new file mode 100644 index 0000000..4ac9352 Binary files /dev/null and b/app/src/main/ic_check_white-web.png differ diff --git a/app/src/main/java/com/kanshu/kanshu/DevelopmentActivity.java b/app/src/main/java/com/kanshu/kanshu/DevelopmentActivity.java index 7b71d8c..7d365f4 100644 --- a/app/src/main/java/com/kanshu/kanshu/DevelopmentActivity.java +++ b/app/src/main/java/com/kanshu/kanshu/DevelopmentActivity.java @@ -50,4 +50,7 @@ public void onFeedbackActivity(View view) { public void onSettingsActivity(View view) { startActivity(new Intent(this, SettingsActivity.class)); } -} + public void onFlashCardActivity(View view) { + startActivity(new Intent(this, FlashCardExerciseActivity.class)); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java b/app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java new file mode 100644 index 0000000..0d5f347 --- /dev/null +++ b/app/src/main/java/com/kanshu/kanshu/ExerciseOptionsListFragment.java @@ -0,0 +1,99 @@ +package com.kanshu.kanshu; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.kanshu.kanshu.model.FlashcardExerciseOption; +import com.kanshu.kanshu.widget.SimpleDividerItemDecoration; + +import java.util.ArrayList; +import java.util.List; + +import com.kanshu.kanshu.FlashCardExerciseAdapter.OnItemClickListener; + +/** + * Created by alouanemed on 17-02-2015. + */ + + +public class ExerciseOptionsListFragment extends Fragment { + private RecyclerView mRecyclerView; + private RecyclerView.Adapter mAdapter; + private LinearLayoutManager mLayoutManager; + /** + * The fragment argument representing the section number for this + * fragment. + */ + private static final String ARG_SECTION_NUMBER = "section_number"; + + /** + * Returns a new instance of this fragment for the given section + * number. + */ + public static ExerciseOptionsListFragment newInstance(int sectionNumber) { + ExerciseOptionsListFragment fragment = new ExerciseOptionsListFragment(); + Bundle args = new Bundle(); + args.putInt(ARG_SECTION_NUMBER, sectionNumber); + fragment.setArguments(args); + return fragment; + } + + public ExerciseOptionsListFragment() {} + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_flashcard_exercise, container, false); + mRecyclerView = (RecyclerView) rootView.findViewById(R.id.my_recycler_view); + mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity())); + + LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); + layoutManager.setOrientation(LinearLayoutManager.VERTICAL); + mRecyclerView.setHasFixedSize(true); + mRecyclerView.setLayoutManager(layoutManager); + + //@todo use the real data to replace dummy data + final List mFlashcardExerciseOptions = new ArrayList(); + mFlashcardExerciseOptions.add(new FlashcardExerciseOption("Airplane",false)); + mFlashcardExerciseOptions.add(new FlashcardExerciseOption("You",false)); + mFlashcardExerciseOptions.add(new FlashcardExerciseOption("Car",true)); + mFlashcardExerciseOptions.add(new FlashcardExerciseOption("Person",false)); + mFlashcardExerciseOptions.add(new FlashcardExerciseOption("Asm",false)); + mFlashcardExerciseOptions.add(new FlashcardExerciseOption("Git",false)); + mFlashcardExerciseOptions.add(new FlashcardExerciseOption("Afourer",false)); + + + // specify an adapter + mAdapter = new FlashCardExerciseAdapter(mFlashcardExerciseOptions); + mRecyclerView.setAdapter(mAdapter); + + ((FlashCardExerciseAdapter)mAdapter).SetOnItemClickListener(new OnItemClickListener() { + View vHelper; + @Override + public void onItemClick(View v , int position) { + vHelper = v; + System.out.println("clicked pos :>" + position); + FlashCardExerciseAdapter.ViewHolder holder = (FlashCardExerciseAdapter.ViewHolder )(v.getTag()); + if (mFlashcardExerciseOptions.get(position).isCorrect_answer()){ + //holder.correctOptionIV.setVisibility(View.VISIBLE); + //holder.wrongOptionIV.setVisibility(View.GONE); + vHelper.setBackgroundColor(getResources().getColor(R.color.white)); + v.setBackgroundColor(getResources().getColor(R.color.correct_answer_green)); + }else{ + vHelper.setBackgroundColor(getResources().getColor(R.color.white)); + v.setBackgroundColor(getResources().getColor(R.color.primary_light_red)); + //holder.wrongOptionIV.setVisibility(View.VISIBLE); + //holder.correctOptionIV.setVisibility(View.GONE); + } + + } + }); + return rootView; + } + +} diff --git a/app/src/main/java/com/kanshu/kanshu/FlashCardExerciseActivity.java b/app/src/main/java/com/kanshu/kanshu/FlashCardExerciseActivity.java new file mode 100644 index 0000000..c8513b5 --- /dev/null +++ b/app/src/main/java/com/kanshu/kanshu/FlashCardExerciseActivity.java @@ -0,0 +1,158 @@ +package com.kanshu.kanshu; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentStatePagerAdapter; +import android.support.v4.view.ViewPager; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.widget.Toolbar; +import android.view.Menu; +import android.view.MenuItem; + +import com.kanshu.kanshu.model.User; + + +/** + * Created by alouanemed on 17-02-2015. + */ +public class FlashCardExerciseActivity extends BaseActivity + implements NavigationDrawerFragment.NavigationDrawerCallbacks, + NavigationDrawerFragment.NavigationDrawerData { + + /** + * Fragment managing the behaviors, interactions and presentation of the navigation drawer. + */ + private NavigationDrawerFragment mNavigationDrawerFragment; + private SlidingTabLayout mSlidingTabLayout; + private FlashCardPagerAdapter mFlashCardPagerAdapter; + private ViewPager mViewPager; + private Toolbar mToolbar; + private User mCurrentUser; + + /** + * Used to store the last screen title. For use in {@link #restoreActionBar()}. + */ + private CharSequence mTitle; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + if (getIntent().hasExtra("user")) { + mCurrentUser = getIntent().getExtras().getParcelable("user"); + } + if (mCurrentUser == null) { + mCurrentUser = new User("name", "level"); + } + + //set custom toolbar + mToolbar = (Toolbar) findViewById(R.id.toolbar); + if (mToolbar != null) { + setSupportActionBar(mToolbar); + } + + mNavigationDrawerFragment = (NavigationDrawerFragment) + getSupportFragmentManager().findFragmentById(R.id.navigation_drawer); + mTitle = getTitle(); + + // Set up the drawer. + mNavigationDrawerFragment.setUp( + R.id.navigation_drawer, + (DrawerLayout) findViewById(R.id.drawer_layout)); + + //Set up the pager + mFlashCardPagerAdapter = + new FlashCardPagerAdapter( + getSupportFragmentManager()); + mViewPager = (ViewPager) findViewById(R.id.pager); + mViewPager.setAdapter(mFlashCardPagerAdapter); + mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs); + mSlidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.white)); + mSlidingTabLayout.setViewPager(mViewPager); + } + + @Override + public void onNavigationDrawerItemSelected(int position) { + } + + public void onSectionAttached(int number) { + switch (number) { + case 1: + mTitle = getString(R.string.title_section1); + break; + case 2: + mTitle = getString(R.string.title_section2); + break; + case 3: + mTitle = getString(R.string.title_section3); + break; + } + } + + public void restoreActionBar() { + mToolbar.setTitle(mTitle); + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + if (!mNavigationDrawerFragment.isDrawerOpen()) { + // Only show items in the action bar relevant to this screen + // if the drawer is not showing. Otherwise, let the drawer + // decide what to show in the action bar. + getMenuInflater().inflate(R.menu.global, menu); + restoreActionBar(); + return true; + } + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + + @Override + public User getCurrentUser() { + return mCurrentUser; + } + + + public class FlashCardPagerAdapter extends FragmentStatePagerAdapter { + + //the list of titles of pages + private String[] pageTitles = {"Flashcard Exercise"}; + + public FlashCardPagerAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public Fragment getItem(int i) { + Fragment fragment = new ExerciseOptionsListFragment(); + return fragment; + } + + @Override + public int getCount() { + return pageTitles.length; + } + + @Override + public CharSequence getPageTitle(int position) { + return pageTitles[position]; + } + } + +} diff --git a/app/src/main/java/com/kanshu/kanshu/FlashCardExerciseAdapter.java b/app/src/main/java/com/kanshu/kanshu/FlashCardExerciseAdapter.java new file mode 100644 index 0000000..1e71dc9 --- /dev/null +++ b/app/src/main/java/com/kanshu/kanshu/FlashCardExerciseAdapter.java @@ -0,0 +1,95 @@ +package com.kanshu.kanshu; + +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import com.kanshu.kanshu.model.FlashcardExerciseOption; + +import java.util.List; + + +/** + * Created by alouanemed on 17-02-2015. + */ + +public class FlashCardExerciseAdapter extends RecyclerView.Adapter { + + private List flashcardExerciseOptionsList; + OnItemClickListener mItemClickListener; + + // Provide a reference to the views for each data item + // Complex data items may need more than one view per item, and + // you provide access to all the views for a data item in a view holder + public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ + public TextView optionNbTV; + public TextView optionTitleTV; + public ImageView wrongOptionIV; + public ImageView correctOptionIV; + + public ViewHolder(View v) { + super(v); + optionNbTV = (TextView) v.findViewById(R.id.option_nb); + optionTitleTV = (TextView) v.findViewById(R.id.option_title); + wrongOptionIV = (ImageView) v.findViewById(R.id.option_wrong); + correctOptionIV = (ImageView) v.findViewById(R.id.option_correct); + v.setOnClickListener(this); + } + + @Override + public void onClick(View view) { + if (mItemClickListener != null) { + mItemClickListener.onItemClick(view, getPosition()); + } + } + } + public interface OnItemClickListener { + public void onItemClick(View view , int position); + } + + public void SetOnItemClickListener(final OnItemClickListener mItemClickListener) { + this.mItemClickListener = mItemClickListener; + } + + + public FlashCardExerciseAdapter(List lst) { + flashcardExerciseOptionsList = lst; + } + + // Create new views (invoked by the layout manager) + @Override + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_falshcard_exercise_options, parent, false); + return new ViewHolder(v); + + } + + @Override + public int getItemViewType(int position) { + //@todo replace this with a real get item new type method based on the real data + //right now I would just make every 5th card an indicator + if (position % 5 == 0) { + return 1; + } else { + return 0; + } + } + + // Replace the contents of a view (invoked by the layout manager) + @Override + public void onBindViewHolder(ViewHolder holder, int position) { + FlashcardExerciseOption _item = flashcardExerciseOptionsList.get(position); + //@todo set the real data here. + holder.optionNbTV.setText(_item.getNumber()+"."); + holder.optionTitleTV.setText(_item.getTitle()); + + } + + @Override + public int getItemCount() { + return flashcardExerciseOptionsList.size(); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExercise.java b/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExercise.java new file mode 100644 index 0000000..31e0689 --- /dev/null +++ b/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExercise.java @@ -0,0 +1,42 @@ +package com.kanshu.kanshu.model; + +import java.util.ArrayList; + +/** + * Created by alouanemed on 18-02-2015. + */ +public class FlashcardExercise { + private String ChineseWord; + private String ChineseWordSpelling; + private ArrayList options; + + public FlashcardExercise(String chineseWord, String chineseWordSpelling, ArrayList options) { + ChineseWord = chineseWord; + ChineseWordSpelling = chineseWordSpelling; + this.options = options; + } + + public String getChineseWord() { + return ChineseWord; + } + + public void setChineseWord(String chineseWord) { + ChineseWord = chineseWord; + } + + public String getChineseWordSpelling() { + return ChineseWordSpelling; + } + + public void setChineseWordSpelling(String chineseWordSpelling) { + ChineseWordSpelling = chineseWordSpelling; + } + + public ArrayList getOptions() { + return options; + } + + public void setOptions(ArrayList options) { + this.options = options; + } +} diff --git a/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExerciseOption.java b/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExerciseOption.java new file mode 100644 index 0000000..25f1928 --- /dev/null +++ b/app/src/main/java/com/kanshu/kanshu/Model/FlashcardExerciseOption.java @@ -0,0 +1,43 @@ +package com.kanshu.kanshu.model; + +/** + * Created by alouanemed on 17-02-2015. + */ +public class FlashcardExerciseOption { + private static int count_ = 0; + private int number ; + private String Title; + private Boolean correct_answer; + + + public FlashcardExerciseOption(String title, Boolean correct_answer) { + Title = title; + this.correct_answer = correct_answer; + count_++; + this.number = count_; + } + + public int getNumber() { + return number; + } + + public void setNumber(int nb) { + this.number = nb; + } + + public String getTitle() { + return Title; + } + + public void setTitle(String title) { + Title = title; + } + + public Boolean isCorrect_answer() { + return correct_answer; + } + + public void setCorrect_answer(Boolean correct_answer) { + this.correct_answer = correct_answer; + } +} diff --git a/app/src/main/res/drawable-hdpi/ic_check_white.png b/app/src/main/res/drawable-hdpi/ic_check_white.png new file mode 100644 index 0000000..91d45e8 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_check_white.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_check_white.png b/app/src/main/res/drawable-mdpi/ic_check_white.png new file mode 100644 index 0000000..fbb2421 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_check_white.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_check_white.png b/app/src/main/res/drawable-xhdpi/ic_check_white.png new file mode 100644 index 0000000..0eb7fb3 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_check_white.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_check_white.png b/app/src/main/res/drawable-xxhdpi/ic_check_white.png new file mode 100644 index 0000000..46b36b5 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_check_white.png differ diff --git a/app/src/main/res/drawable/border_set.xml b/app/src/main/res/drawable/border_set.xml new file mode 100644 index 0000000..0fa7a07 --- /dev/null +++ b/app/src/main/res/drawable/border_set.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_development.xml b/app/src/main/res/layout/activity_development.xml index fcaf6b1..5dc572b 100644 --- a/app/src/main/res/layout/activity_development.xml +++ b/app/src/main/res/layout/activity_development.xml @@ -1,12 +1,12 @@ + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin" + android:paddingBottom="@dimen/activity_vertical_margin" + tools:context="com.kanshu.kanshu.DevelopmentActivity"> +