Search in sources :

Example 1 with UiLifecycleHelper

use of com.facebook.UiLifecycleHelper in project phonegap-facebook-plugin by Wizcorp.

the class ConnectPlugin method initialize.

@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    // Initialize UiLifecycleHelper
    uiHelper = new UiLifecycleHelper(cordova.getActivity(), null);
    // Init logger
    logger = AppEventsLogger.newLogger(cordova.getActivity());
    int appResId = cordova.getActivity().getResources().getIdentifier("fb_app_id", "string", cordova.getActivity().getPackageName());
    applicationId = cordova.getActivity().getString(appResId);
    // Set up the activity result callback to this class
    cordova.setActivityResultCallback(this);
    // Open a session if we have one cached
    Session session = new Session.Builder(cordova.getActivity()).setApplicationId(applicationId).build();
    if (session.getState() == SessionState.CREATED_TOKEN_LOADED) {
        Session.setActiveSession(session);
        // - Create the request
        Session.OpenRequest openRequest = new Session.OpenRequest(cordova.getActivity());
        // - Set the status change call back
        openRequest.setCallback(new Session.StatusCallback() {

            @Override
            public void call(Session session, SessionState state, Exception exception) {
                onSessionStateChange(state, exception);
            }
        });
        session.openForRead(openRequest);
    }
    // If we have a valid open session, get user's info
    if (checkActiveSession(session)) {
        // Call this method to initialize the session state info
        onSessionStateChange(session.getState(), null);
    }
    super.initialize(cordova, webView);
}
Also used : SessionState(com.facebook.SessionState) UiLifecycleHelper(com.facebook.UiLifecycleHelper) FacebookOperationCanceledException(com.facebook.FacebookOperationCanceledException) JSONException(org.json.JSONException) FacebookServiceException(com.facebook.FacebookServiceException) FacebookException(com.facebook.FacebookException) FacebookDialogException(com.facebook.FacebookDialogException) FacebookAuthorizationException(com.facebook.FacebookAuthorizationException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Session(com.facebook.Session)

Example 2 with UiLifecycleHelper

use of com.facebook.UiLifecycleHelper in project Klyph by jonathangerbaud.

the class TitledViewPagerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(getCustomTheme());
    KlyphLocale.defineLocale(getBaseContext());
    KlyphDevice.initDeviceValues(this, true);
    super.onCreate(savedInstanceState);
    currentTheme = getCustomTheme();
    currentLocale = KlyphLocale.getDeviceLocale();
    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);
    userHasDonated = KlyphPreferences.hasUserDonated();
    KlyphDevice.initDeviceValues(this);
    setAppIconBackToHomeEnabled(true);
    displayBackArrow(true);
    getViewPager().setOffscreenPageLimit(3);
    setLoadingView(findViewById(R.id.progressBar));
    if (!KlyphSession.isLogged()) {
        logout();
    } else if (Session.getActiveSession() == null) {
        Session.openActiveSessionFromCache(this);
    }
    if (getIntent().getBooleanExtra(KlyphBundleExtras.SET_NOTIFICATION_AS_READ, false) == true) {
        String id = getIntent().getStringExtra(KlyphBundleExtras.NOTIFICATION_ID);
        if (id != null && id.length() > 0) {
            new AsyncRequest(Query.POST_READ_NOTIFICATION, id, "", null).execute();
        }
    }
}
Also used : AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) UiLifecycleHelper(com.facebook.UiLifecycleHelper)

Example 3 with UiLifecycleHelper

use of com.facebook.UiLifecycleHelper in project Klyph by jonathangerbaud.

the class TitledFragmentActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(getCustomTheme());
    KlyphLocale.defineLocale(getBaseContext());
    super.onCreate(savedInstanceState);
    currentTheme = getCustomTheme();
    currentLocale = KlyphLocale.getDeviceLocale();
    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);
    KlyphDevice.initDeviceValues(this);
    userHasDonated = KlyphPreferences.hasUserDonated();
    if (!(this instanceof MainActivity)) {
        setAppIconBackToHomeEnabled(true);
        displayBackArrow(true);
    } else {
        setAppIconBackToHomeEnabled(false);
    }
    if (!KlyphSession.isLogged()) {
        if (!(this instanceof MainActivity))
            logout();
    } else if (Session.getActiveSession() == null) {
        Session.openActiveSessionFromCache(this);
    }
    if (getIntent().getBooleanExtra(KlyphBundleExtras.SET_NOTIFICATION_AS_READ, false) == true) {
        String id = getIntent().getStringExtra(KlyphBundleExtras.NOTIFICATION_ID);
        if (id != null && id.length() > 0) {
            new AsyncRequest(Query.POST_READ_NOTIFICATION, id, "", null).execute();
        }
    }
}
Also used : AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) UiLifecycleHelper(com.facebook.UiLifecycleHelper)

