mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-02-09 16:08:49 +01:00
show a Rate us button to returning users
This commit is contained in:
parent
37faea3e75
commit
ff7c2b1708
24
app/src/main/java/com/simplemobiletools/notes/Config.java
Normal file
24
app/src/main/java/com/simplemobiletools/notes/Config.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.simplemobiletools.notes;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
package com.simplemobiletools.notes;
|
||||
|
||||
public class Constants {
|
||||
public static final String PREFS = "prefs";
|
||||
public static final String TEXT = "text";
|
||||
|
||||
// shared preferences
|
||||
public static final String PREFS_KEY = "Notes";
|
||||
public static final String IS_FIRST_RUN = "is_first_run";
|
||||
public static final String WIDGET_BG_COLOR = "widget_bg_color";
|
||||
public static final String WIDGET_TEXT_COLOR = "widget_text_color";
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class MyWidgetProvider extends AppWidgetProvider {
|
||||
}
|
||||
|
||||
private void initVariables(Context context) {
|
||||
mPrefs = context.getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
|
||||
mPrefs = context.getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE);
|
||||
mRemoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
|
||||
setupAppOpenIntent(R.id.notes_holder, context);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.simplemobiletools.notes.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.notes.BuildConfig;
|
||||
import com.simplemobiletools.notes.Config;
|
||||
import com.simplemobiletools.notes.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;
|
||||
|
||||
@ -35,6 +39,7 @@ public class AboutActivity extends AppCompatActivity {
|
||||
setupEmail();
|
||||
setupVersion();
|
||||
setupCopyright();
|
||||
setupRateUs();
|
||||
}
|
||||
|
||||
private void setupEmail() {
|
||||
@ -57,6 +62,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);
|
||||
|
@ -14,6 +14,7 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.simplemobiletools.notes.Config;
|
||||
import com.simplemobiletools.notes.Constants;
|
||||
import com.simplemobiletools.notes.MyWidgetProvider;
|
||||
import com.simplemobiletools.notes.R;
|
||||
@ -33,11 +34,17 @@ public class MainActivity extends AppCompatActivity {
|
||||
setContentView(R.layout.activity_main);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
mPrefs = getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
|
||||
mPrefs = getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE);
|
||||
final String text = mPrefs.getString(Constants.TEXT, "");
|
||||
mNotesView.setText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Config.newInstance(getApplicationContext()).setIsFirstRun(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu, menu);
|
||||
|
@ -53,7 +53,7 @@ public class WidgetConfigureActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void initVariables() {
|
||||
final SharedPreferences prefs = getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
|
||||
final SharedPreferences prefs = getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE);
|
||||
mBgColor = prefs.getInt(Constants.WIDGET_BG_COLOR, 1);
|
||||
if (mBgColor == 1) {
|
||||
mBgColor = Color.BLACK;
|
||||
@ -88,7 +88,7 @@ public class WidgetConfigureActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void storeWidgetBackground() {
|
||||
final SharedPreferences prefs = getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
|
||||
final SharedPreferences prefs = getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE);
|
||||
prefs.edit().putInt(Constants.WIDGET_BG_COLOR, mBgColor).apply();
|
||||
prefs.edit().putInt(Constants.WIDGET_TEXT_COLOR, mTextColor).apply();
|
||||
}
|
||||
|
@ -29,11 +29,21 @@
|
||||
android:text="@string/email"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_license"
|
||||
android:id="@+id/about_rate_us"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/about_email"
|
||||
android:layout_marginTop="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/rate_us_underlined"
|
||||
android:textColor="@color/colorPrimary"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_license"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/about_rate_us"
|
||||
android:layout_marginTop="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/third_party_licences_underlined"
|
||||
@ -78,6 +88,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="Copyright © Simple Mobile Tools 2000"/>
|
||||
android:text="Copyright © Simple Mobile Tools 2016"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
@ -14,6 +14,7 @@
|
||||
<string name="email_label">Send your feedback or suggestions at:</string>
|
||||
<string name="email">hello@simplemobiletools.com</string>
|
||||
<string name="third_party_licences_underlined"><u>Third party licences</u></string>
|
||||
<string name="rate_us_underlined"><u>Rate us in the Play Store</u></string>
|
||||
<string name="follow_us">Follow us at:</string>
|
||||
<string name="version">v %1$s</string>
|
||||
<string name="copyright">Copyright © Simple Mobile Tools %1$d</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user