From 6a17fb0bd7d00a39cbee60f46bda8d6bc8a94c6e Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Wed, 4 Sep 2024 12:08:31 +0530 Subject: [PATCH] gradle: Enable nonFinalResIds flag Signed-off-by: Aayush Gupta --- .../android/calendar/AllInOneActivity.java | 49 ++++++++----------- .../com/android/calendar/DynamicTheme.java | 28 +++++------ gradle.properties | 1 - 3 files changed, 34 insertions(+), 44 deletions(-) diff --git a/app/src/main/java/com/android/calendar/AllInOneActivity.java b/app/src/main/java/com/android/calendar/AllInOneActivity.java index a08f934ecc..df297aaffa 100644 --- a/app/src/main/java/com/android/calendar/AllInOneActivity.java +++ b/app/src/main/java/com/android/calendar/AllInOneActivity.java @@ -932,34 +932,27 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public boolean onNavigationItemSelected(MenuItem item) { final int itemId = item.getItemId(); - switch (itemId) { - case R.id.day_menu_item: - if (mCurrentView != ViewType.DAY) { - mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.DAY); - } - break; - case R.id.week_menu_item: - if (mCurrentView != ViewType.WEEK) { - mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.WEEK); - } - break; - case R.id.month_menu_item: - if (mCurrentView != ViewType.MONTH) { - mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.MONTH); - } - break; - case R.id.agenda_menu_item: - if (mCurrentView != ViewType.AGENDA) { - mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.AGENDA); - } - break; - case R.id.action_settings: - mController.sendEvent(this, EventType.LAUNCH_SETTINGS, null, null, 0, 0); - break; - case R.id.action_about: - Intent intent = new Intent(this, AboutActivity.class); - startActivity(intent); - break; + if (itemId == R.id.day_menu_item) { + if (mCurrentView != ViewType.DAY) { + mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.DAY); + } + } else if (itemId == R.id.week_menu_item) { + if (mCurrentView != ViewType.WEEK) { + mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.WEEK); + } + } else if (itemId == R.id.month_menu_item) { + if (mCurrentView != ViewType.MONTH) { + mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.MONTH); + } + } else if (itemId == R.id.agenda_menu_item) { + if (mCurrentView != ViewType.AGENDA) { + mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.AGENDA); + } + } else if (itemId == R.id.action_settings) { + mController.sendEvent(this, EventType.LAUNCH_SETTINGS, null, null, 0, 0); + } else if (itemId == R.id.action_about) { + Intent intent = new Intent(this, AboutActivity.class); + startActivity(intent); } mDrawerLayout.closeDrawers(); return true; diff --git a/app/src/main/java/com/android/calendar/DynamicTheme.java b/app/src/main/java/com/android/calendar/DynamicTheme.java index f5ca0b8e10..573a7be5d1 100644 --- a/app/src/main/java/com/android/calendar/DynamicTheme.java +++ b/app/src/main/java/com/android/calendar/DynamicTheme.java @@ -233,22 +233,20 @@ public static int getColorId(String name) { } public static String getColorName(int id) { - switch (id) { - case R.color.colorPrimary : - return TEAL; - case R.color.colorBluePrimary: - return BLUE; - case R.color.colorOrangePrimary: - return ORANGE; - case R.color.colorGreenPrimary: - return GREEN; - case R.color.colorRedPrimary: - return RED; - case R.color.colorPurplePrimary: - return PURPLE; - default: - throw new UnsupportedOperationException("Unknown color id : " + id); + if (id == R.color.colorPrimary) { + return TEAL; + } else if (id == R.color.colorBluePrimary) { + return BLUE; + } else if (id == R.color.colorOrangePrimary) { + return ORANGE; + } else if (id == R.color.colorGreenPrimary) { + return GREEN; + } else if (id == R.color.colorRedPrimary) { + return RED; + } else if (id == R.color.colorPurplePrimary) { + return PURPLE; } + throw new UnsupportedOperationException("Unknown color id : " + id); } public static int getColor(Context context, String id) { diff --git a/gradle.properties b/gradle.properties index 06f47aff97..5dc70b11cc 100755 --- a/gradle.properties +++ b/gradle.properties @@ -19,4 +19,3 @@ android.useAndroidX=true android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official -android.nonFinalResIds=false