Skip to content
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
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion '25.0.3'

defaultConfig {
applicationId "github.daneren2005.dsub"
minSdkVersion 14
minSdkVersion 19
targetSdkVersion 26
versionCode 202
versionName '5.4.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ public class BookmarkTest extends TestCase {
public void testSetCreated() throws ParseException {
Bookmark bookmark = new Bookmark();
bookmark.setCreated((String) null);
assertEquals(null, bookmark.getCreated());
assertNull(bookmark.getCreated());

bookmark.setCreated("");
assertEquals(null, bookmark.getCreated());
assertNull(bookmark.getCreated());

bookmark.setCreated("2014-04-04");
assertEquals(null, bookmark.getCreated());
assertNull(bookmark.getCreated());

bookmark.setCreated("2014/04/04");
assertEquals(null, bookmark.getCreated());
assertNull(bookmark.getCreated());

bookmark.setCreated("18/03/1988");
assertEquals(null, bookmark.getCreated());
assertNull(bookmark.getCreated());

bookmark.setCreated("18/03/88");
assertEquals(null, bookmark.getCreated());
assertNull(bookmark.getCreated());

Date date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH).parse("2013-10-20T00:00:00");
bookmark.setCreated("2013-10-20T00:00:00");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void testNextWithoutPlayList() {
int oldCurrentPlayingIndex = downloadService.getCurrentPlayingIndex();
downloadService.next();
int newCurrentPlayingIndex = downloadService.getCurrentPlayingIndex();
assertTrue(oldCurrentPlayingIndex == newCurrentPlayingIndex);
assertEquals(oldCurrentPlayingIndex, newCurrentPlayingIndex);
}

/**
Expand All @@ -86,7 +86,7 @@ public void testPreviousWithoutPlayList() {
int oldCurrentPlayingIndex = downloadService.getCurrentPlayingIndex();
downloadService.previous();
int newCurrentPlayingIndex = downloadService.getCurrentPlayingIndex();
assertTrue(oldCurrentPlayingIndex == newCurrentPlayingIndex);
assertEquals(oldCurrentPlayingIndex, newCurrentPlayingIndex);
}

/**
Expand Down Expand Up @@ -279,7 +279,7 @@ private List<MusicDirectory.Entry> createMusicSongs(int size) {
musicEntry.setBitRate(198);
musicEntry.setAlbumId("49");
musicEntry.setDuration(247);
musicEntry.setSize(Long.valueOf(6162717));
musicEntry.setSize(6162717L);
musicEntry.setArtistId("23");
musicEntry.setArtist("The Dada Weatherman");
musicEntry.setCloseness(0);
Expand All @@ -298,7 +298,7 @@ private List<MusicDirectory.Entry> createMusicSongs(int size) {
musicEntry.setType(0);
musicEntry.setVideo(false);

List<MusicDirectory.Entry> musicEntries = new LinkedList<MusicDirectory.Entry>();
List<MusicDirectory.Entry> musicEntries = new LinkedList<>();

for (int i = 0; i < size; i++) {
musicEntries.add(musicEntry);
Expand Down
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import android.app.Activity;
import android.support.v7.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
Expand Down Expand Up @@ -65,7 +64,7 @@ public void onCreate(Bundle savedInstanceState) {
final Activity context = this;
doNothing = context.getResources().getString(R.string.tasker_edit_do_nothing);

shuffleCheckbox = (CheckBox) findViewById(R.id.edit_shuffle_checkbox);
shuffleCheckbox = findViewById(R.id.edit_shuffle_checkbox);
shuffleCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton view, boolean isChecked) {
Expand All @@ -75,8 +74,8 @@ public void onCheckedChanged(CompoundButton view, boolean isChecked) {
}
});

startYearCheckbox = (CheckBox) findViewById(R.id.edit_start_year_checkbox);
startYearBox = (EditText) findViewById(R.id.edit_start_year);
startYearCheckbox = findViewById(R.id.edit_start_year_checkbox);
startYearBox = findViewById(R.id.edit_start_year);
// Disable/enable number box if checked
startYearCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
Expand All @@ -85,16 +84,16 @@ public void onCheckedChanged(CompoundButton view, boolean isChecked) {
}
});

endYearCheckbox = (CheckBox) findViewById(R.id.edit_end_year_checkbox);
endYearBox = (EditText) findViewById(R.id.edit_end_year);
endYearCheckbox = findViewById(R.id.edit_end_year_checkbox);
endYearBox = findViewById(R.id.edit_end_year);
endYearCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton view, boolean isChecked) {
endYearBox.setEnabled(isChecked);
}
});

genreButton = (Button) findViewById(R.id.edit_genre_spinner);
genreButton = findViewById(R.id.edit_genre_spinner);
genreButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
new LoadingTask<List<Genre>>(context, true) {
Expand All @@ -106,7 +105,7 @@ protected List<Genre> doInBackground() throws Throwable {

@Override
protected void done(final List<Genre> genres) {
List<String> names = new ArrayList<String>();
List<String> names = new ArrayList<>();
String blank = context.getResources().getString(R.string.select_genre_blank);
names.add(doNothing);
names.add(blank);
Expand All @@ -117,7 +116,7 @@ protected void done(final List<Genre> genres) {

AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.shuffle_pick_genre)
.setItems(names.toArray(new CharSequence[names.size()]), new DialogInterface.OnClickListener() {
.setItems(names.toArray(new CharSequence[0]), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if(which == 1) {
genreButton.setText("");
Expand Down Expand Up @@ -146,7 +145,7 @@ protected void error(Throwable error) {
});
genreButton.setText(doNothing);

offlineSpinner = (Spinner) findViewById(R.id.edit_offline_spinner);
offlineSpinner = findViewById(R.id.edit_offline_spinner);
ArrayAdapter<CharSequence> offlineAdapter = ArrayAdapter.createFromResource(this, R.array.editServerOptions, android.R.layout.simple_spinner_item);
offlineAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
offlineSpinner.setAdapter(offlineAdapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@
import android.app.SearchManager;
import android.content.Intent;
import android.os.Bundle;
import android.provider.SearchRecentSuggestions;
import android.util.Log;

import github.daneren2005.dsub.fragments.SubsonicFragment;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.provider.DSubSearchProvider;

/**
* Receives search queries and forwards to the SearchFragment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void onCreate(Bundle savedInstanceState) {
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, currentFragment, currentFragment.getSupportTag() + "").commit();
}

Toolbar mainToolbar = (Toolbar) findViewById(R.id.main_toolbar);
Toolbar mainToolbar = findViewById(R.id.main_toolbar);
setSupportActionBar(mainToolbar);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
private boolean drawerIdle = true;
private boolean destroyed = false;
private boolean finished = false;
protected List<SubsonicFragment> backStack = new ArrayList<SubsonicFragment>();
protected final List<SubsonicFragment> backStack = new ArrayList<>();
protected SubsonicFragment currentFragment;
protected View primaryContainer;
protected View secondaryContainer;
protected boolean tv = false;
protected final boolean tv = false;
protected boolean touchscreen = true;
protected Handler handler = new Handler();
protected final Handler handler = new Handler();
Spinner actionBarSpinner;
ArrayAdapter<CharSequence> spinnerAdapter;
ViewGroup rootView;
Expand Down Expand Up @@ -181,9 +181,8 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
Util.getPreferences(this).registerOnSharedPreferenceChangeListener(preferencesListener);
}

if (ContextCompat.checkSelfPermission(this, permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{ permission.WRITE_EXTERNAL_STORAGE }, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
}
if (ContextCompat.checkSelfPermission(this, permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
ActivityCompat.requestPermissions(this, new String[]{permission.WRITE_EXTERNAL_STORAGE}, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
}

@Override
Expand Down Expand Up @@ -290,14 +289,14 @@ public void setContentView(int viewId) {
} else {
super.setContentView(R.layout.abstract_activity);
}
rootView = (ViewGroup) findViewById(R.id.content_frame);
rootView = findViewById(R.id.content_frame);

if(viewId != 0) {
LayoutInflater layoutInflater = getLayoutInflater();
layoutInflater.inflate(viewId, rootView);
}

drawerList = (NavigationView) findViewById(R.id.left_drawer);
drawerList = findViewById(R.id.left_drawer);
drawerList.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(final MenuItem menuItem) {
Expand Down Expand Up @@ -383,19 +382,19 @@ public void onClick(View v) {
}
});

drawerHeaderToggle = (ImageView) drawerHeader.findViewById(R.id.header_select_image);
drawerServerName = (TextView) drawerHeader.findViewById(R.id.header_server_name);
drawerUserName = (TextView) drawerHeader.findViewById(R.id.header_user_name);
drawerHeaderToggle = drawerHeader.findViewById(R.id.header_select_image);
drawerServerName = drawerHeader.findViewById(R.id.header_server_name);
drawerUserName = drawerHeader.findViewById(R.id.header_user_name);

drawerUserAvatar = (ImageView) drawerHeader.findViewById(R.id.header_user_avatar);
drawerUserAvatar = drawerHeader.findViewById(R.id.header_user_avatar);

updateDrawerHeader();

if(!isTv()) {
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer = findViewById(R.id.drawer_layout);

// Pass in toolbar if it exists
Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
Toolbar toolbar = findViewById(R.id.main_toolbar);
drawerToggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.common_appname, R.string.common_appname) {
@Override
public void onDrawerClosed(View view) {
Expand Down Expand Up @@ -949,7 +948,7 @@ protected void restart(boolean resumePosition) {
private void applyTheme() {
theme = ThemeUtil.getTheme(this);

if(theme != null && theme.indexOf("fullscreen") != -1) {
if(theme != null && theme.contains("fullscreen")) {
theme = theme.substring(0, theme.indexOf("_fullscreen"));
ThemeUtil.setTheme(this, theme);
}
Expand Down Expand Up @@ -1130,7 +1129,7 @@ private void showOfflineSyncDialog(final int scrobbleCount, final int starsCount
}

View checkBoxView = this.getLayoutInflater().inflate(R.layout.sync_dialog, null);
final CheckBox checkBox = (CheckBox)checkBoxView.findViewById(R.id.sync_default);
final CheckBox checkBox = checkBoxView.findViewById(R.id.sync_default);

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setIcon(android.R.drawable.ic_dialog_info)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@
* Created by Scott on 10/14/13.
*/
public class SubsonicFragmentActivity extends SubsonicActivity implements DownloadService.OnSongChangedListener {
private static String TAG = SubsonicFragmentActivity.class.getSimpleName();
private static final String TAG = SubsonicFragmentActivity.class.getSimpleName();
private static boolean infoDialogDisplayed;
private static boolean sessionInitialized = false;
private static long ALLOWED_SKEW = 30000L;
private static final long ALLOWED_SKEW = 30000L;

private SlidingUpPanelLayout slideUpPanel;
private SlidingUpPanelLayout.PanelSlideListener panelSlideListener;
Expand Down Expand Up @@ -192,7 +192,7 @@ public void onCreate(Bundle savedInstanceState) {
}
}

slideUpPanel = (SlidingUpPanelLayout) findViewById(R.id.slide_up_panel);
slideUpPanel = findViewById(R.id.slide_up_panel);
panelSlideListener = new SlidingUpPanelLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View panel, float slideOffset) {
Expand Down Expand Up @@ -259,11 +259,11 @@ public void run() {
}

bottomBar = findViewById(R.id.bottom_bar);
mainToolbar = (Toolbar) findViewById(R.id.main_toolbar);
nowPlayingToolbar = (Toolbar) findViewById(R.id.now_playing_toolbar);
coverArtView = (ImageView) bottomBar.findViewById(R.id.album_art);
trackView = (TextView) bottomBar.findViewById(R.id.track_name);
artistView = (TextView) bottomBar.findViewById(R.id.artist_name);
mainToolbar = findViewById(R.id.main_toolbar);
nowPlayingToolbar = findViewById(R.id.now_playing_toolbar);
coverArtView = bottomBar.findViewById(R.id.album_art);
trackView = bottomBar.findViewById(R.id.track_name);
artistView = bottomBar.findViewById(R.id.artist_name);

setSupportActionBar(mainToolbar);

Expand All @@ -274,7 +274,7 @@ public void run() {
trans.commit();
}

rewindButton = (ImageButton) findViewById(R.id.download_rewind);
rewindButton = findViewById(R.id.download_rewind);
rewindButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -292,7 +292,7 @@ protected Void doInBackground() throws Throwable {
}
});

