diff --git a/Emoji Switcher/build.gradle b/Emoji Switcher/build.gradle index 6572f8f..02be4fd 100644 --- a/Emoji Switcher/build.gradle +++ b/Emoji Switcher/build.gradle @@ -5,10 +5,11 @@ android { buildToolsVersion '23.0.3' defaultConfig { + applicationId 'com.stevenschoen.emojiswitcher' minSdkVersion 19 targetSdkVersion 23 - versionCode 16 - versionName "2.0.2" + versionCode 19 + versionName "2.1" } compileOptions { diff --git a/Emoji Switcher/src/main/java/com/stevenschoen/emojiswitcher/EmojiSwitcherUtils.java b/Emoji Switcher/src/main/java/com/stevenschoen/emojiswitcher/EmojiSwitcherUtils.java index 32fa43f..a914bef 100644 --- a/Emoji Switcher/src/main/java/com/stevenschoen/emojiswitcher/EmojiSwitcherUtils.java +++ b/Emoji Switcher/src/main/java/com/stevenschoen/emojiswitcher/EmojiSwitcherUtils.java @@ -46,10 +46,23 @@ public class EmojiSwitcherUtils { public static final String SKU_REMOVEADS = "emojiswitcher_removeads"; private static final String systemFontsPath = "/system/fonts/"; - private static final String systemEmojiFilePath = systemFontsPath + "NotoColorEmoji.ttf"; + private static String systemFontFilePath; private static final String htcFilePath = systemFontsPath + "AndroidEmoji-htc.ttf"; private static final String htcBackupFilePath = htcFilePath + ".bak"; + public static String getSystemFontFilePath() { + if (systemFontFilePath == null) { + String path = systemFontsPath; + if (RootTools.exists(systemFontsPath + "SamsungColorEmoji.ttf")) { + systemFontFilePath = path + "SamsungColorEmoji.ttf"; + } else { + systemFontFilePath = path + "NotoColorEmoji.ttf"; + } + } + + return systemFontFilePath; + } + public static NetworkInterface getNetworkInterface(Context context) { return ((EmojiSwitcherApplication) context.getApplicationContext()).getNetworkInterface(); } @@ -110,7 +123,7 @@ public void onNext(Boolean ready) { InstallProgress progress = new InstallProgress(); progress.currentStage = InstallProgress.Stage.Backup; subscriber.onNext(progress); - File systemEmojiSetFile = new File(systemEmojiFilePath); + File systemEmojiSetFile = new File(getSystemFontFilePath()); File backupFile = new File(systemEmojiBackupFilePath(context)); RootTools.copyFile(systemEmojiSetFile.getAbsolutePath(), backupFile.getAbsolutePath(), true, false); @@ -121,9 +134,9 @@ public void onNext(Boolean ready) { subscriber.onNext(progress); RootTools.copyFile(emojiSet.path.getAbsolutePath(), - new File(systemEmojiFilePath).getAbsolutePath(), true, false); + new File(getSystemFontFilePath()).getAbsolutePath(), true, false); try { - applyPermissions("644", systemEmojiFilePath); + applyPermissions("644", getSystemFontFilePath()); } catch (Exception e) { subscriber.onError(e); } @@ -320,7 +333,7 @@ public static Observable currentEmojiSet(final Context context, @Override public void call(Subscriber subscriber) { File emojiSetDestinationFile = new File(context.getFilesDir() + File.separator + "systemcurrent.ttf"); - RootTools.copyFile(systemEmojiFilePath, emojiSetDestinationFile.getAbsolutePath(), true, false); + RootTools.copyFile(getSystemFontFilePath(), emojiSetDestinationFile.getAbsolutePath(), true, false); try { applyPermissions("777", emojiSetDestinationFile.getAbsolutePath()); } catch (Exception e) { @@ -358,9 +371,9 @@ protected Void doInBackground(Activity... activity) { undoHtcFix(); } - RootTools.copyFile(systemEmojiBackupFilePath(activity[0]), systemEmojiFilePath, true, true); + RootTools.copyFile(systemEmojiBackupFilePath(activity[0]), getSystemFontFilePath(), true, true); try { - applyPermissions("644", systemEmojiFilePath); + applyPermissions("644", getSystemFontFilePath()); } catch (TimeoutException | RootDeniedException | IOException e) { e.printStackTrace(); } diff --git a/Emoji Switcher/src/main/java/com/stevenschoen/emojiswitcher/SwitcherActivity.java b/Emoji Switcher/src/main/java/com/stevenschoen/emojiswitcher/SwitcherActivity.java index d43f94a..3e3b24e 100644 --- a/Emoji Switcher/src/main/java/com/stevenschoen/emojiswitcher/SwitcherActivity.java +++ b/Emoji Switcher/src/main/java/com/stevenschoen/emojiswitcher/SwitcherActivity.java @@ -1,14 +1,10 @@ package com.stevenschoen.emojiswitcher; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.net.ConnectivityManager; -import android.net.Uri; import android.os.Bundle; -import android.preference.PreferenceManager; import android.support.v4.app.Fragment; -import android.support.v7.app.AlertDialog; import android.util.Log; import android.view.Menu; import android.view.MenuItem; @@ -25,7 +21,6 @@ import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.AdSize; import com.google.android.gms.ads.AdView; -import com.stevenschoen.emojiswitcher.billing.IabException; import com.stevenschoen.emojiswitcher.billing.IabHelper; import com.stevenschoen.emojiswitcher.billing.IabResult; import com.stevenschoen.emojiswitcher.billing.Inventory; @@ -35,15 +30,10 @@ import com.trello.rxlifecycle.components.support.RxAppCompatActivity; import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import java.util.Objects; -import java.util.concurrent.Callable; -import rx.Observable; import rx.android.schedulers.AndroidSchedulers; import rx.functions.Action1; -import rx.functions.Func2; import rx.subjects.BehaviorSubject; public class SwitcherActivity extends RxAppCompatActivity implements InstallEmojiFragment.Callbacks { @@ -234,7 +224,6 @@ private void setupBilling() { public void onIabSetupFinished(IabResult result) { if (result.isSuccess()) { checkAds(); - notifyEmojiOnePurchasers(); } else { Log.d("asdf", "Problem setting up in-app billing: " + result); } @@ -290,62 +279,6 @@ public void run() { }); } - private void notifyEmojiOnePurchasers() { - Observable.combineLatest( - Observable.fromCallable(new Callable() { - @Override - public Boolean call() throws Exception { - return PreferenceManager.getDefaultSharedPreferences(SwitcherActivity.this).getBoolean("notifiedEmojiOne", false); - } - }), - emojiSetsResponseObservable, - new Func2() { - @Override - public Boolean call(Boolean alreadyNotified, EmojiSetsResponse emojiSetsResponse) { - if (alreadyNotified) return false; - for (EmojiSetListing listing : emojiSetsResponse.emojiSets) { - if (Objects.equals(listing.googlePlaySku, "emojiswitcher_set_emojione")) { - try { - return billingHelper.queryInventory(true, Collections.singletonList(listing.googlePlaySku), null) - .hasPurchase(listing.googlePlaySku); - } catch (IabException e) { - e.printStackTrace(); - return false; - } - } - } - return false; - } - }).observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Action1() { - @Override - public void call(Boolean notify) { - if (notify) { - new AlertDialog.Builder(SwitcherActivity.this) - .setMessage("Emoji One is now available to everyone for free! You're entitled to a full refund for purchasing it.") - .setPositiveButton("Request refund", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Intent sendEmailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:steven@stevenschoen.com")); - sendEmailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"steven@stevenschoen.com"}); - sendEmailIntent.putExtra(Intent.EXTRA_SUBJECT, "Emoji One refund request"); - sendEmailIntent.putExtra(Intent.EXTRA_TEXT, "My Google Play email is: \n(Enter your Google Play email above.)"); - startActivity(Intent.createChooser(sendEmailIntent, "Request refund by email")); - } - }) - .setNegativeButton("Cancel", null) - .show(); - PreferenceManager.getDefaultSharedPreferences(SwitcherActivity.this).edit().putBoolean("notifiedEmojiOne", true).apply(); - } - } - }, new Action1() { - @Override - public void call(Throwable throwable) { - throwable.printStackTrace(); - } - }); - } - @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); diff --git a/Emoji Switcher/src/main/java/com/stevenschoen/emojiswitcher/billing/IabHelper.java b/Emoji Switcher/src/main/java/com/stevenschoen/emojiswitcher/billing/IabHelper.java index 553f2a0..169d19e 100644 --- a/Emoji Switcher/src/main/java/com/stevenschoen/emojiswitcher/billing/IabHelper.java +++ b/Emoji Switcher/src/main/java/com/stevenschoen/emojiswitcher/billing/IabHelper.java @@ -22,6 +22,7 @@ import android.content.Intent; import android.content.IntentSender.SendIntentException; import android.content.ServiceConnection; +import android.content.pm.ResolveInfo; import android.os.Bundle; import android.os.Handler; import android.os.IBinder;