From e4aa049d141b6c0d3f61e1d167b2caab8702319a Mon Sep 17 00:00:00 2001 From: Madhur Gupta Date: Mon, 9 Mar 2020 02:37:20 +0100 Subject: [PATCH 1/7] Added AboutActivityTest --- .../fr/free/nrw/commons/AboutActivityTest.kt | 116 ++++++++++++++++++ .../java/fr/free/nrw/commons/UITestHelper.kt | 9 ++ .../java/fr/free/nrw/commons/ViewActions.kt | 2 +- app/src/main/java/fr/free/nrw/commons/Urls.kt | 3 + .../main/java/fr/free/nrw/commons/Utils.java | 4 +- 5 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt diff --git a/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt b/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt new file mode 100644 index 0000000000..0117f852f2 --- /dev/null +++ b/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt @@ -0,0 +1,116 @@ +package fr.free.nrw.commons + +import android.app.Activity +import android.app.Instrumentation +import android.content.Intent +import androidx.test.core.app.ApplicationProvider.getApplicationContext +import androidx.test.espresso.Espresso +import androidx.test.espresso.action.ViewActions +import androidx.test.espresso.assertion.ViewAssertions +import androidx.test.espresso.intent.Intents +import androidx.test.espresso.intent.matcher.IntentMatchers +import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.espresso.matcher.ViewMatchers.withText +import androidx.test.rule.ActivityTestRule +import androidx.test.runner.AndroidJUnit4 +import fr.free.nrw.commons.utils.ConfigUtils +import org.hamcrest.CoreMatchers +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class AboutActivityTest { + @get:Rule + var activityRule: ActivityTestRule<*> = ActivityTestRule(AboutActivity::class.java) + + @Before + fun setup() { + Intents.init() + UITestHelper.skipWelcome() + UITestHelper.skipLogin() + Intents.intending(CoreMatchers.not(IntentMatchers.isInternal())) + .respondWith(Instrumentation.ActivityResult(Activity.RESULT_OK, null)) + } + + @Test + fun testBuildNumber() { + Espresso.onView(ViewMatchers.withId(R.id.about_version)) + .check(ViewAssertions.matches(withText(ConfigUtils.getVersionNameWithSha(getApplicationContext())))) + } + + @Test + fun testLaunchWebsite() { + Espresso.onView(ViewMatchers.withId(R.id.website_launch_icon)).perform(ViewActions.click()) + Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), + IntentMatchers.hasData(Urls.WEBSITE_URL))) + } + + @Test + fun testLaunchFacebook() { + Espresso.onView(ViewMatchers.withId(R.id.facebook_launch_icon)).perform(ViewActions.click()) + try { + Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), + IntentMatchers.hasPackage(Urls.FACEBOOK_PACKAGE_NAME))) + } catch (e: Exception) { + Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), + IntentMatchers.hasData(Urls.FACEBOOK_WEB_URL))) + } + } + + @Test + fun testLaunchGithub() { + Espresso.onView(ViewMatchers.withId(R.id.github_launch_icon)).perform(ViewActions.click()) + Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), + IntentMatchers.hasData(Urls.GITHUB_REPO_URL))) + } + + @Test + fun testLaunchRateUs() { + val appPackageName = BuildConfig::class.java.getPackage().name + Espresso.onView(ViewMatchers.withId(R.id.about_rate_us)).perform(ViewActions.click()) + try { + Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), + IntentMatchers.toPackage(Urls.PLAY_STORE_PACKAGE_NAME))) + } catch (e: Exception) { + Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), + IntentMatchers.hasData("${Urls.PLAY_STORE_URL_PREFIX}$appPackageName"))) + } + } + + @Test + fun testLaunchAboutPrivacyPolicy() { + Espresso.onView(ViewMatchers.withId(R.id.about_privacy_policy)).perform(ViewActions.click()) + Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), + IntentMatchers.hasData(BuildConfig.PRIVACY_POLICY_URL))) + } + + @Test + fun testLaunchTranslate() { + Espresso.onView(ViewMatchers.withId(R.id.about_translate)).perform(ViewActions.click()) + Espresso.onView(ViewMatchers.withId(android.R.id.button1)).perform(ViewActions.click()) + val langCode = CommonsApplication.getInstance().languageLookUpTable.codes[0] + Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), + IntentMatchers.hasData("${Urls.TRANSLATE_WIKI_URL}$langCode"))) + } + + @Test + fun testLaunchAboutCredits() { + Espresso.onView(ViewMatchers.withId(R.id.about_credits)).perform(ViewActions.click()) + Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), + IntentMatchers.hasData(Urls.CREDITS_URL))) + } + + @Test + fun testLaunchAboutFaq() { + Espresso.onView(ViewMatchers.withId(R.id.about_faq)).perform(ViewActions.click()) + Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), + IntentMatchers.hasData(Urls.FAQ_URL))) + } + + @Test + fun orientationChange() { + UITestHelper.changeOrientation(activityRule) + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/fr/free/nrw/commons/UITestHelper.kt b/app/src/androidTest/java/fr/free/nrw/commons/UITestHelper.kt index 78a1fb62b1..952af05c12 100644 --- a/app/src/androidTest/java/fr/free/nrw/commons/UITestHelper.kt +++ b/app/src/androidTest/java/fr/free/nrw/commons/UITestHelper.kt @@ -22,6 +22,15 @@ class UITestHelper { } } + fun skipLogin() { + try { + //Skip Login + onView(ViewMatchers.withId(R.id.skip_login)) + .perform(ViewActions.click()) + } catch (ignored: NoMatchingViewException) { + } + } + fun loginUser() { try { //Perform Login diff --git a/app/src/androidTest/java/fr/free/nrw/commons/ViewActions.kt b/app/src/androidTest/java/fr/free/nrw/commons/ViewActions.kt index 856ce4c010..a4a3bb2b9e 100644 --- a/app/src/androidTest/java/fr/free/nrw/commons/ViewActions.kt +++ b/app/src/androidTest/java/fr/free/nrw/commons/ViewActions.kt @@ -8,7 +8,7 @@ import org.hamcrest.Matcher object ViewActions { fun clickChildViewWithId(id: Int): ViewAction { return object : ViewAction { - override fun getConstraints(): Matcher { + override fun getConstraints(): Matcher? { return null } diff --git a/app/src/main/java/fr/free/nrw/commons/Urls.kt b/app/src/main/java/fr/free/nrw/commons/Urls.kt index 7c60d9f91f..ed419f3440 100644 --- a/app/src/main/java/fr/free/nrw/commons/Urls.kt +++ b/app/src/main/java/fr/free/nrw/commons/Urls.kt @@ -7,6 +7,9 @@ internal object Urls { const val CREDITS_URL = "https://github.com/commons-app/apps-android-commons/blob/master/CREDITS" const val FAQ_URL = "https://github.com/commons-app/apps-android-commons/wiki/Frequently-Asked-Questions" const val PLAY_STORE_URL = "https://play.google.com/store/apps/details?id=fr.free.nrw.commons" + const val PLAY_STORE_PREFIX = "market://details?id=" + const val PLAY_STORE_URL_PREFIX = "https://play.google.com/store/apps/details?id=" + const val PLAY_STORE_PACKAGE_NAME = "com.android.vending" const val TRANSLATE_WIKI_URL = "https://translatewiki.net/w/i.php?title=Special:Translate&group=commons-android-strings&filter=%21translated&action=translate&language=" const val FACEBOOK_WEB_URL = "https://www.facebook.com/1921335171459985" const val FACEBOOK_APP_URL = "fb://page/1921335171459985" diff --git a/app/src/main/java/fr/free/nrw/commons/Utils.java b/app/src/main/java/fr/free/nrw/commons/Utils.java index 06b04716c5..3b5c8253e5 100644 --- a/app/src/main/java/fr/free/nrw/commons/Utils.java +++ b/app/src/main/java/fr/free/nrw/commons/Utils.java @@ -117,10 +117,10 @@ public static String fixExtension(String title, String extension) { public static void rateApp(Context context) { final String appPackageName = BuildConfig.class.getPackage().getName(); try { - context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); + context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Urls.PLAY_STORE_PREFIX + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) { - handleWebUrl(context, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)); + handleWebUrl(context, Uri.parse(Urls.PLAY_STORE_URL_PREFIX + appPackageName)); } } From d0132b10ac78ef926e07665505a0c160077471c5 Mon Sep 17 00:00:00 2001 From: Madhur Gupta Date: Tue, 10 Mar 2020 20:56:01 +0100 Subject: [PATCH 2/7] Changes made as per suggestions --- .../fr/free/nrw/commons/AboutActivityTest.kt | 25 ++++++------------- .../java/fr/free/nrw/commons/UITestHelper.kt | 9 ------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt b/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt index 0117f852f2..011302d92f 100644 --- a/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt +++ b/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt @@ -3,6 +3,7 @@ package fr.free.nrw.commons import android.app.Activity import android.app.Instrumentation import android.content.Intent +import androidx.test.InstrumentationRegistry import androidx.test.core.app.ApplicationProvider.getApplicationContext import androidx.test.espresso.Espresso import androidx.test.espresso.action.ViewActions @@ -28,8 +29,6 @@ class AboutActivityTest { @Before fun setup() { Intents.init() - UITestHelper.skipWelcome() - UITestHelper.skipLogin() Intents.intending(CoreMatchers.not(IntentMatchers.isInternal())) .respondWith(Instrumentation.ActivityResult(Activity.RESULT_OK, null)) } @@ -50,13 +49,9 @@ class AboutActivityTest { @Test fun testLaunchFacebook() { Espresso.onView(ViewMatchers.withId(R.id.facebook_launch_icon)).perform(ViewActions.click()) - try { - Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), - IntentMatchers.hasPackage(Urls.FACEBOOK_PACKAGE_NAME))) - } catch (e: Exception) { - Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), - IntentMatchers.hasData(Urls.FACEBOOK_WEB_URL))) - } + Intents.intended(IntentMatchers.hasAction(Intent.ACTION_VIEW)) + Intents.intended(CoreMatchers.anyOf(IntentMatchers.hasPackage(Urls.FACEBOOK_PACKAGE_NAME), + IntentMatchers.hasData(Urls.FACEBOOK_WEB_URL))) } @Test @@ -68,15 +63,11 @@ class AboutActivityTest { @Test fun testLaunchRateUs() { - val appPackageName = BuildConfig::class.java.getPackage().name + val appPackageName = InstrumentationRegistry.getInstrumentation().targetContext.packageName Espresso.onView(ViewMatchers.withId(R.id.about_rate_us)).perform(ViewActions.click()) - try { - Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), - IntentMatchers.toPackage(Urls.PLAY_STORE_PACKAGE_NAME))) - } catch (e: Exception) { - Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), - IntentMatchers.hasData("${Urls.PLAY_STORE_URL_PREFIX}$appPackageName"))) - } + Intents.intended(IntentMatchers.hasAction(Intent.ACTION_VIEW)) + Intents.intended(CoreMatchers.anyOf(IntentMatchers.toPackage(Urls.PLAY_STORE_PACKAGE_NAME), + IntentMatchers.hasData("${Urls.PLAY_STORE_URL_PREFIX}$appPackageName"))) } @Test diff --git a/app/src/androidTest/java/fr/free/nrw/commons/UITestHelper.kt b/app/src/androidTest/java/fr/free/nrw/commons/UITestHelper.kt index 952af05c12..78a1fb62b1 100644 --- a/app/src/androidTest/java/fr/free/nrw/commons/UITestHelper.kt +++ b/app/src/androidTest/java/fr/free/nrw/commons/UITestHelper.kt @@ -22,15 +22,6 @@ class UITestHelper { } } - fun skipLogin() { - try { - //Skip Login - onView(ViewMatchers.withId(R.id.skip_login)) - .perform(ViewActions.click()) - } catch (ignored: NoMatchingViewException) { - } - } - fun loginUser() { try { //Perform Login From b3a4b211da5fe04170012f728ab05e44865c5d2b Mon Sep 17 00:00:00 2001 From: Madhur Gupta Date: Tue, 10 Mar 2020 23:21:51 +0100 Subject: [PATCH 3/7] Removed File to resolve conflict --- .../java/fr/free/nrw/commons/ViewActions.kt | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 app/src/androidTest/java/fr/free/nrw/commons/ViewActions.kt diff --git a/app/src/androidTest/java/fr/free/nrw/commons/ViewActions.kt b/app/src/androidTest/java/fr/free/nrw/commons/ViewActions.kt deleted file mode 100644 index a4a3bb2b9e..0000000000 --- a/app/src/androidTest/java/fr/free/nrw/commons/ViewActions.kt +++ /dev/null @@ -1,25 +0,0 @@ -package fr.free.nrw.commons - -import android.view.View -import androidx.test.espresso.UiController -import androidx.test.espresso.ViewAction -import org.hamcrest.Matcher - -object ViewActions { - fun clickChildViewWithId(id: Int): ViewAction { - return object : ViewAction { - override fun getConstraints(): Matcher? { - return null - } - - override fun getDescription(): String { - return "Click on a child view with specified id." - } - - override fun perform(uiController: UiController, view: View) { - val v = view.findViewById(id) - v.performClick() - } - } - } -} \ No newline at end of file From 46ed7109c3213752170eec3c5f7353e51da7b729 Mon Sep 17 00:00:00 2001 From: Madhur Gupta Date: Wed, 11 Mar 2020 14:18:28 +0100 Subject: [PATCH 4/7] Removed hardcoded packagename --- .../java/fr/free/nrw/commons/AboutActivityTest.kt | 6 ------ app/src/main/java/fr/free/nrw/commons/Urls.kt | 1 - app/src/main/java/fr/free/nrw/commons/Utils.java | 2 +- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt b/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt index 011302d92f..0dfea0ce8c 100644 --- a/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt +++ b/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt @@ -3,7 +3,6 @@ package fr.free.nrw.commons import android.app.Activity import android.app.Instrumentation import android.content.Intent -import androidx.test.InstrumentationRegistry import androidx.test.core.app.ApplicationProvider.getApplicationContext import androidx.test.espresso.Espresso import androidx.test.espresso.action.ViewActions @@ -50,8 +49,6 @@ class AboutActivityTest { fun testLaunchFacebook() { Espresso.onView(ViewMatchers.withId(R.id.facebook_launch_icon)).perform(ViewActions.click()) Intents.intended(IntentMatchers.hasAction(Intent.ACTION_VIEW)) - Intents.intended(CoreMatchers.anyOf(IntentMatchers.hasPackage(Urls.FACEBOOK_PACKAGE_NAME), - IntentMatchers.hasData(Urls.FACEBOOK_WEB_URL))) } @Test @@ -63,11 +60,8 @@ class AboutActivityTest { @Test fun testLaunchRateUs() { - val appPackageName = InstrumentationRegistry.getInstrumentation().targetContext.packageName Espresso.onView(ViewMatchers.withId(R.id.about_rate_us)).perform(ViewActions.click()) Intents.intended(IntentMatchers.hasAction(Intent.ACTION_VIEW)) - Intents.intended(CoreMatchers.anyOf(IntentMatchers.toPackage(Urls.PLAY_STORE_PACKAGE_NAME), - IntentMatchers.hasData("${Urls.PLAY_STORE_URL_PREFIX}$appPackageName"))) } @Test diff --git a/app/src/main/java/fr/free/nrw/commons/Urls.kt b/app/src/main/java/fr/free/nrw/commons/Urls.kt index ed419f3440..980d9e1d21 100644 --- a/app/src/main/java/fr/free/nrw/commons/Urls.kt +++ b/app/src/main/java/fr/free/nrw/commons/Urls.kt @@ -9,7 +9,6 @@ internal object Urls { const val PLAY_STORE_URL = "https://play.google.com/store/apps/details?id=fr.free.nrw.commons" const val PLAY_STORE_PREFIX = "market://details?id=" const val PLAY_STORE_URL_PREFIX = "https://play.google.com/store/apps/details?id=" - const val PLAY_STORE_PACKAGE_NAME = "com.android.vending" const val TRANSLATE_WIKI_URL = "https://translatewiki.net/w/i.php?title=Special:Translate&group=commons-android-strings&filter=%21translated&action=translate&language=" const val FACEBOOK_WEB_URL = "https://www.facebook.com/1921335171459985" const val FACEBOOK_APP_URL = "fb://page/1921335171459985" diff --git a/app/src/main/java/fr/free/nrw/commons/Utils.java b/app/src/main/java/fr/free/nrw/commons/Utils.java index 3b5c8253e5..5f75c86ba4 100644 --- a/app/src/main/java/fr/free/nrw/commons/Utils.java +++ b/app/src/main/java/fr/free/nrw/commons/Utils.java @@ -115,7 +115,7 @@ public static String fixExtension(String title, String extension) { * @param context */ public static void rateApp(Context context) { - final String appPackageName = BuildConfig.class.getPackage().getName(); + final String appPackageName = context.getPackageName(); try { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Urls.PLAY_STORE_PREFIX + appPackageName))); } From a43dda4251c063deb127baf1df4aa3bc150b412c Mon Sep 17 00:00:00 2001 From: Madhur Gupta Date: Wed, 11 Mar 2020 17:27:47 +0100 Subject: [PATCH 5/7] Changes as per suggestion --- .../java/fr/free/nrw/commons/AboutActivityTest.kt | 6 ++++++ app/src/main/java/fr/free/nrw/commons/AboutActivity.java | 2 +- app/src/main/java/fr/free/nrw/commons/Urls.kt | 1 - 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt b/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt index 0dfea0ce8c..1ee2a5ace9 100644 --- a/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt +++ b/app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt @@ -3,6 +3,7 @@ package fr.free.nrw.commons import android.app.Activity import android.app.Instrumentation import android.content.Intent +import androidx.test.InstrumentationRegistry import androidx.test.core.app.ApplicationProvider.getApplicationContext import androidx.test.espresso.Espresso import androidx.test.espresso.action.ViewActions @@ -49,6 +50,8 @@ class AboutActivityTest { fun testLaunchFacebook() { Espresso.onView(ViewMatchers.withId(R.id.facebook_launch_icon)).perform(ViewActions.click()) Intents.intended(IntentMatchers.hasAction(Intent.ACTION_VIEW)) + Intents.intended(CoreMatchers.anyOf(IntentMatchers.hasData(Urls.FACEBOOK_WEB_URL), + IntentMatchers.hasPackage(Urls.FACEBOOK_PACKAGE_NAME))) } @Test @@ -60,8 +63,11 @@ class AboutActivityTest { @Test fun testLaunchRateUs() { + val appPackageName = InstrumentationRegistry.getInstrumentation().targetContext.packageName Espresso.onView(ViewMatchers.withId(R.id.about_rate_us)).perform(ViewActions.click()) Intents.intended(IntentMatchers.hasAction(Intent.ACTION_VIEW)) + Intents.intended(CoreMatchers.anyOf(IntentMatchers.hasData("${Urls.PLAY_STORE_URL_PREFIX}$appPackageName"), + IntentMatchers.hasData("${Urls.PLAY_STORE_URL_PREFIX}$appPackageName"))) } @Test diff --git a/app/src/main/java/fr/free/nrw/commons/AboutActivity.java b/app/src/main/java/fr/free/nrw/commons/AboutActivity.java index b0ec53178f..91b54be023 100644 --- a/app/src/main/java/fr/free/nrw/commons/AboutActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/AboutActivity.java @@ -122,7 +122,7 @@ public boolean onCreateOptionsMenu(Menu menu) { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.share_app_icon: - String shareText = String.format(getString(R.string.share_text), Urls.PLAY_STORE_URL); + String shareText = String.format("%s%s%s", getString(R.string.share_text), Urls.PLAY_STORE_PREFIX, this.getPackageName()); Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, shareText); diff --git a/app/src/main/java/fr/free/nrw/commons/Urls.kt b/app/src/main/java/fr/free/nrw/commons/Urls.kt index 980d9e1d21..52bbf8f48f 100644 --- a/app/src/main/java/fr/free/nrw/commons/Urls.kt +++ b/app/src/main/java/fr/free/nrw/commons/Urls.kt @@ -6,7 +6,6 @@ internal object Urls { const val WEBSITE_URL = "https://commons-app.github.io" const val CREDITS_URL = "https://github.com/commons-app/apps-android-commons/blob/master/CREDITS" const val FAQ_URL = "https://github.com/commons-app/apps-android-commons/wiki/Frequently-Asked-Questions" - const val PLAY_STORE_URL = "https://play.google.com/store/apps/details?id=fr.free.nrw.commons" const val PLAY_STORE_PREFIX = "market://details?id=" const val PLAY_STORE_URL_PREFIX = "https://play.google.com/store/apps/details?id=" const val TRANSLATE_WIKI_URL = "https://translatewiki.net/w/i.php?title=Special:Translate&group=commons-android-strings&filter=%21translated&action=translate&language=" From 8713ea077f4e5c841de02c84e23ad61df46bf9da Mon Sep 17 00:00:00 2001 From: Madhur Gupta Date: Wed, 11 Mar 2020 18:13:16 +0100 Subject: [PATCH 6/7] Removed Unrelated changes --- app/src/main/java/fr/free/nrw/commons/AboutActivity.java | 2 +- app/src/main/java/fr/free/nrw/commons/Urls.kt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/fr/free/nrw/commons/AboutActivity.java b/app/src/main/java/fr/free/nrw/commons/AboutActivity.java index 91b54be023..b0ec53178f 100644 --- a/app/src/main/java/fr/free/nrw/commons/AboutActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/AboutActivity.java @@ -122,7 +122,7 @@ public boolean onCreateOptionsMenu(Menu menu) { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.share_app_icon: - String shareText = String.format("%s%s%s", getString(R.string.share_text), Urls.PLAY_STORE_PREFIX, this.getPackageName()); + String shareText = String.format(getString(R.string.share_text), Urls.PLAY_STORE_URL); Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, shareText); diff --git a/app/src/main/java/fr/free/nrw/commons/Urls.kt b/app/src/main/java/fr/free/nrw/commons/Urls.kt index 52bbf8f48f..980d9e1d21 100644 --- a/app/src/main/java/fr/free/nrw/commons/Urls.kt +++ b/app/src/main/java/fr/free/nrw/commons/Urls.kt @@ -6,6 +6,7 @@ internal object Urls { const val WEBSITE_URL = "https://commons-app.github.io" const val CREDITS_URL = "https://github.com/commons-app/apps-android-commons/blob/master/CREDITS" const val FAQ_URL = "https://github.com/commons-app/apps-android-commons/wiki/Frequently-Asked-Questions" + const val PLAY_STORE_URL = "https://play.google.com/store/apps/details?id=fr.free.nrw.commons" const val PLAY_STORE_PREFIX = "market://details?id=" const val PLAY_STORE_URL_PREFIX = "https://play.google.com/store/apps/details?id=" const val TRANSLATE_WIKI_URL = "https://translatewiki.net/w/i.php?title=Special:Translate&group=commons-android-strings&filter=%21translated&action=translate&language=" From 18917da1ecb65e43ea3d9aa3815f837e0c4347c0 Mon Sep 17 00:00:00 2001 From: Madhur Gupta Date: Wed, 11 Mar 2020 22:32:24 +0100 Subject: [PATCH 7/7] Fixed Build Issues --- app/src/main/java/fr/free/nrw/commons/AboutActivity.java | 2 +- app/src/main/java/fr/free/nrw/commons/Urls.kt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/AboutActivity.java b/app/src/main/java/fr/free/nrw/commons/AboutActivity.java index b0ec53178f..cf461762d1 100644 --- a/app/src/main/java/fr/free/nrw/commons/AboutActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/AboutActivity.java @@ -122,7 +122,7 @@ public boolean onCreateOptionsMenu(Menu menu) { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.share_app_icon: - String shareText = String.format(getString(R.string.share_text), Urls.PLAY_STORE_URL); + String shareText = String.format(getString(R.string.share_text), Urls.PLAY_STORE_URL_PREFIX + this.getPackageName()); Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, shareText); diff --git a/app/src/main/java/fr/free/nrw/commons/Urls.kt b/app/src/main/java/fr/free/nrw/commons/Urls.kt index 980d9e1d21..52bbf8f48f 100644 --- a/app/src/main/java/fr/free/nrw/commons/Urls.kt +++ b/app/src/main/java/fr/free/nrw/commons/Urls.kt @@ -6,7 +6,6 @@ internal object Urls { const val WEBSITE_URL = "https://commons-app.github.io" const val CREDITS_URL = "https://github.com/commons-app/apps-android-commons/blob/master/CREDITS" const val FAQ_URL = "https://github.com/commons-app/apps-android-commons/wiki/Frequently-Asked-Questions" - const val PLAY_STORE_URL = "https://play.google.com/store/apps/details?id=fr.free.nrw.commons" const val PLAY_STORE_PREFIX = "market://details?id=" const val PLAY_STORE_URL_PREFIX = "https://play.google.com/store/apps/details?id=" const val TRANSLATE_WIKI_URL = "https://translatewiki.net/w/i.php?title=Special:Translate&group=commons-android-strings&filter=%21translated&action=translate&language="