Search in sources :

Example 1 with CREATED

use of com.ichi2.anki.CardBrowser.Column.CREATED in project AnkiChinaAndroid by ankichinateam.

the class VideoPlayer method onCreate.

/**
 * Called when the activity is first created.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    Timber.i("onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.video_player);
    mPath = getIntent().getStringExtra("path");
    Timber.i("Video Player intent had path: %s", mPath);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    mVideoView = findViewById(R.id.video_surface);
    mVideoView.getHolder().addCallback(this);
    mSoundPlayer = new Sound();
}
Also used : Sound(com.ichi2.libanki.Sound)

Example 2 with CREATED

use of com.ichi2.anki.CardBrowser.Column.CREATED in project AnkiChinaAndroid by ankichinateam.

the class Sched method _updateCutoff.

/**
 * Daily cutoff ************************************************************* **********************************
 * This function uses GregorianCalendar so as to be sensitive to leap years, daylight savings, etc.
 */
@Override
public void _updateCutoff() {
    Integer oldToday = mToday;
    // days since col created
    mToday = (int) ((getTime().intTime() - mCol.getCrt()) / SECONDS_PER_DAY);
    // end of day cutoff
    mDayCutoff = mCol.getCrt() + ((mToday + 1) * SECONDS_PER_DAY);
    if (oldToday != mToday) {
        mCol.log(mToday, mDayCutoff);
    }
    // instead
    for (Deck deck : mCol.getDecks().all()) {
        update(deck);
    }
    // unbury if the day has rolled over
    int unburied = mCol.getConf().optInt("lastUnburied", 0);
    if (unburied < mToday) {
        SyncStatus.ignoreDatabaseModification(this::unburyCards);
    }
}
Also used : Deck(com.ichi2.libanki.Deck)

Example 3 with CREATED

use of com.ichi2.anki.CardBrowser.Column.CREATED in project AnkiChinaAndroid by ankichinateam.

the class SchedV2 method _updateCutoff.

/**
 * Daily cutoff ************************************************************* **********************************
 * This function uses GregorianCalendar so as to be sensitive to leap years, daylight savings, etc.
 */
/* Overriden: other way to count time*/
public void _updateCutoff() {
    Integer oldToday = mToday == null ? 0 : mToday;
    // days since col created
    mToday = _daysSinceCreation();
    // end of day cutoff
    mDayCutoff = _dayCutoff();
    if (oldToday != mToday) {
        mCol.log(mToday, mDayCutoff);
    }
    // instead
    for (Deck deck : mCol.getDecks().all()) {
        update(deck);
    }
    // unbury if the day has rolled over
    int unburied = mCol.getConf().optInt("lastUnburied", 0);
    if (unburied < mToday) {
        SyncStatus.ignoreDatabaseModification(this::unburyCards);
        mCol.getConf().put("lastUnburied", mToday);
    }
}
Also used : Deck(com.ichi2.libanki.Deck)

Example 4 with CREATED

use of com.ichi2.anki.CardBrowser.Column.CREATED in project Anki-Android by ankidroid.

