Search in sources :

Example 6 with GitHubClient

use of org.eclipse.egit.github.core.client.GitHubClient in project hubroid by EddieRingle.

the class GitHubAuthenticatorActivity method handleLogin.

/**
     * Handles onClick event on the Submit button. Sends username/mPassword to the server for
     * authentication. <p/> Specified by android:onClick="handleLogin" in the layout xml
     */
public void handleLogin(View view) {
    if (mAuthenticationTask != null) {
        return;
    }
    if (mRequestNewAccount) {
        mLogin = mLoginText.getText().toString();
    }
    mPassword = mPasswordText.getText().toString();
    showProgress();
    mAuthenticationTask = new RoboAsyncTask<Boolean>(this) {

        public Boolean call() throws Exception {
            GitHubClient client = new GitHubClient();
            client.setCredentials(mLogin, mPassword);
            client.setUserAgent(USER_AGENT_STRING);
            UserService service = new UserService(client);
            User user = service.getUser();
            if (user != null) {
                /* Make sure we're using the user's username, rather than email */
                mLogin = user.getLogin();
                return true;
            }
            return false;
        }

        @Override
        protected void onException(Exception e) throws RuntimeException {
            Throwable cause = e.getCause() != null ? e.getCause() : e;
            String message;
            /* A 401 is returned as an IOException with this message */
            if ("Received authentication challenge is null".equals(cause.getMessage())) {
                message = getResources().getString(R.string.auth_message_bad_credentials);
            } else {
                message = cause.getMessage();
            }
            ToastUtil.toastOnUiThread(GitHubAuthenticatorActivity.this, message);
        }

        @Override
        public void onSuccess(Boolean authSuccess) {
            onAuthenticationResult(authSuccess);
        }

        @Override
        protected void onFinally() throws RuntimeException {
            hideProgress();
            mAuthenticationTask = null;
        }
    };
    mAuthenticationTask.execute();
}
Also used : GitHubClient(org.eclipse.egit.github.core.client.GitHubClient) User(org.eclipse.egit.github.core.User) UserService(org.eclipse.egit.github.core.service.UserService)

Example 7 with GitHubClient

use of org.eclipse.egit.github.core.client.GitHubClient in project Bitocle by mthli.

the class AddTask method onPreExecute.

@Override
protected void onPreExecute() {
    context = fragment.getContentView().getContext();
    GitHubClient client = fragment.getClient();
    service = new RepositoryService(client);
    pull = fragment.getPull();
    listView = fragment.getListView();
    adapter = fragment.getRepoItemAdapter();
    list = fragment.getRepoItemList();
    pull.setRefreshing(true);
}
Also used : GitHubClient(org.eclipse.egit.github.core.client.GitHubClient) RepositoryService(org.eclipse.egit.github.core.service.RepositoryService)

Example 8 with GitHubClient

use of org.eclipse.egit.github.core.client.GitHubClient in project Bitocle by mthli.

the class RepoTask method onPreExecute.

@Override
protected void onPreExecute() {
    context = fragment.getContentView().getContext();
    flag = fragment.getFlag();
    adapter = fragment.getRepoItemAdapter();
    list = fragment.getRepoItemList();
    GitHubClient client = fragment.getClient();
    service = new RepositoryService(client);
    if (flag == Flag.REPO_FIRST) {
        fragment.setContentEmpty(false);
        fragment.setContentShown(false);
    }
}
Also used : GitHubClient(org.eclipse.egit.github.core.client.GitHubClient) RepositoryService(org.eclipse.egit.github.core.service.RepositoryService)

Example 9 with GitHubClient

use of org.eclipse.egit.github.core.client.GitHubClient in project Bitocle by mthli.

the class WebViewFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setContentView(R.layout.webview_fragment);
    setContentEmpty(false);
    setContentShown(true);
    View view = getContentView();
    webView = (WebView) view.findViewById(R.id.webview);
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setLoadsImagesAutomatically(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS.NORMAL);
    webSettings.setSupportZoom(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setDisplayZoomControls(false);
    SharedPreferences preferences = getActivity().getSharedPreferences(getString(R.string.login_sp), Context.MODE_PRIVATE);
    String OAuth = preferences.getString(getString(R.string.login_sp_oauth), null);
    client = new GitHubClient();
    client.setOAuth2Token(OAuth);
    Intent intent = getActivity().getIntent();
    owner = intent.getStringExtra(getString(R.string.webview_intent_owner));
    name = intent.getStringExtra(getString(R.string.webview_intent_name));
    sha = intent.getStringExtra(getString(R.string.webview_intent_sha));
    filename = intent.getStringExtra(getString(R.string.webview_intent_title));
    task = new WebViewTask(WebViewFragment.this);
    task.execute();
}
Also used : GitHubClient(org.eclipse.egit.github.core.client.GitHubClient) SharedPreferences(android.content.SharedPreferences) WebSettings(android.webkit.WebSettings) Intent(android.content.Intent) View(android.view.View) WebView(android.webkit.WebView)

Example 10 with GitHubClient

use of org.eclipse.egit.github.core.client.GitHubClient in project Bitocle by mthli.

the class RepoContentTask method onPreExecute.

@Override
protected void onPreExecute() {
    context = fragment.getContentView().getContext();
    flag = fragment.getFlag();
    adapter = fragment.getContentItemAdapter();
    list = fragment.getContentItemList();
    bookmark = fragment.getBookmark();
    GitHubClient client = fragment.getClient();
    dataService = new DataService(client);
    owner = fragment.getOwner();
    name = fragment.getName();
    root = fragment.getRoot();
    entry = fragment.getEntry();
    if (flag == Flag.REPO_CONTENT_FIRST || flag == Flag.REPO_CONTENT_REFRESH) {
        fragment.setContentEmpty(false);
        fragment.setContentShown(false);
        bookmark.setVisible(false);
    }
}
Also used : GitHubClient(org.eclipse.egit.github.core.client.GitHubClient) DataService(org.eclipse.egit.github.core.service.DataService)

Aggregations

GitHubClient (org.eclipse.egit.github.core.client.GitHubClient)16 Intent (android.content.Intent)3 IOException (java.io.IOException)3 DataService (org.eclipse.egit.github.core.service.DataService)3 RepositoryService (org.eclipse.egit.github.core.service.RepositoryService)3 WatcherService (org.eclipse.egit.github.core.service.WatcherService)3 ArrayList (java.util.ArrayList)2 OAuthUserProvider (net.idlesoft.android.apps.github.authenticator.OAuthUserProvider)2 User (org.eclipse.egit.github.core.User)2 UserService (org.eclipse.egit.github.core.service.UserService)2 Account (android.accounts.Account)1 AccountsException (android.accounts.AccountsException)1 NetworkErrorException (android.accounts.NetworkErrorException)1 SharedPreferences (android.content.SharedPreferences)1 Rect (android.graphics.Rect)1 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 SparseBooleanArray (android.util.SparseBooleanArray)1 View (android.view.View)1 WebSettings (android.webkit.WebSettings)1