Browse Source

fixed the android wear package name

main
James Fenn 3 years ago
parent
commit
0b1490d077
5 changed files with 34 additions and 31 deletions
  1. +9
    -6
      wear/build.gradle
  2. +1
    -1
      wear/src/main/AndroidManifest.xml
  3. +17
    -17
      wear/src/main/java/james/metronome/MainActivity.java
  4. +6
    -6
      wear/src/main/java/james/metronome/MetronomeService.java
  5. +1
    -1
      wear/src/main/res/layout/activity_main.xml

+ 9
- 6
wear/build.gradle View File

@@ -6,11 +6,11 @@ android {
buildToolsVersion "26.0.0"

defaultConfig {
applicationId "james.metronome.wear"
applicationId "james.metronome"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
versionCode 5
versionName "1.4"
}
buildTypes {
release {
@@ -18,11 +18,14 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:2.0.1'
compile 'com.google.android.gms:play-services-wearable:10.2.1'
provided 'com.google.android.wearable:wearable:1.0.0'
provided 'com.google.android.wearable:wearable:2.0.3'
compile 'com.google.android.support:wearable:2.0.3'
compile 'com.google.android.gms:play-services-wearable:11.0.1'
}

+ 1
- 1
wear/src/main/AndroidManifest.xml View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="james.metronome.wear">
package="james.metronome">

<uses-feature android:name="android.hardware.type.watch" />



wear/src/main/java/james/metronome/wear/MainActivity.java → wear/src/main/java/james/metronome/MainActivity.java View File

@@ -1,4 +1,4 @@
package james.metronome.wear;
package james.metronome;

import android.content.ComponentName;
import android.content.Context;
@@ -30,19 +30,19 @@ public class MainActivity extends WearableActivity implements ServiceConnection,
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setContentView(james.metronome.wear.R.layout.activity_main);
setAmbientEnabled();

container = findViewById(R.id.container);
vibrationView = findViewById(R.id.vibration);
playView = findViewById(R.id.play);
bpmView = findViewById(R.id.bpm);
seekBar = findViewById(R.id.seekBar);
container = findViewById(james.metronome.wear.R.id.container);
vibrationView = findViewById(james.metronome.wear.R.id.vibration);
playView = findViewById(james.metronome.wear.R.id.play);
bpmView = findViewById(james.metronome.wear.R.id.bpm);
seekBar = findViewById(james.metronome.wear.R.id.seekBar);

if (isBound()) {
vibrationView.setImageResource(service.isVibration() ? R.drawable.ic_vibration : R.drawable.ic_sound);
playView.setImageResource(service.isPlaying() ? R.drawable.ic_pause : R.drawable.ic_play);
bpmView.setText(String.format(Locale.getDefault(), getString(R.string.bpm), String.valueOf(service.getBpm())));
vibrationView.setImageResource(service.isVibration() ? james.metronome.wear.R.drawable.ic_vibration : james.metronome.wear.R.drawable.ic_sound);
playView.setImageResource(service.isPlaying() ? james.metronome.wear.R.drawable.ic_pause : james.metronome.wear.R.drawable.ic_play);
bpmView.setText(String.format(Locale.getDefault(), getString(james.metronome.wear.R.string.bpm), String.valueOf(service.getBpm())));
seekBar.setProgress(service.getBpm());
}

@@ -50,7 +50,7 @@ public class MainActivity extends WearableActivity implements ServiceConnection,
@Override
public void onClick(View view) {
service.setVibration(!service.isVibration());
vibrationView.setImageResource(service.isVibration() ? R.drawable.ic_vibration : R.drawable.ic_sound);
vibrationView.setImageResource(service.isVibration() ? james.metronome.wear.R.drawable.ic_vibration : james.metronome.wear.R.drawable.ic_sound);
}
});

@@ -86,7 +86,7 @@ public class MainActivity extends WearableActivity implements ServiceConnection,
private void setBpm(int bpm) {
if (isBound()) {
service.setBpm(bpm);
bpmView.setText(String.format(Locale.getDefault(), getString(R.string.bpm), String.valueOf(bpm)));
bpmView.setText(String.format(Locale.getDefault(), getString(james.metronome.wear.R.string.bpm), String.valueOf(bpm)));
}
}

@@ -144,13 +144,13 @@ public class MainActivity extends WearableActivity implements ServiceConnection,
isBound = true;

if (vibrationView != null)
vibrationView.setImageResource(service.isVibration() ? R.drawable.ic_vibration : R.drawable.ic_sound);
vibrationView.setImageResource(service.isVibration() ? james.metronome.wear.R.drawable.ic_vibration : james.metronome.wear.R.drawable.ic_sound);

if (playView != null)
playView.setImageResource(service.isPlaying() ? R.drawable.ic_pause : R.drawable.ic_play);
playView.setImageResource(service.isPlaying() ? james.metronome.wear.R.drawable.ic_pause : james.metronome.wear.R.drawable.ic_play);

if (bpmView != null)
bpmView.setText(String.format(Locale.getDefault(), getString(R.string.bpm), String.valueOf(service.getBpm())));
bpmView.setText(String.format(Locale.getDefault(), getString(james.metronome.wear.R.string.bpm), String.valueOf(service.getBpm())));

if (seekBar != null)
seekBar.setProgress(service.getBpm());
@@ -163,11 +163,11 @@ public class MainActivity extends WearableActivity implements ServiceConnection,

@Override
public void onStartTicks() {
playView.setImageResource(R.drawable.ic_pause);
playView.setImageResource(james.metronome.wear.R.drawable.ic_pause);
}

@Override
public void onStopTicks() {
playView.setImageResource(R.drawable.ic_play);
playView.setImageResource(james.metronome.wear.R.drawable.ic_play);
}
}

wear/src/main/java/james/metronome/wear/MetronomeService.java → wear/src/main/java/james/metronome/MetronomeService.java View File

@@ -1,4 +1,4 @@
package james.metronome.wear;
package james.metronome;

import android.app.PendingIntent;
import android.app.Service;
@@ -59,7 +59,7 @@ public class MetronomeService extends Service implements Runnable {

isVibration = prefs.getBoolean(PREF_VIBRATION, true);
if (!isVibration)
soundId = soundPool.load(this, R.raw.click, 1);
soundId = soundPool.load(this, james.metronome.wear.R.raw.click, 1);

interval = prefs.getLong(PREF_INTERVAL, 500);
bpm = toBpm(interval);
@@ -95,9 +95,9 @@ public class MetronomeService extends Service implements Runnable {

startForeground(530,
new NotificationCompat.Builder(this)
.setContentTitle(getString(R.string.notification_title))
.setContentText(getString(R.string.notification_desc))
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(getString(james.metronome.wear.R.string.notification_title))
.setContentText(getString(james.metronome.wear.R.string.notification_desc))
.setSmallIcon(james.metronome.wear.R.drawable.ic_notification)
.setContentIntent(PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_ONE_SHOT))
.build()
);
@@ -124,7 +124,7 @@ public class MetronomeService extends Service implements Runnable {
public void setVibration(boolean vibration) {
isVibration = vibration;
if (!isVibration)
soundId = soundPool.load(this, R.raw.click, 1);
soundId = soundPool.load(this, james.metronome.wear.R.raw.click, 1);
else soundId = -1;

prefs.edit().putBoolean(PREF_VIBRATION, isVibration).apply();

+ 1
- 1
wear/src/main/res/layout/activity_main.xml View File

@@ -32,7 +32,7 @@
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="42dp"
android:max="300" />

<TextView


Loading…
Cancel
Save