mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-03 16:48:52 +02:00
Material design
This commit is contained in:
parent
a518146100
commit
ac11f01528
11 changed files with 122 additions and 130 deletions
|
@ -1,15 +1,16 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 20
|
||||
buildToolsVersion "23.0.2"
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion '23.0.2'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "de.badaix.snapcast"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 20
|
||||
targetSdkVersion 23
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
multiDexEnabled true
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
@ -22,6 +23,7 @@ android {
|
|||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:20.0.0'
|
||||
compile 'com.android.support:appcompat-v7:23.0.+'
|
||||
compile 'com.android.support:cardview-v7:23.0.+'
|
||||
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ public class MainActivity extends ActionBarActivity implements View.OnClickListe
|
|||
@Override
|
||||
public void onDiscoveryStarted(String regType) {
|
||||
Log.d(TAG, "Service discovery started");
|
||||
setStatus("Host: searching for a Snapserver");
|
||||
setStatus("Searching for a Snapserver");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
package de.badaix.snapcast;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.app.TaskStackBuilder;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Process;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.PowerManager;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -36,69 +37,68 @@ public class SnapclientService extends Service {
|
|||
private WifiManager.WifiLock wifiWakeLock = null;
|
||||
private Thread reader = null;
|
||||
|
||||
// Handler that receives messages from the thread
|
||||
private final class ServiceHandler extends Handler {
|
||||
public ServiceHandler(Looper looper) {
|
||||
super(looper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
// Normally we would do some work here, like download a file.
|
||||
// For our sample, we just sleep for 5 seconds.
|
||||
long endTime = System.currentTimeMillis() + 5*1000;
|
||||
while (System.currentTimeMillis() < endTime) {
|
||||
synchronized (this) {
|
||||
try {
|
||||
wait(endTime - System.currentTimeMillis());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Stop the service using the startId, so that we don't stop
|
||||
// the service in the middle of handling another job
|
||||
stopSelf(msg.arg1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show();
|
||||
|
||||
NotificationCompat.Builder builder =
|
||||
new NotificationCompat.Builder(this)
|
||||
.setSmallIcon(android.R.drawable.ic_media_play)
|
||||
.setTicker(getText(R.string.ticker_text))
|
||||
.setContentTitle(getText(R.string.notification_title))
|
||||
.setContentText(getText(R.string.notification_text))
|
||||
.setContentInfo(getText(R.string.notification_info));
|
||||
|
||||
Intent resultIntent = new Intent(this, MainActivity.class);
|
||||
|
||||
// The stack builder object will contain an artificial back stack for the
|
||||
// started Activity.
|
||||
// This ensures that navigating backward from the Activity leads out of
|
||||
// your application to the Home screen.
|
||||
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
|
||||
// Adds the back stack for the Intent (but not the Intent itself)
|
||||
stackBuilder.addParentStack(MainActivity.class);
|
||||
// Adds the Intent that starts the Activity to the top of the stack
|
||||
stackBuilder.addNextIntent(resultIntent);
|
||||
PendingIntent resultPendingIntent =
|
||||
stackBuilder.getPendingIntent(
|
||||
0,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
);
|
||||
builder.setContentIntent(resultPendingIntent);
|
||||
NotificationManager mNotificationManager =
|
||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
// mId allows you to update the notification later on.
|
||||
final Notification notification = builder.build();
|
||||
// mNotificationManager.notify(123, notification);
|
||||
startForeground(123, notification);
|
||||
|
||||
|
||||
String host = intent.getStringExtra(EXTRA_HOST);
|
||||
int port = intent.getIntExtra(EXTRA_PORT, 1704);
|
||||
|
||||
Notification notification = new Notification(android.R.drawable.ic_media_play, getText(R.string.ticker_text),
|
||||
System.currentTimeMillis());
|
||||
Intent notificationIntent = new Intent(this, MainActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
|
||||
notification.setLatestEventInfo(this, getText(R.string.notification_title),
|
||||
getText(R.string.notification_message), pendingIntent);
|
||||
startForeground(123, notification);
|
||||
start(host, port);
|
||||
|
||||
// If we get killed, after returning from here, restart
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
// We don't provide binding, so return null
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void stopService() {
|
||||
stop();
|
||||
stopForeground(true);
|
||||
NotificationManager mNotificationManager =
|
||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.cancel(123);
|
||||
}
|
||||
|
||||
private void start(String host, int port) {
|
||||
|
@ -154,6 +154,31 @@ public class SnapclientService extends Service {
|
|||
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_DEFAULT);
|
||||
}
|
||||
|
||||
// Handler that receives messages from the thread
|
||||
private final class ServiceHandler extends Handler {
|
||||
public ServiceHandler(Looper looper) {
|
||||
super(looper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
// Normally we would do some work here, like download a file.
|
||||
// For our sample, we just sleep for 5 seconds.
|
||||
long endTime = System.currentTimeMillis() + 5 * 1000;
|
||||
while (System.currentTimeMillis() < endTime) {
|
||||
synchronized (this) {
|
||||
try {
|
||||
wait(endTime - System.currentTimeMillis());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Stop the service using the startId, so that we don't stop
|
||||
// the service in the middle of handling another job
|
||||
stopSelf(msg.arg1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#CABBBBBB" />
|
||||
<corners android:radius="2dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:bottom="2dp"
|
||||
android:left="0dp"
|
||||
android:right="0dp"
|
||||
android:top="0dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@android:color/white" />
|
||||
<corners android:radius="2dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/card_state_pressed" android:state_pressed="true" />
|
||||
<item android:drawable="@drawable/card_background" />
|
||||
</selector>
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#CA888888" />
|
||||
<corners android:radius="2dp" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:bottom="2dp"
|
||||
android:left="0dp"
|
||||
android:right="0dp"
|
||||
android:top="0dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#caeeeeee" />
|
||||
<corners android:radius="2dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -83,7 +83,7 @@
|
|||
android:listSelector="@android:color/transparent"
|
||||
android:cacheColorHint="@android:color/transparent"
|
||||
android:divider="@null"
|
||||
android:dividerHeight="10dp"
|
||||
android:dividerHeight="2dp"
|
||||
android:id="@+id/lvClient" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -1,49 +1,58 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/card_background_selector"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="5dp">
|
||||
android:orientation="vertical">
|
||||
<!-- android:descendantFocusability="afterDescendants"-->
|
||||
<!-- android:paddingRight="?android:attr/scrollbarSize"-->
|
||||
<!-- android:background="@drawable/big_card"-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal"
|
||||
android:singleLine="true"
|
||||
android:text="Title"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<LinearLayout
|
||||
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/card_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
card_view:cardCornerRadius="4dp">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibMute"
|
||||
style="@style/PlayerButton"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/ic_speaker_icon" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/volumeSeekBar"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical" />
|
||||
</LinearLayout>
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
android:fadingEdge="horizontal"
|
||||
android:paddingLeft="5dp"
|
||||
android:singleLine="true"
|
||||
android:text="Title"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="3dp">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibMute"
|
||||
style="@style/PlayerButton"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/ic_speaker_icon" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/volumeSeekBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<string name="app_name">Snapcast</string>
|
||||
<string name="ticker_text">Snapclient started</string>
|
||||
<string name="notification_title">Snapclient</string>
|
||||
<string name="notification_message">Snapclient is running...</string>
|
||||
<string name="notification_text">Snapclient is running...</string>
|
||||
<string name="notification_info">info...</string>
|
||||
</resources>
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light">
|
||||
<!-- <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> -->
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue