move getFilesystemBrowseStart into FileUtils
Thats far better than extending PlaybackActivity just for this
This commit is contained in:
parent
5652917b49
commit
b3e97c4418
@ -26,8 +26,6 @@ package ch.blinkenlights.android.vanilla;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.FileObserver;
|
import android.os.FileObserver;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -136,7 +134,7 @@ public class FileSystemAdapter
|
|||||||
mFolderIcon = activity.getResources().getDrawable(R.drawable.folder);
|
mFolderIcon = activity.getResources().getDrawable(R.drawable.folder);
|
||||||
mInflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
mInflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
if (limiter == null) {
|
if (limiter == null) {
|
||||||
limiter = buildLimiter( activity.getFilesystemBrowseStart() );
|
limiter = buildLimiter( FileUtils.getFilesystemBrowseStart(activity) );
|
||||||
}
|
}
|
||||||
setLimiter(limiter);
|
setLimiter(limiter);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 Adrian Ulrich <adrian@blinkenlights.ch>
|
* Copyright (C) 2015-2016 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,11 +17,15 @@
|
|||||||
|
|
||||||
package ch.blinkenlights.android.vanilla;
|
package ch.blinkenlights.android.vanilla;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Environment;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides some static File-related utility functions.
|
* Provides some static File-related utility functions.
|
||||||
@ -75,4 +79,13 @@ public class FileUtils {
|
|||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by FileSystem adapter to get the start folder
|
||||||
|
* for browsing directories
|
||||||
|
*/
|
||||||
|
public static File getFilesystemBrowseStart(Context context) {
|
||||||
|
SharedPreferences prefs = PlaybackService.getSettings(context);
|
||||||
|
String folder = prefs.getString(PrefKeys.FILESYSTEM_BROWSE_START, PrefDefaults.FILESYSTEM_BROWSE_START);
|
||||||
|
return new File( folder.equals("") ? Environment.getExternalStorageDirectory().getAbsolutePath() : folder );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
package ch.blinkenlights.android.vanilla;
|
package ch.blinkenlights.android.vanilla;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
@ -27,14 +26,12 @@ import android.view.MenuItem;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
|
||||||
public class FilebrowserStartActivity extends PlaybackActivity {
|
public class FilebrowserStartActivity extends Activity {
|
||||||
|
|
||||||
private ListView mListView;
|
private ListView mListView;
|
||||||
private TextView mPathDisplay;
|
private TextView mPathDisplay;
|
||||||
@ -50,7 +47,7 @@ public class FilebrowserStartActivity extends PlaybackActivity {
|
|||||||
|
|
||||||
setTitle(R.string.filebrowser_start);
|
setTitle(R.string.filebrowser_start);
|
||||||
setContentView(R.layout.filebrowser_content);
|
setContentView(R.layout.filebrowser_content);
|
||||||
mCurrentPath = (String)getFilesystemBrowseStart().getAbsolutePath();
|
mCurrentPath = (String)FileUtils.getFilesystemBrowseStart(this).getAbsolutePath();
|
||||||
mPrefEditor = PlaybackService.getSettings(this).edit();
|
mPrefEditor = PlaybackService.getSettings(this).edit();
|
||||||
mListAdapter = new FilebrowserStartAdapter((FilebrowserStartActivity)this, 0);
|
mListAdapter = new FilebrowserStartAdapter((FilebrowserStartActivity)this, 0);
|
||||||
mPathDisplay = (TextView) findViewById(R.id.path_display);
|
mPathDisplay = (TextView) findViewById(R.id.path_display);
|
||||||
|
@ -35,7 +35,6 @@ import android.os.HandlerThread;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.Environment;
|
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -294,17 +293,6 @@ public abstract class PlaybackActivity extends Activity
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by FileSystem adapter to get the start folder
|
|
||||||
* for browsing directories
|
|
||||||
*/
|
|
||||||
protected File getFilesystemBrowseStart() {
|
|
||||||
SharedPreferences prefs = PlaybackService.getSettings(this);
|
|
||||||
String folder = prefs.getString(PrefKeys.FILESYSTEM_BROWSE_START, PrefDefaults.FILESYSTEM_BROWSE_START);
|
|
||||||
File fs_start = new File( folder.equals("") ? Environment.getExternalStorageDirectory().getAbsolutePath() : folder );
|
|
||||||
return fs_start;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up onClick listeners for our common control buttons bar
|
* Sets up onClick listeners for our common control buttons bar
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user