Search in sources :

Example 1 with DynamicShortcutManager

use of com.kabouzeid.gramophone.appshortcuts.DynamicShortcutManager in project Phonograph by kabouzeid.

the class App method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    app = this;
    // default theme
    if (!ThemeStore.isConfigured(this, 1)) {
        ThemeStore.editTheme(this).activityTheme(R.style.Theme_Phonograph_Light).primaryColorRes(R.color.md_indigo_500).accentColorRes(R.color.md_pink_A400).commit();
    }
    // Set up Crashlytics, disabled for debug builds
    Crashlytics crashlyticsKit = new Crashlytics.Builder().core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()).build();
    if (!BuildConfig.DEBUG) {
        Fabric.with(this, crashlyticsKit, new Answers());
    } else {
        // crashlytics kit is disabled here
        Fabric.with(this, crashlyticsKit);
    }
    // Set up dynamic shortcuts
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        new DynamicShortcutManager(this).initDynamicShortcuts();
    }
    // automatically restores purchases
    billingProcessor = new BillingProcessor(this, App.GOOGLE_PLAY_LICENSE_KEY, new BillingProcessor.IBillingHandler() {

        @Override
        public void onProductPurchased(String productId, TransactionDetails details) {
        }

        @Override
        public void onPurchaseHistoryRestored() {
        // Toast.makeText(App.this, R.string.restored_previous_purchase_please_restart, Toast.LENGTH_LONG).show();
        }

        @Override
        public void onBillingError(int errorCode, Throwable error) {
        }

        @Override
        public void onBillingInitialized() {
        }
    });
}
Also used : Answers(com.crashlytics.android.answers.Answers) DynamicShortcutManager(com.kabouzeid.gramophone.appshortcuts.DynamicShortcutManager) BillingProcessor(com.anjlab.android.iab.v3.BillingProcessor) TransactionDetails(com.anjlab.android.iab.v3.TransactionDetails) Crashlytics(com.crashlytics.android.Crashlytics)

Example 2 with DynamicShortcutManager

use of com.kabouzeid.gramophone.appshortcuts.DynamicShortcutManager in project Phonograph by kabouzeid.

the class SettingsActivity method onColorSelection.

@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
    switch(dialog.getTitle()) {
        case R.string.primary_color:
            if (!App.isProVersion()) {
                Arrays.sort(NonProAllowedColors.PRIMARY_COLORS);
                if (Arrays.binarySearch(NonProAllowedColors.PRIMARY_COLORS, selectedColor) < 0) {
                    // color wasn't found
                    Toast.makeText(this, R.string.only_the_first_5_colors_available, Toast.LENGTH_LONG).show();
                    startActivity(new Intent(this, PurchaseActivity.class));
                    return;
                }
            }
            ThemeStore.editTheme(this).primaryColor(selectedColor).commit();
            break;
        case R.string.accent_color:
            if (!App.isProVersion()) {
                Arrays.sort(NonProAllowedColors.ACCENT_COLORS);
                if (Arrays.binarySearch(NonProAllowedColors.ACCENT_COLORS, selectedColor) < 0) {
                    // color wasn't found
                    Toast.makeText(this, R.string.only_the_first_5_colors_available, Toast.LENGTH_LONG).show();
                    startActivity(new Intent(this, PurchaseActivity.class));
                    return;
                }
            }
            ThemeStore.editTheme(this).accentColor(selectedColor).commit();
            break;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        new DynamicShortcutManager(this).updateDynamicShortcuts();
    }
    recreate();
}
Also used : DynamicShortcutManager(com.kabouzeid.gramophone.appshortcuts.DynamicShortcutManager) Intent(android.content.Intent)

Aggregations

DynamicShortcutManager (com.kabouzeid.gramophone.appshortcuts.DynamicShortcutManager)2 Intent (android.content.Intent)1 BillingProcessor (com.anjlab.android.iab.v3.BillingProcessor)1 TransactionDetails (com.anjlab.android.iab.v3.TransactionDetails)1 Crashlytics (com.crashlytics.android.Crashlytics)1 Answers (com.crashlytics.android.answers.Answers)1