Skip to content
Snippets Groups Projects
Commit 28c09fb7 authored by Michi302's avatar Michi302
Browse files

Merge branch 'master' into fdroid

# Conflicts:
#	.gitlab-ci.yml
#	.magnum.yml
#	.travis.yml
#	app/src/main/java/com/commit451/gitlab/GitLabApp.java
parents 38c2d95b 307cec20
No related branches found
No related tags found
No related merge requests found
Pipeline #
Showing
with 253 additions and 44 deletions
Loading
Loading
@@ -9,8 +9,9 @@ android {
applicationId "com.commit451.gitlab"
minSdkVersion 16
targetSdkVersion 23
versionCode 220
versionName "2.2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionCode 221
versionName "2.2.1"
}
buildTypes {
release {
Loading
Loading
@@ -29,6 +30,8 @@ android {
 
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
Loading
Loading
Loading
Loading
@@ -4,7 +4,6 @@ import android.app.Activity;
import android.os.Bundle;
 
import com.commit451.gitlab.BuildConfig;
import com.commit451.gitlab.api.GitLabClient;
import com.commit451.gitlab.data.Prefs;
import com.commit451.gitlab.model.Account;
import com.commit451.gitlab.util.NavigationManager;
Loading
Loading
@@ -33,7 +32,6 @@ public class GitlabActivity extends Activity {
if(accounts.isEmpty()) {
NavigationManager.navigateToLogin(this);
} else {
GitLabClient.setAccount(accounts.get(0));
NavigationManager.navigateToProjects(this);
}
 
Loading
Loading
Loading
Loading
@@ -15,7 +15,6 @@ import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputLayout;
import android.support.v4.content.ContextCompat;
import android.text.method.LinkMovementMethod;
import android.util.Patterns;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;
Loading
Loading
@@ -36,6 +35,7 @@ import com.commit451.gitlab.util.KeyboardUtil;
import com.commit451.gitlab.util.NavigationManager;
import com.commit451.gitlab.view.EmailAutoCompleteTextView;
import com.squareup.okhttp.Credentials;
import com.squareup.okhttp.HttpUrl;
 
import java.security.cert.CertificateEncodingException;
import java.util.Date;
Loading
Loading
@@ -54,7 +54,6 @@ import timber.log.Timber;
public class LoginActivity extends BaseActivity {
 
private static final int PERMISSION_REQUEST_GET_ACCOUNTS = 1337;
private static Pattern sUrlPattern = Patterns.WEB_URL;
private static Pattern sTokenPattern = Pattern.compile("^[A-Za-z0-9-_]*$");
 
public static Intent newInstance(Context context) {
Loading
Loading
@@ -110,7 +109,18 @@ public class LoginActivity extends BaseActivity {
if (hasEmptyFields(mUrlHint)) {
return;
}
if (!sUrlPattern.matcher(mUrlInput.getText()).matches()) {
Uri uri = null;
try {
String url = mUrlInput.getText().toString();
if (HttpUrl.parse(url) != null) {
uri = Uri.parse(url);
}
} catch (Exception e) {
Timber.e(e, null);
}
if (uri == null) {
mUrlHint.setError(getString(R.string.not_a_valid_url));
return;
} else {
Loading
Loading
@@ -133,10 +143,8 @@ public class LoginActivity extends BaseActivity {
}
}
 
String url = mUrlInput.getText().toString();
mAccount = new Account();
mAccount.setServerUrl(Uri.parse(url));
mAccount.setServerUrl(uri);
mAccount.setTrustedCertificate(mTrustedCertificate);
mAccount.setAuthorizationHeader(mAuthorizationHeader);
 
Loading
Loading
Loading
Loading
@@ -91,7 +91,7 @@ public class UserActivity extends BaseActivity {
 
if (savedInstanceState == null) {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.user_feed, FeedFragment.newInstance(mUser.getFeedUrl().toString())).commit();
fragmentTransaction.add(R.id.user_feed, FeedFragment.newInstance(mUser.getFeedUrl())).commit();
}
}
 
Loading
Loading
Loading
Loading
@@ -54,7 +54,7 @@ public class GroupPagerAdapter extends FragmentPagerAdapter {
 
switch (position) {
case ACTIVITY_POS:
return FeedFragment.newInstance(mGroup.getFeedUrl().toString());
return FeedFragment.newInstance(mGroup.getFeedUrl());
case PROJECTS_POS:
return ProjectsFragment.newInstance(mGroup);
case MEMBERS_POS:
Loading
Loading
Loading
Loading
@@ -77,7 +77,7 @@ public class SectionsPagerAdapter extends FragmentPagerAdapter {
case OVERVIEW_POS:
return OverviewFragment.newInstance();
case ACTIVITY_POS:
return FeedFragment.newInstance(mProject.getFeedUrl().toString());
return FeedFragment.newInstance(mProject.getFeedUrl());
case FILES_POS:
return FilesFragment.newInstance();
case COMMITS_POS:
Loading
Loading
Loading
Loading
@@ -8,6 +8,8 @@ import com.commit451.gitlab.provider.SimpleXmlProvider;
import com.squareup.picasso.OkHttpDownloader;
import com.squareup.picasso.Picasso;
 
import java.util.List;
import retrofit.GsonConverterFactory;
import retrofit.Retrofit;
import retrofit.SimpleXmlConverterFactory;
Loading
Loading
@@ -37,8 +39,12 @@ public final class GitLabClient {
return sAccount;
}
 
/**
* Get a GitLab instance with the current account passed. Used for login only
* @param account the account to try and log in with
* @return the GitLab instance
*/
public static GitLab instance(Account account) {
checkAccountSet(account);
Retrofit restAdapter = new Retrofit.Builder()
.baseUrl(account.getServerUrl().toString())
.client(OkHttpClientProvider.getInstance(account))
Loading
Loading
@@ -49,6 +55,7 @@ public final class GitLabClient {
 
public static GitLab instance() {
if (sGitLab == null) {
checkAccountSet();
sGitLab = instance(sAccount);
}
 
Loading
Loading
@@ -56,7 +63,7 @@ public final class GitLabClient {
}
 
public static GitLabRss rssInstance(Account account) {
checkAccountSet(account);
checkAccountSet();
Retrofit restAdapter = new Retrofit.Builder()
.baseUrl(account.getServerUrl().toString())
.client(OkHttpClientProvider.getInstance(account))
Loading
Loading
@@ -74,7 +81,7 @@ public final class GitLabClient {
}
 
public static Picasso getPicasso(Account account) {
checkAccountSet(account);
checkAccountSet();
return new Picasso.Builder(GitLabApp.instance())
.downloader(new OkHttpDownloader(OkHttpClientProvider.getInstance(account)))
.build();
Loading
Loading
@@ -88,9 +95,10 @@ public final class GitLabClient {
return sPicasso;
}
 
private static void checkAccountSet(Account account) {
if (account == null) {
throw new IllegalStateException("You cannot do any network calls before the account is set!");
private static void checkAccountSet() {
if (sAccount == null) {
List<Account> accounts = Account.getAccounts(GitLabApp.instance());
GitLabClient.setAccount(accounts.get(0));
}
}
}
package com.commit451.gitlab.fragment;
 
import com.commit451.gitlab.GitLabApp;
import com.commit451.gitlab.R;
import com.commit451.gitlab.adapter.FeedAdapter;
import com.commit451.gitlab.api.GitLabClient;
import com.commit451.gitlab.model.rss.Entry;
import com.commit451.gitlab.model.rss.Feed;
import com.commit451.gitlab.util.IntentUtil;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
Loading
Loading
@@ -17,6 +10,14 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
 
import com.commit451.gitlab.GitLabApp;
import com.commit451.gitlab.R;
import com.commit451.gitlab.adapter.FeedAdapter;
import com.commit451.gitlab.api.GitLabClient;
import com.commit451.gitlab.model.rss.Entry;
import com.commit451.gitlab.model.rss.Feed;
import com.commit451.gitlab.util.IntentUtil;
import butterknife.Bind;
import butterknife.ButterKnife;
import retrofit.Callback;
Loading
Loading
@@ -28,9 +29,9 @@ public class FeedFragment extends BaseFragment {
 
private static final String EXTRA_FEED_URL = "extra_feed_url";
 
public static FeedFragment newInstance(String feedUrl) {
public static FeedFragment newInstance(Uri feedUrl) {
Bundle args = new Bundle();
args.putString(EXTRA_FEED_URL, feedUrl);
args.putParcelable(EXTRA_FEED_URL, feedUrl);
 
FeedFragment fragment = new FeedFragment();
fragment.setArguments(args);
Loading
Loading
@@ -41,7 +42,7 @@ public class FeedFragment extends BaseFragment {
@Bind(R.id.list) RecyclerView mEntryListView;
@Bind(R.id.message_text) TextView mMessageView;
 
private String mFeedUrl;
private Uri mFeedUrl;
private EventReceiver mEventReceiver;
private FeedAdapter mFeedAdapter;
 
Loading
Loading
@@ -99,7 +100,7 @@ public class FeedFragment extends BaseFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mFeedUrl = getArguments().getString(EXTRA_FEED_URL);
mFeedUrl = getArguments().getParcelable(EXTRA_FEED_URL);
}
 
@Override
Loading
Loading
@@ -144,8 +145,10 @@ public class FeedFragment extends BaseFragment {
 
if (mFeedUrl == null) {
mSwipeRefreshLayout.setRefreshing(false);
mMessageView.setVisibility(View.VISIBLE);
return;
}
mMessageView.setVisibility(View.GONE);
 
mSwipeRefreshLayout.post(new Runnable() {
@Override
Loading
Loading
@@ -156,7 +159,7 @@ public class FeedFragment extends BaseFragment {
}
});
 
GitLabClient.rssInstance().getFeed(mFeedUrl).enqueue(mUserFeedCallback);
GitLabClient.rssInstance().getFeed(mFeedUrl.toString()).enqueue(mUserFeedCallback);
}
 
private class EventReceiver {
Loading
Loading
Loading
Loading
@@ -289,7 +289,9 @@ public class ProjectsFragment extends BaseFragment {
}
 
public void searchQuery(String query) {
mProjectsAdapter.clearData();
if (mProjectsAdapter != null) {
mProjectsAdapter.clearData();
}
mQuery = query;
loadData();
}
Loading
Loading
package com.commit451.gitlab.model.api;
 
import android.net.Uri;
import android.support.annotation.Nullable;
import com.google.gson.annotations.SerializedName;
 
import org.parceler.Parcel;
 
import android.net.Uri;
@Parcel
public class Group {
@SerializedName("id")
Loading
Loading
@@ -47,7 +48,12 @@ public class Group {
return mWebUrl;
}
 
@Nullable
public Uri getFeedUrl() {
if (mWebUrl == null) {
return null;
}
return Uri.parse(mWebUrl.toString() + ".atom");
}
 
Loading
Loading
package com.commit451.gitlab.model.api;
 
import android.net.Uri;
import android.support.annotation.Nullable;
 
import com.google.gson.annotations.SerializedName;
 
Loading
Loading
@@ -188,8 +189,12 @@ public class Project {
return mOpenIssuesCount;
}
 
@Nullable
public Uri getFeedUrl() {
return Uri.parse(mWebUrl.toString() + ".atom");
if (mWebUrl == null) {
return null;
}
return Uri.parse(mWebUrl + ".atom");
}
 
public boolean belongsToGroup() {
Loading
Loading
package com.commit451.gitlab.model.api;
 
import com.google.gson.annotations.SerializedName;
import android.net.Uri;
 
import com.commit451.gitlab.R;
import com.google.gson.annotations.SerializedName;
 
import org.parceler.Parcel;
 
import android.net.Uri;
@Parcel
public class RepositoryTreeObject {
@SerializedName("id")
Loading
Loading
@@ -38,6 +37,9 @@ public class RepositoryTreeObject {
}
 
public int getDrawableForType() {
if (mType == null) {
return R.drawable.ic_unknown_24dp;
}
switch (mType) {
case FILE:
return R.drawable.ic_file_24dp;
Loading
Loading
@@ -47,7 +49,7 @@ public class RepositoryTreeObject {
return R.drawable.ic_repo_24dp;
}
 
return R.drawable.ic_file_24dp;
return R.drawable.ic_unknown_24dp;
}
 
public Uri getUrl(Project project, String branchName, String currentPath) {
Loading
Loading
package com.commit451.gitlab.model.api;
 
import android.net.Uri;
import android.support.annotation.Nullable;
import com.google.gson.annotations.SerializedName;
 
import org.parceler.Parcel;
 
import android.net.Uri;
@Parcel
public class UserBasic extends UserSafe {
@SerializedName("id")
Loading
Loading
@@ -35,7 +36,11 @@ public class UserBasic extends UserSafe {
return mWebUrl;
}
 
@Nullable
public Uri getFeedUrl() {
if (mWebUrl == null) {
return null;
}
return Uri.parse(mWebUrl.toString() + ".atom");
}
 
Loading
Loading
package com.commit451.gitlab.ssl;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
public class CustomSSLSocketFactory extends SSLSocketFactory {
private final SSLSocketFactory mInternalFactory;
public CustomSSLSocketFactory(SSLSocketFactory internalFactory) {
super();
this.mInternalFactory = internalFactory;
}
@Override
public String[] getDefaultCipherSuites() {
return mInternalFactory.getDefaultCipherSuites();
}
@Override
public String[] getSupportedCipherSuites() {
return mInternalFactory.getSupportedCipherSuites();
}
@Override
public Socket createSocket() throws IOException {
return enableProtocols(mInternalFactory.createSocket());
}
@Override
public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException {
return enableProtocols(mInternalFactory.createSocket(s, host, port, autoClose));
}
@Override
public Socket createSocket(String host, int port) throws IOException {
return enableProtocols(mInternalFactory.createSocket(host, port));
}
@Override
public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException {
return enableProtocols(mInternalFactory.createSocket(host, port, localHost, localPort));
}
@Override
public Socket createSocket(InetAddress host, int port) throws IOException {
return enableProtocols(mInternalFactory.createSocket(host, port));
}
@Override
public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException {
return enableProtocols(mInternalFactory.createSocket(address, port, localAddress, localPort));
}
private static Socket enableProtocols(Socket socket) {
if (socket instanceof SSLSocket) {
SSLSocket sslSocket = ((SSLSocket) socket);
Set<String> supportedProtocols = new HashSet<>(Arrays.asList(sslSocket.getSupportedProtocols()));
Set<String> enabledProtocols = new HashSet<>(Arrays.asList(sslSocket.getEnabledProtocols()));
if (supportedProtocols.contains("TLSv1.2")) {
enabledProtocols.add("TLSv1.1");
}
if (supportedProtocols.contains("TLSv1.2")) {
enabledProtocols.add("TLSv1.2");
}
sslSocket.setEnabledProtocols(enabledProtocols.toArray(new String[enabledProtocols.size()]));
}
return socket;
}
}
Loading
Loading
@@ -99,7 +99,7 @@ public class CustomTrustManager implements X509TrustManager {
try {
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[]{this}, null);
mSSLSocketFactory = sslContext.getSocketFactory();
mSSLSocketFactory = new CustomSSLSocketFactory(sslContext.getSocketFactory());
} catch (Exception e) {
throw new IllegalStateException(e);
}
Loading
Loading
app/src/main/res/drawable-nodpi/header.png

68.5 KiB | W: 1024px | H: 500px

app/src/main/res/drawable-nodpi/header.png

89.8 KiB | W: 1024px | H: 500px

app/src/main/res/drawable-nodpi/header.png
app/src/main/res/drawable-nodpi/header.png
app/src/main/res/drawable-nodpi/header.png
app/src/main/res/drawable-nodpi/header.png
  • 2-up
  • Swipe
  • Onion skin
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,19h-2v-2h2v2zM15.07,11.25l-0.9,0.92C13.45,12.9 13,13.5 13,15h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2L8,9c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z"/>
</vector>
Loading
Loading
@@ -13,7 +13,8 @@
android:contentDescription="@null"
android:fitsSystemWindows="false"
android:scaleType="fitXY"
android:src="@drawable/header"/>
android:src="@drawable/header"
android:background="#D7C1E5"/>
 
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image"
Loading
Loading
package com.commit451.gitlab;
import android.net.Uri;
import com.commit451.gitlab.api.GitLabClient;
import com.commit451.gitlab.model.Account;
import com.commit451.gitlab.model.api.Project;
import com.commit451.gitlab.model.api.UserLogin;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import java.util.List;
import retrofit.Response;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* Tests account login and basic retrieval stuff
*/
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21)
public class LoginUnitTest {
@Test
public void loginTest() throws Exception {
Account testAccount = getTestAccount();
Response<UserLogin> loginResponse = GitLabClient.instance(testAccount)
.loginWithUsername("TestAllTheThings", "testing123")
.execute();
assertTrue(loginResponse.isSuccess());
assertNotNull(loginResponse.body().getPrivateToken());
//attach the newly retrieved private token
testAccount.setPrivateToken(loginResponse.body().getPrivateToken());
GitLabClient.setAccount(testAccount);
Response<List<Project>> projectsResponse = GitLabClient.instance()
.getAllProjects()
.execute();
assertTrue(projectsResponse.isSuccess());
assertNotNull(projectsResponse.body());
}
public static Account getTestAccount() {
Account account = new Account();
account.setServerUrl(Uri.parse("https://gitlab.com"));
return account;
}
}
\ No newline at end of file
package com.commit451.gitlab;
import org.robolectric.TestLifecycleApplication;
import java.lang.reflect.Method;
/**
* Test version of our Application class, used by Robolectric
*/
public class TestGitLabApp extends GitLabApp implements TestLifecycleApplication {
@Override
public void beforeTest(Method method) {
}
@Override
public void prepareTest(Object test) {
}
@Override
public void afterTest(Method method) {
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment