New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ask review #26

Merged
merged 1 commit into from May 14, 2016
Jump to file or symbol
Failed to load files and symbols.
+324 −3
Diff settings

Always

Just for now

View
@@ -112,6 +112,7 @@ dependencies {
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.growthbeat:growthbeat-android:1.2.6@aar'
//DI
@@ -34,7 +34,9 @@ public void sendEvent(Category category, Action action, String label) {
public enum Category {
DEFAULT("default");
DEFAULT("default"),
REVIEW("review"),
GOOGLE_PLUS("google_plus");
String categoty;
Category(String categoty) {
@@ -52,7 +54,13 @@ public String getCategoty() {
SEARCH_PLAYER_TAP("search-player-tap"),
EXPAND_SEARCH_PLAYER("expand-search-player"),
PLAYER_SEX_TAP("player-sex-tap"),
PLAYER_SAVE("player-save");
PLAYER_SAVE("player-save"),
REVIEW_SHOW("review-show"),
REVIEW_OK("review-ok"),
REVIEW_CANCEL("review-cancel"),
REVIEW_QUESTIONATE("review-questionate"),
GOOGLE_PLUS_SHOW("google-plus-show"),
GOOGLE_PLUS_CANCEL("google-plus-cancel");
String action;
Action(String action) {
@@ -4,6 +4,8 @@
import com.bowyer.app.playermanage.ui.activity.MainActivity;
import com.bowyer.app.playermanage.ui.activity.PlayerManageActivity;
import com.bowyer.app.playermanage.ui.activity.WebViewActivity;
import com.bowyer.app.playermanage.ui.dialog.GooglePlusDialogFragment;
import com.bowyer.app.playermanage.ui.dialog.ReviewDialogFragment;
import dagger.Component;
import javax.inject.Singleton;
@@ -16,4 +18,8 @@
void inject(LicenseActivity activity);
void inject(WebViewActivity activity);
void inject(GooglePlusDialogFragment dialogFragment);
void inject(ReviewDialogFragment dialogFragment);
}
@@ -0,0 +1,43 @@
package com.bowyer.app.playermanage.logic;
import android.support.v7.app.AppCompatActivity;
import com.bowyer.app.playermanage.preference.ReviewPreferences;
import com.bowyer.app.playermanage.ui.dialog.GooglePlusDialogFragment;
import com.bowyer.app.playermanage.ui.dialog.ReviewDialogFragment;
public class ReviewLogic {
private static final int REVIEW_COUNT_1 = 10;
private static final int GOOGLE_COUNT_1 = 15;
public static void showReviewDialogIfNeed(AppCompatActivity activity) {
ReviewPreferences preferences = new ReviewPreferences(activity);
int count = preferences.getPlayerSaveCount();
switch (count) {
case REVIEW_COUNT_1:
showDialog(activity, count, preferences);
break;
case GOOGLE_COUNT_1:
showGoogleDialog(activity, count, preferences);
break;
default:
break;
}
}
private static void showDialog(final AppCompatActivity activity, final int count,
final ReviewPreferences preferences) {
if (preferences.isShowedReview(count)) {
return;
}
ReviewDialogFragment.newInstance(count).show((activity).getSupportFragmentManager(), "");
}
private static void showGoogleDialog(AppCompatActivity activity, int count,
ReviewPreferences preferences) {
if (preferences.isShowedReview(count)) {
return;
}
GooglePlusDialogFragment.newInstance(count).show((activity).getSupportFragmentManager(), "");
}
}
@@ -0,0 +1,36 @@
package com.bowyer.app.playermanage.preference;
import android.content.Context;
import android.content.SharedPreferences;
public class PreferenceHelper {
private final SharedPreferences mSharedPreferences;
public PreferenceHelper(Context context, String name, int mode) {
mSharedPreferences = context.getSharedPreferences(name, mode);
}
protected final boolean getBoolean(String key, boolean defVal) {
return mSharedPreferences.getBoolean(key, defVal);
}
protected void putBoolean(String key, boolean val) {
mSharedPreferences.edit().putBoolean(key, val).apply();
}
protected String getString(String key, String defVal) {
return mSharedPreferences.getString(key, defVal);
}
protected void putString(String key, String val) {
mSharedPreferences.edit().putString(key, val).apply();
}
protected int getInt(String key, int defVal) {
return mSharedPreferences.getInt(key, defVal);
}
protected void putInt(String key, int val) {
mSharedPreferences.edit().putInt(key, val).apply();
}
}
@@ -0,0 +1,30 @@
package com.bowyer.app.playermanage.preference;
import android.content.Context;
public class ReviewPreferences extends PreferenceHelper {
private static final String REVIEW_PREFERENCES = "review_preferences";
private static final String KEY_PLAYER_SAVE_COUNT = "key_player_save_count";
public ReviewPreferences(Context context) {
super(context, REVIEW_PREFERENCES, Context.MODE_PRIVATE);
}
public int getPlayerSaveCount() {
return getInt(KEY_PLAYER_SAVE_COUNT, 0);
}
public void increasePlayerSaveCount() {
int addCount = getPlayerSaveCount() + 1;
putInt(KEY_PLAYER_SAVE_COUNT, addCount);
}
public boolean isShowedReview(int count) {
return getBoolean(KEY_PLAYER_SAVE_COUNT + count, false);
}
public void reviewShowed(int count) {
putBoolean(KEY_PLAYER_SAVE_COUNT + count, true);
}
}
@@ -32,6 +32,7 @@
import com.bowyer.app.playermanage.gcm.GrowthPush;
import com.bowyer.app.playermanage.logic.GrowthPushLogic;
import com.bowyer.app.playermanage.logic.GrowthbeatLogic;
import com.bowyer.app.playermanage.logic.ReviewLogic;
import com.bowyer.app.playermanage.ui.adapter.PlayerAdapter;
import com.bowyer.app.playermanage.ui.dialog.RankSelectDialogFragment;
import com.github.aakira.expandablelayout.ExpandableLayoutListenerAdapter;
@@ -82,6 +83,7 @@
@Override protected void onResume() {
super.onResume();
doSearch();
ReviewLogic.showReviewDialogIfNeed(this);
}
@Override protected void onStart() {
@@ -21,11 +21,13 @@
import com.bowyer.app.playermanage.R;
import com.bowyer.app.playermanage.database.dto.Player;
import com.bowyer.app.playermanage.database.dto.Sex;
import com.bowyer.app.playermanage.preference.ReviewPreferences;
import com.bowyer.app.playermanage.ui.dialog.RankSelectDialogFragment;
import com.squareup.sqlbrite.BriteDatabase;
import javax.inject.Inject;
public class PlayerManageActivity extends AppCompatActivity implements RankSelectDialogFragment.OnRankSelectListener{
public class PlayerManageActivity extends AppCompatActivity
implements RankSelectDialogFragment.OnRankSelectListener {
public static final String KEY_PLAYER = "key_player";
@@ -151,6 +153,7 @@ private void insertPlayer() {
.rank(mRankText.getText().toString())
.build());
finish();
new ReviewPreferences(this).increasePlayerSaveCount();
}
@Override public void onRankSelect(String rank) {
@@ -0,0 +1,73 @@
package com.bowyer.app.playermanage.ui.dialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.bowyer.app.playermanage.AnalyticsTracker;
import com.bowyer.app.playermanage.BuildConfig;
import com.bowyer.app.playermanage.PlayerApplication;
import com.bowyer.app.playermanage.R;
import com.bowyer.app.playermanage.preference.ReviewPreferences;
import com.google.android.gms.plus.PlusOneButton;
import javax.inject.Inject;
public class GooglePlusDialogFragment extends DialogFragment {
private static final String KEY_COUNT = "key_count";
@Bind(R.id.plus_one_button) PlusOneButton mPlusOneButton;
@Inject AnalyticsTracker mAnalyticsTracker;
public static GooglePlusDialogFragment newInstance(int count) {
GooglePlusDialogFragment f = new GooglePlusDialogFragment();
Bundle args = new Bundle();
args.putInt(KEY_COUNT, count);
f.setArguments(args);
return f;
}
@Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater layoutInflater =
(LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View content = layoutInflater.inflate(R.layout.dialog_google_plus, null);
PlayerApplication.getComponent(getContext()).inject(this);
ReviewPreferences preferences = new ReviewPreferences(getActivity());
int count = getArguments().getInt(KEY_COUNT, 0);
preferences.reviewShowed(count);
mAnalyticsTracker.sendEvent(AnalyticsTracker.Category.GOOGLE_PLUS,
AnalyticsTracker.Action.GOOGLE_PLUS_SHOW, String.valueOf(count));
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.google_plus_dialog_title);
builder.setView(content);
builder.setPositiveButton(android.R.string.cancel, (dialogInterface, i) -> {
mAnalyticsTracker.sendEvent(AnalyticsTracker.Category.GOOGLE_PLUS,
AnalyticsTracker.Action.GOOGLE_PLUS_CANCEL, String.valueOf(count));
dismiss();
});
Dialog dialog = builder.create();
ButterKnife.bind(this, content);
initGooglePlus();
this.setCancelable(false);
return dialog;
}
private void initGooglePlus() {
String applicationId = BuildConfig.APPLICATION_ID.replace("." + BuildConfig.BUILD_TYPE, "");
String url = "https://market.android.com/details?id=" + applicationId;
int requestCode = 1;
mPlusOneButton.initialize(url, requestCode);
}
}
@@ -0,0 +1,70 @@
package com.bowyer.app.playermanage.ui.dialog;
import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import com.bowyer.app.playermanage.AnalyticsTracker;
import com.bowyer.app.playermanage.BuildConfig;
import com.bowyer.app.playermanage.PlayerApplication;
import com.bowyer.app.playermanage.R;
import com.bowyer.app.playermanage.preference.ReviewPreferences;
import com.bowyer.app.playermanage.ui.activity.WebViewActivity;
import javax.inject.Inject;
public class ReviewDialogFragment extends DialogFragment {
private static final String KEY_COUNT = "key_count";
@Inject AnalyticsTracker mAnalyticsTracker;
public static ReviewDialogFragment newInstance(int count) {
ReviewDialogFragment f = new ReviewDialogFragment();
Bundle args = new Bundle();
args.putInt(KEY_COUNT, count);
f.setArguments(args);
return f;
}
@Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PlayerApplication.getComponent(getContext()).inject(this);
ReviewPreferences preferences = new ReviewPreferences(getActivity());
int count = getArguments().getInt(KEY_COUNT, 0);
preferences.reviewShowed(count);
mAnalyticsTracker.sendEvent(AnalyticsTracker.Category.REVIEW,
AnalyticsTracker.Action.REVIEW_SHOW, String.valueOf(count));
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.review_dialog_title);
builder.setMessage(R.string.review_dialog_text);
builder.setPositiveButton(R.string.review_dialog_review, (dialog, which) -> {
mAnalyticsTracker.sendEvent(AnalyticsTracker.Category.REVIEW,
AnalyticsTracker.Action.REVIEW_OK, String.valueOf(count));
String applicationId = BuildConfig.APPLICATION_ID.replace("." + BuildConfig.BUILD_TYPE, "");
final Intent intent =
new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + applicationId));
getActivity().startActivity(intent);
dismiss();
});
builder.setNeutralButton(R.string.review_dialog_demand, (dialog, which) -> {
mAnalyticsTracker.sendEvent(AnalyticsTracker.Category.REVIEW,
AnalyticsTracker.Action.REVIEW_QUESTIONATE, String.valueOf(count));
WebViewActivity.startWebViewActivity(getActivity(), "http://goo.gl/forms/bfUL4n0S4T");
dismiss();
});
builder.setNegativeButton(R.string.review_dialog_cancel, (dialog, which) -> {
mAnalyticsTracker.sendEvent(AnalyticsTracker.Category.REVIEW,
AnalyticsTracker.Action.REVIEW_CANCEL, String.valueOf(count));
dismiss();
});
return builder.create();
}
}
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:id="@+id/dialog_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:padding="10dp"
android:text="@string/google_plus_dialog_message"
/>
<com.google.android.gms.plus.PlusOneButton
xmlns:plus="http://schemas.android.com/apk/lib.com.google.android.gms.plus"
android:id="@+id/plus_one_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
plus:annotation="inline"
plus:size="standard"
/>
</LinearLayout>
@@ -28,4 +28,15 @@
<!--License-->
<string name="title_app_license">ライセンス</string>
<!--GooglePlus-->
<string name="google_plus_dialog_title">+1でアプリを応援</string>
<string name="google_plus_dialog_message">アプリを気に入って頂いた方は、応援よろしくお願いします</string>
<!-- レビュー訴求-->
<string name="review_dialog_title">レビューにご協力お願いします</string>
<string name="review_dialog_text">いつもご利用ありがとうございます。\nよろしければ励ましのレビューをお寄せください。</string>
<string name="review_dialog_review">レビューする</string>
<string name="review_dialog_demand">要望を書く</string>
<string name="review_dialog_cancel">いいえ</string>
</resources>
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.