Skip to content

Commit d171118

Browse files
committed
Updated to Android-8 (API 27) and bug fixes
- Fixed issue of display of extenstion less files when filter is applied - Added translations support - Updated FastScroll Lib. Hopefully no more crashes
1 parent 8074574 commit d171118

26 files changed

+283
-143
lines changed

.idea/.name

Lines changed: 0 additions & 1 deletion
This file was deleted.

.idea/gradle.xml

Lines changed: 4 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 14 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
buildscript {
44
repositories {
55
jcenter()
6+
google()
67
}
78
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.1.3'
9+
classpath 'com.android.tools.build:gradle:3.3.0'
910

1011
// NOTE: Do not place your application dependencies here; they belong
1112
// in the individual module build.gradle files
@@ -15,6 +16,7 @@ buildscript {
1516
allprojects {
1617
repositories {
1718
jcenter()
19+
google()
1820
}
1921
}
2022

filebrowser/build.gradle

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ apply plugin: 'com.android.library'
33
ext {
44
PUBLISH_GROUP_ID = 'com.adityak'
55
PUBLISH_ARTIFACT_ID = 'browsemyfiles'
6-
PUBLISH_VERSION = '1.7'
6+
PUBLISH_VERSION = '1.8'
77
}
88

99
android {
10-
compileSdkVersion 25
11-
buildToolsVersion "25.0.2"
10+
compileSdkVersion 27
11+
buildToolsVersion "28.0.3"
1212

1313
defaultConfig {
1414
//applicationId "com.aditya.filebrowser"
1515
minSdkVersion 15
16-
targetSdkVersion 25
17-
versionCode 9
18-
versionName "1.7"
16+
targetSdkVersion 27
17+
versionCode 10
18+
versionName "1.8"
1919
}
2020
buildTypes {
2121
release {
@@ -26,14 +26,15 @@ android {
2626
}
2727

2828
dependencies {
29-
compile fileTree(include: ['*.jar'], dir: 'libs')
30-
testCompile 'junit:junit:4.12'
31-
compile 'com.android.support:appcompat-v7:25.3.0'
32-
compile 'com.android.support:recyclerview-v7:25.3.0'
33-
compile 'com.beardedhen:androidbootstrap:2.3.1'
34-
compile 'com.roughike:bottom-bar:2.3.1'
35-
compile 'com.simplecityapps:recyclerview-fastscroll:1.0.14'
36-
compile files('libs/commons-io-2.5.jar')
29+
implementation fileTree(include: ['*.jar'], dir: 'libs')
30+
testImplementation 'junit:junit:4.12'
31+
implementation 'com.android.support:design:27.1.1'
32+
implementation 'com.android.support:appcompat-v7:27.1.1'
33+
implementation 'com.android.support:recyclerview-v7:27.1.1'
34+
implementation 'com.beardedhen:androidbootstrap:2.3.1'
35+
implementation 'com.roughike:bottom-bar:2.3.1'
36+
implementation 'com.simplecityapps:recyclerview-fastscroll:1.0.20'
37+
implementation files('libs/commons-io-2.6.jar')
3738
}
3839

3940
apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'

filebrowser/libs/commons-io-2.5.jar

-204 KB
Binary file not shown.

filebrowser/libs/commons-io-2.6.jar

210 KB
Binary file not shown.

filebrowser/src/main/AndroidManifest.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@
3030
</meta-data>
3131
</activity>
3232
<activity android:name=".utils.Permissions" android:theme="@style/Theme.AppCompat.Translucent" />
33+
<provider
34+
android:name="android.support.v4.content.FileProvider"
35+
android:authorities="com.aditya.filebrowser.provider"
36+
android:exported="false"
37+
android:grantUriPermissions="true">
38+
<meta-data
39+
android:name="android.support.FILE_PROVIDER_PATHS"
40+
android:resource="@xml/provider_paths"/>
41+
</provider>
3342
</application>
3443

3544
</manifest>

filebrowser/src/main/java/com/aditya/filebrowser/Constants.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ public enum SELECTION_MODES {
5353
public static final String EXTERNALSTORAGE = "External Storage";
5454
public static File internalStorageRoot = Environment.getExternalStorageDirectory();
5555
public static File externalStorageRoot;
56+
public static final String SHOW_FOLDER_SIZE = "false";
57+
public static final String DATE_FORMAT = "dd.MM.yyyy HH:mm:ss";
58+
5659
static {
5760

5861
try {
@@ -76,7 +79,4 @@ public enum SELECTION_MODES {
7679
externalStorageRoot = new File("/");
7780
}
7881
}
79-
80-
public static final String SHOW_FOLDER_SIZE = "false";
81-
public static final String DATE_FORMAT = "dd-MM-yyyy HH:mm:ss";
8282
}

filebrowser/src/main/java/com/aditya/filebrowser/FileBrowser.java

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import android.os.Bundle;
1414
import android.os.Handler;
1515
import android.os.Looper;
16+
import android.support.v4.content.FileProvider;
1617
import android.support.v7.app.AppCompatActivity;
1718
import android.support.v7.view.ActionMode;
1819
import android.support.v7.widget.LinearLayoutManager;
@@ -60,7 +61,7 @@ public class FileBrowser extends AppCompatActivity implements OnFileChangedListe
6061

6162
private CustomAdapter mAdapter;
6263
private FastScrollRecyclerView.LayoutManager mLayoutManager;
63-
private FastScrollRecyclerView mFilesList;
64+
private FastScrollRecyclerView mFilesListView;
6465

6566
private BottomBar mBottomView;
6667
private BottomBar mPathChange;
@@ -129,7 +130,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
129130
super.onActivityResult(requestCode, resultCode, data);
130131
if(requestCode==APP_PERMISSION_REQUEST ) {
131132
if(resultCode != Activity.RESULT_OK)
132-
Toast.makeText(mContext,"Some permissions not granted!. App may not work properly!. Please grant the required permissions!",Toast.LENGTH_LONG).show();
133+
Toast.makeText(mContext,mContext.getString(R.string.error_no_permissions),Toast.LENGTH_LONG).show();
133134
loadUi();
134135
}
135136
}
@@ -160,7 +161,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
160161
onFileChanged(mNavigationHelper.getCurrentDirectory());
161162
}
162163
else if (item.getItemId()== R.id.action_newfolder) {
163-
UIUtils.showEditTextDialog(this, "Folder Name", "" , new IFuncPtr(){
164+
UIUtils.showEditTextDialog(this, getString(R.string.new_folder), "" , new IFuncPtr(){
164165
@Override
165166
public void execute(final String val) {
166167
io.createDirectory(new File(mNavigationHelper.getCurrentDirectory(),val.trim()));
@@ -169,11 +170,11 @@ public void execute(final String val) {
169170
}
170171
else if(item.getItemId()== R.id.action_paste) {
171172
if (op.getOperation() == Operations.FILE_OPERATIONS.NONE) {
172-
UIUtils.ShowToast("No operation selected", mContext);
173+
UIUtils.ShowToast(mContext.getString(R.string.no_operation_error), mContext);
173174
return false;
174175
}
175176
if(op.getSelectedFiles()==null) {
176-
UIUtils.ShowToast("No files selected to paste", mContext);
177+
UIUtils.ShowToast(mContext.getString(R.string.no_files_paste), mContext);
177178
return false;
178179
}
179180
io.pasteFiles(mNavigationHelper.getCurrentDirectory());
@@ -197,12 +198,12 @@ private void loadUi() {
197198
setContentView(R.layout.filebrowser_activity_main);
198199

199200
mCurrentPath = (TextView) findViewById(R.id.currentPath);
200-
mFilesList = (FastScrollRecyclerView) findViewById(R.id.recycler_view);
201+
mFilesListView = (FastScrollRecyclerView) findViewById(R.id.recycler_view);
201202
mAdapter = new CustomAdapter(mFileList,mContext);
202-
mFilesList.setAdapter(mAdapter);
203+
mFilesListView.setAdapter(mAdapter);
203204
mLayoutManager = new LinearLayoutManager(mContext);
204-
mFilesList.setLayoutManager(mLayoutManager);
205-
final CustomAdapterItemClickListener onItemClickListener = new CustomAdapterItemClickListener(mContext, mFilesList, new CustomAdapterItemClickListener.OnItemClickListener() {
205+
mFilesListView.setLayoutManager(mLayoutManager);
206+
final CustomAdapterItemClickListener onItemClickListener = new CustomAdapterItemClickListener(mContext, mFilesListView, new CustomAdapterItemClickListener.OnItemClickListener() {
206207
@Override
207208
public void onItemClick(View view, int position) {
208209
// TODO Handle item click
@@ -215,12 +216,14 @@ public void onItemClick(View view, int position) {
215216
MimeTypeMap mimeMap = MimeTypeMap.getSingleton();
216217
Intent openFileIntent = new Intent(Intent.ACTION_VIEW);
217218
String mimeType = mimeMap.getMimeTypeFromExtension(FilenameUtils.getExtension(f.getName()));
218-
openFileIntent.setDataAndType(Uri.fromFile(f),mimeType);
219+
Uri uri = FileProvider.getUriForFile(mContext,"com.aditya.filebrowser.provider", f);
220+
openFileIntent.setDataAndType(uri,mimeType);
219221
openFileIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
222+
openFileIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
220223
try {
221224
mContext.startActivity(openFileIntent);
222225
} catch (ActivityNotFoundException e) {
223-
Toast.makeText(mContext, "No app found to handle this type of file.", Toast.LENGTH_LONG).show();
226+
Toast.makeText(mContext, mContext.getString(R.string.no_app_to_handle), Toast.LENGTH_LONG).show();
224227
}
225228
}
226229
}
@@ -230,12 +233,12 @@ public void onItemClick(View view, int position) {
230233
public void onItemLongClick(View view, int position) {
231234
switchMode(Constants.CHOICE_MODE.MULTI_CHOICE);
232235
mAdapter.selectItem(position);
233-
mFilesList.scrollToPosition(position);
236+
mFilesListView.scrollToPosition(position);
234237
}
235238
});
236-
mFilesList.addOnItemTouchListener(onItemClickListener);
239+
mFilesListView.addOnItemTouchListener(onItemClickListener);
237240

238-
mFilesList.setStateChangeListener(new OnFastScrollStateChangeListener() {
241+
mFilesListView.setOnFastScrollStateChangeListener(new OnFastScrollStateChangeListener() {
239242
@Override
240243
public void onFastScrollStart() {
241244
onItemClickListener.setmFastScrolling(true);
@@ -256,7 +259,7 @@ public void onFastScrollStop() {
256259
mPathChange = (BottomBar) findViewById(R.id.currPath_Nav);
257260

258261
mTabChangeListener = new TabChangeListener(this,mNavigationHelper,mAdapter,io,this);
259-
mTabChangeListener.setmRecyclerView(mFilesList);
262+
mTabChangeListener.setmRecyclerView(mFilesListView);
260263

261264
mBottomView.setOnTabSelectListener(mTabChangeListener);
262265
mBottomView.setOnTabReselectListener(mTabChangeListener);
@@ -286,7 +289,7 @@ public void switchMode(Constants.CHOICE_MODE mode) {
286289
closeSearchView();
287290
ToolbarActionMode newToolBar = new ToolbarActionMode(this,this,mAdapter,Constants.APP_MODE.FILE_BROWSER,io);
288291
mActionMode = startSupportActionMode(newToolBar);
289-
mActionMode.setTitle("Select Multiple Files");
292+
mActionMode.setTitle(mContext.getString(R.string.select_multiple));
290293
}
291294
}
292295
}
@@ -311,9 +314,9 @@ public void setNullToActionMode() {
311314

312315
@Override
313316
public void reDrawFileList() {
314-
mFilesList.setLayoutManager(null);
315-
mFilesList.setAdapter(mAdapter);
316-
mFilesList.setLayoutManager(mLayoutManager);
317+
mFilesListView.setLayoutManager(null);
318+
mFilesListView.setAdapter(mAdapter);
319+
mFilesListView.setLayoutManager(mLayoutManager);
317320
mTabChangeListener.setmAdapter(mAdapter);
318321
mAdapter.notifyDataSetChanged();
319322
}

0 commit comments

Comments
 (0)