diff --git a/LibraryRateMe/build.gradle b/LibraryRateMe/build.gradle index 7a84392..908a44b 100644 --- a/LibraryRateMe/build.gradle +++ b/LibraryRateMe/build.gradle @@ -1,17 +1,19 @@ apply plugin: 'com.android.library' repositories { - mavenCentral() + google() + jcenter() + //mavenCentral() } android { - compileSdkVersion 22 - buildToolsVersion "22.0.1" + compileSdkVersion 30 + buildToolsVersion "29.0.3" resourcePrefix "rateme__" defaultConfig { - minSdkVersion 11 - targetSdkVersion 22 + minSdkVersion 14 + targetSdkVersion 30 versionName project.VERSION_NAME versionCode Integer.parseInt(project.VERSION_CODE) } @@ -32,5 +34,10 @@ android { abortOnError true } } + +dependencies { + implementation 'androidx.appcompat:appcompat:1.2.0' +} + // Used to push in maven apply from: '../maven_push.gradle' diff --git a/LibraryRateMe/src/com/androidsx/rateme/FeedbackDialog.java b/LibraryRateMe/src/com/androidsx/rateme/FeedbackDialog.java index e8afb82..97197a0 100644 --- a/LibraryRateMe/src/com/androidsx/rateme/FeedbackDialog.java +++ b/LibraryRateMe/src/com/androidsx/rateme/FeedbackDialog.java @@ -2,7 +2,9 @@ import android.app.AlertDialog; import android.app.Dialog; -import android.app.DialogFragment; + +import androidx.annotation.NonNull; +import androidx.fragment.app.DialogFragment; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Bundle; @@ -77,16 +79,17 @@ public FeedbackDialog() { // Empty constructor, required for pause/resume } + @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity()); initializeUiFieldsDialogGoToMail(); Log.d(TAG, "All components were initialized successfully"); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dismiss(); - onActionListener.onRating(OnRatingListener.RatingAction.LOW_RATING_REFUSED_TO_GIVE_FEEDBACK, getArguments().getFloat(EXTRA_RATING_BAR)); + onActionListener.onRating(OnRatingListener.RatingAction.LOW_RATING_REFUSED_TO_GIVE_FEEDBACK, requireArguments().getFloat(EXTRA_RATING_BAR)); Log.d(TAG, "Canceled the feedback dialog"); } }); @@ -94,8 +97,8 @@ public void onClick(View v) { yes.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - goToMail(getArguments().getString(EXTRA_APP_NAME)); - onActionListener.onRating(OnRatingListener.RatingAction.LOW_RATING_GAVE_FEEDBACK, getArguments().getFloat(EXTRA_RATING_BAR)); + goToMail(requireArguments().getString(EXTRA_APP_NAME)); + onActionListener.onRating(OnRatingListener.RatingAction.LOW_RATING_GAVE_FEEDBACK, requireArguments().getFloat(EXTRA_RATING_BAR)); Log.d(TAG, "Agreed to provide feedback"); dismiss(); } @@ -105,25 +108,25 @@ public void onClick(View v) { } private void initializeUiFieldsDialogGoToMail() { - confirmDialogTitleView = View.inflate(getActivity(), R.layout.rateme__feedback_dialog_title, null); - confirmDialogView = View.inflate(getActivity(), R.layout.rateme__feedback_dialog_message, null); - confirmDialogTitleView.setBackgroundColor(getArguments().getInt(EXTRA_DIALOG_TITLE_COLOR)); - confirmDialogView.setBackgroundColor(getArguments().getInt(EXTRA_DIALOG_COLOR)); - if (getArguments().getInt(EXTRA_LOGO) == 0) { + confirmDialogTitleView = View.inflate(requireActivity(), R.layout.rateme__feedback_dialog_title, null); + confirmDialogView = View.inflate(requireActivity(), R.layout.rateme__feedback_dialog_message, null); + confirmDialogTitleView.setBackgroundColor(requireArguments().getInt(EXTRA_DIALOG_TITLE_COLOR)); + confirmDialogView.setBackgroundColor(requireArguments().getInt(EXTRA_DIALOG_COLOR)); + if (requireArguments().getInt(EXTRA_LOGO) == 0) { confirmDialogView.findViewById(R.id.app_icon_dialog_mail).setVisibility(View.GONE); } else { - ((ImageView) confirmDialogView.findViewById(R.id.app_icon_dialog_mail)).setImageResource(getArguments().getInt(EXTRA_LOGO)); + ((ImageView) confirmDialogView.findViewById(R.id.app_icon_dialog_mail)).setImageResource(requireArguments().getInt(EXTRA_LOGO)); confirmDialogView.findViewById(R.id.app_icon_dialog_mail).setVisibility(View.VISIBLE); } - ((TextView) confirmDialogTitleView.findViewById(R.id.confirmDialogTitle)).setTextColor(getArguments().getInt(EXTRA_HEADER_TEXT_COLOR)); - ((TextView) confirmDialogView.findViewById(R.id.mail_dialog_message)).setTextColor(getArguments().getInt(EXTRA_TEXT_COLOR)); + ((TextView) confirmDialogTitleView.findViewById(R.id.confirmDialogTitle)).setTextColor(requireArguments().getInt(EXTRA_HEADER_TEXT_COLOR)); + ((TextView) confirmDialogView.findViewById(R.id.mail_dialog_message)).setTextColor(requireArguments().getInt(EXTRA_TEXT_COLOR)); cancel = (Button) confirmDialogView.findViewById(R.id.buttonCancel); yes = (Button) confirmDialogView.findViewById(R.id.buttonYes); - cancel.setTextColor(getArguments().getInt(EXTRA_RATE_BUTTON_TEXT_COLOR)); - yes.setTextColor(getArguments().getInt(EXTRA_RATE_BUTTON_TEXT_COLOR)); - cancel.setBackgroundColor(getArguments().getInt(EXTRA_RATE_BUTTON_BG_COLOR)); - yes.setBackgroundColor(getArguments().getInt(EXTRA_RATE_BUTTON_BG_COLOR)); - onActionListener = getArguments().getParcelable(EXTRA_ON_ACTION_LISTENER); + cancel.setTextColor(requireArguments().getInt(EXTRA_RATE_BUTTON_TEXT_COLOR)); + yes.setTextColor(requireArguments().getInt(EXTRA_RATE_BUTTON_TEXT_COLOR)); + cancel.setBackgroundColor(requireArguments().getInt(EXTRA_RATE_BUTTON_BG_COLOR)); + yes.setBackgroundColor(requireArguments().getInt(EXTRA_RATE_BUTTON_BG_COLOR)); + onActionListener = requireArguments().getParcelable(EXTRA_ON_ACTION_LISTENER); } private void goToMail(String appName) { @@ -134,10 +137,10 @@ private void goToMail(String appName) { if (isPackageInstalled(gmailPackageName)) { Intent sendMailWithGmail = new Intent(Intent.ACTION_SEND); sendMailWithGmail.setType("plain/text"); - sendMailWithGmail.putExtra(Intent.EXTRA_EMAIL, new String[]{getArguments().getString(EXTRA_EMAIL)}); + sendMailWithGmail.putExtra(Intent.EXTRA_EMAIL, new String[]{requireArguments().getString(EXTRA_EMAIL)}); sendMailWithGmail.putExtra(Intent.EXTRA_SUBJECT, subject); - sendMailWithGmail.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail"); - startActivity(Intent.createChooser(sendMailWithGmail, "")); + sendMailWithGmail.setPackage(gmailPackageName); + startActivity(sendMailWithGmail); } else { sendGenericMail(subject); } @@ -152,12 +155,12 @@ public void onStart() { final int titleDividerId = getResources().getIdentifier("titleDivider", "id", "android"); final View titleDivider = getDialog().findViewById(titleDividerId); if (titleDivider != null) { - titleDivider.setBackgroundColor(getArguments().getInt(EXTRA_TITLE_DIVIDER)); + titleDivider.setBackgroundColor(requireArguments().getInt(EXTRA_TITLE_DIVIDER)); } } private boolean isPackageInstalled(String packageName) { - PackageManager pm = getActivity().getPackageManager(); + PackageManager pm = requireContext().getPackageManager(); try { pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); return true; @@ -170,7 +173,7 @@ private void sendGenericMail(String subject) { Log.w(TAG, "Cannot send the email with GMail. Will use the generic chooser"); Intent sendGeneric = new Intent(Intent.ACTION_SEND); sendGeneric.setType("plain/text"); - sendGeneric.putExtra(Intent.EXTRA_EMAIL, new String[] { getArguments().getString(EXTRA_EMAIL) }); + sendGeneric.putExtra(Intent.EXTRA_EMAIL, new String[] { requireArguments().getString(EXTRA_EMAIL) }); sendGeneric.putExtra(Intent.EXTRA_SUBJECT, subject); startActivity(Intent.createChooser(sendGeneric, "")); } diff --git a/LibraryRateMe/src/com/androidsx/rateme/RateMeDialog.java b/LibraryRateMe/src/com/androidsx/rateme/RateMeDialog.java index f8ff0af..2a68a87 100644 --- a/LibraryRateMe/src/com/androidsx/rateme/RateMeDialog.java +++ b/LibraryRateMe/src/com/androidsx/rateme/RateMeDialog.java @@ -2,7 +2,10 @@ import android.app.AlertDialog; import android.app.Dialog; -import android.app.DialogFragment; + +import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; +import androidx.fragment.app.DialogFragment; import android.content.Intent; import android.graphics.Color; import android.graphics.LightingColorFilter; @@ -23,7 +26,7 @@ * Rate Me dialog. Entry point into the library. Use the {@link com.androidsx.rateme.RateMeDialog.Builder} to * construct your instance. */ -public class RateMeDialog extends DialogFragment { +public class RateMeDialog extends DialogFragment { private static final String TAG = RateMeDialog.class.getSimpleName(); private static final String MARKET_CONSTANT = "market://details?id="; @@ -108,6 +111,7 @@ public RateMeDialog(String appPackageName, this.onRatingListener = onRatingListener; } + @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { initializeUiFields(); @@ -144,9 +148,9 @@ public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) @Override public void onClick(View v) { dismiss(); - RateMeDialogTimer.clearSharedPreferences(getActivity()); + RateMeDialogTimer.clearSharedPreferences(requireActivity()); Log.d(TAG, "Clear the shared preferences"); - RateMeDialogTimer.setOptOut(getActivity(), true); + RateMeDialogTimer.setOptOut(requireActivity(), true); onRatingListener.onRating(OnRatingListener.RatingAction.DISMISSED_WITH_CROSS, ratingBar.getRating()); } }); @@ -202,7 +206,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putString("appPackageName", appPackageName); @@ -271,7 +275,7 @@ private void configureButtons() { public void onClick(View v) { rateApp(); Log.d(TAG, "Yes: open the Google Play Store"); - RateMeDialogTimer.setOptOut(getActivity(), true); + RateMeDialogTimer.setOptOut(requireActivity(), true); onRatingListener.onRating(OnRatingListener.RatingAction.HIGH_RATING_WENT_TO_GOOGLE_PLAY, ratingBar.getRating()); dismiss(); } @@ -293,14 +297,14 @@ public void onClick(View v) { rateButtonBackgroundColor, ratingBar.getRating(), onRatingListener); - dialogMail.show(getFragmentManager(), "feedbackByEmailEnabled"); + dialogMail.show(requireFragmentManager(), "feedbackByEmailEnabled"); dismiss(); Log.d(TAG, "No: open the feedback dialog"); } else { dismiss(); onRatingListener.onRating(OnRatingListener.RatingAction.LOW_RATING, ratingBar.getRating()); } - RateMeDialogTimer.setOptOut(getActivity(), true); + RateMeDialogTimer.setOptOut(requireActivity(), true); } }); } @@ -326,9 +330,9 @@ private Intent shareApp(String appPackageName) { } private void setIconsTitleColor(int colorClose, int colorShare) { - getResources().getDrawable(android.R.drawable.ic_menu_close_clear_cancel) + ContextCompat.getDrawable(requireContext(), android.R.drawable.ic_menu_close_clear_cancel) .setColorFilter(new LightingColorFilter(colorClose, colorClose)); - getResources().getDrawable(android.R.drawable.ic_menu_share) + ContextCompat.getDrawable(requireContext(), android.R.drawable.ic_menu_share) .setColorFilter(new LightingColorFilter(colorShare, colorShare)); } diff --git a/SampleProject/build.gradle b/SampleProject/build.gradle index f369863..bc3e4e9 100644 --- a/SampleProject/build.gradle +++ b/SampleProject/build.gradle @@ -2,24 +2,26 @@ apply plugin: 'com.android.application' buildscript{ repositories{ - mavenCentral() + google() + jcenter() } dependencies{ - classpath 'com.android.tools.build:gradle:1.1.0' + classpath 'com.android.tools.build:gradle:4.0.2' } } repositories { - mavenCentral() + google() + jcenter() } android { - compileSdkVersion 22 - buildToolsVersion "21.1.2" + compileSdkVersion 30 + buildToolsVersion "29.0.3" defaultConfig { minSdkVersion 14 - targetSdkVersion 22 + targetSdkVersion 30 versionName project.VERSION_NAME versionCode Integer.parseInt(project.VERSION_CODE) } @@ -43,6 +45,6 @@ android { } dependencies { - compile project(':LibraryRateMe') - compile 'com.android.support:appcompat-v7:22.2.0' + implementation project(':LibraryRateMe') + implementation 'androidx.appcompat:appcompat:1.2.0' } diff --git a/SampleProject/src/com/androidsx/rateme/demo1/SampleProjectMainActivity.java b/SampleProject/src/com/androidsx/rateme/demo1/SampleProjectMainActivity.java index 114cee1..0e37956 100755 --- a/SampleProject/src/com/androidsx/rateme/demo1/SampleProjectMainActivity.java +++ b/SampleProject/src/com/androidsx/rateme/demo1/SampleProjectMainActivity.java @@ -2,7 +2,7 @@ import android.os.Bundle; import android.os.Parcel; -import android.support.v7.app.ActionBarActivity; +import androidx.appcompat.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -13,7 +13,7 @@ import com.androidsx.rateme.RateMeDialogTimer; import com.androidsx.rateme.demo.R; -public class SampleProjectMainActivity extends ActionBarActivity { +public class SampleProjectMainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { @@ -37,14 +37,11 @@ public boolean onCreateOptionsMenu(Menu menu) { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.RateMe: { + if (item.getItemId() == R.id.RateMe) { showPlainRateMeDialog(); return true; } - default: - return super.onOptionsItemSelected(item); - } + return super.onOptionsItemSelected(item); } @Override @@ -64,7 +61,7 @@ protected void onStart() { private void showPlainRateMeDialog() { new RateMeDialog.Builder(getPackageName(), getString(R.string.app_name)) .build() - .show(getFragmentManager(), "plain-dialog"); + .show(getSupportFragmentManager(), "plain-dialog"); } private void showCustomRateMeDialog() { @@ -95,6 +92,6 @@ public void writeToParcel(Parcel dest, int flags) { } }) .build() - .show(getFragmentManager(), "custom-dialog"); + .show(getSupportFragmentManager(), "custom-dialog"); } } diff --git a/build.gradle b/build.gradle index c8cf958..37e37e8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,11 @@ buildscript { repositories { - mavenCentral() + google() + jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.1.0' + classpath 'com.android.tools.build:gradle:4.0.2' } } @@ -17,7 +18,8 @@ allprojects { group = GROUP repositories { - mavenCentral() + google() + jcenter() } } diff --git a/gradle.properties b/gradle.properties index b623bde..d3b836e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,3 +12,5 @@ POM_LICENCE_URL=https://github.com/androidsx/rate-me/blob/master/LICENSE.md POM_LICENCE_DIST=repo POM_DEVELOPER_ID=pocho23 POM_DEVELOPER_NAME=Lucas Ponzoda +android.useAndroidX=true +android.enableJetifier=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0382d5c..9b953e1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/rate-me.zip b/rate-me.zip new file mode 100644 index 0000000..5e09597 Binary files /dev/null and b/rate-me.zip differ