Skip to content

Commit 6afd28e

Browse files
committed
add toggling between displaying full / not full path
1 parent 252803e commit 6afd28e

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

app/src/main/java/com/simplemobiletools/filemanager/Breadcrumbs.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
import com.simplemobiletools.filemanager.models.FileDirItem;
1515

1616
public class Breadcrumbs extends LinearLayout implements View.OnClickListener {
17-
private LayoutInflater mInflater;
1817
private int mDeviceWidth;
18+
private boolean mShowFullPath;
19+
20+
private LayoutInflater mInflater;
1921
private BreadcrumbsListener mListener;
2022

2123
public Breadcrumbs(Context context, AttributeSet attrs) {
@@ -100,22 +102,33 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
100102
}
101103

102104
public void setInitialBreadcrumb(String fullPath) {
105+
mShowFullPath = Config.newInstance(getContext()).getShowFullPath();
103106
final String basePath = Environment.getExternalStorageDirectory().toString();
104-
final String tempPath = fullPath.replace(basePath, getContext().getString(R.string.initial_breadcrumb) + "/");
107+
String tempPath = fullPath;
108+
if (!mShowFullPath) {
109+
tempPath = fullPath.replace(basePath, getContext().getString(R.string.initial_breadcrumb) + "/");
110+
}
111+
105112
removeAllViewsInLayout();
106113
final String[] dirs = tempPath.split("/");
107114
String currPath = basePath;
108115
for (int i = 0; i < dirs.length; i++) {
109116
final String dir = dirs[i];
110117
if (i > 0) {
111118
currPath += dir + "/";
119+
} else if (mShowFullPath) {
120+
addRootFolder();
112121
}
113122

114123
if (dir.isEmpty())
115124
continue;
116125

117126
final FileDirItem item = new FileDirItem(i > 0 ? currPath : basePath, dir, true, 0, 0);
118-
addBreadcrumb(item, i > 1);
127+
addBreadcrumb(item, i > 0 || mShowFullPath);
128+
}
129+
130+
if (dirs.length == 0 && mShowFullPath) {
131+
addRootFolder();
119132
}
120133
}
121134

@@ -137,6 +150,11 @@ public void removeBreadcrumb() {
137150
removeView(getChildAt(getChildCount() - 1));
138151
}
139152

153+
private void addRootFolder() {
154+
final FileDirItem item = new FileDirItem("/", " / ", true, 0, 0);
155+
addBreadcrumb(item, false);
156+
}
157+
140158
@Override
141159
public void onClick(View v) {
142160
final int cnt = getChildCount();

app/src/main/java/com/simplemobiletools/filemanager/activities/MainActivity.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,37 @@ public class MainActivity extends SimpleActivity implements ItemsFragment.ItemIn
2525

2626
private static final int STORAGE_PERMISSION = 1;
2727
private static int mRootFoldersCnt;
28+
private static boolean mShowFullPath;
29+
private static Config mConfig;
2830

2931
@Override
3032
protected void onCreate(Bundle savedInstanceState) {
3133
super.onCreate(savedInstanceState);
3234
setContentView(R.layout.activity_main);
3335
ButterKnife.bind(this);
3436
mBreadcrumbs.setListener(this);
37+
mConfig = Config.newInstance(getApplicationContext());
3538
tryInitFileManager();
3639
}
3740

41+
@Override
42+
protected void onResume() {
43+
super.onResume();
44+
if (Utils.hasStoragePermission(getApplicationContext())) {
45+
final boolean showFullPath = mConfig.getShowFullPath();
46+
if (showFullPath != mShowFullPath)
47+
initRootFileManager();
48+
49+
mShowFullPath = showFullPath;
50+
}
51+
}
52+
53+
@Override
54+
protected void onPause() {
55+
super.onPause();
56+
mShowFullPath = mConfig.getShowFullPath();
57+
}
58+
3859
@Override
3960
protected void onDestroy() {
4061
super.onDestroy();
@@ -122,7 +143,7 @@ public void itemClicked(FileDirItem item) {
122143
public void breadcrumbClicked(int id) {
123144
final FileDirItem item = (FileDirItem) mBreadcrumbs.getChildAt(id).getTag();
124145
final String path = item.getPath();
125-
openPath(path);
126146
mBreadcrumbs.setInitialBreadcrumb(path);
147+
openPath(path);
127148
}
128149
}

0 commit comments

Comments
 (0)