Esempio n. 1
0
 @Override
 public Bitmap getDetailTexture(int n) {
   Bitmap bitmap =
       Bitmap.createBitmap(DETAIL_TEXTURE_WIDTH, DETAIL_TEXTURE_HEIGHT, Bitmap.Config.ARGB_8888);
   Canvas canvas = new Canvas(bitmap);
   canvas.drawARGB(32, 10, 10, 10);
   mPaint.setTextSize(15.0f);
   mPaint.setAntiAlias(true);
   OpenPath mPath = mPathItems[n];
   if (mPath == null)
     canvas.drawText("Detail text for card " + n, 0, DETAIL_TEXTURE_HEIGHT / 2, mPaint);
   else {
     Path p = new Path();
     RectF bounds = new RectF();
     String s = mPath.getName();
     int y = (int) mPaint.getTextSize() + 2;
     while (s != "") {
       mPaint.getTextPath(s, 0, s.length(), 0, 0, p);
       p.computeBounds(bounds, true);
       float lines = Math.max(1, bounds.right / DETAIL_TEXTURE_WIDTH);
       int chars = (int) (s.length() / lines);
       canvas.drawText(s, 0, chars, 0, y, mPaint);
       if (chars >= s.length()) break;
       y += bounds.height() + 2;
       s = s.substring(chars).trim();
     }
   }
   return bitmap;
 }
Esempio n. 2
0
 @Override
 public OpenPath getChild(String name) {
   try {
     for (OpenPath kid : list()) if (kid.getName().equals(name)) return kid;
   } catch (IOException e) {
   }
   return null;
 }
 @Override
 public Uri getUri() {
   String s = "content://org.brandroid.openmanager/merge/";
   for (OpenPath p : mParents) s += Uri.encode(p.getPath()) + ":";
   s = s.substring(0, s.length() - 1);
   Uri ret = null;
   ret = Uri.parse(s);
   return ret;
 }
Esempio n. 4
0
 @Override
 public OpenPath getChild(String name) {
   try {
     OpenPath[] kids = list();
     for (OpenPath kid : kids) if (kid.getName().equals(name)) return kid;
   } catch (Exception e) {
   }
   return null;
 }
