Skip to content

Commit fc8b522

Browse files
Rate Us method added to Utils.java and called on AboutActivity.java
1 parent 4432f2c commit fc8b522

File tree

11 files changed

+30
-18
lines changed

11 files changed

+30
-18
lines changed

app/src/main/java/fr/free/nrw/commons/AboutActivity.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,10 @@ public void launchWebsite(View view) {
6565
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://commons-app.github.io/\\"));
6666
startActivity(browserIntent);
6767
}
68+
69+
@OnClick(R.id.about_rate_us)
70+
public void rateApp(View view) {
71+
72+
Utils.rateApp(this);
73+
}
6874
}

app/src/main/java/fr/free/nrw/commons/Utils.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package fr.free.nrw.commons;
22

33
import android.content.Context;
4+
import android.content.Intent;
5+
import android.net.Uri;
46
import android.preference.PreferenceManager;
57
import android.support.annotation.NonNull;
68

@@ -159,4 +161,15 @@ public static String getAppLogs() {
159161

160162
return stringBuilder.toString();
161163
}
162-
}
164+
165+
public static void rateApp(Context context) {
166+
final String appPackageName = context.getPackageName();
167+
try {
168+
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
169+
}
170+
catch (android.content.ActivityNotFoundException anfe) {
171+
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
172+
}
173+
return ;
174+
}
175+
}

app/src/main/java/fr/free/nrw/commons/theme/NavigationBaseActivity.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import fr.free.nrw.commons.BuildConfig;
2424
import fr.free.nrw.commons.CommonsApplication;
2525
import fr.free.nrw.commons.R;
26+
import fr.free.nrw.commons.Utils;
2627
import fr.free.nrw.commons.WelcomeActivity;
2728
import fr.free.nrw.commons.auth.AccountUtil;
2829
import fr.free.nrw.commons.auth.LoginActivity;
@@ -133,17 +134,6 @@ public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
133134
Toast.makeText(this, R.string.no_email_client, Toast.LENGTH_SHORT).show();
134135
}
135136
return true;
136-
case R.id.action_rate:
137-
drawerLayout.closeDrawer(navigationView);
138-
final String appPackageName = getPackageName();
139-
Toast.makeText(this, appPackageName, Toast.LENGTH_SHORT).show();
140-
try {
141-
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
142-
}
143-
catch (android.content.ActivityNotFoundException anfe) {
144-
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
145-
}
146-
return true;
147137
case R.id.action_logout:
148138
new AlertDialog.Builder(this)
149139
.setMessage(R.string.logout_verification)
-440 Bytes
Binary file not shown.
-296 Bytes
Binary file not shown.
-577 Bytes
Binary file not shown.
-844 Bytes
Binary file not shown.
-1.12 KB
Binary file not shown.

app/src/main/res/layout/activity_about.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@
104104

105105
</LinearLayout>
106106

107+
<TextView
108+
android:id="@+id/about_rate_us"
109+
android:layout_width="wrap_content"
110+
android:layout_height="wrap_content"
111+
android:layout_marginTop="@dimen/standard_gap"
112+
android:gravity="center"
113+
android:textColor="@color/primaryColor"
114+
android:text="@string/about_rate_us" />
107115
<fr.free.nrw.commons.ui.widget.HtmlTextView
108116
android:id="@+id/about_privacy_policy"
109117
style="?android:textAppearanceSmall"

app/src/main/res/menu/drawer.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@
3030
android:icon="@drawable/ic_feedback_black_24dp"
3131
android:title="@string/navigation_item_feedback"/>
3232

33-
<item
34-
android:id="@+id/action_rate"
35-
android:icon="@drawable/ic_star_black_24dp"
36-
android:title="@string/navigation_item_rate"/>
37-
3833
<item
3934
android:id="@+id/action_logout"
4035
android:icon="@drawable/ic_exit_to_app_black_24dp"

0 commit comments

Comments
 (0)