0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 20:03:05 +02:00

More improvements to study options and tablet layout

This commit is contained in:
timrae 2015-10-03 18:21:21 +09:00
parent 15a3538a4f
commit 304afd1a69
25 changed files with 269 additions and 475 deletions

View File

@ -371,8 +371,12 @@ public class AnkiActivity extends AppCompatActivity implements LoaderManager.Loa
* @param listener listener for the action (if null no action shown) * @param listener listener for the action (if null no action shown)
* @oaram root View Snackbar will attach to. Should be CoordinatorLayout for swipe-to-dismiss to work. * @oaram root View Snackbar will attach to. Should be CoordinatorLayout for swipe-to-dismiss to work.
*/ */
protected void showSnackbar(int mainTextResource, boolean shortLength, protected void showSnackbar(int mainTextResource, boolean shortLength, int actionTextResource,
int actionTextResource, View.OnClickListener listener, View root) { View.OnClickListener listener, View root) {
showSnackbar(mainTextResource,shortLength,actionTextResource,listener,root);
}
protected void showSnackbar(int mainTextResource, boolean shortLength, int actionTextResource,
View.OnClickListener listener, View root, Snackbar.Callback callback) {
if (root == null) { if (root == null) {
root = findViewById(android.R.id.content); root = findViewById(android.R.id.content);
if (root == null) { if (root == null) {
@ -385,6 +389,9 @@ public class AnkiActivity extends AppCompatActivity implements LoaderManager.Loa
if (listener != null) { if (listener != null) {
sb.setAction(actionTextResource, listener); sb.setAction(actionTextResource, listener);
} }
if (callback != null) {
sb.setCallback(callback);
}
// Make the text white to avoid interference from our theme colors. // Make the text white to avoid interference from our theme colors.
View view = sb.getView(); View view = sb.getView();
TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text); TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text);

View File

@ -38,6 +38,7 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -467,6 +468,7 @@ public class DeckPicker extends NavigationDrawerActivity implements
getMenuInflater().inflate(R.menu.deck_picker, menu); getMenuInflater().inflate(R.menu.deck_picker, menu);
boolean sdCardAvailable = AnkiDroidApp.isSdCardMounted(); boolean sdCardAvailable = AnkiDroidApp.isSdCardMounted();
menu.findItem(R.id.action_sync).setEnabled(sdCardAvailable); menu.findItem(R.id.action_sync).setEnabled(sdCardAvailable);
menu.findItem(R.id.action_unbury).setEnabled(sdCardAvailable);
menu.findItem(R.id.action_new_filtered_deck).setEnabled(sdCardAvailable); menu.findItem(R.id.action_new_filtered_deck).setEnabled(sdCardAvailable);
menu.findItem(R.id.action_check_database).setEnabled(sdCardAvailable); menu.findItem(R.id.action_check_database).setEnabled(sdCardAvailable);
menu.findItem(R.id.action_check_media).setEnabled(sdCardAvailable); menu.findItem(R.id.action_check_media).setEnabled(sdCardAvailable);
@ -625,7 +627,7 @@ public class DeckPicker extends NavigationDrawerActivity implements
} }
}); });
} }
}, findViewById(R.id.root_layout)); }, findViewById(R.id.root_layout), mSnackbarShowHideCallback);
} }
} }
} }
@ -1668,7 +1670,7 @@ public class DeckPicker extends NavigationDrawerActivity implements
CustomStudyDialog d = CustomStudyDialog.newInstance(CustomStudyDialog.CONTEXT_MENU_LIMITS, true); CustomStudyDialog d = CustomStudyDialog.newInstance(CustomStudyDialog.CONTEXT_MENU_LIMITS, true);
showDialogFragment(d); showDialogFragment(d);
} }
}, findViewById(R.id.root_layout)); }, findViewById(R.id.root_layout), mSnackbarShowHideCallback);
} else if (deckDueTreeNode.children.size() == 0 && getCol().cardCount(new long[]{did}) == 0) { } else if (deckDueTreeNode.children.size() == 0 && getCol().cardCount(new long[]{did}) == 0) {
// If the deck is empty and has no children then show a message saying it's empty // If the deck is empty and has no children then show a message saying it's empty
showSnackbar(R.string.empty_deck, false, R.string.help, new OnClickListener() { showSnackbar(R.string.empty_deck, false, R.string.help, new OnClickListener() {
@ -1678,7 +1680,7 @@ public class DeckPicker extends NavigationDrawerActivity implements
.getString(R.string.link_manual_getting_started))); .getString(R.string.link_manual_getting_started)));
startActivityWithoutAnimation(helpIntent); startActivityWithoutAnimation(helpIntent);
} }
}, findViewById(R.id.root_layout)); }, findViewById(R.id.root_layout), mSnackbarShowHideCallback);
} else { } else {
// Otherwise say there are no cards scheduled to study, and give option to do custom study // Otherwise say there are no cards scheduled to study, and give option to do custom study
showSnackbar(R.string.studyoptions_empty_schedule, false, R.string.custom_study, new OnClickListener() { showSnackbar(R.string.studyoptions_empty_schedule, false, R.string.custom_study, new OnClickListener() {
@ -1688,7 +1690,7 @@ public class DeckPicker extends NavigationDrawerActivity implements
CustomStudyDialog.CONTEXT_MENU_EMPTY_SCHEDULE, true); CustomStudyDialog.CONTEXT_MENU_EMPTY_SCHEDULE, true);
showDialogFragment(d); showDialogFragment(d);
} }
}, findViewById(R.id.root_layout)); }, findViewById(R.id.root_layout), mSnackbarShowHideCallback);
} }
} }
@ -1739,7 +1741,9 @@ public class DeckPicker extends NavigationDrawerActivity implements
if (eta != -1) { if (eta != -1) {
time = res.getString(R.string.time_quantity_minutes, eta); time = res.getString(R.string.time_quantity_minutes, eta);
} }
getSupportActionBar().setSubtitle(res.getQuantityString(R.plurals.deckpicker_title, due, due, time)); if (getSupportActionBar() != null) {
getSupportActionBar().setSubtitle(res.getQuantityString(R.plurals.deckpicker_title, due, due, time));
}
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
Timber.e(e, "RuntimeException setting time remaining"); Timber.e(e, "RuntimeException setting time remaining");
@ -1969,4 +1973,25 @@ public class DeckPicker extends NavigationDrawerActivity implements
} }
updateDeckList(); updateDeckList();
} }
/**
* FAB can't be animated to move out of the way of the snackbar button on API < 11
*/
Snackbar.Callback mSnackbarShowHideCallback = new Snackbar.Callback() {
@Override
public void onDismissed(Snackbar snackbar, int event) {
if (!CompatHelper.isHoneycomb()) {
final FloatingActionsMenu actionsMenu = (FloatingActionsMenu) findViewById(R.id.add_content_menu);
actionsMenu.setEnabled(true);
}
}
@Override
public void onShown(Snackbar snackbar) {
if (!CompatHelper.isHoneycomb()) {
final FloatingActionsMenu actionsMenu = (FloatingActionsMenu) findViewById(R.id.add_content_menu);
actionsMenu.setEnabled(false);
}
}
};
} }

