Fixed dir settings
This commit is contained in:
parent
0156a4f39e
commit
6940021293
6 changed files with 50 additions and 120 deletions
|
|
@ -28,6 +28,8 @@ import android.support.annotation.NonNull;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import us.shandian.giga.util.Utility;
|
||||
|
||||
/**
|
||||
* Helper for global settings
|
||||
*/
|
||||
|
|
@ -46,10 +48,34 @@ public class NewPipeSettings {
|
|||
return getFolder(context, R.string.download_path_key, Environment.DIRECTORY_MOVIES);
|
||||
}
|
||||
|
||||
public static String getVideoDownloadPath(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
final String key = context.getString(R.string.download_path_key);
|
||||
String downloadPath = prefs.getString(key, Environment.DIRECTORY_MOVIES);
|
||||
|
||||
return downloadPath;
|
||||
}
|
||||
|
||||
public static File getAudioDownloadFolder(Context context) {
|
||||
return getFolder(context, R.string.download_path_audio_key, Environment.DIRECTORY_MUSIC);
|
||||
}
|
||||
|
||||
public static String getAudioDownloadPath(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
final String key = context.getString(R.string.download_path_audio_key);
|
||||
String downloadPath = prefs.getString(key, Environment.DIRECTORY_MUSIC);
|
||||
|
||||
return downloadPath;
|
||||
}
|
||||
|
||||
public static String getDownloadPath(Context context, String fileName)
|
||||
{
|
||||
if(Utility.isVideoFile(fileName)) {
|
||||
return NewPipeSettings.getVideoDownloadPath(context);
|
||||
}
|
||||
return NewPipeSettings.getAudioDownloadPath(context);
|
||||
}
|
||||
|
||||
private static File getFolder(Context context, int keyID, String defaultDirectoryName) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
final String key = context.getString(keyID);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import android.widget.Toast;
|
|||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.VideoItemDetailActivity;
|
||||
import org.schabi.newpipe.VideoItemListActivity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
|
@ -139,7 +138,6 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte
|
|||
.replace(R.id.frame, mFragment)
|
||||
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
||||
.commit();
|
||||
|
||||
}
|
||||
|
||||
private void showUrlDialog() {
|
||||
|
|
@ -297,7 +295,8 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte
|
|||
NavUtils.navigateUpTo(this, intent);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
return mFragment.onOptionsItemSelected(item) ||
|
||||
super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue