Skip to content
Snippets Groups Projects
Commit 93f24fed authored by John Carlson's avatar John Carlson
Browse files

Fix issue where text and hint would overlap on url in login

parent ee86bf76
No related branches found
No related tags found
No related merge requests found
Pipeline #
Showing with 83 additions and 127 deletions
# LabCoat for GitLab
[![Google Play](https://gitlab.com/Commit451/LabCoat/raw/master/art/google-play-badge.png)](https://play.google.com/store/apps/details?id=com.commit451.gitlab)
 
[![build status](https://gitlab.com/ci/projects/7701/status.png?ref=master)](https://gitlab.com/ci/projects/7701?ref=master)
 
![Image](https://gitlab.com/Commit451/LabCoat/raw/master/art/screenshot-1.png)
[![Google Play](https://gitlab.com/Commit451/LabCoat/raw/master/art/google-play-badge.png)](https://play.google.com/store/apps/details?id=com.commit451.gitlab)
 
## Issues
Please see the [issues](https://gitlab.com/Commit451/LabCoat/issues) section to report any bugs or feature requests and to see the list of known issues.
 
## Building
You should be able to build the project from Android Studio without any further setup. The app uses Fabric for Crashlytics, so if you wanted to do a release build, you would need to generate your own Crashlytics/Fabric key. All in all, your gradle.properties will look something like this:
You should be able to build the project from Android Studio without any further setup. The app uses Fabric for crash reporting, so if you wanted to do a release build, you would need to generate your own Crashlytics/Fabric key. All in all, your `gradle.properties` will look something like this:
```Gradle
LABCOAT_FABRIC_KEY = FABRIC_KEY_GOES_HERE_BUT_ONLY_REALLY_NEEDED_FOR_RELEASE_BUILDS
```
Loading
Loading
@@ -62,6 +62,8 @@ The following 3rd party libraries and resources are the reason this app works. R
## Contributing
Please fork this repository and contribute back! All Merge Requests should be made against the `develop` branch, as it is the active branch for development. Please make your best effort to break up commits as much as possible to improve the reviewing process.
 
If you are making substantial changes, please refer to Commit 451's style [guidelines](https://github.com/Commit451/guidelines) for Android
License
--------
 
Loading
Loading
Loading
Loading
@@ -93,7 +93,7 @@
<activity
android:name=".activity.PickBranchOrTagActivity"
android:theme="@style/Activity.Translucent" />
<activity android:name=".activity.WebviewLoginActivity" />
<activity android:name=".activity.WebLoginActivity" />
 
<activity
android:name=".activity.AttachActivity"
Loading
Loading
Loading
Loading
@@ -33,9 +33,9 @@ public class ActivityActivity extends BaseActivity {
}
 
@BindView(R.id.drawer_layout)
DrawerLayout mDrawerLayout;
DrawerLayout drawerLayout;
@BindView(R.id.toolbar)
Toolbar mToolbar;
Toolbar toolbar;
 
@Override
protected void onCreate(Bundle savedInstanceState) {
Loading
Loading
@@ -45,12 +45,12 @@ public class ActivityActivity extends BaseActivity {
 
App.bus().register(this);
 
mToolbar.setTitle(R.string.nav_activity);
mToolbar.setNavigationIcon(R.drawable.ic_menu_24dp);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
toolbar.setTitle(R.string.nav_activity);
toolbar.setNavigationIcon(R.drawable.ic_menu_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDrawerLayout.openDrawer(GravityCompat.START);
drawerLayout.openDrawer(GravityCompat.START);
}
});
 
Loading
Loading
@@ -79,6 +79,6 @@ public class ActivityActivity extends BaseActivity {
 
@Subscribe
public void onCloseDrawerEvent(CloseDrawerEvent event) {
mDrawerLayout.closeDrawers();
drawerLayout.closeDrawers();
}
}
Loading
Loading
@@ -8,7 +8,6 @@ import android.content.Intent;
import android.os.Bundle;
 
import com.commit451.gitlab.App;
import com.commit451.gitlab.BuildConfig;
import com.commit451.gitlab.R;
import com.commit451.gitlab.model.Account;
import com.commit451.gitlab.navigation.Navigator;
Loading
Loading
@@ -16,8 +15,6 @@ import com.commit451.gitlab.ssl.CustomKeyManager;
 
import java.util.List;
 
import timber.log.Timber;
/**
* This activity acts as switching platform for the application directing the user to the appropriate
* activity based on their logged in state
Loading
Loading
@@ -33,12 +30,6 @@ public class LaunchActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
 
int savedVersion = App.get().getPrefs().getSavedVersion();
if (savedVersion != -1 && savedVersion < BuildConfig.VERSION_CODE) {
Timber.d("Performing upgrade");
performUpgrade(savedVersion, BuildConfig.VERSION_CODE);
App.get().getPrefs().setSavedVersion();
}
List<Account> accounts = Account.getAccounts();
if(accounts.isEmpty()) {
Navigator.navigateToLogin(this);
Loading
Loading
@@ -113,11 +104,4 @@ public class LaunchActivity extends Activity {
loadPrivateKey(accounts, i + 1);
}
}
/**
* Perform an upgrade from one version to another. This should only be one time upgrade things
*/
private void performUpgrade(int previousVersion, int currentVersion) {
}
}
Loading
Loading
@@ -22,7 +22,6 @@ import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.Patterns;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
Loading
Loading
@@ -48,7 +47,6 @@ import com.commit451.gitlab.ssl.CustomHostnameVerifier;
import com.commit451.gitlab.ssl.CustomKeyManager;
import com.commit451.gitlab.ssl.X509CertificateException;
import com.commit451.gitlab.ssl.X509Util;
import com.commit451.reptar.retrofit.ResponseSingleObserver;
import com.commit451.teleprinter.Teleprinter;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
 
Loading
Loading
@@ -69,6 +67,7 @@ import javax.net.ssl.SSLPeerUnverifiedException;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.OnEditorAction;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
Loading
Loading
@@ -125,17 +124,16 @@ public class LoginActivity extends BaseActivity {
@BindView(R.id.progress)
View progress;
 
private boolean isNormalLogin = true;
private Account account;
private Teleprinter teleprinter;
Teleprinter teleprinter;
 
private final TextView.OnEditorActionListener onEditorActionListener = new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
onLoginClick();
return true;
}
};
boolean isNormalLogin = true;
Account account;
@OnEditorAction({R.id.password_input, R.id.token_input})
boolean onPasswordEditorAction() {
onLoginClick();
return true;
}
 
@OnClick(R.id.login_button)
public void onLoginClick() {
Loading
Loading
@@ -235,8 +233,7 @@ public class LoginActivity extends BaseActivity {
}
});
}
textPassword.setOnEditorActionListener(onEditorActionListener);
textToken.setOnEditorActionListener(onEditorActionListener);
textUser.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
Loading
Loading
@@ -245,6 +242,7 @@ public class LoginActivity extends BaseActivity {
}
}
});
textUrl.setText(R.string.url_gitlab);
}
 
