Skip to content

Commit

Permalink
Merge pull request #59 from tobexyz/feat/issue45
Browse files Browse the repository at this point in the history
Feat/issue45
  • Loading branch information
tobexyz authored Jan 14, 2023
2 parents 0f7a7a2 + ce32e5e commit 7e3ec5d
Show file tree
Hide file tree
Showing 22 changed files with 462 additions and 431 deletions.
1 change: 1 addition & 0 deletions yaacc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies {
implementation 'org.apache.httpcomponents.core5:httpcore5:5.2'
implementation 'org.slf4j:slf4j-simple:2.0.6'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.preference:preference:1.1.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
//https://developer.android.com/jetpack/androidx/migrate/artifact-mappings
Expand Down
4 changes: 2 additions & 2 deletions yaacc/src/main/java/de/yaacc/browser/BrowseItemAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
*/
public class BrowseItemAdapter extends BaseAdapter implements AbsListView.OnScrollListener {
public static final Item LOAD_MORE_FAKE_ITEM = new Item("LoadMoreFakeItem", (String) null, "...", "", (DIDLObject.Class) null);
private static final long CHUNK_SIZE = 10;

private static final Item LOADING_FAKE_ITEM = new Item("LoadingFakeItem", (String) null, "Loading...", "", (DIDLObject.Class) null);
private boolean loading = false;

Expand Down Expand Up @@ -287,7 +287,7 @@ public void loadMore() {

Log.d(getClass().getName(), "loadMore from: " + from);

BrowseItemLoadTask browseItemLoadTask = new BrowseItemLoadTask(this, CHUNK_SIZE);
BrowseItemLoadTask browseItemLoadTask = new BrowseItemLoadTask(this, Long.parseLong(PreferenceManager.getDefaultSharedPreferences(getContext()).getString(getContext().getString(R.string.settings_browse_chunk_size_key), "50")));
asyncTasks.add(browseItemLoadTask);
browseItemLoadTask.executeOnExecutor(((Yaacc) getContext().getApplicationContext()).getContentLoadExecutor(), from);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package de.yaacc.player;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
Expand All @@ -36,6 +35,8 @@
import android.widget.Switch;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import org.fourthline.cling.model.meta.Device;

import java.net.URI;
Expand All @@ -59,7 +60,7 @@
*
* @author Tobias Schoene (openbit)
*/
public class AVTransportPlayerActivity extends Activity implements ServiceConnection {
public class AVTransportPlayerActivity extends AppCompatActivity implements ServiceConnection {

protected boolean updateTime = false;
protected SeekBar seekBar = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package de.yaacc.player;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
Expand All @@ -29,6 +28,8 @@
import android.view.MenuItem;
import android.widget.ImageButton;

import androidx.appcompat.app.AppCompatActivity;

import de.yaacc.R;
import de.yaacc.settings.SettingsActivity;
import de.yaacc.util.AboutActivity;
Expand All @@ -39,7 +40,7 @@
*
* @author Tobias Schoene (openbit)
*/
public class MultiContentPlayerActivity extends Activity implements ServiceConnection {
public class MultiContentPlayerActivity extends AppCompatActivity implements ServiceConnection {

private PlayerService playerService;

Expand Down
5 changes: 3 additions & 2 deletions yaacc/src/main/java/de/yaacc/player/MusicPlayerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package de.yaacc.player;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
Expand All @@ -33,6 +32,8 @@
import android.widget.SeekBar;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import java.net.URI;
import java.text.ParseException;
import java.text.SimpleDateFormat;
Expand All @@ -53,7 +54,7 @@
*
* @author Tobias Schoene (openbit)
*/
public class MusicPlayerActivity extends Activity implements ServiceConnection {
public class MusicPlayerActivity extends AppCompatActivity implements ServiceConnection {

protected boolean updateTime = false;
protected SeekBar seekBar = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package de.yaacc.player;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
Expand All @@ -29,6 +28,8 @@
import android.view.MenuItem;
import android.widget.ImageButton;

import androidx.appcompat.app.AppCompatActivity;

import de.yaacc.R;
import de.yaacc.settings.SettingsActivity;
import de.yaacc.util.AboutActivity;
Expand All @@ -39,7 +40,7 @@
*
* @author Tobias Schoene (openbit)
*/
public class ThirdPartieMusicPlayerActivity extends Activity implements ServiceConnection {
public class ThirdPartieMusicPlayerActivity extends AppCompatActivity implements ServiceConnection {

private PlayerService playerService;

Expand Down
8 changes: 4 additions & 4 deletions yaacc/src/main/java/de/yaacc/settings/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@
*/
package de.yaacc.settings;

import android.app.Activity;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import de.yaacc.browser.TabBrowserActivity;

/**
* @author Christoph Hähnel (eyeless)
*/
public class SettingsActivity extends Activity {
public class SettingsActivity extends AppCompatActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

getFragmentManager().beginTransaction()
getSupportFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment()).commit();

}

@Override
Expand Down
33 changes: 24 additions & 9 deletions yaacc/src/main/java/de/yaacc/settings/SettingsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
package de.yaacc.settings;

import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.MultiSelectListPreference;
import android.preference.PreferenceFragment;
import android.text.InputType;

import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.MultiSelectListPreference;
import androidx.preference.PreferenceFragmentCompat;

import org.fourthline.cling.model.meta.Device;

Expand All @@ -35,13 +38,25 @@
/**
* @author Christoph Hähnel (eyeless)
*/
public class SettingsFragment extends PreferenceFragment implements UpnpClientListener {
public class SettingsFragment extends PreferenceFragmentCompat implements UpnpClientListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

addPreferencesFromResource(R.xml.preference);

public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preference, rootKey);
EditTextPreference numberPreference = findPreference(getString(R.string.settings_device_playback_offset_key));
if (numberPreference != null) {
numberPreference.setOnBindEditTextListener(
editText -> editText.setInputType(InputType.TYPE_CLASS_NUMBER));
}
numberPreference = findPreference(getString(R.string.settings_browse_load_threads_key));
if (numberPreference != null) {
numberPreference.setOnBindEditTextListener(
editText -> editText.setInputType(InputType.TYPE_CLASS_NUMBER));
}
numberPreference = findPreference(getString(R.string.settings_browse_chunk_size_key));
if (numberPreference != null) {
numberPreference.setOnBindEditTextListener(
editText -> editText.setInputType(InputType.TYPE_CLASS_NUMBER));
}
populateDeviceLists();
((Yaacc) getActivity().getApplicationContext()).getUpnpClient().addUpnpClientListener(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package de.yaacc.upnp.server;

import android.app.Activity;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
Expand All @@ -30,6 +29,8 @@
import android.widget.Button;
import android.widget.CheckBox;

import androidx.appcompat.app.AppCompatActivity;

import de.yaacc.R;
import de.yaacc.settings.SettingsActivity;
import de.yaacc.util.AboutActivity;
Expand All @@ -40,7 +41,7 @@
*
* @author Tobias Schoene (openbit)
*/
public class YaaccUpnpServerControlActivity extends Activity {
public class YaaccUpnpServerControlActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down
7 changes: 4 additions & 3 deletions yaacc/src/main/java/de/yaacc/util/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,23 @@
*/
package de.yaacc.util;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import de.yaacc.R;

/**
* An about dialog for yaacc
*
* @author Tobias Schoene (openbit)
*/
public class AboutActivity extends Activity {
public static void showAbout(Activity activity) {
public class AboutActivity extends AppCompatActivity {
public static void showAbout(AppCompatActivity activity) {
activity.startActivity(new Intent(activity, AboutActivity.class));
}

Expand Down
7 changes: 4 additions & 3 deletions yaacc/src/main/java/de/yaacc/util/YaaccLogActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@
*/
package de.yaacc.util;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import de.yaacc.R;

public class YaaccLogActivity extends Activity {
public static void showLog(Activity activity) {
public class YaaccLogActivity extends AppCompatActivity {
public static void showLog(AppCompatActivity activity) {
activity.startActivity(new Intent(activity, YaaccLogActivity.class));
}

Expand Down
20 changes: 10 additions & 10 deletions yaacc/src/main/java/org/fourthline/cling/model/meta/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@

package org.fourthline.cling.model.meta;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import org.fourthline.cling.model.ServiceReference;
import org.fourthline.cling.model.ValidationError;
import org.fourthline.cling.model.ValidationException;
import org.fourthline.cling.model.types.Datatype;
import org.fourthline.cling.model.types.ServiceId;
import org.fourthline.cling.model.types.ServiceType;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

/**
* The metadata of a service, with actions and state variables.
*
* @author Christian Bauer
*/
public abstract class Service<D extends Device, S extends Service> {

final private static Logger log = Logger.getLogger(Service.class.getName());
final private static Logger log = Logger.getLogger(Service.class.getName());

final private ServiceType serviceType;
final private ServiceId serviceId;
Expand Down Expand Up @@ -103,7 +103,7 @@ public D getDevice() {
}

void setDevice(D device) {
if (this.device != null)
if (this.device != null && !this.device.equals(device))
throw new IllegalStateException("Final value has been set already, model is immutable");
this.device = device;
}
Expand Down Expand Up @@ -186,13 +186,13 @@ public List<ValidationError> validate() {
// errors.addAll(action.validate());

List<ValidationError> actionErrors = action.validate();
if(actionErrors.size() > 0) {
if (actionErrors.size() > 0) {
actions.remove(action.getName()); // Remove it
log.warning("Discarding invalid action of service '" + getServiceId() + "': " + action.getName());
for (ValidationError actionError : actionErrors) {
log.warning("Invalid action '" + action.getName() + "': " + actionError);
}
}
}
}
}

Expand Down
Loading

0 comments on commit 7e3ec5d

Please sign in to comment.