Search in sources :

Example 1 with QuranSettings

use of com.quran.labs.androidquran.util.QuranSettings in project quran_android by quran.

the class InlineTranslationView method initResources.

private void initResources() {
    QuranSettings settings = QuranSettings.getInstance(context);
    fontSize = settings.getTranslationTextSize();
    textStyle = R.style.TranslationText;
}
Also used : QuranSettings(com.quran.labs.androidquran.util.QuranSettings)

Example 2 with QuranSettings

use of com.quran.labs.androidquran.util.QuranSettings in project quran_android by quran.

the class TranslationManagerActivity method removeItem.

private void removeItem(final TranslationRowData translationRowData) {
    if (adapter == null) {
        return;
    }
    final TranslationItem selectedItem = (TranslationItem) translationRowData;
    String msg = String.format(getString(R.string.remove_dlg_msg), selectedItem.name());
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.remove_dlg_title).setMessage(msg).setPositiveButton(R.string.remove_button, (dialog, id) -> {
        quranFileUtils.removeTranslation(TranslationManagerActivity.this, selectedItem.translation.getFileName());
        TranslationItem updatedItem = selectedItem.withTranslationRemoved();
        updateTranslationItem(updatedItem);
        // remove from active translations
        QuranSettings settings = QuranSettings.getInstance(this);
        Set<String> activeTranslations = settings.getActiveTranslations();
        activeTranslations.remove(selectedItem.translation.getFileName());
        settings.setActiveTranslations(activeTranslations);
        generateListItems();
    }).setNegativeButton(R.string.cancel, (dialog, i) -> dialog.dismiss());
    builder.show();
}
Also used : TranslationItem(com.quran.labs.androidquran.dao.translation.TranslationItem) AlertDialog(android.support.v7.app.AlertDialog) Bundle(android.os.Bundle) TranslationRowData(com.quran.labs.androidquran.dao.translation.TranslationRowData) SparseIntArray(android.util.SparseIntArray) QuranDownloadService(com.quran.labs.androidquran.service.QuranDownloadService) ServiceIntentHelper(com.quran.labs.androidquran.service.util.ServiceIntentHelper) Intent(android.content.Intent) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) TranslationsAdapter(com.quran.labs.androidquran.ui.adapter.TranslationsAdapter) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) TranslationHeader(com.quran.labs.androidquran.dao.translation.TranslationHeader) R(com.quran.labs.androidquran.R) QuranFileUtils(com.quran.labs.androidquran.util.QuranFileUtils) QuranSettings(com.quran.labs.androidquran.util.QuranSettings) ActionBar(android.support.v7.app.ActionBar) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) IntentFilter(android.content.IntentFilter) QuranDownloadNotifier(com.quran.labs.androidquran.service.util.QuranDownloadNotifier) Set(java.util.Set) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TranslationManagerPresenter(com.quran.labs.androidquran.presenter.translation.TranslationManagerPresenter) QuranApplication(com.quran.labs.androidquran.QuranApplication) File(java.io.File) Timber(timber.log.Timber) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) Disposable(io.reactivex.disposables.Disposable) AlertDialog(android.support.v7.app.AlertDialog) TranslationItem(com.quran.labs.androidquran.dao.translation.TranslationItem) DefaultDownloadReceiver(com.quran.labs.androidquran.service.util.DefaultDownloadReceiver) Snackbar(android.support.design.widget.Snackbar) Set(java.util.Set) QuranSettings(com.quran.labs.androidquran.util.QuranSettings)

Example 3 with QuranSettings

use of com.quran.labs.androidquran.util.QuranSettings in project quran_android by quran.

the class TranslationManagerActivity method handleDownloadSuccess.