@TargetApi(23)
Loading
Loading
@@ -273,7 +271,7 @@ public class LoginActivity extends BaseActivity {
switch (requestCode) {
case REQUEST_PRIVATE_TOKEN:
if (resultCode == RESULT_OK) {
String token = data.getStringExtra(WebviewLoginActivity.EXTRA_TOKEN);
String token = data.getStringExtra(WebLoginActivity.EXTRA_TOKEN);
textInputLayoutToken.getEditText().setText(token);
}
break;
Loading
Loading
@@ -624,6 +622,7 @@ public class LoginActivity extends BaseActivity {
private Set<String> getEmailAccounts() {
HashSet<String> emailAccounts = new HashSet<>();
AccountManager manager = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE);
@SuppressWarnings("MissingPermission")
final android.accounts.Account[] accounts = manager.getAccounts();
for (android.accounts.Account account : accounts) {
if (!TextUtils.isEmpty(account.name) && Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) {
Loading
Loading
Loading
Loading
@@ -6,13 +6,9 @@ import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
 
import com.commit451.gitlab.R;
import com.commit451.gitlab.adapter.SearchPagerAdapter;
Loading
Loading
@@ -22,6 +18,8 @@ import com.commit451.teleprinter.Teleprinter;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.OnEditorAction;
import butterknife.OnTextChanged;
import timber.log.Timber;
 
 
Loading
Loading
@@ -61,63 +59,51 @@ public class SearchActivity extends BaseActivity {
});
textSearch.getText().clear();
mTeleprinter.showKeyboard(textSearch);
mSearchDebouncer.cancel();
debouncer.cancel();
}
 
private Teleprinter mTeleprinter;
 
private Debouncer<CharSequence> mSearchDebouncer = new Debouncer<CharSequence>() {
private Debouncer<CharSequence> debouncer = new Debouncer<CharSequence>() {
@Override
public void onValueSet(CharSequence value) {
search();
}
};
 
private final TextView.OnEditorActionListener mOnSearchEditorActionListener = new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (TextUtils.isEmpty(textSearch.getText())) {
textSearch.setText("unicorns");
}
search();
mTeleprinter.hideKeyboard();
return false;
@OnEditorAction(R.id.search)
boolean onSearchEditorAction() {
if (TextUtils.isEmpty(textSearch.getText())) {
textSearch.setText("unicorns");
}
};
search();
mTeleprinter.hideKeyboard();
return false;
}
 
private final TextWatcher mTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@OnTextChanged(R.id.search)
void onSearchTextChanged(CharSequence s, int start, int before, int count) {
if (TextUtils.isEmpty(s)) {
buttonClear.animate().alpha(0.0f).withEndAction(new Runnable() {
@Override
public void run() {
buttonClear.setVisibility(View.GONE);
}
});
} else if (count == 1) {
buttonClear.setVisibility(View.VISIBLE);
buttonClear.animate().alpha(1.0f);
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (TextUtils.isEmpty(s)) {
buttonClear.animate().alpha(0.0f).withEndAction(new Runnable() {
@Override
public void run() {
buttonClear.setVisibility(View.GONE);
}
});
} else if (count == 1) {
buttonClear.setVisibility(View.VISIBLE);
buttonClear.animate().alpha(1.0f);
}
if (s != null && s.length() > 3) {
Timber.d("Posting new future search");
mSearchDebouncer.setValue(s);
}
//This means they are backspacing
if (before > count) {
Timber.d("Removing future search");
mSearchDebouncer.cancel();
}
if (s != null && s.length() > 3) {
Timber.d("Posting new future search");
debouncer.setValue(s);
}
@Override
public void afterTextChanged(Editable s) {
//This means they are backspacing
if (before > count) {
Timber.d("Removing future search");
debouncer.cancel();
}
};
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
Loading
Loading
@@ -135,8 +121,6 @@ public class SearchActivity extends BaseActivity {
adapterSearch = new SearchPagerAdapter(this, getSupportFragmentManager());
viewPager.setAdapter(adapterSearch);
tabLayout.setupWithViewPager(viewPager);
textSearch.setOnEditorActionListener(mOnSearchEditorActionListener);
textSearch.addTextChangedListener(mTextWatcher);
}
 
private void search() {
Loading
Loading
Loading
Loading
@@ -24,7 +24,7 @@ import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
/**
* Shows user a WebView for login and intercepts the headers to get the private token. Hmmmm
*/
public class WebviewLoginActivity extends BaseActivity {
public class WebLoginActivity extends BaseActivity {
public static final String EXTRA_TOKEN = "token";
 
private static final String JAVASCRIPT_INTERFACE_EXTRACTOR = "TokenExtractor";
Loading
Loading
@@ -33,7 +33,7 @@ public class WebviewLoginActivity extends BaseActivity {
private static final String KEY_EXTRACTING_PRIVATE_TOKEN = "extracting_private_token";
 
public static Intent newIntent(Context context, String url, boolean extractingPrivateToken) {
Intent intent = new Intent(context, WebviewLoginActivity.class);
Intent intent = new Intent(context, WebLoginActivity.class);
intent.putExtra(KEY_URL, url);
intent.putExtra(KEY_EXTRACTING_PRIVATE_TOKEN, extractingPrivateToken);
return intent;
Loading
Loading
@@ -118,16 +118,16 @@ public class WebviewLoginActivity extends BaseActivity {
url = url.substring(0, url.length() - 1);
}
 
if (url.equals(WebviewLoginActivity.this.url)) {
if (url.equals(WebLoginActivity.this.url)) {
if (isExtracting()) {
webView.loadUrl(WebviewLoginActivity.this.url + "/profile/account");
webView.loadUrl(WebLoginActivity.this.url + "/profile/account");
} else {
webView.loadUrl(WebviewLoginActivity.this.url + "/profile/personal_access_tokens");
webView.loadUrl(WebLoginActivity.this.url + "/profile/personal_access_tokens");
}
return;
}
 
if (url.equals(WebviewLoginActivity.this.url + "/profile/account")) {
if (url.equals(WebLoginActivity.this.url + "/profile/account")) {
webView.loadUrl("javascript:" + JAVASCRIPT_INTERFACE_EXTRACTOR + ".extract" +
"(document.getElementById('token').value);");
return;
Loading
Loading
Loading
Loading
@@ -9,7 +9,6 @@ import android.support.annotation.NonNull;
import android.text.TextUtils;
 
import com.bluelinelabs.logansquare.LoganSquare;
import com.commit451.gitlab.BuildConfig;
import com.commit451.gitlab.model.Account;
 
import java.io.IOException;
Loading
Loading
@@ -24,7 +23,6 @@ import java.util.List;
public class Prefs {
 
private static final String KEY_ACCOUNTS = "accounts";
private static final String KEY_VERSION = "current_version";
private static final String KEY_STARTING_VIEW = "starting_view";
private static final String KEY_REQUIRE_DEVICE_AUTH = "require_device_auth";
 
Loading
Loading
@@ -93,16 +91,6 @@ public class Prefs {
}
}
 
public int getSavedVersion() {
return prefs.getInt(KEY_VERSION, -1);
}
public void setSavedVersion() {
prefs.edit()
.putInt(KEY_VERSION, BuildConfig.VERSION_CODE)
.apply();
}
@StartingView
public int getStartingView() {
@StartingView
Loading
Loading
Loading
Loading
@@ -39,7 +39,7 @@ import com.commit451.gitlab.activity.SearchActivity;
import com.commit451.gitlab.activity.SettingsActivity;
import com.commit451.gitlab.activity.TodosActivity;
import com.commit451.gitlab.activity.UserActivity;
import com.commit451.gitlab.activity.WebviewLoginActivity;
import com.commit451.gitlab.activity.WebLoginActivity;
import com.commit451.gitlab.data.Prefs;
import com.commit451.gitlab.model.Account;
import com.commit451.gitlab.model.Ref;
Loading
Loading
@@ -130,7 +130,7 @@ public class Navigator {
}
 
public static void navigateToWebSignin(Activity activity, String url, boolean extractingPrivateToken, int requestCode) {
Intent intent = WebviewLoginActivity.newIntent(activity, url, extractingPrivateToken);
Intent intent = WebLoginActivity.newIntent(activity, url, extractingPrivateToken);
activity.startActivityForResult(intent, requestCode);
}
 
Loading
Loading
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent">
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent">
 
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="0dp"/>
android:elevation="0dp" />
 
<ImageView
android:layout_width="wrap_content"
Loading
Loading
@@ -17,7 +17,7 @@
android:layout_gravity="center_horizontal"
android:layout_marginTop="32dp"
android:contentDescription="@string/app_name"
app:srcCompat="@drawable/ic_logo"/>
app:srcCompat="@drawable/ic_logo" />
 
<LinearLayout
android:layout_width="match_parent"
Loading
Loading
@@ -39,8 +39,7 @@
android:layout_below="@+id/title"
android:layout_centerHorizontal="true"
android:hint="@string/url_hint"
android:inputType="textUri"
android:text="@string/url_gitlab"/>
android:inputType="textUri" />
 
</android.support.design.widget.TextInputLayout>
 
Loading
Loading
@@ -63,7 +62,7 @@
android:ems="10"
android:hint="@string/user_hint"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"/>
android:inputType="textEmailAddress" />
 
</android.support.design.widget.TextInputLayout>
 
Loading
Loading
@@ -79,7 +78,7 @@
android:layout_below="@+id/user_input"
android:layout_centerHorizontal="true"
android:hint="@string/password_hint"
android:inputType="textPassword"/>
android:inputType="textPassword" />
 
</android.support.design.widget.TextInputLayout>
</LinearLayout>
Loading
Loading
@@ -103,34 +102,34 @@
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:hint="@string/token_hint"
android:inputType="textVisiblePassword"/>
android:inputType="textVisiblePassword" />
</android.support.design.widget.TextInputLayout>
 
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/or"/>
android:text="@string/or" />
 
<Button
android:id="@+id/button_open_login_page"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/open_login_page"/>
android:text="@string/open_login_page" />
 
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/or"/>
android:text="@string/or" />
 
<Button
android:id="@+id/button_open_login_page_for_personal_access"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/open_login_page_for_personal_access_token"/>
android:text="@string/open_login_page_for_personal_access_token" />
</LinearLayout>
 
</LinearLayout>
Loading
Loading
@@ -141,8 +140,8 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="16dp"
android:text="@string/login_button"/>
android:text="@string/login_button" />
 
<include layout="@layout/progress_fullscreen"/>
<include layout="@layout/progress_fullscreen" />
 
</FrameLayout>
\ No newline at end of file
Loading
Loading
@@ -286,7 +286,7 @@
<!-- About -->
<string name="about">About</string>
<string name="contributors">Contributors</string>
<string name="sauce">See the source</string>
<string name="sauce">View project on GitLab</string>
<string name="source_url">https://gitlab.com/Commit451/LabCoat</string>
<string name="failed_to_load_contributors">Failed to load contributors</string>
 
Loading
Loading
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