Add gradle build file for PhoneCommon
Note, the gradle build fails in DialpadView.java. The problem is that
with library projects resource IDs are no longer final. This means
that they can't be used inside switch statements. Fix was to change
everything to if statements
Bug: 26676586
Change-Id: I1a36d6fc955445ae1c6787fbdbc73af6ff54b1f1
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..17fb78b
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,9 @@
+apply plugin: 'com.android.library'
+
+android {
+ sourceSets.main {
+ java.srcDirs = ['src']
+ manifest.srcFile 'AndroidManifest.xml'
+ res.srcDirs = ['res']
+ }
+}
diff --git a/src/com/android/phone/common/dialpad/DialpadView.java b/src/com/android/phone/common/dialpad/DialpadView.java
index d8ee4db..ed4ec83 100644
--- a/src/com/android/phone/common/dialpad/DialpadView.java
+++ b/src/com/android/phone/common/dialpad/DialpadView.java
@@ -326,53 +326,77 @@
private int getKeyButtonAnimationDelay(int buttonId) {
if (mIsLandscape) {
if (mIsRtl) {
- switch (buttonId) {
- case R.id.three: return KEY_FRAME_DURATION * 1;
- case R.id.six: return KEY_FRAME_DURATION * 2;
- case R.id.nine: return KEY_FRAME_DURATION * 3;
- case R.id.pound: return KEY_FRAME_DURATION * 4;
- case R.id.two: return KEY_FRAME_DURATION * 5;
- case R.id.five: return KEY_FRAME_DURATION * 6;
- case R.id.eight: return KEY_FRAME_DURATION * 7;
- case R.id.zero: return KEY_FRAME_DURATION * 8;
- case R.id.one: return KEY_FRAME_DURATION * 9;
- case R.id.four: return KEY_FRAME_DURATION * 10;
- case R.id.seven:
- case R.id.star:
- return KEY_FRAME_DURATION * 11;
+ if (buttonId == R.id.three) {
+ return KEY_FRAME_DURATION * 1;
+ } else if (buttonId == R.id.six) {
+ return KEY_FRAME_DURATION * 2;
+ } else if (buttonId == R.id.nine) {
+ return KEY_FRAME_DURATION * 3;
+ } else if (buttonId == R.id.pound) {
+ return KEY_FRAME_DURATION * 4;
+ } else if (buttonId == R.id.two) {
+ return KEY_FRAME_DURATION * 5;
+ } else if (buttonId == R.id.five) {
+ return KEY_FRAME_DURATION * 6;
+ } else if (buttonId == R.id.eight) {
+ return KEY_FRAME_DURATION * 7;
+ } else if (buttonId == R.id.zero) {
+ return KEY_FRAME_DURATION * 8;
+ } else if (buttonId == R.id.one) {
+ return KEY_FRAME_DURATION * 9;
+ } else if (buttonId == R.id.four) {
+ return KEY_FRAME_DURATION * 10;
+ } else if (buttonId == R.id.seven || buttonId == R.id.star) {
+ return KEY_FRAME_DURATION * 11;
}
} else {
- switch (buttonId) {
- case R.id.one: return KEY_FRAME_DURATION * 1;
- case R.id.four: return KEY_FRAME_DURATION * 2;
- case R.id.seven: return KEY_FRAME_DURATION * 3;
- case R.id.star: return KEY_FRAME_DURATION * 4;
- case R.id.two: return KEY_FRAME_DURATION * 5;
- case R.id.five: return KEY_FRAME_DURATION * 6;
- case R.id.eight: return KEY_FRAME_DURATION * 7;
- case R.id.zero: return KEY_FRAME_DURATION * 8;
- case R.id.three: return KEY_FRAME_DURATION * 9;
- case R.id.six: return KEY_FRAME_DURATION * 10;
- case R.id.nine:
- case R.id.pound:
- return KEY_FRAME_DURATION * 11;
+ if (buttonId == R.id.one) {
+ return KEY_FRAME_DURATION * 1;
+ } else if (buttonId == R.id.four) {
+ return KEY_FRAME_DURATION * 2;
+ } else if (buttonId == R.id.seven) {
+ return KEY_FRAME_DURATION * 3;
+ } else if (buttonId == R.id.star) {
+ return KEY_FRAME_DURATION * 4;
+ } else if (buttonId == R.id.two) {
+ return KEY_FRAME_DURATION * 5;
+ } else if (buttonId == R.id.five) {
+ return KEY_FRAME_DURATION * 6;
+ } else if (buttonId == R.id.eight) {
+ return KEY_FRAME_DURATION * 7;
+ } else if (buttonId == R.id.zero) {
+ return KEY_FRAME_DURATION * 8;
+ } else if (buttonId == R.id.three) {
+ return KEY_FRAME_DURATION * 9;
+ } else if (buttonId == R.id.six) {
+ return KEY_FRAME_DURATION * 10;
+ } else if (buttonId == R.id.nine || buttonId == R.id.pound) {
+ return KEY_FRAME_DURATION * 11;
}
}
} else {
- switch (buttonId) {
- case R.id.one: return KEY_FRAME_DURATION * 1;
- case R.id.two: return KEY_FRAME_DURATION * 2;
- case R.id.three: return KEY_FRAME_DURATION * 3;
- case R.id.four: return KEY_FRAME_DURATION * 4;
- case R.id.five: return KEY_FRAME_DURATION * 5;
- case R.id.six: return KEY_FRAME_DURATION * 6;
- case R.id.seven: return KEY_FRAME_DURATION * 7;
- case R.id.eight: return KEY_FRAME_DURATION * 8;
- case R.id.nine: return KEY_FRAME_DURATION * 9;
- case R.id.star: return KEY_FRAME_DURATION * 10;
- case R.id.zero:
- case R.id.pound:
- return KEY_FRAME_DURATION * 11;
+ if (buttonId == R.id.one) {
+ return KEY_FRAME_DURATION * 1;
+ } else if (buttonId == R.id.two) {
+ return KEY_FRAME_DURATION * 2;
+ } else if (buttonId == R.id.three) {
+ return KEY_FRAME_DURATION * 3;
+ } else if (buttonId == R.id.four) {
+ return KEY_FRAME_DURATION * 4;
+ } else if (buttonId == R.id.five) {
+ return KEY_FRAME_DURATION * 5;
+ } else if (buttonId == R.id.six) {
+ return KEY_FRAME_DURATION * 6;
+ } else if (buttonId == R.id.seven) {
+ return KEY_FRAME_DURATION * 7;
+ } else if (buttonId == R.id.eight) {
+ return KEY_FRAME_DURATION * 8;
+ } else if (buttonId == R.id.nine) {
+ return KEY_FRAME_DURATION * 9;
+ } else if (buttonId == R.id.star) {
+ return KEY_FRAME_DURATION * 10;
+ } else if (buttonId == R.id.zero || buttonId == R.id.pound) {
+ return KEY_FRAME_DURATION * 11;
}
}
@@ -390,59 +414,36 @@
private int getKeyButtonAnimationDuration(int buttonId) {
if (mIsLandscape) {
if (mIsRtl) {
- switch (buttonId) {
- case R.id.one:
- case R.id.four:
- case R.id.seven:
- case R.id.star:
- return KEY_FRAME_DURATION * 8;
- case R.id.two:
- case R.id.five:
- case R.id.eight:
- case R.id.zero:
- return KEY_FRAME_DURATION * 9;
- case R.id.three:
- case R.id.six:
- case R.id.nine:
- case R.id.pound:
- return KEY_FRAME_DURATION * 10;
+ if (buttonId == R.id.one || buttonId == R.id.four || buttonId == R.id.seven
+ || buttonId == R.id.star) {
+ return KEY_FRAME_DURATION * 8;
+ } else if (buttonId == R.id.two || buttonId == R.id.five || buttonId == R.id.eight
+ || buttonId == R.id.zero) {
+ return KEY_FRAME_DURATION * 9;
+ } else if (buttonId == R.id.three || buttonId == R.id.six || buttonId == R.id.nine
+ || buttonId == R.id.pound) {
+ return KEY_FRAME_DURATION * 10;
}
} else {
- switch (buttonId) {
- case R.id.one:
- case R.id.four:
- case R.id.seven:
- case R.id.star:
- return KEY_FRAME_DURATION * 10;
- case R.id.two:
- case R.id.five:
- case R.id.eight:
- case R.id.zero:
- return KEY_FRAME_DURATION * 9;
- case R.id.three:
- case R.id.six:
- case R.id.nine:
- case R.id.pound:
- return KEY_FRAME_DURATION * 8;
+ if (buttonId == R.id.one || buttonId == R.id.four || buttonId == R.id.seven
+ || buttonId == R.id.star) {
+ return KEY_FRAME_DURATION * 10;
+ } else if (buttonId == R.id.two || buttonId == R.id.five || buttonId == R.id.eight
+ || buttonId == R.id.zero) {
+ return KEY_FRAME_DURATION * 9;
+ } else if (buttonId == R.id.three || buttonId == R.id.six || buttonId == R.id.nine
+ || buttonId == R.id.pound) {
+ return KEY_FRAME_DURATION * 8;
}
}
} else {
- switch (buttonId) {
- case R.id.one:
- case R.id.two:
- case R.id.three:
- case R.id.four:
- case R.id.five:
- case R.id.six:
- return KEY_FRAME_DURATION * 10;
- case R.id.seven:
- case R.id.eight:
- case R.id.nine:
- return KEY_FRAME_DURATION * 9;
- case R.id.star:
- case R.id.zero:
- case R.id.pound:
- return KEY_FRAME_DURATION * 8;
+ if (buttonId == R.id.one || buttonId == R.id.two || buttonId == R.id.three
+ || buttonId == R.id.four || buttonId == R.id.five || buttonId == R.id.six) {
+ return KEY_FRAME_DURATION * 10;
+ } else if (buttonId == R.id.seven || buttonId == R.id.eight || buttonId == R.id.nine) {
+ return KEY_FRAME_DURATION * 9;
+ } else if (buttonId == R.id.star || buttonId == R.id.zero || buttonId == R.id.pound) {
+ return KEY_FRAME_DURATION * 8;
}
}