Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/sony-headphones-control.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2019-08-28 15:46:51 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2019-08-28 15:47:59 +0300
commit26cadea41a214b3c892c9003980ae1c1185087c3 (patch)
tree666effd12c395ebad5b8e007753c659735e9a7c6
parent6eb49e90c727439fa2d3bdaef4e56202ed9ee26c (diff)
Standalone mode, design optimizations, Android TV support
-rw-r--r--.gitignore14
-rw-r--r--app/build.gradle2
-rw-r--r--app/src/main/AndroidManifest.xml4
-rw-r--r--app/src/main/java/com/clusterrr/sonyheadphonescontrol/MainActivity.java6
-rw-r--r--app/src/main/java/com/clusterrr/sonyheadphonescontrol/TaskerFireReceiver.java16
-rw-r--r--app/src/main/res/layout/activity_main.xml179
-rw-r--r--app/src/main/res/mipmap/banner.pngbin0 -> 20934 bytes
-rw-r--r--app/src/main/res/values/strings.xml4
-rw-r--r--screenshots/main.jpgbin0 -> 164517 bytes
-rw-r--r--screenshots/tasker.jpgbin0 -> 223777 bytes
10 files changed, 134 insertions, 91 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ebdd23d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,14 @@
+*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+.cxx
diff --git a/app/build.gradle b/app/build.gradle
index f80ff87..f5c928d 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -4,7 +4,7 @@ android {
compileSdkVersion 28
defaultConfig {
applicationId "com.clusterrr.sonyheadphonescontrol"
- minSdkVersion 14
+ minSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 4f8a51d..b0bcd39 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -17,6 +17,7 @@
<application
android:allowBackup="true"
android:icon="@mipmap/headphones"
+ android:banner="@mipmap/banner"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
@@ -33,6 +34,9 @@
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="com.twofortyfouram.locale.intent.action.EDIT_SETTING" />
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
</application>
diff --git a/app/src/main/java/com/clusterrr/sonyheadphonescontrol/MainActivity.java b/app/src/main/java/com/clusterrr/sonyheadphonescontrol/MainActivity.java
index ceb4e16..34b92aa 100644
--- a/app/src/main/java/com/clusterrr/sonyheadphonescontrol/MainActivity.java
+++ b/app/src/main/java/com/clusterrr/sonyheadphonescontrol/MainActivity.java
@@ -61,6 +61,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
((Button) findViewById(R.id.buttonTest)).setOnClickListener(this);
((Button) findViewById(R.id.buttonSave)).setOnClickListener(this);
+ if (getCallingActivity() == null) // standalone mode
+ {
+ ((Button) findViewById(R.id.buttonTest)).setText(R.string.apply);
+ ((Button) findViewById(R.id.buttonSave)).setVisibility(View.GONE);
+ }
+
saveSettings();
}
diff --git a/app/src/main/java/com/clusterrr/sonyheadphonescontrol/TaskerFireReceiver.java b/app/src/main/java/com/clusterrr/sonyheadphonescontrol/TaskerFireReceiver.java
index 642b145..b6e066b 100644
--- a/app/src/main/java/com/clusterrr/sonyheadphonescontrol/TaskerFireReceiver.java
+++ b/app/src/main/java/com/clusterrr/sonyheadphonescontrol/TaskerFireReceiver.java
@@ -91,9 +91,9 @@ public final class TaskerFireReceiver extends BroadcastReceiver {
if (intent != null)
TaskerPlugin.Setting.signalFinish(context, intent, TaskerPlugin.Setting.RESULT_CODE_OK, null);
else
- Toast.makeText(context, "OK", Toast.LENGTH_SHORT).show();
+ Toast.makeText(context, context.getString(R.string.ok), Toast.LENGTH_SHORT).show();
} else {
- final String message = "Sony Headset is not found";
+ final String message = context.getString(R.string.headset_not_found);
if (intent != null) {
Bundle vars = new Bundle();
vars.putString(TaskerPlugin.Setting.VARNAME_ERROR_MESSAGE, message);
@@ -104,7 +104,7 @@ public final class TaskerFireReceiver extends BroadcastReceiver {
}
} catch (IOException e) {
e.printStackTrace();
- final String message = "IO error (another application using a headset?)";
+ final String message = context.getString(R.string.io_error);
if (intent != null) {
Bundle vars = new Bundle();
vars.putString(TaskerPlugin.Setting.VARNAME_ERROR_MESSAGE, message);
@@ -139,17 +139,17 @@ public final class TaskerFireReceiver extends BroadcastReceiver {
break;
}
if (headset == null) {
- Log.e(TAG, "Headset not found");
+// Log.e(TAG, "Headset not found");
return false;
} else {
- Log.d(TAG, "Headset found: " + headset.getAddress() + " " + headset.getName());
+// Log.d(TAG, "Headset found: " + headset.getAddress() + " " + headset.getName());
}
BluetoothSocket socket = headset.createRfcommSocketToServiceRecord(uuid);
try {
- Log.i(TAG, "Socket connected: " + socket.isConnected());
+// Log.i(TAG, "Socket connected: " + socket.isConnected());
socket.connect();
- Log.i(TAG, "Socket connected: " + socket.isConnected());
+// Log.i(TAG, "Socket connected: " + socket.isConnected());
byte[] packet = new byte[data.length + 2];
packet[0] = 0x0c;
@@ -190,7 +190,7 @@ public final class TaskerFireReceiver extends BroadcastReceiver {
for (int j = 0; j < r; j++) {
sb.append(String.format(" %02x", buffer[j]));
}
- Log.i(TAG, "Read: " + r + " bytes:" + sb);
+// Log.i(TAG, "Read: " + r + " bytes:" + sb);
break;
}
Thread.sleep(50);
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 29e6e45..fe47d6d 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -6,90 +6,105 @@
android:layout_height="match_parent"
tools:context=".MainActivity">
- <RadioGroup
- android:id="@+id/radioGroup"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
+ <ScrollView
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ app:layout_constraintBottom_toTopOf="@+id/buttonTest"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
- <RadioButton
- android:id="@+id/radioButtonDisable"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="16dp"
- android:layout_marginTop="32dp"
- android:checked="true"
- android:text="@string/disable_ambient_sound_control"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
-
- <RadioButton
- android:id="@+id/radioButtonNoiseCancelling"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="16dp"
- android:layout_marginTop="32dp"
- android:text="@string/enable_noise_cancelling"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/radioButtonDisable" />
-
- <RadioButton
- android:id="@+id/radioButtonWindCancelling"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="16dp"
- android:layout_marginTop="32dp"
- android:text="@string/enable_wind_cancelling"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/radioButtonNoiseCancelling" />
-
- <RadioButton
- android:id="@+id/radioButtonAmbientSound"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="16dp"
- android:layout_marginTop="32dp"
- android:text="@string/ambient_sound"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/radioButtonWindCancelling" />
-
- </RadioGroup>
-
- <TextView
- android:id="@+id/textView"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="32dp"
- android:layout_marginTop="16dp"
- android:text="@string/volume"
- android:textAppearance="@style/TextAppearance.AppCompat.Body1"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/radioGroup" />
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
- <SeekBar
- android:id="@+id/seekBarVolume"
- style="@style/Widget.AppCompat.SeekBar.Discrete"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_marginEnd="32dp"
- android:max="20"
- android:min="1"
- android:progress="20"
- app:layout_constraintBottom_toBottomOf="@+id/textView"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toEndOf="@+id/textView"
- app:layout_constraintTop_toTopOf="@+id/textView" />
+ <RadioGroup
+ android:id="@+id/radioGroup"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ app:layout_constraintTop_toTopOf="parent">
- <Switch
- android:id="@+id/switchVoiceOptimized"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="16dp"
- android:switchPadding="16dp"
- android:text="@string/voice_optimized"
- app:layout_constraintStart_toStartOf="@+id/textView"
- app:layout_constraintTop_toBottomOf="@+id/textView" />
+ <RadioButton
+ android:id="@+id/radioButtonDisable"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginTop="24dp"
+ android:checked="true"
+ android:text="@string/disable_ambient_sound_control"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <RadioButton
+ android:id="@+id/radioButtonNoiseCancelling"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginTop="16dp"
+ android:text="@string/enable_noise_cancelling"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/radioButtonDisable" />
+
+ <RadioButton
+ android:id="@+id/radioButtonWindCancelling"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginTop="16dp"
+ android:text="@string/enable_wind_cancelling"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/radioButtonNoiseCancelling" />
+
+ <RadioButton
+ android:id="@+id/radioButtonAmbientSound"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginTop="16dp"
+ android:text="@string/ambient_sound"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/radioButtonWindCancelling" />
+
+ </RadioGroup>
+
+ <SeekBar
+ android:id="@+id/seekBarVolume"
+ style="@style/Widget.AppCompat.SeekBar.Discrete"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="32dp"
+ android:max="20"
+ android:min="1"
+ android:progress="20"
+ app:layout_constraintBottom_toBottomOf="@+id/textView"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/textView"
+ app:layout_constraintTop_toTopOf="@+id/textView" />
+
+ <Switch
+ android:id="@+id/switchVoiceOptimized"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="16dp"
+ android:switchPadding="16dp"
+ android:text="@string/voice_optimized"
+ app:layout_constraintStart_toStartOf="@+id/textView"
+ app:layout_constraintTop_toBottomOf="@+id/textView" />
+
+ <TextView
+ android:id="@+id/textView"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="32dp"
+ android:layout_marginTop="16dp"
+ android:text="@string/volume"
+ android:textAppearance="@style/TextAppearance.AppCompat.Body1"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/radioGroup" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+ </ScrollView>
<Button
android:id="@+id/buttonTest"
@@ -97,7 +112,6 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
- android:layout_marginBottom="16dp"
android:text="@string/test"
app:layout_constraintBottom_toTopOf="@+id/buttonSave"
app:layout_constraintEnd_toEndOf="parent"
@@ -109,10 +123,11 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
- android:layout_marginBottom="16dp"
+ android:layout_marginBottom="24dp"
android:text="@string/save"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
+
</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file
diff --git a/app/src/main/res/mipmap/banner.png b/app/src/main/res/mipmap/banner.png
new file mode 100644
index 0000000..edd4c29
--- /dev/null
+++ b/app/src/main/res/mipmap/banner.png
Binary files differ
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d46044f..1b83a90 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -8,4 +8,8 @@
<string name="voice_optimized">Voice optimized</string>
<string name="test">Test</string>
<string name="save">Save</string>
+ <string name="apply">Apply</string>
+ <string name="io_error">IO error (Another application using a headset? Is it connected?)</string>
+ <string name="headset_not_found">Sony Headset is not found</string>
+ <string name="ok">OK</string>
</resources>
diff --git a/screenshots/main.jpg b/screenshots/main.jpg
new file mode 100644
index 0000000..6c6d733
--- /dev/null
+++ b/screenshots/main.jpg
Binary files differ
diff --git a/screenshots/tasker.jpg b/screenshots/tasker.jpg
new file mode 100644
index 0000000..3b0d56b
--- /dev/null
+++ b/screenshots/tasker.jpg
Binary files differ