View File

@ -163,7 +163,9 @@ public class NavigationDrawerActivity extends AnkiActivity implements Drawer.OnD
@Override @Override
public void setTitle(CharSequence title) { public void setTitle(CharSequence title) {
mTitle = title; mTitle = title;
getSupportActionBar().setTitle(mTitle); if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(mTitle);
}
} }

View File

@ -52,18 +52,6 @@ public class StudyOptionsActivity extends NavigationDrawerActivity implements St
} }
} }
@Override
public boolean onPrepareOptionsMenu(Menu menu){
// Make the add button visible when not fragmented layout
MenuItem addFromStudyOptions = menu.findItem(R.id.action_add_note_from_study_options);
if (addFromStudyOptions != null) {
addFromStudyOptions.setVisible(true);
}
return true;
}
private void loadStudyOptionsFragment() { private void loadStudyOptionsFragment() {
boolean withDeckOptions = false; boolean withDeckOptions = false;
if (getIntent().getExtras() != null) { if (getIntent().getExtras() != null) {

View File

@ -20,30 +20,21 @@ import android.content.SharedPreferences;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager; import android.support.v7.widget.Toolbar;
import android.support.v4.content.Loader;
import android.support.v7.app.AppCompatActivity;
import android.text.Html; import android.text.Html;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.afollestad.materialdialogs.MaterialDialog; import com.afollestad.materialdialogs.MaterialDialog;
import com.ichi2.anim.ActivityTransitionAnimation; import com.ichi2.anim.ActivityTransitionAnimation;
import com.ichi2.anim.ViewAnimation;
import com.ichi2.anki.dialogs.CustomStudyDialog; import com.ichi2.anki.dialogs.CustomStudyDialog;
import com.ichi2.anki.stats.AnkiStatsTaskHandler;
import com.ichi2.anki.stats.ChartView;
import com.ichi2.async.CollectionLoader;
import com.ichi2.async.DeckTask; import com.ichi2.async.DeckTask;
import com.ichi2.libanki.Collection; import com.ichi2.libanki.Collection;
import com.ichi2.libanki.Utils; import com.ichi2.libanki.Utils;
@ -52,19 +43,14 @@ import com.ichi2.themes.StyledProgressDialog;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.Arrays;
import java.util.List;
import timber.log.Timber; import timber.log.Timber;
public class StudyOptionsFragment extends Fragment implements LoaderManager.LoaderCallbacks<Collection> { public class StudyOptionsFragment extends Fragment implements Toolbar.OnMenuItemClickListener {
/** /**
* Available options performed by other activities * Available options performed by other activities
*/ */
public static final int PREFERENCES_UPDATE = 0;
private static final int ADD_NOTE = 2;
private static final int BROWSE_CARDS = 3; private static final int BROWSE_CARDS = 3;
private static final int STATISTICS = 4; private static final int STATISTICS = 4;
private static final int DECK_OPTIONS = 5; private static final int DECK_OPTIONS = 5;
@ -83,7 +69,6 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
* Preferences * Preferences
*/ */
private int mCurrentContentView = CONTENT_STUDY_OPTIONS; private int mCurrentContentView = CONTENT_STUDY_OPTIONS;
boolean mInvertedColors = false;
/** Alerts to inform the user about different situations */ /** Alerts to inform the user about different situations */
private MaterialDialog mProgressDialog; private MaterialDialog mProgressDialog;
@ -94,8 +79,6 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
private View mStudyOptionsView; private View mStudyOptionsView;
private View mDeckInfoLayout; private View mDeckInfoLayout;
private Button mButtonStart; private Button mButtonStart;
private Button mButtonCustomStudy;
private Button mButtonUnbury;
private TextView mTextDeckName; private TextView mTextDeckName;
private TextView mTextDeckDescription; private TextView mTextDeckDescription;
private TextView mTextTodayNew; private TextView mTextTodayNew;
@ -104,17 +87,13 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
private TextView mTextNewTotal; private TextView mTextNewTotal;
private TextView mTextTotal; private TextView mTextTotal;
private TextView mTextETA; private TextView mTextETA;
private Button mDeckOptions;
private Button mCramOptions;
private TextView mTextCongratsMessage; private TextView mTextCongratsMessage;
private View mCongratsLayout; private Toolbar mToolbar;
private ChartView mChartView;
// Flag to indicate if the fragment should load the deck options immediately after it loads // Flag to indicate if the fragment should load the deck options immediately after it loads
private boolean mLoadWithDeckOptions; private boolean mLoadWithDeckOptions;
private boolean mFragmented; private boolean mFragmented;
private Collection mCollection;
private Thread mFullNewCountThread = null; private Thread mFullNewCountThread = null;
@ -142,46 +121,15 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
private View.OnClickListener mButtonClickListener = new View.OnClickListener() { private View.OnClickListener mButtonClickListener = new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Collection col = getCol();
// long timeLimit = 0; // long timeLimit = 0;
switch (v.getId()) { switch (v.getId()) {
case R.id.studyoptions_start: case R.id.studyoptions_start:
Timber.i("StudyOptionsFragment:: start study button pressed"); Timber.i("StudyOptionsFragment:: start study button pressed");
openReviewer(); if (mCurrentContentView != CONTENT_CONGRATS) {
return; openReviewer();
case R.id.studyoptions_custom: } else {
Timber.i("StudyOptionsFragment:: custom study button pressed"); showCustomStudyContextMenu();
showCustomStudyContextMenu(); }
return;
case R.id.studyoptions_unbury:
case R.id.studyoptions_unbury_cram:
Timber.i("StudyOptionsFragment:: unbury button pressed");
col.getSched().unburyCardsForDeck();
refreshInterfaceAndDecklist(true);
return;
case R.id.studyoptions_options_cram:
Timber.i("StudyOptionsFragment:: cram deck options button pressed");
openFilteredDeckOptions();
return;
case R.id.studyoptions_options:
Timber.i("StudyOptionsFragment:: deck options button pressed");
Intent i = new Intent(getActivity(), DeckOptions.class);
startActivityForResult(i, DECK_OPTIONS);
ActivityTransitionAnimation.slide(getActivity(), ActivityTransitionAnimation.FADE);
return;
case R.id.studyoptions_rebuild_cram:
Timber.i("StudyOptionsFragment:: rebuild cram deck button pressed");
mProgressDialog = StyledProgressDialog.show(getActivity(), "",
getResources().getString(R.string.rebuild_cram_deck), true);
DeckTask.launchDeckTask(DeckTask.TASK_TYPE_REBUILD_CRAM, getDeckTaskListener(true),
new DeckTask.TaskData(mFragmented));
return;
case R.id.studyoptions_empty_cram:
Timber.i("StudyOptionsFragment:: empty cram deck button pressed");
mProgressDialog = StyledProgressDialog.show(getActivity(), "",
getResources().getString(R.string.empty_cram_deck), false);
DeckTask.launchDeckTask(DeckTask.TASK_TYPE_EMPTY_CRAM, getDeckTaskListener(true),
new DeckTask.TaskData(mFragmented));
return; return;
default: default:
} }
@ -230,24 +178,18 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
} }
restorePreferences(); restorePreferences();
mStudyOptionsView = inflater.inflate(R.layout.studyoptions_fragment, container, false); mStudyOptionsView = inflater.inflate(R.layout.studyoptions_fragment, container, false);
mToolbar = (Toolbar) mStudyOptionsView.findViewById(R.id.studyOptionsToolbar);
if (mToolbar != null) {
configureToolbar();
}
mFragmented = getActivity().getClass() != StudyOptionsActivity.class; mFragmented = getActivity().getClass() != StudyOptionsActivity.class;
NavigationDrawerActivity.setIsWholeCollection(false); NavigationDrawerActivity.setIsWholeCollection(false);
startLoadingCollection();
showProgressBar();
return mStudyOptionsView;
}
// Called when the collection loader has finished
// NOTE: Fragment transactions are NOT allowed to be called from here onwards
private void onCollectionLoaded(Collection col) {
mCollection = col;
initAllContentViews(); initAllContentViews();
if (getArguments() != null) { if (getArguments() != null) {
mLoadWithDeckOptions = getArguments().getBoolean("withDeckOptions"); mLoadWithDeckOptions = getArguments().getBoolean("withDeckOptions");
} }
refreshInterface(true); refreshInterface(true);
setHasOptionsMenu(true); return mStudyOptionsView;
hideProgressBar();
} }
@ -264,10 +206,8 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (colOpen()) { Timber.d("onResume()");
Timber.d("onResume()"); refreshInterface(true);
refreshInterface(true);
}
} }
@ -293,15 +233,6 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
} }
private void addNote() {
Preferences.COMING_FROM_ADD = true;
Intent intent = new Intent(getActivity(), NoteEditor.class);
intent.putExtra(NoteEditor.EXTRA_CALLER, NoteEditor.CALLER_STUDYOPTIONS);
startActivityForResult(intent, ADD_NOTE);
animateLeft();
}
private void animateLeft() { private void animateLeft() {
ActivityTransitionAnimation.slide(getActivity(), ActivityTransitionAnimation.LEFT); ActivityTransitionAnimation.slide(getActivity(), ActivityTransitionAnimation.LEFT);
} }
@ -314,26 +245,7 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
// make links clickable // make links clickable
mTextDeckDescription.setMovementMethod(LinkMovementMethod.getInstance()); mTextDeckDescription.setMovementMethod(LinkMovementMethod.getInstance());
mButtonStart = (Button) mStudyOptionsView.findViewById(R.id.studyoptions_start); mButtonStart = (Button) mStudyOptionsView.findViewById(R.id.studyoptions_start);
mButtonCustomStudy = (Button) mStudyOptionsView.findViewById(R.id.studyoptions_custom);
mDeckOptions = (Button) mStudyOptionsView.findViewById(R.id.studyoptions_options);
mCramOptions = (Button) mStudyOptionsView.findViewById(R.id.studyoptions_options_cram);
mCongratsLayout = mStudyOptionsView.findViewById(R.id.studyoptions_congrats_layout);
mTextCongratsMessage = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_congrats_message); mTextCongratsMessage = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_congrats_message);
if (getCol().getDecks().isDyn(getCol().getDecks().selected())) {
Button rebBut = (Button) mStudyOptionsView.findViewById(R.id.studyoptions_rebuild_cram);
rebBut.setOnClickListener(mButtonClickListener);
Button emptyBut = (Button) mStudyOptionsView.findViewById(R.id.studyoptions_empty_cram);
emptyBut.setOnClickListener(mButtonClickListener);
// Enable the dynamic deck buttons and disable the normal ones
mStudyOptionsView.findViewById(R.id.studyoptions_cram_buttons).setVisibility(View.VISIBLE);
mStudyOptionsView.findViewById(R.id.studyoptions_regular_buttons).setVisibility(View.GONE);
// Dynamic decks have their own unbury button to keep a reference to
mButtonUnbury = (Button) mStudyOptionsView.findViewById(R.id.studyoptions_unbury_cram);
} else {
mButtonUnbury = (Button) mStudyOptionsView.findViewById(R.id.studyoptions_unbury);
}
mButtonUnbury.setOnClickListener(mButtonClickListener);
// Code common to both fragmented and non-fragmented view // Code common to both fragmented and non-fragmented view
mTextTodayNew = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_new); mTextTodayNew = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_new);
mTextTodayLrn = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_lrn); mTextTodayLrn = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_lrn);
@ -342,16 +254,6 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
mTextTotal = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_total); mTextTotal = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_total);
mTextETA = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_eta); mTextETA = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_eta);
mButtonStart.setOnClickListener(mButtonClickListener); mButtonStart.setOnClickListener(mButtonClickListener);
mButtonCustomStudy.setOnClickListener(mButtonClickListener);
mDeckOptions.setOnClickListener(mButtonClickListener);
mCramOptions.setOnClickListener(mButtonClickListener);
/*mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addNote();
}
});*/
} }
@ -371,22 +273,70 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
} }
private void updateChart(double[][] serieslist) { @Override
if (mChartView != null && mCurrentContentView != CONTENT_EMPTY) { public boolean onMenuItemClick(MenuItem item) {
Collection col = CollectionHelper.getInstance().getCol(getActivity()); switch (item.getItemId()) {
AnkiStatsTaskHandler.createSmallDueChartChart(col, serieslist, mChartView); case R.id.action_undo:
if (mChartView.getVisibility() == View.INVISIBLE) { Timber.i("StudyOptionsFragment:: Undo button pressed");
mChartView.setVisibility(View.VISIBLE); getCol().undo();
mChartView.setAnimation(ViewAnimation.fade(ViewAnimation.FADE_IN, 500, 0)); refreshInterfaceAndDecklist(true);
} configureToolbar();
return true;
case R.id.action_deck_options:
Timber.i("StudyOptionsFragment:: Deck options button pressed");
if (getCol().getDecks().isDyn(getCol().getDecks().selected())) {
openFilteredDeckOptions();
} else {
Intent i = new Intent(getActivity(), DeckOptions.class);
startActivityForResult(i, DECK_OPTIONS);
ActivityTransitionAnimation.slide(getActivity(), ActivityTransitionAnimation.FADE);
}
return true;
case R.id.action_custom_study:
Timber.i("StudyOptionsFragment:: custom study button pressed");
showCustomStudyContextMenu();
return true;
case R.id.action_unbury:
Timber.i("StudyOptionsFragment:: unbury button pressed");
getCol().getSched().unburyCardsForDeck();
refreshInterfaceAndDecklist(true);
return true;
case R.id.action_rebuild:
Timber.i("StudyOptionsFragment:: rebuild cram deck button pressed");
mProgressDialog = StyledProgressDialog.show(getActivity(), "",
getResources().getString(R.string.rebuild_cram_deck), true);
DeckTask.launchDeckTask(DeckTask.TASK_TYPE_REBUILD_CRAM, getDeckTaskListener(true),
new DeckTask.TaskData(mFragmented));
return true;
case R.id.action_empty:
Timber.i("StudyOptionsFragment:: empty cram deck button pressed");
mProgressDialog = StyledProgressDialog.show(getActivity(), "",
getResources().getString(R.string.empty_cram_deck), false);
DeckTask.launchDeckTask(DeckTask.TASK_TYPE_EMPTY_CRAM, getDeckTaskListener(true),
new DeckTask.TaskData(mFragmented));
return true;
default:
return false;
} }
} }
public void configureToolbar() {
@Override mToolbar.inflateMenu(R.menu.study_options_fragment);
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { mToolbar.setOnMenuItemClickListener(this);
getActivity().getMenuInflater().inflate(R.menu.study_options_fragment, menu); Menu menu = mToolbar.getMenu();
// Switch on or off rebuild/empty/custom study depending on whether or not filtered deck
if (getCol().getDecks().isDyn(getCol().getDecks().selected())) {
menu.findItem(R.id.action_rebuild).setVisible(true);
menu.findItem(R.id.action_empty).setVisible(true);
menu.findItem(R.id.action_custom_study).setVisible(false);
} else {
menu.findItem(R.id.action_rebuild).setVisible(false);
menu.findItem(R.id.action_empty).setVisible(false);
menu.findItem(R.id.action_custom_study).setVisible(true);
}
// Switch on or off unbury depending on if there are cards to unbury
menu.findItem(R.id.action_unbury).setVisible(getCol().getSched().haveBuried());
// Switch on or off unbury depending on whether undo is available
if (!getCol().undoAvailable()) { if (!getCol().undoAvailable()) {
menu.findItem(R.id.action_undo).setVisible(false); menu.findItem(R.id.action_undo).setVisible(false);
} else { } else {
@ -394,30 +344,6 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
Resources res = AnkiDroidApp.getAppResources(); Resources res = AnkiDroidApp.getAppResources();
menu.findItem(R.id.action_undo).setTitle(res.getString(R.string.studyoptions_congrats_undo, getCol().undoName(res))); menu.findItem(R.id.action_undo).setTitle(res.getString(R.string.studyoptions_congrats_undo, getCol().undoName(res)));
} }
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_undo:
Timber.i("StudyOptionsFragment:: Undo button pressed");
if (colOpen()) {
getCol().undo();
refreshInterfaceAndDecklist(true);
getActivity().supportInvalidateOptionsMenu();
}
return true;
case R.id.action_add_note_from_study_options:
Timber.i("StudyOptionsFragment:: Add note button pressed");
addNote();
return true;
default:
return super.onOptionsItemSelected(item);
}
} }
@ -435,12 +361,6 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
return; return;
} }
// check that the collection is open before doing anything
if (!colOpen()) {
startLoadingCollection();
return;
}
// perform some special actions depending on which activity we're returning from // perform some special actions depending on which activity we're returning from
if (requestCode == STATISTICS || requestCode == BROWSE_CARDS) { if (requestCode == STATISTICS || requestCode == BROWSE_CARDS) {
// select original deck if the statistics or card browser were opened, // select original deck if the statistics or card browser were opened,
@ -553,10 +473,9 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
int totalNew = (Integer) obj[3]; int totalNew = (Integer) obj[3];
int totalCards = (Integer) obj[4]; int totalCards = (Integer) obj[4];
int eta = (Integer) obj[7]; int eta = (Integer) obj[7];
double[][] serieslist = (double[][]) obj[8];
// Don't do anything if the fragment is no longer attached to it's Activity or col has been closed // Don't do anything if the fragment is no longer attached to it's Activity or col has been closed
if (getActivity() == null || !colOpen()) { if (getActivity() == null) {
Timber.e("StudyOptionsFragment.mRefreshFragmentListener :: can't refresh"); Timber.e("StudyOptionsFragment.mRefreshFragmentListener :: can't refresh");
return; return;
} }
@ -583,12 +502,6 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
nameBuilder.append("\n").append(name[name.length - 1]); nameBuilder.append("\n").append(name[name.length - 1]);
} }
mTextDeckName.setText(nameBuilder.toString()); mTextDeckName.setText(nameBuilder.toString());
// Also set deck name in activity title in action bar if not tablet mode
if (!mFragmented) {
getActivity().setTitle(getResources().getString(R.string.studyoptions_title));
List<String> parts = Arrays.asList(fullName.split("::"));
((AppCompatActivity)getActivity()).getSupportActionBar().setSubtitle(parts.get(parts.size() - 1));
}
} catch (JSONException e) { } catch (JSONException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -603,25 +516,26 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
if (totalCards == 0 && !isDynamic) { if (totalCards == 0 && !isDynamic) {
mCurrentContentView = CONTENT_EMPTY; mCurrentContentView = CONTENT_EMPTY;
mDeckInfoLayout.setVisibility(View.VISIBLE); mDeckInfoLayout.setVisibility(View.VISIBLE);
mCongratsLayout.setVisibility(View.VISIBLE); mTextCongratsMessage.setVisibility(View.VISIBLE);
mTextCongratsMessage.setText(R.string.studyoptions_empty); mTextCongratsMessage.setText(R.string.studyoptions_empty);
mButtonStart.setVisibility(View.GONE); mButtonStart.setVisibility(View.GONE);
if (mChartView != null) {
mChartView.setVisibility(View.INVISIBLE);
}
} else if (newCards + lrnCards + revCards == 0) { } else if (newCards + lrnCards + revCards == 0) {
mCurrentContentView = CONTENT_CONGRATS; mCurrentContentView = CONTENT_CONGRATS;
if (!isDynamic) { if (!isDynamic) {
mDeckInfoLayout.setVisibility(View.GONE); mDeckInfoLayout.setVisibility(View.GONE);
mButtonStart.setVisibility(View.VISIBLE);
mButtonStart.setText(R.string.custom_study);
} else {
mButtonStart.setVisibility(View.GONE);
} }
mCongratsLayout.setVisibility(View.VISIBLE); mTextCongratsMessage.setVisibility(View.VISIBLE);
mTextCongratsMessage.setText(getCol().getSched().finishedMsg(getActivity())); mTextCongratsMessage.setText(getCol().getSched().finishedMsg(getActivity()));
mButtonStart.setVisibility(View.GONE);
} else { } else {
mCurrentContentView = CONTENT_STUDY_OPTIONS; mCurrentContentView = CONTENT_STUDY_OPTIONS;
mDeckInfoLayout.setVisibility(View.VISIBLE); mDeckInfoLayout.setVisibility(View.VISIBLE);
mCongratsLayout.setVisibility(View.GONE); mTextCongratsMessage.setVisibility(View.GONE);
mButtonStart.setVisibility(View.VISIBLE); mButtonStart.setVisibility(View.VISIBLE);
mButtonStart.setText(R.string.studyoptions_start);
} }
// Set deck description // Set deck description
@ -638,9 +552,6 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
mTextDeckDescription.setVisibility(View.GONE); mTextDeckDescription.setVisibility(View.GONE);
} }
// Update the chart (for tablet view)
updateChart(serieslist);
// Set new/learn/review card counts // Set new/learn/review card counts
mTextTodayNew.setText(String.valueOf(newCards)); mTextTodayNew.setText(String.valueOf(newCards));
mTextTodayLrn.setText(String.valueOf(lrnCards)); mTextTodayLrn.setText(String.valueOf(lrnCards));
@ -691,15 +602,8 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
} else { } else {
mTextETA.setText("-"); mTextETA.setText("-");
} }
// Rebuild the options menu
// Show unbury button if necessary getActivity().supportInvalidateOptionsMenu();
if (mButtonUnbury != null) {
if (getCol().getSched().haveBuried()) {
mButtonUnbury.setVisibility(View.VISIBLE);
} else {
mButtonUnbury.setVisibility(View.GONE);
}
}
} }
// If in fragmented mode, refresh the deck list // If in fragmented mode, refresh the deck list
@ -720,60 +624,7 @@ public class StudyOptionsFragment extends Fragment implements LoaderManager.Load
}; };
} }
private Collection getCol() { private Collection getCol() {
return mCollection; return CollectionHelper.getInstance().getCol(getContext());
}
private boolean colOpen() {
return getCol() != null && getCol().getDb() != null;
}
// Method for loading the collection which is inherited by all AnkiActivitys
protected void startLoadingCollection() {
// Initialize the open collection loader
Timber.d("startLoadingCollection()");
getLoaderManager().initLoader(0, null, this);
}
// CollectionLoader Listener callbacks
@Override
public Loader<Collection> onCreateLoader(int id, Bundle args) {
// Currently only using one loader, so ignore id
return new CollectionLoader(getActivity());
}
@Override
public void onLoadFinished(Loader<Collection> loader, Collection col) {
if (col != null) {
onCollectionLoaded(col);
} else {
AnkiDatabaseManager.closeDatabase(CollectionHelper.getCollectionPath(getActivity()));
//showDialog(DIALOG_LOAD_FAILED);
}
}
@Override
public void onLoaderReset(Loader<Collection> arg0) {
// We don't currently retain any references, so no need to free any data here
}
private void showProgressBar() {
ProgressBar progressBar = (ProgressBar) mStudyOptionsView.findViewById(R.id.progress_bar);
if (progressBar != null) {
mStudyOptionsView.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.VISIBLE);
}
}
private void hideProgressBar() {
ProgressBar progressBar = (ProgressBar) mStudyOptionsView.findViewById(R.id.progress_bar);
if (progressBar != null) {
mStudyOptionsView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
}
} }
} }