@Override
public void handleDownloadSuccess() {
    if (downloadingItem != null) {
        if (downloadingItem.exists()) {
            try {
                File f = new File(databaseDirectory, downloadingItem.translation.getFileName() + UPGRADING_EXTENSION);
                if (f.exists()) {
                    f.delete();
                }
            } catch (Exception e) {
                Timber.d(e, "error removing old database file");
            }
        }
        TranslationItem updated = downloadingItem.withTranslationVersion(downloadingItem.translation.getCurrentVersion());
        updateTranslationItem(updated);
        // update active translations and add this item to it
        QuranSettings settings = QuranSettings.getInstance(this);
        Set<String> activeTranslations = settings.getActiveTranslations();
        activeTranslations.add(downloadingItem.translation.getFileName());
        settings.setActiveTranslations(activeTranslations);
    }
    downloadingItem = null;
    generateListItems();
}
Also used : TranslationItem(com.quran.labs.androidquran.dao.translation.TranslationItem) QuranSettings(com.quran.labs.androidquran.util.QuranSettings) File(java.io.File)

Example 4 with QuranSettings

use of com.quran.labs.androidquran.util.QuranSettings in project quran_android by quran.

the class JuzListFragment method onResume.

@Override
public void onResume() {
    final Activity activity = getActivity();
    if (activity instanceof QuranActivity) {
        disposable = ((QuranActivity) activity).getLatestPageObservable().first(Constants.NO_PAGE).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableSingleObserver<Integer>() {

            @Override
            public void onSuccess(Integer recentPage) {
                if (recentPage != Constants.NO_PAGE) {
                    int juz = quranInfo.getJuzFromPage(recentPage);
                    int position = (juz - 1) * 9;
                    mRecyclerView.scrollToPosition(position);
                }
            }

            @Override
            public void onError(Throwable e) {
            }
        });
    }
    QuranSettings settings = QuranSettings.getInstance(activity);
    if (settings.isArabicNames()) {
        updateScrollBarPositionHoneycomb();
    }
    super.onResume();
}
Also used : DisposableSingleObserver(io.reactivex.observers.DisposableSingleObserver) QuranActivity(com.quran.labs.androidquran.ui.QuranActivity) QuranActivity(com.quran.labs.androidquran.ui.QuranActivity) Activity(android.app.Activity) QuranSettings(com.quran.labs.androidquran.util.QuranSettings)

Example 5 with QuranSettings

use of com.quran.labs.androidquran.util.QuranSettings in project quran_android by quran.

the class SuraListFragment method onResume.

@Override
public void onResume() {
    final Activity activity = getActivity();
    if (activity instanceof QuranActivity) {
        QuranSettings settings = QuranSettings.getInstance(activity);
        disposable = ((QuranActivity) activity).getLatestPageObservable().first(Constants.NO_PAGE).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableSingleObserver<Integer>() {

            @Override
            public void onSuccess(Integer recentPage) {
                if (recentPage != Constants.NO_PAGE) {
                    int sura = quranInfo.safelyGetSuraOnPage(recentPage);
                    int juz = quranInfo.getJuzFromPage(recentPage);
                    int position = sura + juz - 1;
                    mRecyclerView.scrollToPosition(position);
                }
            }

            @Override
            public void onError(Throwable e) {
            }
        });
        if (settings.isArabicNames()) {
            updateScrollBarPositionHoneycomb();
        }
    }
    super.onResume();
}
Also used : DisposableSingleObserver(io.reactivex.observers.DisposableSingleObserver) QuranActivity(com.quran.labs.androidquran.ui.QuranActivity) QuranActivity(com.quran.labs.androidquran.ui.QuranActivity) Activity(android.app.Activity) QuranSettings(com.quran.labs.androidquran.util.QuranSettings)

Aggregations

QuranSettings (com.quran.labs.androidquran.util.QuranSettings)8 Activity (android.app.Activity)2 Context (android.content.Context)2 TranslationItem (com.quran.labs.androidquran.dao.translation.TranslationItem)2 QuranActivity (com.quran.labs.androidquran.ui.QuranActivity)2 StorageUtils (com.quran.labs.androidquran.util.StorageUtils)2 DisposableSingleObserver (io.reactivex.observers.DisposableSingleObserver)2 File (java.io.File)2 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Bundle (android.os.Bundle)1 Snackbar (android.support.design.widget.Snackbar)1 LocalBroadcastManager (android.support.v4.content.LocalBroadcastManager)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 ActionBar (android.support.v7.app.ActionBar)1 AlertDialog (android.support.v7.app.AlertDialog)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SparseIntArray (android.util.SparseIntArray)1 MenuItem (android.view.MenuItem)1