From 1e28fa3c20b663b88a8ee55f119889cdea7a1809 Mon Sep 17 00:00:00 2001 From: veliymolfar Date: Fri, 17 Jan 2020 15:21:22 +0200 Subject: [PATCH] remove DashRateUsFragment --- .../src/net/osmand/plus/OsmandSettings.java | 5 +- .../plus/dashboard/DashRateUsFragment.java | 165 ------------------ .../osmand/plus/dashboard/DashboardOnMap.java | 2 - 3 files changed, 1 insertion(+), 171 deletions(-) delete mode 100644 OsmAnd/src/net/osmand/plus/dashboard/DashRateUsFragment.java diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 644b5250bf..e29ca9da5a 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -3208,16 +3208,13 @@ public class OsmandSettings { public final OsmandPreference NUMBER_OF_FREE_DOWNLOADS = new IntPreference(NUMBER_OF_FREE_DOWNLOADS_ID, 0).makeGlobal(); - // For DashRateUsFragment + // For RateUsDialog public final OsmandPreference LAST_DISPLAY_TIME = new LongPreference("last_display_time", 0).makeGlobal().cache(); public final OsmandPreference LAST_CHECKED_UPDATES = new LongPreference("last_checked_updates", 0).makeGlobal(); - public final OsmandPreference NUMBER_OF_APPLICATION_STARTS = - new IntPreference("number_of_app_starts", 0).makeGlobal().cache(); - public final OsmandPreference NUMBER_OF_APP_STARTS_AFTER_DISLIKE = new IntPreference("number_of_app_starts_after_dislike", 0).makeGlobal().cache(); diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashRateUsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashRateUsFragment.java deleted file mode 100644 index bb372f91f9..0000000000 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashRateUsFragment.java +++ /dev/null @@ -1,165 +0,0 @@ -package net.osmand.plus.dashboard; - -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.TextView; - -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.R; -import net.osmand.plus.Version; -import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.dashboard.tools.DashFragmentData; -import net.osmand.plus.dialogs.RateUsBottomSheetDialog; - -public class DashRateUsFragment extends DashBaseFragment { - public static final String TAG = "DASH_RATE_US_FRAGMENT"; - - public static final DashFragmentData.ShouldShowFunction SHOULD_SHOW_FUNCTION = - new DashboardOnMap.DefaultShouldShow() { - @Override - public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) { - return RateUsBottomSheetDialog.shouldShow(activity.getMyApplication()) - && super.shouldShow(settings, activity, tag); - } - }; - - private RateUsBottomSheetDialog.FragmentState state = RateUsBottomSheetDialog.FragmentState.INITIAL_STATE; - private RateUsDismissListener mRateUsDismissListener; - - @Override - public void onOpenDash() { - - } - - @Override - public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View view = getActivity().getLayoutInflater().inflate(R.layout.dash_rate_us_fragment, container, false); - TextView header = (TextView) view.findViewById(R.id.header); - TextView subheader = (TextView) view.findViewById(R.id.subheader); - Button positiveButton = (Button) view.findViewById(R.id.positive_button); - Button negativeButton = (Button) view.findViewById(R.id.negative_button); - positiveButton.setOnClickListener( - new PositiveButtonListener(header, subheader, positiveButton, negativeButton)); - negativeButton.setOnClickListener( - new NegativeButtonListener(header, subheader, positiveButton, negativeButton)); - OsmandSettings settings = getMyApplication().getSettings(); - mRateUsDismissListener = new RateUsDismissListener(dashboard, settings); - return view; - } - - @Override - public DismissListener getDismissCallback() { - return mRateUsDismissListener; - } - - public class PositiveButtonListener implements View.OnClickListener { - private TextView header; - private TextView subheader; - private Button positiveButton; - private Button negativeButton; - - public PositiveButtonListener(TextView header, TextView subheader, Button positiveButton, - Button negativeButton) { - this.header = header; - this.subheader = subheader; - this.positiveButton = positiveButton; - this.negativeButton = negativeButton; - } - - @Override - public void onClick(View v) { - final OsmandSettings settings = getMyApplication().getSettings(); - switch (state) { - case INITIAL_STATE: - state = RateUsBottomSheetDialog.FragmentState.USER_LIKES_APP; - - header.setText(getResources().getString(R.string.rate_this_app)); - subheader.setText(getResources().getString(R.string.rate_this_app_long)); - positiveButton.setText(getResources().getString(R.string.shared_string_ok)); - negativeButton.setText(getResources().getString(R.string.shared_string_no_thanks)); - return; - case USER_LIKES_APP: - settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.LIKED); - Uri uri = Uri.parse(Version.getUrlWithUtmRef(getMyApplication(), getActivity().getPackageName())); - Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); - startActivity(goToMarket); - break; - case USER_DISLIKES_APP: - String email = getString(R.string.support_email); - settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.DISLIKED_WITH_MESSAGE); - settings.NUMBER_OF_APPLICATION_STARTS.set(0); - settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis()); - Intent sendEmail = new Intent(Intent.ACTION_SENDTO); - sendEmail.setType("text/plain"); - sendEmail.setData(Uri.parse("mailto:" + email)); - sendEmail.putExtra(Intent.EXTRA_EMAIL, email); - startActivity(sendEmail); - break; - } - dashboard.refreshDashboardFragments(); - } - } - - public class NegativeButtonListener implements View.OnClickListener { - private TextView header; - private TextView subheader; - private Button positiveButton; - private Button negativeButton; - - public NegativeButtonListener(TextView header, TextView subheader, Button positiveButton, - Button negativeButton) { - this.header = header; - this.subheader = subheader; - this.positiveButton = positiveButton; - this.negativeButton = negativeButton; - } - - @Override - public void onClick(View v) { - final OsmandSettings settings = getMyApplication().getSettings(); - switch (state) { - case INITIAL_STATE: - state = RateUsBottomSheetDialog.FragmentState.USER_DISLIKES_APP; - - header.setText(getResources().getString(R.string.user_hates_app_get_feedback)); - subheader.setText(getResources().getString(R.string.user_hates_app_get_feedback_long)); - positiveButton.setText(getResources().getString(R.string.shared_string_ok)); - negativeButton.setText(getResources().getString(R.string.shared_string_no_thanks)); - return; - case USER_LIKES_APP: - settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.IGNORED); - break; - case USER_DISLIKES_APP: - settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.DISLIKED_WITHOUT_MESSAGE); - break; - } - settings.NUMBER_OF_APPLICATION_STARTS.set(0); - settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis()); - dashboard.refreshDashboardFragments(); - } - } - - private static class RateUsDismissListener implements DismissListener { - private DashboardOnMap dashboardOnMap; - private OsmandSettings settings; - - public RateUsDismissListener(DashboardOnMap dashboardOnMap, OsmandSettings settings) { - this.dashboardOnMap = dashboardOnMap; - this.settings = settings; - } - - @Override - public void onDismiss() { - settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.IGNORED); - settings.NUMBER_OF_APPLICATION_STARTS.set(0); - settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis()); - dashboardOnMap.refreshDashboardFragments(); - } - } -} diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index d7999b53fb..eb4ecde9ba 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -103,8 +103,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo private final DashFragmentData[] fragmentsData = new DashFragmentData[]{ - new DashFragmentData(DashRateUsFragment.TAG, DashRateUsFragment.class, - DashRateUsFragment.SHOULD_SHOW_FUNCTION, 0, null), new DashFragmentData(DashDashboardOrDrawerFragment.TAG, DashDashboardOrDrawerFragment.class, DashDashboardOrDrawerFragment.SHOULD_SHOW_FUNCTION, 5, null), new DashFragmentData(DashErrorFragment.TAG, DashErrorFragment.class,