Skip to content

Commit

Permalink
refactor(app): update navigation menu
Browse files Browse the repository at this point in the history
links to #602
  • Loading branch information
ashutoshgngwr committed Apr 25, 2021
1 parent fc4b933 commit 40e3266
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import androidx.test.espresso.intent.matcher.IntentMatchers.*
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.github.ashutoshgngwr.noice.fragment.AboutFragment
import com.github.ashutoshgngwr.noice.fragment.PresetFragment
import com.github.ashutoshgngwr.noice.fragment.SoundLibraryFragment
Expand Down Expand Up @@ -169,17 +168,13 @@ class MainActivityTest {
onView(withId(R.id.navigation_drawer))
.perform(NavigationViewActions.navigateTo(R.id.report_issue))

intended(
filterEquals(
Intent(
Intent.ACTION_VIEW, Uri.parse(
InstrumentationRegistry.getInstrumentation()
.targetContext
.getString(R.string.app_issues_url)
)
)
)
)
val context = ApplicationProvider.getApplicationContext<Context>()
var url = context.getString(R.string.app_issues_github_url)
if (BuildConfig.IS_PLAY_STORE_BUILD) {
url = context.getString(R.string.app_issues_form_url)
}

intended(filterEquals(Intent(Intent.ACTION_VIEW, Uri.parse(url))))
} finally {
Intents.release()
}
Expand All @@ -203,39 +198,8 @@ class MainActivityTest {
filterEquals(
Intent(
Intent.ACTION_VIEW, Uri.parse(
InstrumentationRegistry.getInstrumentation()
.targetContext
.getString(R.string.feedback_form_url)
)
)
)
)
} finally {
Intents.release()
}
}

@Test
fun testRateOnPlayStoreMenuItem() {
Intents.init()
try {
Intents.intending(hasAction(Intent.ACTION_VIEW))
.respondWith(Instrumentation.ActivityResult(Activity.RESULT_OK, Intent()))

onView(withId(R.id.layout_main))
.check(matches(isClosed(Gravity.START)))
.perform(DrawerActions.open(Gravity.START))

onView(withId(R.id.navigation_drawer))
.perform(NavigationViewActions.navigateTo(R.id.rate_on_play_store))

intended(
filterEquals(
Intent(
Intent.ACTION_VIEW,
Uri.parse(
ApplicationProvider.getApplicationContext<Context>()
.getString(R.string.rate_us_on_play_store_url)
.getString(R.string.feedback_form_url)
)
)
)
Expand Down
15 changes: 6 additions & 9 deletions app/src/main/java/com/github/ashutoshgngwr/noice/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte

// setup listener for navigation item clicks
binding.navigationDrawer.setNavigationItemSelectedListener(this)
binding.navigationDrawer.menu.findItem(R.id.rate_on_play_store).isVisible =
BuildConfig.IS_PLAY_STORE_BUILD

// bind navigation drawer menu items checked state with fragment back stack
supportFragmentManager.addOnBackStackChangedListener {
Expand Down Expand Up @@ -201,17 +199,16 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
startActivity(Intent(this, AppIntroActivity::class.java))
}
R.id.report_issue -> {
customTabsIntent.launchUrl(this, Uri.parse(getString(R.string.app_issues_url)))
var url = getString(R.string.app_issues_github_url)
if (BuildConfig.IS_PLAY_STORE_BUILD) {
url = getString(R.string.app_issues_form_url)
}

customTabsIntent.launchUrl(this, Uri.parse(url))
}
R.id.submit_feedback -> {
customTabsIntent.launchUrl(this, Uri.parse(getString(R.string.feedback_form_url)))
}
R.id.rate_on_play_store -> {
startActivity(
Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.rate_us_on_play_store_url)))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
)
}
}

// hack to avoid stuttering in animations
Expand Down
18 changes: 6 additions & 12 deletions app/src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
android:icon="@drawable/ic_nav_settings"
android:title="@string/settings" />

<item
android:id="@+id/support_development"
android:icon="@drawable/ic_nav_support_development"
android:title="@string/support_development"
android:checkable="true" />

<item
android:id="@+id/about"
android:icon="@drawable/ic_nav_info"
Expand All @@ -49,12 +55,6 @@
android:title="@string/help"
android:checkable="false" />

<item
android:id="@+id/support_development"
android:icon="@drawable/ic_nav_support_development"
android:title="@string/support_development"
android:checkable="true" />

<item
android:id="@+id/report_issue"
android:icon="@drawable/ic_nav_report"
Expand All @@ -67,10 +67,4 @@
android:icon="@drawable/ic_nav_feedback"
android:title="@string/submit_feedback" />

<item
android:id="@+id/rate_on_play_store"
android:icon="@drawable/ic_nav_rate"
android:title="@string/about_play_store"
android:checkable="false" />

</menu>
5 changes: 4 additions & 1 deletion app/src/main/res/values/dont_translate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@
</string>
<string name="credits__sound_wind_in_palm_trees" translatable="false">Palm Trees from BBC Sound Effects</string>
<string name="credits__sound_wind_in_palm_trees_url" translatable="false">https://sound-effects.bbcrewind.co.uk/search?q=NHU05078140</string>
<string name="app_issues_url" translatable="false">https://github.com/ashutoshgngwr/noice/issues</string>
<string name="app_issues_github_url" translatable="false">https://github.com/ashutoshgngwr/noice/issues</string>
<string name="app_issues_form_url" translatable="false">
https://docs.google.com/forms/d/e/1FAIpQLSdYhyYjxhJ7IKyiqdc3AE3uINSoRWBw8ROB003gkZ47KeSjWw/viewform?usp=sf_link
</string>
<string name="feedback_form_url" translatable="false">
https://docs.google.com/forms/d/e/1FAIpQLSdEfOCyWfQ4QFMnLqlLj3BF27VKS1C-CQIokbmkXFchf6QZ6g/viewform?usp=sf_link
</string>
Expand Down

0 comments on commit 40e3266

Please sign in to comment.