diff --git a/app/src/main/java/com/simplemobiletools/calculator/Config.java b/app/src/main/java/com/simplemobiletools/calculator/Config.java
new file mode 100644
index 0000000..ea3cb3f
--- /dev/null
+++ b/app/src/main/java/com/simplemobiletools/calculator/Config.java
@@ -0,0 +1,24 @@
+package com.simplemobiletools.calculator;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+public class Config {
+ private SharedPreferences mPrefs;
+
+ public static Config newInstance(Context context) {
+ return new Config(context);
+ }
+
+ public Config(Context context) {
+ mPrefs = context.getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE);
+ }
+
+ public boolean getIsFirstRun() {
+ return mPrefs.getBoolean(Constants.IS_FIRST_RUN, true);
+ }
+
+ public void setIsFirstRun(boolean firstRun) {
+ mPrefs.edit().putBoolean(Constants.IS_FIRST_RUN, firstRun).apply();
+ }
+}
diff --git a/app/src/main/java/com/simplemobiletools/calculator/Constants.java b/app/src/main/java/com/simplemobiletools/calculator/Constants.java
index 27b3005..ca067eb 100644
--- a/app/src/main/java/com/simplemobiletools/calculator/Constants.java
+++ b/app/src/main/java/com/simplemobiletools/calculator/Constants.java
@@ -28,4 +28,8 @@ public class Constants {
public static final String PREFS = "prefs";
public static final String WIDGET_BG_COLOR = "widget_bg_color";
public static final String WIDGET_TEXT_COLOR = "widget_text_color";
+
+ // shared preferences
+ public static final String PREFS_KEY = "Calculator";
+ public static final String IS_FIRST_RUN = "is_first_run";
}
diff --git a/app/src/main/java/com/simplemobiletools/calculator/activities/AboutActivity.java b/app/src/main/java/com/simplemobiletools/calculator/activities/AboutActivity.java
index c2b07ed..3426545 100644
--- a/app/src/main/java/com/simplemobiletools/calculator/activities/AboutActivity.java
+++ b/app/src/main/java/com/simplemobiletools/calculator/activities/AboutActivity.java
@@ -1,5 +1,6 @@
package com.simplemobiletools.calculator.activities;
+import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
@@ -7,9 +8,11 @@ import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Html;
import android.text.method.LinkMovementMethod;
+import android.view.View;
import android.widget.TextView;
import com.simplemobiletools.calculator.BuildConfig;
+import com.simplemobiletools.calculator.Config;
import com.simplemobiletools.calculator.R;
import java.util.Calendar;
@@ -22,6 +25,7 @@ public class AboutActivity extends AppCompatActivity {
@BindView(R.id.about_copyright) TextView mCopyright;
@BindView(R.id.about_version) TextView mVersion;
@BindView(R.id.about_email) TextView mEmailTV;
+ @BindView(R.id.about_rate_us) View mRateUs;
private static Resources mRes;
@Override
@@ -34,6 +38,7 @@ public class AboutActivity extends AppCompatActivity {
setupEmail();
setupVersion();
setupCopyright();
+ setupRateUs();
}
private void setupEmail() {
@@ -56,6 +61,22 @@ public class AboutActivity extends AppCompatActivity {
mCopyright.setText(copyrightText);
}
+ private void setupRateUs() {
+ if (Config.newInstance(getApplicationContext()).getIsFirstRun()) {
+ mRateUs.setVisibility(View.GONE);
+ }
+ }
+
+ @OnClick(R.id.about_rate_us)
+ public void rateUsClicked() {
+ final Uri uri = Uri.parse("market://details?id=" + getPackageName());
+ try {
+ startActivity(new Intent(Intent.ACTION_VIEW, uri));
+ } catch (ActivityNotFoundException ignored) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName())));
+ }
+ }
+
@OnClick(R.id.about_license)
public void licenseClicked() {
final Intent intent = new Intent(getApplicationContext(), LicenseActivity.class);
diff --git a/app/src/main/java/com/simplemobiletools/calculator/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/calculator/activities/MainActivity.java
index ff98d83..f051bba 100644
--- a/app/src/main/java/com/simplemobiletools/calculator/activities/MainActivity.java
+++ b/app/src/main/java/com/simplemobiletools/calculator/activities/MainActivity.java
@@ -13,6 +13,7 @@ import android.widget.TextView;
import com.simplemobiletools.calculator.Calculator;
import com.simplemobiletools.calculator.CalculatorImpl;
+import com.simplemobiletools.calculator.Config;
import com.simplemobiletools.calculator.Constants;
import com.simplemobiletools.calculator.Formatter;
import com.simplemobiletools.calculator.R;
@@ -42,6 +43,12 @@ public class MainActivity extends AppCompatActivity implements Calculator {
AutofitHelper.create(mFormula);
}
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ Config.newInstance(getApplicationContext()).setIsFirstRun(false);
+ }
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml
index c054d11..152f60e 100644
--- a/app/src/main/res/layout/activity_about.xml
+++ b/app/src/main/res/layout/activity_about.xml
@@ -29,11 +29,21 @@
android:text="@string/email"/>
+
+ Send your feedback or suggestions at:
hello@simplemobiletools.com
Third party licences
+ Rate us in the Play Store
Follow us at:
v %1$s
Copyright © Simple Mobile Tools %1$d