Example 4 with UiLifecycleHelper

use of com.facebook.UiLifecycleHelper in project Klyph by jonathangerbaud.

the class LoginFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    uiHelper = new UiLifecycleHelper(getActivity(), callback);
    uiHelper.onCreate(savedInstanceState);
}
Also used : UiLifecycleHelper(com.facebook.UiLifecycleHelper)

Example 5 with UiLifecycleHelper

use of com.facebook.UiLifecycleHelper in project Klyph by jonathangerbaud.

the class PreferencesActivity method onCreate.

@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(KlyphPreferences.getPreferencesTheme());
    KlyphLocale.defineLocale(getBaseContext());
    super.onCreate(savedInstanceState);
    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
    final Preference p = findPreference(KlyphPreferences.PREFERENCE_IMAGE_CLEAR_CACHE);
    p.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            p.setEnabled(false);
            Toast.makeText(PreferencesActivity.this, R.string.preference_images_cache_clearing, Toast.LENGTH_SHORT).show();
            new ClearCacheTask().execute();
            return true;
        }
    });
    setNotificationsIntervalEnabled();
    refreshRingtoneSummary();
    refreshInterval();
    refreshAppLanguage();
    refreshFbLanguage();
    previousRingtone = KlyphPreferences.getNotificationRingtone();
    Preference aboutPref = findPreference(ABOUT_KEY);
    Preference changelogPref = findPreference(CHANGELOG_KEY);
    aboutPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent = new Intent(PreferencesActivity.this, AboutActivity.class);
            startActivity(intent);
            return true;
        }
    });
    changelogPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent = new Intent(PreferencesActivity.this, ChangeLogActivity.class);
            startActivity(intent);
            return true;
        }
    });
    if (KlyphPreferences.arePushNotificationsAvailable() == false) {
        Preference notificationSystemPref = findPreference(NOTIFICATIONS_SYSTEM);
        notificationSystemPref.setEnabled(false);
        notificationSystemPref.setShouldDisableView(true);
    }
    if (KlyphFlags.IS_PRO_VERSION == true || KlyphFlags.IS_AMAZON_VERSION == true) {
        Preference buyProPref = findPreference(BUY_PRO_VERSION_KEY);
        buyProPref.setEnabled(false);
        buyProPref.setShouldDisableView(true);
    }
/*
		 * Preference p = findPreference(KlyphPreferences.PREFERENCE_IMAGE_SAVE_DIRECTORY);
		 * p.setSummary("hi/ha/yalala");
		 * 
		 * p.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
		 * 
		 * @Override
		 * public boolean  onPreferenceClick(Preference preference)
		 * {
		 * Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
		 * intent.setType("folder://");
		 * intent.addCategory(Intent.CATEGORY_OPENABLE);
		 * 
		 * try {
		 * startActivityForResult(
		 * Intent.createChooser(intent, "Select a File to Upload"),
		 * 12);
		 * } catch (android.content.ActivityNotFoundException ex) {
		 * // Potentially direct the user to the Market with a Dialog
		 * Toast.makeText(PreferencesActivity.this, "Please install a File Manager.",
		 * Toast.LENGTH_SHORT).show();
		 * }
		 * return false;
		 * }
		 * });
		 */
}
Also used : CheckBoxPreference(android.preference.CheckBoxPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) UiLifecycleHelper(com.facebook.UiLifecycleHelper) Intent(android.content.Intent)

Aggregations

UiLifecycleHelper (com.facebook.UiLifecycleHelper)5 AsyncRequest (com.abewy.android.apps.klyph.request.AsyncRequest)2 Intent (android.content.Intent)1 CheckBoxPreference (android.preference.CheckBoxPreference)1 ListPreference (android.preference.ListPreference)1 Preference (android.preference.Preference)1 FacebookAuthorizationException (com.facebook.FacebookAuthorizationException)1 FacebookDialogException (com.facebook.FacebookDialogException)1 FacebookException (com.facebook.FacebookException)1 FacebookOperationCanceledException (com.facebook.FacebookOperationCanceledException)1 FacebookServiceException (com.facebook.FacebookServiceException)1 Session (com.facebook.Session)1 SessionState (com.facebook.SessionState)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 JSONException (org.json.JSONException)1