Search in sources :

Example 31 with FileMeta

use of com.foobnix.dao2.FileMeta in project LibreraReader by foobnix.

the class AppDB method addRecent.

public void addRecent(String path) {
    if (!UITab.isShowRecent()) {
        return;
    }
    if (!new File(path).isFile()) {
        LOG.d("Can't add to recent, it's not a file", path);
        return;
    }
    LOG.d("Add Recent", path);
    FileMeta load = getOrCreate(path);
    load.setIsRecent(true);
    load.setIsRecentTime(System.currentTimeMillis());
    fileMetaDao.update(load);
}
Also used : File(java.io.File) FileMeta(com.foobnix.dao2.FileMeta)

Example 32 with FileMeta

use of com.foobnix.dao2.FileMeta in project LibreraReader by foobnix.

the class AppDB method clearAllRecent.

public void clearAllRecent() {
    List<FileMeta> recent = getRecent();
    for (FileMeta meta : recent) {
        meta.setIsRecent(false);
    }
    fileMetaDao.updateInTx(recent);
}
Also used : FileMeta(com.foobnix.dao2.FileMeta)

Example 33 with FileMeta

use of com.foobnix.dao2.FileMeta in project LibreraReader by foobnix.

the class AppDB method addStarFile.

public void addStarFile(String path) {
    if (!new File(path).isFile()) {
        LOG.d("Can't add to recent, it's not a file", path);
        return;
    }
    LOG.d("addStarFile", path);
    FileMeta load = getOrCreate(path);
    load.setIsStar(true);
    load.setIsStarTime(System.currentTimeMillis());
    load.setCusType(FileMetaAdapter.DISPLAY_TYPE_FILE);
    fileMetaDao.update(load);
}
Also used : File(java.io.File) FileMeta(com.foobnix.dao2.FileMeta)

Example 34 with FileMeta

use of com.foobnix.dao2.FileMeta in project LibreraReader by foobnix.

the class RecentUpates method updateAll.

@TargetApi(25)
public static void updateAll(final Context c) {
    if (c == null) {
        return;
    }
    LOG.d("RecentUpates", "MUPDF!", c.getClass());
    try {
        {
            Intent intent = new Intent(c, RecentBooksWidget.class);
            intent.setAction("android.appwidget.action.APPWIDGET_UPDATE");
            c.sendBroadcast(intent);
        }
    } catch (Exception e) {
        LOG.e(e);
    }
    if (Build.VERSION.SDK_INT >= 25) {
        try {
            FileMeta recentLast = AppDB.get().getRecentLast();
            if (recentLast != null) {
                ShortcutManager shortcutManager = c.getSystemService(ShortcutManager.class);
                String url = IMG.toUrl(recentLast.getPath(), ImageExtractor.COVER_PAGE, IMG.getImageSize());
                Bitmap image = ImageLoader.getInstance().loadImageSync(url, IMG.displayCacheMemoryDisc);
                Intent lastBookIntent = new Intent(c, VerticalViewActivity.class);
                if (AppState.get().isAlwaysOpenAsMagazine) {
                    lastBookIntent = new Intent(c, HorizontalViewActivity.class);
                }
                lastBookIntent.setAction(Intent.ACTION_VIEW);
                lastBookIntent.setData(Uri.fromFile(new File(recentLast.getPath())));
                ShortcutInfo shortcut = // 
                new ShortcutInfo.Builder(c, "last").setShortLabel(// 
                recentLast.getTitle()).setLongLabel(// 
                TxtUtils.getFileMetaBookName(recentLast)).setIcon(// 
                Icon.createWithBitmap(image)).setIntent(// 
                lastBookIntent).build();
                Intent tTSIntent = new Intent(c, TTSActivity.class);
                tTSIntent.setData(Uri.fromFile(new File(recentLast.getPath())));
                tTSIntent.setAction(Intent.ACTION_VIEW);
                ShortcutInfo tts = // 
                new ShortcutInfo.Builder(c, "tts").setShortLabel(// 
                c.getString(R.string.reading_out_loud)).setLongLabel(// 
                c.getString(R.string.reading_out_loud)).setIcon(// 
                Icon.createWithBitmap(image)).setIntent(// 
                tTSIntent).build();
                shortcutManager.setDynamicShortcuts(Arrays.asList(tts, shortcut));
            // shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));
            }
        } catch (Exception e) {
            LOG.e(e);
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) ShortcutInfo(android.content.pm.ShortcutInfo) ShortcutManager(android.content.pm.ShortcutManager) Intent(android.content.Intent) HorizontalViewActivity(com.foobnix.pdf.search.activity.HorizontalViewActivity) File(java.io.File) FileMeta(com.foobnix.dao2.FileMeta) TargetApi(android.annotation.TargetApi)

Example 35 with FileMeta

use of com.foobnix.dao2.FileMeta in project LibreraReader by foobnix.

the class ExportSettingsManager method fileMetaTagToJSON.

public static JSONArray fileMetaTagToJSON(List<FileMeta> list) {
    JSONArray jsonObject = new JSONArray();
    if (list == null) {
        return jsonObject;
    }
    for (FileMeta value : list) {
        JSONObject obj = new JSONObject();
        try {
            obj.put("path", value.getPath());
            obj.put("tag", value.getTag());
        } catch (Exception e) {
            LOG.e(e);
        }
        jsonObject.put(obj);
    }
    return jsonObject;
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) FileMeta(com.foobnix.dao2.FileMeta) JSONException(org.json.JSONException)

Aggregations

FileMeta (com.foobnix.dao2.FileMeta)42 File (java.io.File)26 View (android.view.View)10 OnClickListener (android.view.View.OnClickListener)10 ImageView (android.widget.ImageView)10 TextView (android.widget.TextView)10 Intent (android.content.Intent)8 Bitmap (android.graphics.Bitmap)8 ArrayList (java.util.ArrayList)6 TargetApi (android.annotation.TargetApi)4 AlertDialog (android.app.AlertDialog)4 DialogInterface (android.content.DialogInterface)4 DocumentFile (android.support.v4.provider.DocumentFile)4 RecyclerView (android.support.v7.widget.RecyclerView)4 HorizontalViewActivity (com.foobnix.pdf.search.activity.HorizontalViewActivity)4 MainTabs2 (com.foobnix.ui2.MainTabs2)4 SuppressLint (android.annotation.SuppressLint)3 PendingIntent (android.app.PendingIntent)3 OnDismissListener (android.content.DialogInterface.OnDismissListener)3 Uri (android.net.Uri)3