Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions LibraryRateMe/build.gradle
Original file line number Diff line number Diff line change
@@ -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)
}
Expand All @@ -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'
51 changes: 27 additions & 24 deletions LibraryRateMe/src/com/androidsx/rateme/FeedbackDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -77,25 +79,26 @@ 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");
}
});

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();
}
Expand All @@ -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) {
Expand All @@ -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);
}
Expand All @@ -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;
Expand All @@ -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, ""));
}
Expand Down
24 changes: 14 additions & 10 deletions LibraryRateMe/src/com/androidsx/rateme/RateMeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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=";
Expand Down Expand Up @@ -108,6 +111,7 @@ public RateMeDialog(String appPackageName,
this.onRatingListener = onRatingListener;
}

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
initializeUiFields();
Expand Down Expand Up @@ -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());
}
});
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand All @@ -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);
}
});
}
Expand All @@ -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));
}

Expand Down
18 changes: 10 additions & 8 deletions SampleProject/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -95,6 +92,6 @@ public void writeToParcel(Parcel dest, int flags) {
}
})
.build()
.show(getFragmentManager(), "custom-dialog");
.show(getSupportFragmentManager(), "custom-dialog");
}
}
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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'
}
}

Expand All @@ -17,7 +18,8 @@ allprojects {
group = GROUP

repositories {
mavenCentral()
google()
jcenter()
}
}

Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file added rate-me.zip
Binary file not shown.