Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-11-30 22:39:16 +01:00
commit 357e387cb7
2 changed files with 30 additions and 43 deletions

View file

@ -1,6 +1,5 @@
package net.osmand.plus.dashboard; package net.osmand.plus.dashboard;
import android.content.ActivityNotFoundException;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -76,37 +75,32 @@ public class DashRateUsFragment extends DashBaseFragment {
public void onClick(View v) { public void onClick(View v) {
final OsmandSettings settings = getMyApplication().getSettings(); final OsmandSettings settings = getMyApplication().getSettings();
switch (state) { switch (state) {
case INITIAL_STATE: case INITIAL_STATE:
state = RateUsBottomSheetDialog.FragmentState.USER_LIKES_APP; state = RateUsBottomSheetDialog.FragmentState.USER_LIKES_APP;
header.setText(getResources().getString(R.string.rate_this_app)); header.setText(getResources().getString(R.string.rate_this_app));
subheader.setText(getResources().getString(R.string.rate_this_app_long)); subheader.setText(getResources().getString(R.string.rate_this_app_long));
positiveButton.setText(getResources().getString(R.string.shared_string_ok)); positiveButton.setText(getResources().getString(R.string.shared_string_ok));
negativeButton.setText(getResources().getString(R.string.shared_string_no_thanks)); negativeButton.setText(getResources().getString(R.string.shared_string_no_thanks));
return; return;
case USER_LIKES_APP: <<<<<<< HEAD
settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.LIKED); case USER_LIKES_APP:
Uri uri = Uri.parse(Version.marketPrefix(getMyApplication()) + getActivity().getPackageName()); settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.LIKED);
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); Uri uri = Uri.parse(Version.marketPrefix(getMyApplication()) + getActivity().getPackageName());
try { Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
startActivity(goToMarket); startActivity(goToMarket);
} catch (ActivityNotFoundException e) { break;
startActivity(new Intent(Intent.ACTION_VIEW, case USER_DISLIKES_APP:
String email = getString(R.string.support_email);
Uri.parse(Version.marketPrefix(getMyApplication()) + getActivity().getPackageName()))); settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.DISLIKED_WITH_MESSAGE);
} settings.NUMBER_OF_APPLICATION_STARTS.set(0);
break; settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis());
case USER_DISLIKES_APP: Intent sendEmail = new Intent(Intent.ACTION_SENDTO);
String email = getString(R.string.support_email); sendEmail.setType("text/plain");
settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.DISLIKED_WITH_MESSAGE); sendEmail.setData(Uri.parse("mailto:" + email));
settings.NUMBER_OF_APPLICATION_STARTS.set(0); sendEmail.putExtra(Intent.EXTRA_EMAIL, email);
settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis()); startActivity(sendEmail);
Intent sendEmail = new Intent(Intent.ACTION_SENDTO); break;
sendEmail.setType("text/plain");
sendEmail.setData(Uri.parse("mailto:" + email));
sendEmail.putExtra(Intent.EXTRA_EMAIL, email);
startActivity(sendEmail);
break;
} }
dashboard.refreshDashboardFragments(); dashboard.refreshDashboardFragments();
} }

View file

@ -1,6 +1,5 @@
package net.osmand.plus.dialogs; package net.osmand.plus.dialogs;
import android.content.ActivityNotFoundException;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -10,6 +9,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -35,11 +35,11 @@ public class RateUsBottomSheetDialog extends BottomSheetDialogFragment {
return view; return view;
} }
public static boolean shouldShow(OsmandApplication app) { public static boolean shouldShow(OsmandApplication application) {
if(!Version.isMarketEnabled(app)) { if (Version.isMarketEnabled(application)) {
return false; return false;
} }
OsmandSettings settings = app.getSettings(); OsmandSettings settings = application.getSettings();
if(!settings.LAST_DISPLAY_TIME.isSet()) { if(!settings.LAST_DISPLAY_TIME.isSet()) {
settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis()); settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis());
} }
@ -115,16 +115,9 @@ public class RateUsBottomSheetDialog extends BottomSheetDialogFragment {
return; return;
case USER_LIKES_APP: case USER_LIKES_APP:
settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.LIKED); settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.LIKED);
// Assuming GooglePlay Uri uri = Uri.parse(Version.marketPrefix(getMyApplication()) + getActivity().getPackageName());
Uri uri = Uri.parse("market://details?id=" + getActivity().getPackageName());
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
try { startActivity(goToMarket);
startActivity(goToMarket);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id="
+ getActivity().getPackageName())));
}
break; break;
case USER_DISLIKES_APP: case USER_DISLIKES_APP:
String email = getString(R.string.support_email); String email = getString(R.string.support_email);