Add shuffle button and currently playing song
This commit is contained in:
parent
d21a32b542
commit
4cc392067d
|
@ -3,14 +3,11 @@
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
<compositeConfiguration>
|
||||||
|
<compositeBuild compositeDefinitionSource="SCRIPT" />
|
||||||
|
</compositeConfiguration>
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="modules">
|
|
||||||
<set>
|
|
||||||
<option value="$PROJECT_DIR$" />
|
|
||||||
<option value="$PROJECT_DIR$/app" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
|
|
|
@ -1,29 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="NullableNotNullManager">
|
<component name="CMakeSettings">
|
||||||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
<configurations>
|
||||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
|
||||||
<option name="myNullables">
|
</configurations>
|
||||||
<value>
|
|
||||||
<list size="5">
|
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
|
||||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
|
||||||
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
|
||||||
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
|
||||||
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
|
||||||
</list>
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
<option name="myNotNulls">
|
|
||||||
<value>
|
|
||||||
<list size="4">
|
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
|
||||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
|
||||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
|
||||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
|
||||||
</list>
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -4,7 +4,7 @@ android {
|
||||||
compileSdkVersion 27
|
compileSdkVersion 27
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "me.xor_hydrogen.i3control"
|
applicationId "me.xor_hydrogen.i3control"
|
||||||
minSdkVersion 22
|
minSdkVersion 27
|
||||||
targetSdkVersion 27
|
targetSdkVersion 27
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
@ -21,6 +21,6 @@ android {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
|
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||||
implementation 'com.android.volley:volley:1.1.0'
|
implementation 'com.android.volley:volley:1.1.0'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="me.xor_hydrogen.i3control">
|
package="com.theedgeofrage.i3control">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
@ -11,14 +11,14 @@
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
<activity android:name=".MainActivity">
|
<activity android:name="com.theedgeofrage.i3control.MainActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".SettingsActivity"
|
android:name="com.theedgeofrage.i3control.SettingsActivity"
|
||||||
android:label="@string/title_activity_settings"
|
android:label="@string/title_activity_settings"
|
||||||
android:theme="@style/DialogTheme"/>
|
android:theme="@style/DialogTheme"/>
|
||||||
</application>
|
</application>
|
||||||
|
|
|
@ -0,0 +1,153 @@
|
||||||
|
package com.theedgeofrage.i3control;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.Response;
|
||||||
|
import com.android.volley.VolleyError;
|
||||||
|
import com.android.volley.toolbox.JsonObjectRequest;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
public void sendRequest(String endpoint, final Context context) {
|
||||||
|
RequestQueue queue = Volley.newRequestQueue(context);
|
||||||
|
|
||||||
|
SharedPreferences settings = context.getSharedPreferences(
|
||||||
|
context.getApplicationContext().getPackageName() + "_preferences", 0);
|
||||||
|
String host = settings.getString("pref_host", "");
|
||||||
|
if (host.equals("")) {
|
||||||
|
Toast.makeText(context, "No host set", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String url ="http://" + host + "/" + endpoint;
|
||||||
|
JsonObjectRequest stringRequest = new JsonObjectRequest(Request.Method.GET, url, new JSONObject(), new Response.Listener<JSONObject>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(JSONObject response) {
|
||||||
|
if (response.length() > 0) {
|
||||||
|
try {
|
||||||
|
String current = response.getString("artist") + " - " + response.getString("title");
|
||||||
|
((TextView)findViewById(R.id.currentlyPlayingText)).setText(current);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, new Response.ErrorListener() {
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
queue.add(stringRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.actionbar_menu, menu);
|
||||||
|
return super.onCreateOptionsMenu(menu);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.action_settings:
|
||||||
|
startActivity(new Intent(MainActivity.this, SettingsActivity.class));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
final Context context = this;
|
||||||
|
|
||||||
|
View.OnClickListener buttonClickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
switch (v.getId()) {
|
||||||
|
case R.id.muteButton:
|
||||||
|
((MainActivity)context).sendRequest("mute", context);
|
||||||
|
break;
|
||||||
|
case R.id.volDownButton:
|
||||||
|
((MainActivity)context).sendRequest("vol_down", context);
|
||||||
|
break;
|
||||||
|
case R.id.volUpButton:
|
||||||
|
((MainActivity)context).sendRequest("vol_up", context);
|
||||||
|
break;
|
||||||
|
case R.id.prevButton:
|
||||||
|
((MainActivity)context).sendRequest("prev", context);
|
||||||
|
break;
|
||||||
|
case R.id.playButton:
|
||||||
|
((MainActivity)context).sendRequest("play", context);
|
||||||
|
break;
|
||||||
|
case R.id.nextButton:
|
||||||
|
((MainActivity)context).sendRequest("next", context);
|
||||||
|
break;
|
||||||
|
case R.id.shuffleButton:
|
||||||
|
((MainActivity)context).sendRequest("shuffle", context);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
findViewById(R.id.muteButton).setOnClickListener(buttonClickListener);
|
||||||
|
findViewById(R.id.volDownButton).setOnClickListener(buttonClickListener);
|
||||||
|
findViewById(R.id.volUpButton).setOnClickListener(buttonClickListener);
|
||||||
|
findViewById(R.id.prevButton).setOnClickListener(buttonClickListener);
|
||||||
|
findViewById(R.id.playButton).setOnClickListener(buttonClickListener);
|
||||||
|
findViewById(R.id.nextButton).setOnClickListener(buttonClickListener);
|
||||||
|
findViewById(R.id.shuffleButton).setOnClickListener(buttonClickListener);
|
||||||
|
|
||||||
|
class RunnableQuery implements Runnable {
|
||||||
|
private Handler mHandler;
|
||||||
|
private boolean mRun = false;
|
||||||
|
|
||||||
|
RunnableQuery() {
|
||||||
|
mHandler = new Handler(getMainLooper());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
mRun = true;
|
||||||
|
mHandler.postDelayed(this, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop() {
|
||||||
|
mRun = false;
|
||||||
|
mHandler.removeCallbacks(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!mRun) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
((MainActivity) context).sendRequest("query", context);
|
||||||
|
mHandler.postDelayed(this, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RunnableQuery runnableQuery = new RunnableQuery();
|
||||||
|
runnableQuery.start();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package me.xor_hydrogen.i3control;
|
package com.theedgeofrage.i3control;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
|
@ -1,42 +0,0 @@
|
||||||
package me.xor_hydrogen.i3control;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.android.volley.Request;
|
|
||||||
import com.android.volley.RequestQueue;
|
|
||||||
import com.android.volley.Response;
|
|
||||||
import com.android.volley.VolleyError;
|
|
||||||
import com.android.volley.toolbox.StringRequest;
|
|
||||||
import com.android.volley.toolbox.Volley;
|
|
||||||
|
|
||||||
class ApiService {
|
|
||||||
static void sendRequest(String endpoint, Context context) {
|
|
||||||
RequestQueue queue = Volley.newRequestQueue(context);
|
|
||||||
|
|
||||||
SharedPreferences settings = context.getSharedPreferences(
|
|
||||||
context.getApplicationContext().getPackageName() + "_preferences", 0);
|
|
||||||
String host = settings.getString("pref_host", "");
|
|
||||||
if (host.equals("")) {
|
|
||||||
Toast.makeText(context, "No host set", Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String url ="http://" + host + "/" + endpoint;
|
|
||||||
Log.i(context.getClass().getName(), "Sending request to: " + url);
|
|
||||||
|
|
||||||
StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(String response) {
|
|
||||||
}
|
|
||||||
}, new Response.ErrorListener() {
|
|
||||||
@Override
|
|
||||||
public void onErrorResponse(VolleyError error) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
queue.add(stringRequest);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
package me.xor_hydrogen.i3control;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
MenuInflater inflater = getMenuInflater();
|
|
||||||
inflater.inflate(R.menu.actionbar_menu, menu);
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.action_settings:
|
|
||||||
startActivity(new Intent(MainActivity.this, SettingsActivity.class));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_main);
|
|
||||||
|
|
||||||
final Context context = this;
|
|
||||||
ImageButton muteButton = findViewById(R.id.muteButton);
|
|
||||||
ImageButton volDownButton = findViewById(R.id.volDownButton);
|
|
||||||
ImageButton volUpButton = findViewById(R.id.volUpButton);
|
|
||||||
ImageButton prevButton = findViewById(R.id.prevButton);
|
|
||||||
ImageButton playButton = findViewById(R.id.playButton);
|
|
||||||
ImageButton nextButton = findViewById(R.id.nextButton);
|
|
||||||
|
|
||||||
View.OnClickListener buttonClickListener = new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
switch (v.getId()) {
|
|
||||||
case R.id.muteButton:
|
|
||||||
ApiService.sendRequest("mute", context);
|
|
||||||
break;
|
|
||||||
case R.id.volDownButton:
|
|
||||||
ApiService.sendRequest("vol_down", context);
|
|
||||||
break;
|
|
||||||
case R.id.volUpButton:
|
|
||||||
ApiService.sendRequest("vol_up", context);
|
|
||||||
break;
|
|
||||||
case R.id.prevButton:
|
|
||||||
ApiService.sendRequest("prev", context);
|
|
||||||
break;
|
|
||||||
case R.id.playButton:
|
|
||||||
ApiService.sendRequest("play", context);
|
|
||||||
break;
|
|
||||||
case R.id.nextButton:
|
|
||||||
ApiService.sendRequest("next", context);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
muteButton.setOnClickListener(buttonClickListener);
|
|
||||||
volDownButton.setOnClickListener(buttonClickListener);
|
|
||||||
volUpButton.setOnClickListener(buttonClickListener);
|
|
||||||
prevButton.setOnClickListener(buttonClickListener);
|
|
||||||
playButton.setOnClickListener(buttonClickListener);
|
|
||||||
nextButton.setOnClickListener(buttonClickListener);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M10.59,9.17L5.41,4 4,5.41l5.17,5.17 1.42,-1.41zM14.5,4l2.04,2.04L4,18.59 5.41,20 17.96,7.46 20,9.5L20,4h-5.5zM14.83,13.41l-1.41,1.41 3.13,3.13L14.5,20L20,20v-5.5l-2.04,2.04 -3.13,-3.13z"/>
|
||||||
|
</vector>
|
|
@ -4,114 +4,130 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="me.xor_hydrogen.i3control.MainActivity">
|
tools:context="com.theedgeofrage.i3control.MainActivity">
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/muteButton"
|
android:id="@+id/muteButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:layout_marginStart="64dp"
|
android:layout_marginStart="64dp"
|
||||||
android:layout_marginTop="128dp"
|
android:layout_marginTop="256dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:contentDescription="@string/mute"
|
||||||
android:scaleX="2"
|
android:scaleX="2"
|
||||||
android:scaleY="2"
|
android:scaleY="2"
|
||||||
android:tint="@color/colorForeground"
|
android:tint="@color/colorForeground"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/prevButton"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/volDownButton"
|
app:layout_constraintEnd_toStartOf="@+id/volDownButton"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:srcCompat="@drawable/ic_volume_mute_black_24dp"
|
app:srcCompat="@drawable/ic_volume_mute_black_24dp" />
|
||||||
android:contentDescription="@string/mute" />
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/volDownButton"
|
android:id="@+id/volDownButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="128dp"
|
android:layout_marginTop="256dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:contentDescription="@string/vol_down"
|
||||||
android:scaleX="2"
|
android:scaleX="2"
|
||||||
android:scaleY="2"
|
android:scaleY="2"
|
||||||
android:tint="@color/colorForeground"
|
android:tint="@color/colorForeground"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/playButton"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/volUpButton"
|
app:layout_constraintEnd_toStartOf="@+id/volUpButton"
|
||||||
app:layout_constraintStart_toEndOf="@+id/muteButton"
|
app:layout_constraintStart_toEndOf="@+id/muteButton"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:srcCompat="@drawable/ic_volume_down_black_24dp"
|
app:srcCompat="@drawable/ic_volume_down_black_24dp" />
|
||||||
android:contentDescription="@string/vol_down"/>
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/volUpButton"
|
android:id="@+id/volUpButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:layout_marginEnd="64dp"
|
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="128dp"
|
android:layout_marginTop="256dp"
|
||||||
|
android:layout_marginEnd="64dp"
|
||||||
|
android:contentDescription="@string/vol_up"
|
||||||
android:scaleX="2"
|
android:scaleX="2"
|
||||||
android:scaleY="2"
|
android:scaleY="2"
|
||||||
android:tint="@color/colorForeground"
|
android:tint="@color/colorForeground"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/nextButton"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@+id/volDownButton"
|
app:layout_constraintStart_toEndOf="@+id/volDownButton"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:srcCompat="@drawable/ic_volume_up_black_24dp"
|
app:srcCompat="@drawable/ic_volume_up_black_24dp" />
|
||||||
android:contentDescription="@string/vol_up"/>
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/prevButton"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="256dp"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:layout_marginStart="64dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:scaleX="2"
|
|
||||||
android:scaleY="2"
|
|
||||||
android:tint="@color/colorForeground"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/playButton"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/muteButton"
|
|
||||||
app:srcCompat="@drawable/ic_skip_previous_black_24dp"
|
|
||||||
android:contentDescription="@string/previous"/>
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/playButton"
|
android:id="@+id/playButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="256dp"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="64dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:contentDescription="@string/play"
|
||||||
|
android:scaleX="2"
|
||||||
|
android:scaleY="2"
|
||||||
|
android:tint="@color/colorForeground"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/prevButton"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/muteButton"
|
||||||
|
app:srcCompat="@drawable/ic_play_arrow_black_24dp" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/prevButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="64dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:contentDescription="@string/previous"
|
||||||
android:scaleX="2"
|
android:scaleX="2"
|
||||||
android:scaleY="2"
|
android:scaleY="2"
|
||||||
android:tint="@color/colorForeground"
|
android:tint="@color/colorForeground"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/nextButton"
|
app:layout_constraintEnd_toStartOf="@+id/nextButton"
|
||||||
app:layout_constraintStart_toEndOf="@+id/prevButton"
|
app:layout_constraintStart_toEndOf="@+id/playButton"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/volDownButton"
|
app:layout_constraintTop_toBottomOf="@+id/volDownButton"
|
||||||
app:srcCompat="@drawable/ic_play_arrow_black_24dp"
|
app:srcCompat="@drawable/ic_skip_previous_black_24dp" />
|
||||||
android:contentDescription="@string/play"/>
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/nextButton"
|
android:id="@+id/nextButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="256dp"
|
|
||||||
android:layout_marginEnd="64dp"
|
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="64dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:contentDescription="@string/next"
|
||||||
android:scaleX="2"
|
android:scaleX="2"
|
||||||
android:scaleY="2"
|
android:scaleY="2"
|
||||||
android:tint="@color/colorForeground"
|
android:tint="@color/colorForeground"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintEnd_toStartOf="@id/shuffleButton"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintStart_toEndOf="@+id/prevButton"
|
||||||
app:layout_constraintStart_toEndOf="@+id/playButton"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/volUpButton"
|
app:layout_constraintTop_toBottomOf="@+id/volUpButton"
|
||||||
app:srcCompat="@drawable/ic_skip_next_black_24dp"
|
app:srcCompat="@drawable/ic_skip_next_black_24dp" />
|
||||||
android:contentDescription="@string/next"/>
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/shuffleButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="64dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:contentDescription="@string/next"
|
||||||
|
android:scaleX="2"
|
||||||
|
android:scaleY="2"
|
||||||
|
android:tint="@color/colorForeground"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/nextButton"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/volUpButton"
|
||||||
|
app:srcCompat="@drawable/ic_shuffle_black_24dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/currentlyPlayingText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
|
android:layout_marginTop="64dp"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:textSize="18sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/playButton" />
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.constraint.ConstraintLayout>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from flask import Flask
|
from flask import Flask, jsonify
|
||||||
from subprocess import call
|
from subprocess import call, Popen, PIPE
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
@ -8,40 +8,70 @@ app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/mute')
|
@app.route('/mute')
|
||||||
def mute():
|
def mute():
|
||||||
call(['pactl', 'set-sink-mute', '0', 'toggle'])
|
call(['pactl', 'set-sink-mute', '0', 'toggle'])
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
@app.route('/vol_down')
|
@app.route('/vol_down')
|
||||||
def vol_down():
|
def vol_down():
|
||||||
call(['pactl', 'set-sink-volume', '0', '-5%'])
|
call(['pactl', 'set-sink-volume', '0', '-2%'])
|
||||||
return ''
|
return 'vol down'
|
||||||
|
|
||||||
|
|
||||||
@app.route('/vol_up')
|
@app.route('/vol_up')
|
||||||
def vol_up():
|
def vol_up():
|
||||||
call(['pactl', 'set-sink-volume', '0', '+5%'])
|
call(['pactl', 'set-sink-volume', '0', '+2%'])
|
||||||
return ''
|
return 'vol up'
|
||||||
|
|
||||||
|
|
||||||
@app.route('/prev')
|
@app.route('/prev')
|
||||||
def prev():
|
def prev():
|
||||||
call(['cmus-remote', '-r'])
|
call(['cmus-remote', '-r'])
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
@app.route('/play')
|
@app.route('/play')
|
||||||
def play():
|
def play():
|
||||||
call(['cmus-remote', '-u'])
|
call(['cmus-remote', '-u'])
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
@app.route('/next')
|
@app.route('/next')
|
||||||
def next():
|
def next():
|
||||||
call(['cmus-remote', '-n'])
|
call(['cmus-remote', '-n'])
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/shuffle')
|
||||||
|
def shuffle():
|
||||||
|
call(['cmus-remote', '-S'])
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/query')
|
||||||
|
def query():
|
||||||
|
p = Popen(['cmus-remote', '-Q'], stdout=PIPE, stderr=PIPE)
|
||||||
|
output, err = p.communicate()
|
||||||
|
output = output.decode()
|
||||||
|
status = {}
|
||||||
|
|
||||||
|
for line in output.split('\n'):
|
||||||
|
if line == 'status playing':
|
||||||
|
status['playing'] = True
|
||||||
|
elif line == 'status paused':
|
||||||
|
status['playing'] = False
|
||||||
|
elif line.startswith('tag artist '):
|
||||||
|
status['artist'] = line[11:]
|
||||||
|
elif line.startswith('tag title '):
|
||||||
|
status['title'] = line[10:]
|
||||||
|
elif line == 'set shuffle true':
|
||||||
|
status['shuffle'] = True
|
||||||
|
elif line == 'set shuffle false':
|
||||||
|
status['shuffle'] = False
|
||||||
|
|
||||||
|
return jsonify(status)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run()
|
app.run(host='0.0.0.0')
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ buildscript {
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.1.3'
|
classpath 'com.android.tools.build:gradle:3.3.0'
|
||||||
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#Mon Apr 02 19:56:32 CEST 2018
|
#Wed Jan 16 16:47:13 CET 2019
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
|
||||||
|
|
Loading…
Reference in New Issue