Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update .travis.yml #35

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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-.+
- '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
12 changes: 11 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.kanshu.kanshu.SignupActivity" />
</activity>

<activity
android:name=".FlashCardExerciseActivity"
android:parentActivityName=".DevelopmentActivity"
android:theme="@style/Kanshu.Light.DarkToolBar"
android:windowSoftInputMode="stateHidden">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.kanshu.kanshu.ArticleActivity" />
</activity>
</application>

</manifest>
</manifest>
Binary file added app/src/main/ic_check_white-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion app/src/main/java/com/kanshu/kanshu/DevelopmentActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
@@ -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<FlashcardExerciseOption> mFlashcardExerciseOptions = new ArrayList<FlashcardExerciseOption>();
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;
}

}
158 changes: 158 additions & 0 deletions app/src/main/java/com/kanshu/kanshu/FlashCardExerciseActivity.java
Original file line number Diff line number Diff line change
@@ -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];
}
}

}
Loading