View File

@ -732,10 +732,8 @@ public class DeckTask extends BaseAsyncTask<DeckTask.TaskData, DeckTask.TaskData
int totalCount = sched.cardCount(); int totalCount = sched.cardCount();
double progressMature = ((double) sched.matureCount()) / ((double) totalCount); double progressMature = ((double) sched.matureCount()) / ((double) totalCount);
double progressAll = 1 - (((double) (totalNewCount + counts[1])) / ((double) totalCount)); double progressAll = 1 - (((double) (totalNewCount + counts[1])) / ((double) totalCount));
double[][] serieslist = null;
serieslist = Stats.getSmallDueStats(col);
return new TaskData(new Object[] { counts[0], counts[1], counts[2], totalNewCount, totalCount, return new TaskData(new Object[] { counts[0], counts[1], counts[2], totalNewCount, totalCount,
progressMature, progressAll, sched.eta(counts), serieslist }); progressMature, progressAll, sched.eta(counts)});
} catch (RuntimeException e) { } catch (RuntimeException e) {
Timber.e(e, "doInBackgroundUpdateValuesFromDeck - an error occurred"); Timber.e(e, "doInBackgroundUpdateValuesFromDeck - an error occurred");
return null; return null;

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="0"
android:gradientRadius="0dp"
android:startColor="#10000000"
android:endColor="?android:attr/colorBackground"/>
</shape>

View File

@ -4,5 +4,5 @@
android:angle="0" android:angle="0"
android:gradientRadius="0dp" android:gradientRadius="0dp"
android:startColor="#10000000" android:startColor="#10000000"
android:endColor="?android:attr/colorBackground"/> android:endColor="#10FFFFFF"/>
</shape> </shape>

View File

@ -13,7 +13,8 @@
<include layout="@layout/toolbar"/> <include layout="@layout/toolbar"/>
<ScrollView <ScrollView
android:layout_width="fill_parent" android:layout_width="@dimen/match_parent_or_600dp"
android:layout_gravity="center_horizontal"
android:layout_height="0dp" android:layout_height="0dp"
android:fillViewport="true" android:fillViewport="true"
android:layout_weight="1" android:layout_weight="1"

View File

@ -5,38 +5,24 @@
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="?android:attr/colorBackground" android:background="?android:attr/colorBackground"
android:orientation="horizontal" android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android">
xmlns:app="http://schemas.android.com/apk/res-auto">
<include layout="@layout/deck_picker" <include layout="@layout/deck_picker"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_weight="3" android:layout_weight="3"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
<LinearLayout <LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="2" android:layout_weight="2"
android:orientation="vertical"> android:layout_width="0dip"
<android.support.v7.widget.Toolbar android:layout_height="match_parent"
android:id="@+id/studyOptionsToolbar" android:orientation="horizontal">
android:layout_width="fill_parent" <View
android:layout_height="wrap_content" android:id="@+id/studyoptions_gradient"
android:minHeight="?attr/actionBarSize" android:layout_width="15dp"
android:background="?attr/colorPrimary" android:layout_height="fill_parent"
android:theme="?attr/actionBarThemeRef" android:background="@drawable/shadow_left" />
app:popupTheme="?attr/actionBarPopupThemeRef"/> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout android:id="@+id/studyoptions_fragment"
android:layout_width="match_parent" android:layout_width="fill_parent"
android:layout_height="match_parent" android:layout_height="fill_parent"/>
android:orientation="horizontal">
<View
android:id="@+id/studyoptions_gradient"
android:layout_width="15dp"
android:layout_height="fill_parent"
android:background="@drawable/shadow_left" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/studyoptions_fragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -12,7 +12,9 @@
android:gravity="center" android:gravity="center"
android:orientation="vertical" > android:orientation="vertical" >
<include layout="@layout/toolbar" /> <include layout="@layout/toolbar" />
<LinearLayout android:layout_width="match_parent" <LinearLayout
android:layout_width="@dimen/match_parent_or_600dp"
android:gravity="center_horizontal"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<com.ichi2.ui.SlidingTabLayout <com.ichi2.ui.SlidingTabLayout

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_layout" android:id="@+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:gravity="center" android:layout_width="@dimen/match_parent_or_600dp"
android:layout_gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
android:paddingTop="12dp" > android:paddingTop="12dp" >
<!-- Front --> <!-- Front -->

View File

@ -12,10 +12,9 @@
<include layout="@layout/toolbar" /> <include layout="@layout/toolbar" />
<ListView <ListView
android:layout_width="match_parent" android:layout_width="@dimen/match_parent_or_600dp"
android:gravity="center"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/note_type_editor_fields" android:id="@+id/note_type_editor_fields"/>
android:layout_gravity="center_horizontal"/>
</LinearLayout> </LinearLayout>
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>

View File

@ -1,9 +1,10 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/model_editor_list_display" android:id="@+id/model_editor_list_display"
android:layout_width="fill_parent" android:layout_width="600dp"
android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
android:paddingBottom="7dip" android:layout_height="wrap_content"
android:paddingLeft="@dimen/keyline_1" android:paddingBottom="7dip"
android:paddingRight="5dip" android:paddingLeft="@dimen/keyline_1"
android:textSize="20sp" android:paddingRight="5dip"
android:textColor="?android:textColorPrimary"/> android:textSize="20sp"
android:textColor="?android:textColorPrimary"/>

View File

@ -13,7 +13,8 @@
<LinearLayout <LinearLayout
android:id="@+id/LinearLayoutForSpareMenuFieldEdit" android:id="@+id/LinearLayoutForSpareMenuFieldEdit"
android:layout_width="match_parent" android:layout_width="@dimen/match_parent_or_600dp"
android:gravity="center"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" > android:orientation="horizontal" >
</LinearLayout> </LinearLayout>

View File

@ -11,8 +11,9 @@
android:orientation="vertical"> android:orientation="vertical">
<include layout="@layout/toolbar"/> <include layout="@layout/toolbar"/>
<ScrollView <ScrollView
android:layout_width="fill_parent" android:layout_width="@dimen/match_parent_or_600dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:fillViewport="true" android:fillViewport="true"
android:layout_weight="1"> android:layout_weight="1">

View File

@ -15,10 +15,10 @@
<LinearLayout <LinearLayout
android:id="@+id/logged_text" android:id="@+id/logged_text"
android:layout_width="fill_parent" android:layout_width="@dimen/match_parent_or_600dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="15dp" android:layout_marginBottom="15dp"
android:gravity="center" android:gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
android:padding="20dp" android:padding="20dp"
android:layout_centerInParent="true" android:layout_centerInParent="true"

View File

@ -13,8 +13,9 @@
<include layout="@layout/toolbar"/> <include layout="@layout/toolbar"/>
<ScrollView <ScrollView
android:layout_width="fill_parent" android:layout_width="@dimen/match_parent_or_600dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:fillViewport="true" android:fillViewport="true"
android:layout_weight="1"> android:layout_weight="1">

View File

@ -15,8 +15,9 @@
<ScrollView <ScrollView
android:id="@+id/CardEditorScroll" android:id="@+id/CardEditorScroll"
android:layout_width="fill_parent" android:layout_width="@dimen/match_parent_or_600dp"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:padding="5dp" > android:padding="5dp" >
<LinearLayout <LinearLayout

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>

View File

@ -8,9 +8,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<include layout="@layout/toolbar" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/studyoptions_frame" android:id="@+id/studyoptions_frame"
android:layout_width="fill_parent" android:layout_width="fill_parent"

View File

@ -1,59 +1,74 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout <android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/studyoptions_main" android:id="@+id/studyoptions_main"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:paddingLeft="@dimen/keyline_1"
android:paddingRight="@dimen/keyline_1"
android:orientation="vertical" android:orientation="vertical"
android:gravity="center"> android:gravity="center">
<LinearLayout <RelativeLayout
android:id="@+id/studyoptions_mainframe" android:id="@+id/studyoptions_mainframe"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:orientation="vertical"> android:orientation="vertical"
android:paddingBottom="32dp" >
<android.support.v7.widget.Toolbar
android:id="@+id/studyOptionsToolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="?attr/actionBarThemeRef"
android:layout_alignParentTop="true"
app:popupTheme="?attr/actionBarPopupThemeRef"/>
<ScrollView <ScrollView
android:id="@+id/studyoptions_scrollview" android:id="@+id/studyoptions_scrollview"
android:layout_below="@id/studyOptionsToolbar"
android:layout_above="@id/bottom_area_layout"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="0dp" android:layout_height="fill_parent"
android:layout_weight="1" android:paddingLeft="@dimen/study_options_padding"
android:paddingRight="@dimen/study_options_padding"
android:paddingBottom="16dp"
android:fadeScrollbars="false" android:fadeScrollbars="false"
android:fillViewport="true"> android:fillViewport="true">
<LinearLayout <LinearLayout
android:id="@+id/studyoptions_scrollcontainer" android:id="@+id/studyoptions_scrollcontainer"
android:layout_width="fill_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:layout_gravity="center"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/studyoptions_deck_name" android:id="@+id/studyoptions_deck_name"
android:layout_width="fill_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="5dp"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center" android:gravity="center"
android:maxLines="3" android:maxLines="3"
android:text="" android:text="Deck Title"
android:textSize="28sp" android:textSize="28sp"
android:textStyle="bold" /> android:textStyle="bold" />
<LinearLayout <LinearLayout
android:id="@+id/studyoptions_deckinformation" android:id="@+id/studyoptions_deckinformation"
android:layout_width="fill_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center" android:gravity="center"
android:orientation="vertical"> android:orientation="vertical"
android:layout_gravity="center_horizontal">
<TableLayout <TableLayout
android:id="@+id/studyoptions_deckcounts" android:id="@+id/studyoptions_deckcounts"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dip" android:layout_marginBottom="5dip"
android:layout_marginEnd="3dip" android:layout_marginEnd="3dip"
@ -69,7 +84,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="0dip" android:paddingLeft="0dip"
android:paddingRight="5dip" android:paddingRight="5dip"
android:text="@string/studyoptions_due_today" /> android:text="@string/studyoptions_due_today"/>
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -147,149 +162,48 @@
android:gravity="end" /> android:gravity="end" />
</TableRow> </TableRow>
</TableLayout> </TableLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/studyoptions_deck_description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center"
android:text="" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout <TextView
android:id="@+id/studyoptions_congrats_layout" android:id="@+id/studyoptions_deck_description"
android:layout_width="fill_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="10dp" android:layout_marginTop="32dp"
android:orientation="vertical"> android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
<TextView android:layout_marginRight="10dp"
android:id="@+id/studyoptions_congrats_message" android:gravity="center"
android:layout_width="fill_parent" android:text="This is a deck description. It tells us about what the deck does and where it comes from blah blah." />
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center"
android:text="" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:id="@+id/bottom_area_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:layout_alignParentBottom="true"
android:paddingTop="5dip"> android:layout_centerHorizontal="true"
android:orientation="vertical">
<LinearLayout <TextView
android:layout_width="fill_parent" android:id="@+id/studyoptions_congrats_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:minLines="2"
android:text="Congratulations! You have finished for now."
<Button android:layout_gravity="center_horizontal"
android:id="@+id/studyoptions_start" android:gravity="center"/>
android:layout_width="0dip" <Button
android:layout_height="fill_parent" android:id="@+id/studyoptions_start"
android:layout_weight="1" android:background="@color/fab_normal"
android:lines="3" android:textColor="@color/white"
android:text="@string/studyoptions_start" android:layout_marginTop="16dp"
android:textSize="20sp" android:layout_width="200dip"
android:textStyle="bold" />
</LinearLayout>
<!-- This is the layout for a normal deck (not filtered). We show this by default and
hide/replace it with another one if it's a filtered deck.-->
<LinearLayout
android:id="@+id/studyoptions_regular_buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:lines="2"
android:text="@string/studyoptions_start"
<Button android:textSize="20sp"
android:id="@+id/studyoptions_options" android:textStyle="bold"
android:layout_width="0px" android:layout_gravity="center_horizontal"/>
android:layout_height="match_parent"
android:layout_weight="1"
android:lines="1"
android:text="@string/study_options"
android:textSize="12sp"
android:textStyle="bold" />
<Button
android:id="@+id/studyoptions_custom"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
android:lines="1"
android:text="@string/custom_study"
android:textSize="12sp"
android:textStyle="bold" />
<Button
android:id="@+id/studyoptions_unbury"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
android:lines="1"
android:text="@string/unbury"
android:textSize="12sp"
android:textStyle="bold"
android:visibility="gone" />
</LinearLayout>
<!-- This is the layout used for filtered decks. It is hidden by default and made visible
at runtime if we are loading a filtered deck. -->
<LinearLayout
android:id="@+id/studyoptions_cram_buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<Button
android:id="@+id/studyoptions_options_cram"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/study_options"
android:textSize="12sp" />
<Button
android:id="@+id/studyoptions_rebuild_cram"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/rebuild_cram_label"
android:textSize="12sp" />
<Button
android:id="@+id/studyoptions_empty_cram"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/empty_cram_label"
android:textSize="12sp" />
<Button
android:id="@+id/studyoptions_unbury_cram"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/unbury"
android:textSize="12sp"
android:visibility="gone" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </RelativeLayout>
<include layout="@layout/anki_progress"/> <include layout="@layout/anki_progress"/>
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>

View File

@ -5,12 +5,23 @@
android:enabled="true" android:enabled="true"
android:icon="@drawable/ic_undo_white_24dp" android:icon="@drawable/ic_undo_white_24dp"
android:title="@string/undo" android:title="@string/undo"
ankidroid:showAsAction="always" ankidroid:showAsAction="always"/>
android:visibility = "gone" />
<item <item
android:id="@+id/action_add_note_from_study_options" android:id="@+id/action_deck_options"
android:icon="@drawable/ic_add_white_24dp" android:title="@string/study_options"/>
android:title="@string/menu_add" <item
ankidroid:showAsAction="always" android:id="@+id/action_custom_study"
android:visible="false" /> android:title="@string/custom_study"/>
<item
android:id="@+id/action_unbury"
android:title="@string/unbury"
android:visibility = "gone"/>
<item
android:id="@+id/action_rebuild"
android:title="@string/rebuild_cram_label"
android:visibility = "gone"/>
<item
android:id="@+id/action_empty"
android:title="@string/empty_cram_label"
android:visibility = "gone"/>
</menu> </menu>

View File

@ -2,7 +2,9 @@
<resources> <resources>
<dimen name="keyline_1">24dp</dimen> <dimen name="keyline_1">24dp</dimen>
<dimen name="default_width">64dp</dimen> <dimen name="default_width">64dp</dimen>
<dimen name="study_options_padding">16dp</dimen>
<dimen name="deck_picker_left_padding_small">12dp</dimen> <dimen name="deck_picker_left_padding_small">12dp</dimen>
<dimen name="deck_picker_left_padding">24dp</dimen> <dimen name="deck_picker_left_padding">24dp</dimen>
<dimen name="deck_picker_right_padding">12dp</dimen> <dimen name="deck_picker_right_padding">12dp</dimen>
<dimen name="match_parent_or_600dp">600dp</dimen>
</resources> </resources>

View File

@ -3,6 +3,10 @@
<dimen name="touch_target">48dp</dimen> <dimen name="touch_target">48dp</dimen>
<dimen name="default_width">56dp</dimen> <dimen name="default_width">56dp</dimen>
<dimen name="keyline_1">16dp</dimen> <dimen name="keyline_1">16dp</dimen>
<dimen name="study_options_padding">8dp</dimen>
<!-- match_parent or max 600dp -->
<dimen name="match_parent_or_600dp">-1px</dimen>
<!-- Top margin for action bar subtitles --> <!-- Top margin for action bar subtitles -->
<dimen name="action_bar_subtitle_top_margin">-3dp</dimen> <dimen name="action_bar_subtitle_top_margin">-3dp</dimen>