Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced the deprecated ActionBarActivity, moved to AndroidStudio 3.x… #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Replaced the deprecated ActionBarActivity, moved to AndroidStudio 3.x…
…, fixed some crashes
  • Loading branch information
ugochirico committed Sep 15, 2018
commit 733b9484036ea067f44c87dfc425410e9d5ef5b1
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
classpath 'com.android.tools.build:gradle:3.1.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -14,6 +15,9 @@ buildscript {

allprojects {
repositories {
google()
mavenLocal()
mavenCentral()
jcenter()
}
}
33 changes: 19 additions & 14 deletions demo-app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
applicationId 'com.psaravan.filebrowserview.demo'
minSdkVersion 14
targetSdkVersion 20
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// buildTypes {
// release {
// runProguard false
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// }
// }
// productFlavors {
// }
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:20.0.0'
compile project(':library')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation project(':library')
}
4 changes: 4 additions & 0 deletions demo-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.psaravan.filebrowserview.demo" >

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import android.content.Context;
import android.os.Bundle;
import android.os.Environment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -47,7 +48,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

//Customize the view.
mFileBrowserView.setFileBrowserLayoutType(FileBrowserView.FILE_BROWSER_LIST_LAYOUT) //Set the type of view to use.
.setDefaultDirectory(new File("/")) //Set the default directory to show.
.setDefaultDirectory(Environment.getExternalStorageDirectory()) //Set the default directory to show.
.setShowHiddenFiles(true) //Set whether or not you want to show hidden files.
.showItemSizes(true) //Shows the sizes of each item in the list.
.showOverflowMenus(true) //Shows the overflow menus for each item in the list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Environment;

import com.psaravan.filebrowserview.demo.R;
import com.psaravan.filebrowserview.lib.Interfaces.NavigationInterface;
Expand Down Expand Up @@ -49,7 +50,7 @@ protected void onCreate(Bundle savedInstanceState) {

//Customize the view.
mFileBrowserView.setFileBrowserLayoutType(FileBrowserView.FILE_BROWSER_GRID_LAYOUT) //Set the type of view to use.
.setDefaultDirectory(new File("/")) //Set the default directory to show.
.setDefaultDirectory(Environment.getExternalStorageDirectory()) //Set the default directory to show.
.setShowHiddenFiles(true) //Set whether or not you want to show hidden files.
.showItemSizes(true) //Shows the sizes of each item in the list.
.showOverflowMenus(true) //Shows the overflow menus for each item in the list.
Expand All @@ -70,7 +71,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onNewDirLoaded(File dirFile) {
//Update the action bar title.
getActionBar().setTitle(dirFile.getAbsolutePath());
setTitle(dirFile.getAbsolutePath());
}

@Override
Expand All @@ -92,17 +93,20 @@ public void onFileFolderOpenFailed(File file) {

@Override
public void onBackPressed() {
if (mFileBrowserView!=null) {
if (mFileBrowserView != null) {
File parentDir = mFileBrowserView.getParentDir();

if (parentDir!=null) {
mFileBrowserView.getFileBrowserEngine().loadDir(parentDir);
if (parentDir != null) {
try {
mFileBrowserView.getFileBrowserEngine().loadDir(parentDir);
mFileBrowserView.setDefaultDirectory(parentDir);
mFileBrowserView.init();
} catch (Exception ex) {
super.onBackPressed();
}
} else {
super.onBackPressed();
}

}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;

import com.psaravan.filebrowserview.demo.R;
import com.psaravan.filebrowserview.lib.Interfaces.NavigationInterface;
Expand Down Expand Up @@ -49,7 +51,7 @@ protected void onCreate(Bundle savedInstanceState) {

//Customize the view.
mFileBrowserView.setFileBrowserLayoutType(FileBrowserView.FILE_BROWSER_LIST_LAYOUT) //Set the type of view to use.
.setDefaultDirectory(new File("/")) //Set the default directory to show.
.setDefaultDirectory(Environment.getExternalStorageDirectory()) //Set the default directory to show.
.setShowHiddenFiles(true) //Set whether or not you want to show hidden files.
.showItemSizes(true) //Shows the sizes of each item in the list.
.showOverflowMenus(true) //Shows the overflow menus for each item in the list.
Expand All @@ -70,22 +72,22 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onNewDirLoaded(File dirFile) {
//Update the action bar title.
getActionBar().setTitle(dirFile.getAbsolutePath());
setTitle(dirFile.getAbsolutePath());
}

@Override
public void onFileOpened(File file) {

Log.d("ListActivity", "onFileOpened");
}

@Override
public void onParentDirLoaded(File dirFile) {

Log.d("ListActivity", "onParentDirLoaded");
}

@Override
public void onFileFolderOpenFailed(File file) {

Log.d("ListActivity", "onFileFolderOpenFailed");
}

};
Expand All @@ -96,7 +98,15 @@ public void onBackPressed() {
File parentDir = mFileBrowserView.getParentDir();

if (parentDir!=null) {
mFileBrowserView.getFileBrowserEngine().loadDir(parentDir);
try {
mFileBrowserView.getFileBrowserEngine().loadDir(parentDir);
mFileBrowserView.setDefaultDirectory(parentDir);
mFileBrowserView.init();
}
catch(Exception ex)
{
super.onBackPressed();
}
} else {
super.onBackPressed();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
Expand All @@ -36,7 +36,7 @@
*
* @author Saravan Pantham
*/
public class MainActivity extends ActionBarActivity {
public class MainActivity extends AppCompatActivity {

//Context.
private Context mContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onNewDirLoaded(File dirFile) {
//Update the action bar title.
getActionBar().setTitle(dirFile.getAbsolutePath());
setTitle(dirFile.getAbsolutePath());
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
distributionUrl=http\://services.gradle.org/distributions/gradle-4.4-all.zip
35 changes: 20 additions & 15 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
applicationId 'com.psaravan.filebrowserview.lib'
minSdkVersion 14
targetSdkVersion 20
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

// buildTypes {
// release {
//// runProguard false
//// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// }
// }
// productFlavors {
// }
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:20.0.0'
compile files('libs/commons-io-2.4.jar')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation files('libs/commons-io-2.4.jar')
}
Loading