previousButton = (ImageButton) findViewById(R.id.download_previous);
previousButton = findViewById(R.id.download_previous);
previousButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -310,7 +310,7 @@ protected Void doInBackground() throws Throwable {
}
});

startButton = (ImageButton) findViewById(R.id.download_start);
startButton = findViewById(R.id.download_start);
startButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -332,7 +332,7 @@ protected Void doInBackground() throws Throwable {
}
});

nextButton = (ImageButton) findViewById(R.id.download_next);
nextButton = findViewById(R.id.download_next);
nextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -350,7 +350,7 @@ protected Void doInBackground() throws Throwable {
}
});

fastforwardButton = (ImageButton) findViewById(R.id.download_fastforward);
fastforwardButton = findViewById(R.id.download_fastforward);
fastforwardButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -744,7 +744,7 @@ private void loadSettings() {
private boolean resetCacheLocation(SharedPreferences prefs) {
String newDirectory = FileUtil.getDefaultMusicDirectory(this).getPath();
String oldDirectory = prefs.getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, null);
if(newDirectory == null || (oldDirectory != null && newDirectory.equals(oldDirectory))) {
if(newDirectory == null || (newDirectory.equals(oldDirectory))) {
return false;
} else {
SharedPreferences.Editor editor = prefs.edit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@
import android.content.Intent;
import android.os.Bundle;
import android.provider.MediaStore;
import android.provider.SearchRecentSuggestions;
import android.util.Log;

import github.daneren2005.dsub.fragments.SubsonicFragment;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.provider.DSubSearchProvider;

/**
* Receives voice search queries and forwards to the SearchFragment.
Expand Down
Loading