Esempio n. 5
0
 @Override
 public OpenPath getChild(String name) {
   try {
     for (OpenPath kid : list()) if (kid.getName().equals(name)) return kid;
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return null;
 }
Esempio n. 6
0
 /**
  * Indicates all OpenPath hierarchy (parent, grandparent, etc.).
  *
  * @param andSelf Use selected path as first object.
  * @return List<OpenPath> collection of OpenPath objects.
  */
 public List<OpenPath> getAncestors(boolean andSelf) {
   ArrayList<OpenPath> ret = new ArrayList<OpenPath>();
   OpenPath tmp = this;
   if (!andSelf) tmp = tmp.getParent();
   while (tmp != null) {
     ret.add(tmp);
     tmp = tmp.getParent();
   }
   return ret;
 }
Esempio n. 7
0
 /**
  * Get selected directory's child count, if applicable. If thread is required, this will return 0.
  *
  * @param countHidden Count hidden children
  * @return Integer representing number of children.
  * @throws IOException
  */
 public int getChildCount(boolean countHidden) throws IOException {
   if (requiresThread()) return 0;
   if (countHidden) return list().length;
   else {
     int ret = 0;
     OpenPath[] kids = list();
     if (kids == null) return 0;
     for (OpenPath kid : kids) if (!kid.isHidden()) ret++;
     return ret;
   }
 }
Esempio n. 8
0
 /**
  * Compare two OpenPath files, with sorting taken into account
  *
  * @param fa First OpenPath
  * @param fb Second OpenPath
  * @return an int determined by comparing the two paths. Possible values are described in the
  *     Comparable interface.
  * @see Comparable
  */
 public static int compare(OpenPath fa, OpenPath fb) {
   try {
     if (fa == null && fb != null) return 1;
     if (fb == null && fa != null) return 0;
     if (fb == null || fa == null) return 0;
     if (Sorting.foldersFirst()) {
       if (fb.isDirectory() && !fa.isDirectory()) return 1;
       if (fa.isDirectory() && !fb.isDirectory()) return -1;
     }
     String a = fa.getName();
     String b = fb.getName();
     Long sa = fa.length();
     Long sb = fb.length();
     Long ma = fa.lastModified();
     Long mb = fb.lastModified();
     if (a == null && b != null) return 1;
     if (a == null || b == null) return 0;
     switch (Sorting.getType()) {
       case ALPHA_DESC:
         return b.toLowerCase().compareTo(a.toLowerCase());
       case ALPHA:
         return a.toLowerCase().compareTo(b.toLowerCase());
       case SIZE_DESC:
         if (sa == null && sb != null) return 1;
         if (sa == null || sb == null) return 0;
         return sa.compareTo(sb);
       case SIZE:
         if (sb == null && sa != null) return 1;
         if (sa == null || sb == null) return 0;
         return sb.compareTo(sa);
       case DATE_DESC:
         if (ma == null && mb != null) return 1;
         if (ma == null || mb == null) return 0;
         return ma.compareTo(mb);
       case DATE:
         if (mb == null && ma != null) return 1;
         if (ma == null || mb == null) return 0;
         return mb.compareTo(ma);
       case TYPE:
         String ea = a.substring(a.lastIndexOf(".") + 1, a.length()).toLowerCase();
         String eb = b.substring(b.lastIndexOf(".") + 1, b.length()).toLowerCase();
         return ea.compareTo(eb);
       case NONE:
         return 0;
       default:
         return a.toLowerCase().compareTo(b.toLowerCase());
     }
   } catch (Exception e) {
     Logger.LogError("Unable to sort.", e);
     return 0;
   }
 }
Esempio n. 9
0
    @Override
    public Bitmap getTexture(int n) {
      final int textw = TEXTURE_WIDTH;
      final int texth = TEXTURE_HEIGHT;
      final int px = PIXEL_BORDER;

      Bitmap bitmap = Bitmap.createBitmap(textw, texth, Bitmap.Config.ARGB_8888);
      Canvas canvas = new Canvas(bitmap);

      int w = textw;
      int h = texth;

      SoftReference<Bitmap> thumb = null;

      final OpenPath mPath = mPathItems[n];
      mPaint.setColor(0x40808080);

      canvas.drawARGB(0, 0, 0, 0);
      mPaint.setColor(0xffffffff);
      mPaint.setAntiAlias(true);

      if (mPathItems != null
          && (thumb = ThumbnailCreator.generateThumb(mPath, textw, texth, getApplicationContext()))
              != null
          && thumb.get() != null) {
        Bitmap b = thumb.get();
        w = b.getWidth();
        h = b.getHeight();
        // canvas.drawRect(2, 2, w - 2, h - 2, mPaint);
        // canvas.drawRect(px, px, textw - px, texth, mBlackPaint);
        Matrix matrix = canvas.getMatrix();
        matrix.setRectToRect(new RectF(0, 0, w, h), new RectF(0, 0, w, h), ScaleToFit.START);
        canvas.drawBitmap(b, matrix, null);
      } else {
        canvas.drawRect(2, 2, w - 2, h - 2, mPaint);
        mPaint.setTextSize(100.0f);
        if (mPath == null) canvas.drawText("" + n, 2, h - 10, mPaint);
        else {
          mPaint.setTextSize(30f);
          canvas.drawText(mPath.getName(), 2, h - 10, mPaint);
        }
        canvas.drawBitmap(mGlossyOverlay, null, new Rect(px, px, textw - px, texth - px), mPaint);
      }
      return bitmap;
    }
Esempio n. 10
0
 @Override
 protected void finalize() throws Throwable {
   super.finalize();
   if (mLZMA != null)
     try {
       mLZMA.close();
     } catch (Exception e) {
     }
   if (mRAF != null)
     try {
       mRAF.close();
     } catch (Exception e) {
     }
 }
Esempio n. 11
0
  public void refreshData(Bundle data, boolean allowSkips) {
    // ArrayList<OpenPath> mData = new ArrayList<OpenPath>();

    try {
      mPathItems = mPath.listFiles();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    Arrays.sort(mPathItems);

    // mPathItems = mData.toArray(new OpenPath[mData.size()]);
    // rerun();
  }
Esempio n. 12
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (!isVisible() || isDetached()) return;
    super.onCreateOptionsMenu(menu, inflater);
    if (mPath == null || !mPath.isFile() || !IntentManager.isIntentAvailable(mPath, getExplorer()))
      MenuUtils.setMenuVisible(menu, false, R.id.menu_context_edit, R.id.menu_context_view);
    Logger.LogVerbose("ContentFragment.onCreateOptionsMenu");
    if (!menu.hasVisibleItems()) inflater.inflate(R.menu.content, menu);
    MenuUtils.setMenuVisible(menu, OpenExplorer.IS_DEBUG_BUILD, R.id.menu_debug);
    if (!OpenExplorer.BEFORE_HONEYCOMB && OpenExplorer.USE_ACTION_BAR) {
      MenuUtils.setMenuVisible(menu, false, R.id.menu_more);
      try {
        final SearchView mSearchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
        if (mSearchView != null)
          mSearchView.setOnQueryTextListener(
              new SearchView.OnQueryTextListener() {
                @TargetApi(11)
                public boolean onQueryTextSubmit(String query) {
                  mSearchView.clearFocus();
                  Intent intent = getExplorer().getIntent();
                  if (intent == null) intent = new Intent();
                  intent.setAction(Intent.ACTION_SEARCH);
                  Bundle appData = new Bundle();
                  appData.putString(
                      "path", getExplorer().getDirContentFragment(false).getPath().getPath());
                  intent.putExtra(SearchManager.APP_DATA, appData);
                  intent.putExtra(SearchManager.QUERY, query);
                  getExplorer().handleIntent(intent);
                  return true;
                }

                public boolean onQueryTextChange(String newText) {
                  return false;
                }
              });
      } catch (NullPointerException e) {
        Logger.LogError("Couldn't set up Search ActionView", e);
      }
    }
  }
Esempio n. 13
0
 /**
  * Only list child directories, if any.
  *
  * @return Array of OpenPath representing child directories
  * @throws IOException
  */
 public OpenPath[] listDirectories() throws IOException {
   ArrayList<OpenPath> ret = new ArrayList<OpenPath>();
   for (OpenPath path : list()) if (path.isDirectory()) ret.add(path);
   return ret.toArray(new OpenPath[ret.size()]);
 }
Esempio n. 14
0
 @Override
 public String getDetails(boolean countHiddenChildren) {
   String ret = super.getDetails(countHiddenChildren);
   if (!isDirectory()) ret += " (" + OpenPath.formatSize(ze.getCompressedSize()) + ")";
   return ret;
 }
Esempio n. 15
0
 @Override
 public OpenPath getChild(String name) {
   for (OpenPath kid : mKids) if (kid.getName().equals(name)) return kid;
   return null;
 }
Esempio n. 16
0
 public void refreshKids() throws IOException {
   for (OpenPath parent : mParents)
     for (OpenPath kid : parent.list()) if (!mKids.contains(kid)) mKids.add(kid);
   mDirty = false;
 }
Esempio n. 17
0
 @Override
 public Long lastModified() {
   long last = 0;
   for (OpenPath kid : mKids) last = Math.max(kid.lastModified(), last);
   return null;
 }
Esempio n. 18
0
 @Override
 public CharSequence getTitle() {
   return mPath.getName();
 }
Esempio n. 19
0
 public static String formatSize(long size, int decimalPoints) {
   return OpenPath.formatSize(size, decimalPoints, true);
 }
Esempio n. 20
0
 public OpenPath push(OpenPath file) {
   if (mStack.size() == 0 || !mStack.peek().getPath().equals(file.getPath())) mStack.push(file);
   return file;
 }