the class DeckPicker method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Resources res = getResources();
    if (getDrawerToggle().onOptionsItemSelected(item)) {
        return true;
    }
    int itemId = item.getItemId();
    if (itemId == R.id.action_undo) {
        Timber.i("DeckPicker:: Undo button pressed");
        undo();
        return true;
    } else if (itemId == R.id.action_sync) {
        Timber.i("DeckPicker:: Sync button pressed");
        sync();
        return true;
    } else if (itemId == R.id.action_import) {
        Timber.i("DeckPicker:: Import button pressed");
        showDialogFragment(ImportFileSelectionFragment.createInstance(this));
        return true;
    } else if (itemId == R.id.action_new_filtered_deck) {
        CreateDeckDialog createFilteredDeckDialog = new CreateDeckDialog(DeckPicker.this, R.string.new_deck, CreateDeckDialog.DeckDialogType.FILTERED_DECK, null);
        createFilteredDeckDialog.setOnNewDeckCreated((id) -> {
            // a filtered deck was created
            openStudyOptions(true);
        });
        createFilteredDeckDialog.showFilteredDeckDialog();
        return true;
    } else if (itemId == R.id.action_check_database) {
        Timber.i("DeckPicker:: Check database button pressed");
        showDatabaseErrorDialog(DatabaseErrorDialog.DIALOG_CONFIRM_DATABASE_CHECK);
        return true;
    } else if (itemId == R.id.action_check_media) {
        Timber.i("DeckPicker:: Check media button pressed");
        showMediaCheckDialog(MediaCheckDialog.DIALOG_CONFIRM_MEDIA_CHECK);
        return true;
    } else if (itemId == R.id.action_empty_cards) {
        Timber.i("DeckPicker:: Empty cards button pressed");
        handleEmptyCards();
        return true;
    } else if (itemId == R.id.action_model_browser_open) {
        Timber.i("DeckPicker:: Model browser button pressed");
        Intent noteTypeBrowser = new Intent(this, ModelBrowser.class);
        startActivityForResultWithAnimation(noteTypeBrowser, 0, START);
        return true;
    } else if (itemId == R.id.action_restore_backup) {
        Timber.i("DeckPicker:: Restore from backup button pressed");
        showDatabaseErrorDialog(DatabaseErrorDialog.DIALOG_CONFIRM_RESTORE_BACKUP);
        return true;
    } else if (itemId == R.id.action_export) {
        Timber.i("DeckPicker:: Export collection button pressed");
        String msg = getResources().getString(R.string.confirm_apkg_export);
        mExportingDelegate.showExportDialog(msg);
        return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) StartupFailure(com.ichi2.anki.InitialActivity.StartupFailure) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) DialogHandler(com.ichi2.anki.dialogs.DialogHandler) Drawable(android.graphics.drawable.Drawable) ShortcutManagerCompat(androidx.core.content.pm.ShortcutManagerCompat) Manifest(android.Manifest) Decks(com.ichi2.libanki.Decks) Fragment(androidx.fragment.app.Fragment) JSONException(com.ichi2.utils.JSONException) ContextCompat(androidx.core.content.ContextCompat) DeckPickerBackupNoSpaceLeftDialog(com.ichi2.anki.dialogs.DeckPickerBackupNoSpaceLeftDialog) IntentFilter(android.content.IntentFilter) Triple(com.ichi2.utils.Triple) SearchView(androidx.appcompat.widget.SearchView) DeckPickerContextMenu(com.ichi2.anki.dialogs.DeckPickerContextMenu) Cancellable(com.ichi2.async.Cancellable) DeckRenameException(com.ichi2.libanki.backend.exception.DeckRenameException) StringRes(androidx.annotation.StringRes) Unit(kotlin.Unit) Nullable(androidx.annotation.Nullable) Message(android.os.Message) HostNumFactory(com.ichi2.anki.web.HostNumFactory) CompatHelper(com.ichi2.compat.CompatHelper) DeckAdapter(com.ichi2.anki.widgets.DeckAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DeckPickerNoSpaceToDowngradeDialog(com.ichi2.anki.dialogs.DeckPickerNoSpaceToDowngradeDialog) DeckPickerConfirmDeleteDeckDialog(com.ichi2.anki.dialogs.DeckPickerConfirmDeleteDeckDialog) Direction(com.ichi2.anim.ActivityTransitionAnimation.Direction) FULL_DOWNLOAD(com.ichi2.async.Connection.ConflictResolution.FULL_DOWNLOAD) SdCardReceiver(com.ichi2.anki.receiver.SdCardReceiver) Editor(android.content.SharedPreferences.Editor) CustomSyncServerUrlException(com.ichi2.libanki.sync.CustomSyncServerUrlException) FileSizeFormatter(com.ichi2.anki.dialogs.DeckPickerNoSpaceToDowngradeDialog.FileSizeFormatter) DeckPickerNoSpaceLeftDialog(com.ichi2.anki.dialogs.DeckPickerNoSpaceLeftDialog) StudyOptionsListener(com.ichi2.anki.StudyOptionsFragment.StudyOptionsListener) BadgeDrawableBuilder(com.ichi2.ui.BadgeDrawableBuilder) Menu(android.view.Menu) DeckService(com.ichi2.anki.servicelayer.DeckService) Connection(com.ichi2.async.Connection) Settings(android.provider.Settings) AnkiPackageImporter(com.ichi2.libanki.importer.AnkiPackageImporter) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) CollectionIntegrityStorageCheck(com.ichi2.anki.CollectionHelper.CollectionIntegrityStorageCheck) ActivityExportingDelegate(com.ichi2.anki.export.ActivityExportingDelegate) TextUtils(android.text.TextUtils) File(java.io.File) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) IconCompat(androidx.core.graphics.drawable.IconCompat) ImportUtils(com.ichi2.utils.ImportUtils) EditText(android.widget.EditText) SchedulerService(com.ichi2.anki.servicelayer.SchedulerService) LinearLayout(android.widget.LinearLayout) AsyncDialogFragment(com.ichi2.anki.dialogs.AsyncDialogFragment) PackageManager(android.content.pm.PackageManager) TaskManager(com.ichi2.async.TaskManager) WindowManager(android.view.WindowManager) UsageAnalytics(com.ichi2.anki.analytics.UsageAnalytics) ModelManager(com.ichi2.libanki.ModelManager) ConfirmationDialog(com.ichi2.anki.dialogs.ConfirmationDialog) AnkiStatsTaskHandler(com.ichi2.anki.stats.AnkiStatsTaskHandler) Permissions(com.ichi2.utils.Permissions) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SyncStatus(com.ichi2.utils.SyncStatus) FragmentTransaction(androidx.fragment.app.FragmentTransaction) BroadcastReceiver(android.content.BroadcastReceiver) DatabaseErrorDialog(com.ichi2.anki.dialogs.DatabaseErrorDialog) CustomStudyDialogFactory(com.ichi2.anki.dialogs.customstudy.CustomStudyDialogFactory) Timber(timber.log.Timber) UndoService(com.ichi2.anki.servicelayer.UndoService) List(java.util.List) TextView(android.widget.TextView) ImportFileSelectionFragment(com.ichi2.anki.dialogs.ImportFileSelectionFragment) RelativeLayout(android.widget.RelativeLayout) Filterable(android.widget.Filterable) TaskListenerWithContext(com.ichi2.async.TaskListenerWithContext) ViewPropertyAnimator(android.view.ViewPropertyAnimator) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Snackbar(com.google.android.material.snackbar.Snackbar) Window(android.view.Window) VersionUtils(com.ichi2.utils.VersionUtils) Context(android.content.Context) TaskListener(com.ichi2.async.TaskListener) KeyEvent(android.view.KeyEvent) GravityEnum(com.afollestad.materialdialogs.GravityEnum) Pair(android.util.Pair) DeckPickerAnalyticsOptInDialog(com.ichi2.anki.dialogs.DeckPickerAnalyticsOptInDialog) ImportDialog(com.ichi2.anki.dialogs.ImportDialog) Intent(android.content.Intent) Collection(com.ichi2.libanki.Collection) StyledProgressDialog(com.ichi2.themes.StyledProgressDialog) PixelFormat(android.graphics.PixelFormat) TypedArray(android.content.res.TypedArray) MenuItem(android.view.MenuItem) WidgetStatus(com.ichi2.widget.WidgetStatus) SyncErrorDialog(com.ichi2.anki.dialogs.SyncErrorDialog) Payload(com.ichi2.async.Connection.Payload) Model(com.ichi2.libanki.Model) Build(android.os.Build) ShortcutInfoCompat(androidx.core.content.pm.ShortcutInfoCompat) Utils(com.ichi2.libanki.Utils) DialogInterface(android.content.DialogInterface) ConfirmModSchemaException(com.ichi2.anki.exception.ConfirmModSchemaException) Computation(com.ichi2.utils.Computation) AbstractDeckTreeNode(com.ichi2.libanki.sched.AbstractDeckTreeNode) ActivityCompat(androidx.core.app.ActivityCompat) CreateDeckDialog(com.ichi2.anki.dialogs.CreateDeckDialog) CollectionTask(com.ichi2.async.CollectionTask) SQLException(android.database.SQLException) CustomStudyDialog(com.ichi2.anki.dialogs.customstudy.CustomStudyDialog) Syncer(com.ichi2.libanki.sync.Syncer) MediaCheckDialog(com.ichi2.anki.dialogs.MediaCheckDialog) AdaptionUtil(com.ichi2.utils.AdaptionUtil) VisibleForTesting(androidx.annotation.VisibleForTesting) Resources(android.content.res.Resources) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) Resources(android.content.res.Resources) CreateDeckDialog(com.ichi2.anki.dialogs.CreateDeckDialog)

