Skip to content

Commit

Permalink
Updated mobile app to work with new REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
Wassup789 committed Jul 26, 2017
1 parent 0c36909 commit 3b48736
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 70 deletions.
4 changes: 2 additions & 2 deletions mobile/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
android:icon="@drawable/ic_headset_black_48dp"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:versionCode="4"
android:versionName="1.0.1.0">
android:versionCode="5"
android:versionName="1.0.2.0">
<activity
android:configChanges="orientation|screenSize"
android:name=".MainActivity"
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public MyResultReceiver(Handler handler) {
@Override
protected void onReceiveResult(int resultCode, final Bundle resultData) {

if(resultCode == 100){//Update status information
if(resultCode == BackgroundService.STATUS_UPDATE){//Update status information
runOnUiThread( new Thread() {
public void run() {
String status = resultData.getString("data");
Expand Down Expand Up @@ -260,7 +260,7 @@ public void run() {
}
}
});
}else if(resultCode == 101){//Set download information
}else if(resultCode == BackgroundService.STATUS_DOWNLOADINFO){//Set download information
runOnUiThread( new Thread() {
public void run() {
String total = resultData.getString("data");
Expand All @@ -269,7 +269,7 @@ public void run() {
filesToDownloadValue.setText(total);
}
});
}else if(resultCode == 102){//Set current download information
}else if(resultCode == BackgroundService.STATUS_CURRENTDOWNLOADINFO){//Set current download information
runOnUiThread( new Thread() {
public void run() {
String currentDownload = resultData.getString("data");
Expand All @@ -278,7 +278,7 @@ public void run() {
currentDownloadValue.setText(currentDownload);
}
});
}else if(resultCode == 103){//Set current playlist
}else if(resultCode == BackgroundService.STATUS_CURRENTPLAYLIST){//Set current playlist
runOnUiThread( new Thread() {
public void run() {
String currentPlaylist = resultData.getString("data");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,24 @@ protected void onPostExecute(Long result) {}
public void setListViewDefault() {
isViewingPlaylist = false;


getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
ListView filesList = (ListView) getActivity().findViewById(R.id.filesListView);
if (filesList != null)
filesList.setVisibility(View.GONE);
TextView title = (TextView) getActivity().findViewById(R.id.title);
if (title != null)
title.setText("Playlists:");
Button toggleButton = (Button) getActivity().findViewById(R.id.toggleButton);
if (toggleButton != null)
toggleButton.setVisibility(View.GONE);
}
});
try {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
ListView filesList = (ListView) getActivity().findViewById(R.id.filesListView);
if (filesList != null)
filesList.setVisibility(View.GONE);
TextView title = (TextView) getActivity().findViewById(R.id.title);
if (title != null)
title.setText("Playlists:");
Button toggleButton = (Button) getActivity().findViewById(R.id.toggleButton);
if (toggleButton != null)
toggleButton.setVisibility(View.GONE);
}
});
}catch (Exception e) {
e.printStackTrace();
}

SharedPreferences settings = getActivity().getSharedPreferences("settings", Context.MODE_PRIVATE);
ArrayList<DoubleListItem> data = new ArrayList<DoubleListItem>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.support.v4.app.Fragment;
import android.text.Html;
import android.text.InputType;
import android.util.Base64;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -281,9 +282,9 @@ public void retrievePlaylistSelection() {
ArrayList<PlaylistInformation> output = gson.fromJson(data, new TypeToken<ArrayList<PlaylistInformation>>() {}.getType());
final String[] playlists = new String[output.size()];
for(int i = 0; i < output.size(); i++) {
playlists[i] = output.get(i).name;
playlists[i] = new String(Base64.decode(output.get(i).name, Base64.DEFAULT), "UTF-8");
for(int ii = 0; ii < savedPlaylists.length; ii++){
if(output.get(i).name.equals(savedPlaylists[ii])){
if(playlists[i].equals(savedPlaylists[ii])){
playlistsToSelect.add(i);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public class MediaInformation {
public String name;
public String name_b64;
public int size;
public long size;
public long dateCreated;
public long dateModified;
}
2 changes: 1 addition & 1 deletion mobile/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<string name="dialog_outdatedVersion_title">Version Outdated</string>
<string name="dialog_outdatedVersion_desc"><![CDATA[
The version numbers of the server and the client do not match. Please update both the server and the client to the latest version.<br><br>
Continuing to use the outdated application(s) may result in crashes.<br><br>
Continuing to use the outdated application(s) may produce unexpected results.<br><br>
<a href=\'https://github.com/Wassup789/Music-Sync/releases\'>Download via Github.com</a>
]]></string>
</resources>

0 comments on commit 3b48736

Please sign in to comment.