private void configureContribPrefs() { Preference pref1 = findPreference(MyApplication.PrefKey.REQUEST_LICENCE.getKey()), pref2 = findPreference(MyApplication.PrefKey.CONTRIB_DONATE.getKey()); if (MyApplication.getInstance().isContribEnabled()) { ((PreferenceCategory) findPreference(MyApplication.PrefKey.CATEGORY_CONTRIB.getKey())) .removePreference(pref1); pref2.setSummary( Utils.concatResStrings( this, R.string.thank_you, R.string.pref_contrib_donate_summary_already_contrib)); } else { pref1.setOnPreferenceClickListener(this); pref1.setSummary( getString( R.string.pref_request_licence_summary, Secure.getString(getContentResolver(), Secure.ANDROID_ID))); pref2.setSummary(R.string.pref_contrib_donate_summary); } pref2.setOnPreferenceClickListener(this); findPreference(MyApplication.PrefKey.SHORTCUT_CREATE_SPLIT.getKey()) .setEnabled(MyApplication.getInstance().isContribEnabled()); }
@Override public boolean onPreferenceClick(Preference preference) { if (preference.getKey().equals(MyApplication.PrefKey.CONTRIB_DONATE.getKey())) { Utils.contribBuyDo(MyPreferenceActivity.this); return true; } if (preference.getKey().equals(MyApplication.PrefKey.REQUEST_LICENCE.getKey())) { String androidId = Secure.getString(getContentResolver(), Secure.ANDROID_ID); Intent i = new Intent(android.content.Intent.ACTION_SEND); i.setType("plain/text"); i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {MyApplication.FEEDBACK_EMAIL}); i.putExtra( android.content.Intent.EXTRA_SUBJECT, "[" + getString(R.string.app_name) + "] " + getString(R.string.contrib_key)); i.putExtra( android.content.Intent.EXTRA_TEXT, getString(R.string.request_licence_mail_head, androidId) + " \n\n[" + getString(R.string.request_licence_mail_description) + "]"); if (!Utils.isIntentAvailable(MyPreferenceActivity.this, i)) { Toast.makeText( getBaseContext(), R.string.no_app_handling_email_available, Toast.LENGTH_LONG) .show(); } else { startActivity(i); } return true; } if (preference.getKey().equals(MyApplication.PrefKey.SEND_FEEDBACK.getKey())) { CommonCommands.dispatchCommand(this, R.id.FEEDBACK_COMMAND, null); return true; } if (preference.getKey().equals(MyApplication.PrefKey.RATE.getKey())) { PrefKey.NEXT_REMINDER_RATE.putLong(-1); CommonCommands.dispatchCommand(this, R.id.RATE_COMMAND, null); return true; } if (preference.getKey().equals(MyApplication.PrefKey.MORE_INFO_DIALOG.getKey())) { showDialog(R.id.MORE_INFO_DIALOG); return true; } if (preference.getKey().equals(MyApplication.PrefKey.RESTORE.getKey()) || preference.getKey().equals(MyApplication.PrefKey.RESTORE_LEGACY.getKey())) { startActivityForResult(preference.getIntent(), RESTORE_REQUEST); return true; } if (preference.getKey().equals(MyApplication.PrefKey.APP_DIR.getKey())) { File appDir = Utils.requireAppDir(); Preference pref = findPreference(MyApplication.PrefKey.APP_DIR.getKey()); if (appDir == null) { pref.setSummary(R.string.external_storage_unavailable); pref.setEnabled(false); } else { Intent intent = new Intent(this, FolderBrowser.class); intent.putExtra(FolderBrowser.PATH, appDir.getPath()); startActivityForResult(intent, PICK_FOLDER_REQUEST); } return true; } if (preference.getKey().equals(MyApplication.PrefKey.SHORTCUT_CREATE_TRANSACTION.getKey())) { Bundle extras = new Bundle(); extras.putBoolean(AbstractWidget.EXTRA_START_FROM_WIDGET, true); extras.putBoolean(AbstractWidget.EXTRA_START_FROM_WIDGET_DATA_ENTRY, true); addShortcut( ".activity.ExpenseEdit", R.string.transaction, R.drawable.shortcut_create_transaction_icon, extras); return true; } if (preference.getKey().equals(MyApplication.PrefKey.SHORTCUT_CREATE_TRANSFER.getKey())) { Bundle extras = new Bundle(); extras.putBoolean(AbstractWidget.EXTRA_START_FROM_WIDGET, true); extras.putBoolean(AbstractWidget.EXTRA_START_FROM_WIDGET_DATA_ENTRY, true); extras.putInt(MyApplication.KEY_OPERATION_TYPE, MyExpenses.TYPE_TRANSFER); addShortcut( ".activity.ExpenseEdit", R.string.transfer, R.drawable.shortcut_create_transfer_icon, extras); return true; } if (preference.getKey().equals(MyApplication.PrefKey.SHORTCUT_CREATE_SPLIT.getKey())) { Bundle extras = new Bundle(); extras.putBoolean(AbstractWidget.EXTRA_START_FROM_WIDGET, true); extras.putBoolean(AbstractWidget.EXTRA_START_FROM_WIDGET_DATA_ENTRY, true); extras.putInt(MyApplication.KEY_OPERATION_TYPE, MyExpenses.TYPE_SPLIT); addShortcut( ".activity.ExpenseEdit", R.string.split_transaction, R.drawable.shortcut_create_split_icon, extras); return true; } return false; }