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

Revert "Revert "Display study options properly on start on tablet (#8756)""

This reverts commit b559521a06.
This commit is contained in:
Mike Hardy 2021-07-04 23:10:11 -05:00
parent 517db207b3
commit e323c5291f
No known key found for this signature in database
GPG Key ID: 2FB9315A0E38FF42
2 changed files with 23 additions and 4 deletions

View File

@ -224,6 +224,9 @@ public class DeckPicker extends NavigationDrawerActivity implements
// flag keeping track of when the app has been paused
private boolean mActivityPaused = false;
// Flag to keep track of startup error
private boolean mStartupError = false;
private String mExportFileName;
@Nullable private CollectionTask<?, ?> mEmptyCardTask = null;
@ -468,6 +471,11 @@ public class DeckPicker extends NavigationDrawerActivity implements
// set protected variable from NavigationDrawerActivity
mFragmented = mStudyoptionsFrame != null && mStudyoptionsFrame.getVisibility() == View.VISIBLE;
// Open StudyOptionsFragment if in fragmented mode
if (mFragmented && !mStartupError) {
loadStudyOptionsFragment(false);
}
registerExternalStorageListener();
// create inherited navigation drawer layout here so that it can be used by parent class
@ -542,10 +550,12 @@ public class DeckPicker extends NavigationDrawerActivity implements
// Show any necessary dialogs (e.g. changelog, special messages, etc)
SharedPreferences sharedPrefs = AnkiDroidApp.getSharedPrefs(this);
showStartupScreensAndDialogs(sharedPrefs, 0);
mStartupError = false;
} else {
// Show error dialogs
StartupFailure failure = InitialActivity.getStartupFailureType(this);
handleStartupFailure(failure);
mStartupError = true;
}
} else {
requestStoragePermission();
@ -1130,10 +1140,7 @@ public class DeckPicker extends NavigationDrawerActivity implements
getDialogHandler().sendMessage(handlerMessage);
}
}
// Open StudyOptionsFragment if in fragmented mode
if (mFragmented) {
loadStudyOptionsFragment(false);
}
automaticSync();
}

View File

@ -5,6 +5,8 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageManager;
import android.database.SQLException;
import android.os.Bundle;
import android.view.Menu;
import com.ichi2.anki.dialogs.DatabaseErrorDialog;
@ -21,6 +23,7 @@ import com.ichi2.utils.ResourceLoader;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.annotation.Config;
import java.io.File;
import java.util.HashMap;
@ -407,6 +410,15 @@ public class DeckPickerTest extends RobolectricTest {
}
}
@Test
@Config(qualifiers = "xlarge-port")
public void checkDisplayOfStudyOptionsOnTablet() {
DeckPickerEx deckPickerEx = super.startActivityNormallyOpenCollectionWithIntent(DeckPickerEx.class, new Intent());
StudyOptionsFragment studyOptionsFragment = (StudyOptionsFragment) deckPickerEx.getSupportFragmentManager().findFragmentById(R.id.studyoptions_fragment);
assertThat("Study options should show on start on tablet", studyOptionsFragment, notNullValue());
}
private void useCollection(@SuppressWarnings("SameParameterValue") CollectionType collectionType) {
// load asset into temp