Example 5 with CREATED

use of com.ichi2.anki.CardBrowser.Column.CREATED in project Anki-Android by ankidroid.

the class DeckPicker method onCreate.

// ----------------------------------------------------------------------------
// ANDROID ACTIVITY METHODS
// ----------------------------------------------------------------------------
/**
 * Called when the activity is first created.
 */
@Override
protected void onCreate(Bundle savedInstanceState) throws SQLException {
    if (showedActivityFailedScreen(savedInstanceState)) {
        return;
    }
    Timber.d("onCreate()");
    mExportingDelegate = new ActivityExportingDelegate(this, this::getCol);
    mCustomStudyDialogFactory = new CustomStudyDialogFactory(this::getCol, this).attachToActivity(this);
    mContextMenuFactory = new DeckPickerContextMenu.Factory(this::getCol).attachToActivity(this);
    // we need to restore here, as we need it before super.onCreate() is called.
    restoreWelcomeMessage(savedInstanceState);
    // Then set theme and content view
    super.onCreate(savedInstanceState);
    handleStartup();
    setContentView(R.layout.homescreen);
    View mainView = findViewById(android.R.id.content);
    // check, if tablet layout
    mStudyoptionsFrame = findViewById(R.id.studyoptions_fragment);
    // 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
    initNavigationDrawer(mainView);
    setTitle(getResources().getString(R.string.app_name));
    mDeckPickerContent = findViewById(R.id.deck_picker_content);
    mRecyclerView = findViewById(R.id.files);
    mNoDecksPlaceholder = findViewById(R.id.no_decks_placeholder);
    mDeckPickerContent.setVisibility(View.GONE);
    mNoDecksPlaceholder.setVisibility(View.GONE);
    // specify a LinearLayoutManager and set up item dividers for the RecyclerView
    mRecyclerViewLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mRecyclerViewLayoutManager);
    TypedArray ta = this.obtainStyledAttributes(new int[] { R.attr.deckDivider });
    Drawable divider = ta.getDrawable(0);
    ta.recycle();
    DividerItemDecoration dividerDecorator = new DividerItemDecoration(this, mRecyclerViewLayoutManager.getOrientation());
    dividerDecorator.setDrawable(divider);
    mRecyclerView.addItemDecoration(dividerDecorator);
    // Add background to Deckpicker activity
    View view = mFragmented ? findViewById(R.id.deckpicker_xl_view) : findViewById(R.id.root_layout);
    boolean hasDeckPickerBackground = false;
    try {
        hasDeckPickerBackground = applyDeckPickerBackground(view);
    } catch (OutOfMemoryError e) {
        // 6608 - OOM should be catchable here.
        Timber.w(e, "Failed to apply background - OOM");
        UIUtils.showThemedToast(this, getString(R.string.background_image_too_large), false);
    } catch (Exception e) {
        Timber.w(e, "Failed to apply background");
        UIUtils.showThemedToast(this, getString(R.string.failed_to_apply_background_image, e.getLocalizedMessage()), false);
    }
    // create and set an adapter for the RecyclerView
    mDeckListAdapter = new DeckAdapter(getLayoutInflater(), this);
    mDeckListAdapter.setDeckClickListener(mDeckClickListener);
    mDeckListAdapter.setCountsClickListener(mCountsClickListener);
    mDeckListAdapter.setDeckExpanderClickListener(mDeckExpanderClickListener);
    mDeckListAdapter.setDeckLongClickListener(mDeckLongClickListener);
    mDeckListAdapter.enablePartialTransparencyForBackground(hasDeckPickerBackground);
    mRecyclerView.setAdapter(mDeckListAdapter);
    mPullToSyncWrapper = findViewById(R.id.pull_to_sync_wrapper);
    mPullToSyncWrapper.setDistanceToTriggerSync(SWIPE_TO_SYNC_TRIGGER_DISTANCE);
    mPullToSyncWrapper.setOnRefreshListener(() -> {
        Timber.i("Pull to Sync: Syncing");
        mPullToSyncWrapper.setRefreshing(false);
        sync();
    });
    mPullToSyncWrapper.getViewTreeObserver().addOnScrollChangedListener(() -> mPullToSyncWrapper.setEnabled(mRecyclerViewLayoutManager.findFirstCompletelyVisibleItemPosition() == 0));
    // Setup the FloatingActionButtons, should work everywhere with min API >= 15
    mFloatingActionMenu = new DeckPickerFloatingActionMenu(view, this);
    mReviewSummaryTextView = findViewById(R.id.today_stats_text_view);
    mShortAnimDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);
    new Onboarding.DeckPicker(this, mRecyclerViewLayoutManager).onCreate();
}
Also used : Drawable(android.graphics.drawable.Drawable) HostNumFactory(com.ichi2.anki.web.HostNumFactory) CustomStudyDialogFactory(com.ichi2.anki.dialogs.customstudy.CustomStudyDialogFactory) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) SearchView(androidx.appcompat.widget.SearchView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) JSONException(com.ichi2.utils.JSONException) DeckRenameException(com.ichi2.libanki.backend.exception.DeckRenameException) CustomSyncServerUrlException(com.ichi2.libanki.sync.CustomSyncServerUrlException) ConfirmModSchemaException(com.ichi2.anki.exception.ConfirmModSchemaException) SQLException(android.database.SQLException) DeckAdapter(com.ichi2.anki.widgets.DeckAdapter) CustomStudyDialogFactory(com.ichi2.anki.dialogs.customstudy.CustomStudyDialogFactory) TypedArray(android.content.res.TypedArray) ActivityExportingDelegate(com.ichi2.anki.export.ActivityExportingDelegate)

Aggregations

Collection (com.ichi2.libanki.Collection)9 ConfirmModSchemaException (com.ichi2.anki.exception.ConfirmModSchemaException)7 JSONException (com.ichi2.utils.JSONException)7 File (java.io.File)7 Intent (android.content.Intent)5 Model (com.ichi2.libanki.Model)5 SharedPreferences (android.content.SharedPreferences)4 Uri (android.net.Uri)4 Bundle (android.os.Bundle)4 View (android.view.View)4 TextView (android.widget.TextView)4 Deck (com.ichi2.libanki.Deck)4 Manifest (android.Manifest)3 BroadcastReceiver (android.content.BroadcastReceiver)3 Context (android.content.Context)3 IntentFilter (android.content.IntentFilter)3 PackageManager (android.content.pm.PackageManager)3 Resources (android.content.res.Resources)3 Message (android.os.Message)3 DeckRenameException (com.ichi2.libanki.backend.exception.DeckRenameException)3