Skip to content

Commit

Permalink
Merge pull request #417 from martincz/master
Browse files Browse the repository at this point in the history
AmazeFileManager: fixed more issues.
  • Loading branch information
VishalNehra authored Jan 23, 2017
2 parents 9fffe5f + 3b90796 commit c33b437
Show file tree
Hide file tree
Showing 122 changed files with 16,145 additions and 9,939 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/amaze/filemanager/adapters/RarAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.support.v7.widget.RecyclerView;
import android.text.format.Formatter;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -322,7 +323,7 @@ void onBindView(RecyclerView.ViewHolder vholder,final int position1){
}
} } else {
if (zipViewer.showSize)
holder.txtDesc.setText(Futils.readableFileSize(rowItem.getSize()));
holder.txtDesc.setText(Formatter.formatFileSize(c, rowItem.getSize()));
holder.txtTitle.setText(rowItem.getName().substring(rowItem.getName().lastIndexOf("/") + 1));
if (zipViewer.coloriseIcons) {
if (Icons.isVideo(rowItem.getName()) || Icons.isPicture(rowItem.getName()))
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/com/amaze/filemanager/filesystem/HFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ public HFile(OpenMode mode, String path, String name, boolean isDirectory) {
} else this.path = path + "/" + name;
}
public void generateMode(Context context){
if(path.startsWith("smb://"))mode=OpenMode.SMB;
else if (path.startsWith("otg:/")) {

if (path.startsWith("smb://")) {
mode = OpenMode.SMB;
} else if (path.startsWith("otg:/")) {
mode = OpenMode.OTG;
} else {
} else if (isCustomPath()) {
mode = OpenMode.CUSTOM;
}else {
if(context==null){
mode=OpenMode.FILE;
return;
Expand Down Expand Up @@ -202,9 +204,9 @@ public boolean isCustomPath(){
path.equals("1") ||
path.equals("2") ||
path.equals("3") ||
path.equals("4") ||
path.equals("5") ||
path.equals("6") ||
path.equals("4"))
path.equals("6"))
return true;
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/amaze/filemanager/fragments/AppsList.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.ListFragment;
import android.text.format.Formatter;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
Expand Down Expand Up @@ -210,7 +211,7 @@ protected ArrayList<Layoutelements> doInBackground(Void[] p1) {
a.add(new Layoutelements(new BitmapDrawable(getActivity().getResources(),
BitmapFactory.decodeResource(getActivity().getResources(), R.drawable.ic_doc_apk_grid)),
object.applicationInfo.loadLabel(p).toString(), object.applicationInfo.publicSourceDir,
object.packageName, object.versionName, Futils.readableFileSize(f.length()),f.length(), false,
object.packageName, object.versionName, Formatter.formatFileSize(getContext(), f.length()),f.length(), false,
f.lastModified()+"", false));
c.add(object);
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/amaze/filemanager/fragments/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.text.format.Formatter;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -1318,7 +1319,7 @@ public ArrayList<Layoutelements> addToSmb(SmbFile[] mFile, String path) throws S
} else {
file_count++;
try {
Layoutelements layoutelements = new Layoutelements(Icons.loadMimeIcon(getActivity(), mFile[i].getPath(), !IS_LIST, res), name, mFile[i].getPath(), "", "", Futils.readableFileSize(mFile[i].length()), mFile[i].length(), false, mFile[i].lastModified() + "", false);
Layoutelements layoutelements = new Layoutelements(Icons.loadMimeIcon(getActivity(), mFile[i].getPath(), !IS_LIST, res), name, mFile[i].getPath(), "", "", Formatter.formatFileSize(getContext(), mFile[i].length()), mFile[i].length(), false, mFile[i].lastModified() + "", false);
layoutelements.setMode(OpenMode.SMB);
searchHelper.add(layoutelements.generateBaseFile());
a.add(layoutelements);
Expand Down Expand Up @@ -1346,7 +1347,7 @@ private void addTo(BaseFile mFile) {
try {
if (mFile.getSize() != -1) {
longSize = Long.valueOf(mFile.getSize());
size = Futils.readableFileSize(longSize);
size = Formatter.formatFileSize(getContext(), longSize);
} else {
size = "";
longSize = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import android.support.v7.widget.CardView;
import android.text.Html;
import android.text.Spanned;
import android.text.format.Formatter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -361,9 +362,9 @@ public void processResults(final DataPackage dataPackage, ServiceType serviceTyp
mProgressFileNameText.setText(name);

Spanned bytesText = Html.fromHtml(getString(R.string.written)
+ " <font color='" + accentColor + "'><i>" + Futils.readableFileSize(doneBytes)
+ " <font color='" + accentColor + "'><i>" + Formatter.formatFileSize(getContext(), doneBytes)
+ " </font></i>" + getString(R.string.out_of) + " <i>"
+ Futils.readableFileSize(total) + "</i>");
+ Formatter.formatFileSize(getContext(), total) + "</i>");
mProgressBytesText.setText(bytesText);

Spanned fileProcessedSpan = Html.fromHtml(getString(R.string.processing_file)
Expand All @@ -374,7 +375,7 @@ public void processResults(final DataPackage dataPackage, ServiceType serviceTyp

Spanned speedSpan = Html.fromHtml(getString(R.string.current_speed)
+ ": <font color='" + accentColor + "'><i>"
+ Futils.readableFileSize(dataPackage.getSpeedRaw())
+ Formatter.formatFileSize(getContext(), dataPackage.getSpeedRaw())
+ "/s</font></i>");
mProgressSpeedText.setText(speedSpan);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.v4.widget.NestedScrollView;
import android.text.format.Formatter;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
Expand All @@ -17,6 +18,8 @@
import com.amaze.filemanager.filesystem.BaseFile;
import com.amaze.filemanager.utils.Futils;

import java.io.File;

/**
* Created by vishal on 14/12/16.
*/
Expand Down Expand Up @@ -62,9 +65,9 @@ public void setupDialog(Dialog dialog, int style) {
mFileNameTextView = (TextView) rootView.findViewById(R.id.text_view_file_name);
mFileNameTextView.setText(mFile.getName());
mFileTypeTextView = (TextView) rootView.findViewById(R.id.text_view_file_type);
mFileTypeTextView.setText(mFile.getName().substring(mFile.getName().lastIndexOf(".")));
mFileTypeTextView.setText(mFile.isDirectory() ? getString(R.string.folder) : mFile.getName().substring(mFile.getName().lastIndexOf(".")));
mFileSizeTextView = (TextView) rootView.findViewById(R.id.text_view_file_size);
mFileSizeTextView.setText(Math.round(mFile.getSize()) + "");
mFileSizeTextView.setText(Formatter.formatFileSize(dialog.getContext(), mFile.isDirectory() ? Futils.folderSize(new File(mFile.getPath())) : mFile.getSize()));
mFileLocationTextView = (TextView) rootView.findViewById(R.id.text_view_file_location);
mFileLocationTextView.setText(mFile.getPath());
mFileAccessedTextView = (TextView) rootView.findViewById(R.id.text_view_file_accessed);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/amaze/filemanager/services/CopyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.app.NotificationCompat;
import android.text.format.Formatter;
import android.util.Log;

import com.amaze.filemanager.R;
Expand Down Expand Up @@ -450,8 +451,8 @@ private void publishResults(int id, String fileName, int sourceFiles, int source
int title = R.string.copying;
if (move) title = R.string.moving;
mBuilder.setContentTitle(c.getResources().getString(title));
mBuilder.setContentText(fileName + " " + Futils.readableFileSize(writtenSize) + "/" +
Futils.readableFileSize(totalSize));
mBuilder.setContentText(fileName + " " + Formatter.formatFileSize(c, writtenSize) + "/" +
Formatter.formatFileSize(c, totalSize));
int id1 = Integer.parseInt("456" + id);
mNotifyManager.notify(id1, mBuilder.build());
if (writtenSize == totalSize || totalSize == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.text.format.Formatter;
import android.util.Log;

import com.amaze.filemanager.R;
Expand Down Expand Up @@ -159,13 +160,13 @@ private void publishResults(int id, String fileName, int sourceFiles, int source
float progressPercent = ((float) done/total)*100;
mBuilder.setProgress(100, Math.round(progressPercent), false);
mBuilder.setOngoing(true);
mBuilder.setContentText(fileName + " " + Futils.readableFileSize(done) + "/"
+ Futils.readableFileSize(total));
mBuilder.setContentText(fileName + " " + Formatter.formatFileSize(cd, done) + "/"
+ Formatter.formatFileSize(cd, total));
int id1=Integer.parseInt("123"+id);
mNotifyManager.notify(id1, mBuilder.build());
if(progressPercent==100 || total == 0){
mBuilder.setContentTitle(getString(R.string.extract_complete));
mBuilder.setContentText(fileName + " " + Futils.readableFileSize(total));
mBuilder.setContentText(fileName + " " + Formatter.formatFileSize(cd, total));
mBuilder.setProgress(100, 100, false);
mBuilder.setOngoing(false);
mNotifyManager.notify(id1, mBuilder.build());
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/amaze/filemanager/services/ZipTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.text.format.Formatter;

import com.amaze.filemanager.R;
import com.amaze.filemanager.activities.MainActivity;
Expand Down Expand Up @@ -269,7 +270,7 @@ private void publishResults(int id, String fileName, int sourceFiles, int source
int title = R.string.compressing;
mBuilder.setContentTitle(c.getResources().getString(title));
mBuilder.setContentText(new File(fileName).getName() + " " +
Futils.readableFileSize(done) + "/" + Futils.readableFileSize(total));
Formatter.formatFileSize(c, done) + "/" + Formatter.formatFileSize(c, total));
int id1 = Integer.parseInt("789" + id);
mNotifyManager.notify(id1, mBuilder.build());
if (done == total || total == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.os.AsyncTask;
import android.text.format.Formatter;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
Expand Down Expand Up @@ -73,10 +74,10 @@ protected void onPostExecute(long[] longs) {
if (longs[0] != -1 && longs[0] != 0) {
float r1 = (longs[0] - longs[1]) * 360 / longs[0];
float r2 = (longs[2]) * 360 / longs[0];
t1.setText(Futils.readableFileSize(longs[0]));
t2.setText(Futils.readableFileSize(longs[1]));
t3.setText(Futils.readableFileSize(longs[0] - longs[1] - longs[2]));
t4.setText(Futils.readableFileSize(longs[2]));
t1.setText(Formatter.formatFileSize(c, longs[0]));
t2.setText(Formatter.formatFileSize(c, longs[1]));
t3.setText(Formatter.formatFileSize(c, longs[0] - longs[1] - longs[2]));
t4.setText(Formatter.formatFileSize(c, longs[2]));

CircleAnimation animation = new CircleAnimation(g.sizeDrawable, r1, r2);
animation.setDuration(Math.round(r1 * 5));
Expand Down Expand Up @@ -116,7 +117,7 @@ protected String doInBackground(String... params) {
int x = f.listFiles(false).size();
items = x + " " + c.getResources().getString(x == 0 ? R.string.item : R.string.items);
} else {
items = Futils.readableFileSize(f.length());
items = Formatter.formatFileSize(c, f.length());
}
publishProgress("");
String md5 = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.database.Cursor;
import android.os.AsyncTask;
import android.provider.MediaStore;
import android.text.format.Formatter;
import android.widget.Toast;

import com.amaze.filemanager.activities.BaseActivity;
Expand Down Expand Up @@ -216,7 +217,7 @@ private ArrayList<Layoutelements> addTo(ArrayList<BaseFile> mFile) {
try {
if (ele.getSize() != -1) {
longSize = Long.valueOf(ele.getSize());
size = Futils.readableFileSize(longSize);
size = Formatter.formatFileSize(c, longSize);
} else {
size = "";
longSize = 0;
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/com/amaze/filemanager/utils/Futils.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,6 @@ public void shareFiles(ArrayList<File> a, Activity c,AppTheme appTheme,int fab_s
}
}

public static String readableFileSize(long size) {
if (size <= 0)
return "0 B";
final String[] units = new String[]{"B", "KB", "MB", "GB", "TB"};
int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
return new DecimalFormat("#,##0.##").format(size
/ Math.pow(1024, digitGroups))
+ "" + units[digitGroups];
}

public static float readableFileSizeFloat(long size) {
if (size <= 0)
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

Expand Down Expand Up @@ -66,8 +65,8 @@ class ViewHolder extends RecyclerView.ViewHolder {

rootView = view;

TextView a = ((TextView) view.findViewById(R.id.firstline));
ImageView v = (ImageView) view.findViewById(R.id.icon);
a = ((TextView) view.findViewById(R.id.firstline));
v = (ImageView) view.findViewById(R.id.icon);
}

void render(final int position) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/res/layout/authors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
android:layout_height="wrap_content"
style="@android:style/TextAppearance.Medium"
android:textStyle="bold"
android:text="Arpit Khurana"/>
android:text="@string/author_1"/>
<TextView
android:id="@+id/git1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/name1"
android:layout_marginTop="15dp"
style="@android:style/TextAppearance.Small"
android:text="Github"/>
android:text="@string/github"/>
<TextView
android:id="@+id/googlePlus1"
android:layout_width="wrap_content"
Expand All @@ -34,7 +34,7 @@
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
style="@android:style/TextAppearance.Small"
android:text="Google+"/>
android:text="@string/googleplus"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
Expand All @@ -49,15 +49,15 @@
android:layout_height="wrap_content"
style="@android:style/TextAppearance.Medium"
android:textStyle="bold"
android:text="Vishal Nehra"/>
android:text="@string/author_2"/>
<TextView
android:id="@+id/git2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/name2"
android:layout_marginTop="15dp"
style="@android:style/TextAppearance.Small"
android:text="Github"/>
android:text="@string/github"/>
<TextView
android:id="@+id/googlePlus2"
android:layout_width="wrap_content"
Expand All @@ -67,7 +67,7 @@
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
style="@android:style/TextAppearance.Small"
android:text="Google+"/>
android:text="@string/googleplus"/>
</RelativeLayout>

<TextView
Expand Down
2 changes: 1 addition & 1 deletion src/main/res/layout/bookmarkrow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
android:layout_height="fill_parent"
android:src="@drawable/ic_action_cancel_light"
android:background="?android:selectableItemBackground"
android:contentDescription="Delete Bookmark" />
android:contentDescription="@string/delbook" />

<LinearLayout
android:layout_height="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion src/main/res/layout/copy_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:text="@string/medium_text"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
Expand Down
2 changes: 1 addition & 1 deletion src/main/res/layout/divider.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
android:textSize="11dip"
android:layout_gravity="center"
android:layout_height="fill_parent"
android:text="Tap and hold on a File or Folder for more options"/>
android:text="@string/tap_and_hold_tips"/>
</FrameLayout>
3 changes: 0 additions & 3 deletions src/main/res/layout/fragment_ftp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="@+id/statusText"
android:layout_above="@+id/startStopButton"
android:layout_centerHorizontal="true"
Expand All @@ -16,7 +15,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text=""
android:id="@+id/ftpAddressText"
android:layout_below="@+id/startStopButton"
android:layout_centerHorizontal="true" />
Expand All @@ -34,7 +32,6 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/primary_red"
android:text=""
android:id="@+id/warningText"
android:layout_above="@+id/startStopButton"
android:layout_centerHorizontal="true" />
Expand Down
Loading

0 comments on commit c33b437

Please sign in to comment.