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();
}
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);
}
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);
}
}
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();
}
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);
}
}
Aggregations