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

Remove GET_ACCOUNTS permission since it requires a privacy policy

parent 811d3429
No related branches found
No related tags found
No related merge requests found
Pipeline #
Showing
with 50 additions and 93 deletions
Loading
Loading
@@ -17,7 +17,7 @@ apply plugin: 'io.fabric'
 
def versionMajor = 2
def versionMinor = 4
def versionPatch = 1
def versionPatch = 2
def versionBuild = 0 // bump for dogfood builds, public betas, etc.
 
android {
Loading
Loading
Loading
Loading
@@ -5,7 +5,6 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
 
<application
android:name=".App"
Loading
Loading
Loading
Loading
@@ -122,7 +122,7 @@ public class AddIssueActivity extends MorphActivity {
members = new HashSet<>();
adapterLabels = new AddIssueLabelAdapter(new AddIssueLabelAdapter.Listener() {
@Override
public void onLabelLongClicked(final Label label) {
public void onLabelClicked(final Label label) {
new AlertDialog.Builder(AddIssueActivity.this)
.setTitle(R.string.remove)
.setMessage(R.string.are_you_sure_you_want_to_remove)
Loading
Loading
package com.commit451.gitlab.activity;
 
import android.Manifest;
import android.accounts.AccountManager;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.security.KeyChain;
Loading
Loading
@@ -16,15 +12,11 @@ import android.security.KeyChainAliasCallback;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputLayout;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.AppCompatAutoCompleteTextView;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.Patterns;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.TextView;
 
import com.bluelinelabs.logansquare.LoganSquare;
Loading
Loading
@@ -53,12 +45,8 @@ import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import java.io.IOException;
import java.net.ConnectException;
import java.security.cert.CertificateEncodingException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
 
import javax.net.ssl.SSLHandshakeException;
Loading
Loading
@@ -83,7 +71,6 @@ public class LoginActivity extends BaseActivity {
 
private static final String EXTRA_SHOW_CLOSE = "show_close";
 
private static final int REQUEST_PERMISSION_GET_ACCOUNTS = 1337;
private static final int REQUEST_PRIVATE_TOKEN = 123;
private static Pattern sTokenPattern = Pattern.compile("^[A-Za-z0-9-_]*$");
 
Loading
Loading
@@ -108,7 +95,7 @@ public class LoginActivity extends BaseActivity {
@BindView(R.id.user_input_hint)
TextInputLayout textInputLayoutUser;
@BindView(R.id.user_input)
AppCompatAutoCompleteTextView textUser;
EditText textUser;
@BindView(R.id.password_hint)
TextInputLayout textInputLayoutPassword;
@BindView(R.id.password_input)
Loading
Loading
@@ -234,37 +221,9 @@ public class LoginActivity extends BaseActivity {
});
}
 
textUser.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
checkAccountPermission();
}
}
});
textUrl.setText(R.string.url_gitlab);
}
 
@TargetApi(23)
private void checkAccountPermission() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.GET_ACCOUNTS) == PackageManager.PERMISSION_GRANTED) {
retrieveAccounts();
} else {
requestPermissions(new String[]{Manifest.permission.GET_ACCOUNTS}, REQUEST_PERMISSION_GET_ACCOUNTS);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
switch (requestCode) {
case REQUEST_PERMISSION_GET_ACCOUNTS: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
retrieveAccounts();
}
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Loading
Loading
@@ -599,36 +558,4 @@ public class LoginActivity extends BaseActivity {
}
return false;
}
/**
* Manually retrieve the accounts, typically used for API 23+ after getting the permission. Called automatically
* on creation, but needs to be recalled if the permission is granted later
*/
private void retrieveAccounts() {
Collection<String> accounts = getEmailAccounts();
if (accounts != null && !accounts.isEmpty()) {
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
R.layout.support_simple_spinner_dropdown_item,
new ArrayList<>(accounts));
textUser.setAdapter(adapter);
}
}
/**
* Get all the accounts that appear to be email accounts. HashSet so that we do not get duplicates
*
* @return list of email accounts
*/
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()) {
emailAccounts.add(account.name);
}
}
return emailAccounts;
}
}
Loading
Loading
@@ -5,6 +5,7 @@ import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
 
import com.commit451.adapterlayout.AdapterLayout;
import com.commit451.gitlab.model.api.Label;
import com.commit451.gitlab.viewHolder.AddLabelViewHolder;
 
Loading
Loading
@@ -50,12 +51,12 @@ public class AddIssueLabelAdapter extends RecyclerView.Adapter<AddLabelViewHolde
@Override
public AddLabelViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
final AddLabelViewHolder holder = AddLabelViewHolder.inflate(parent);
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public boolean onLongClick(View v) {
Label label = getEntry(holder.getAdapterPosition());
listener.onLabelLongClicked(label);
return true;
public void onClick(View v) {
int position = AdapterLayout.getAdapterPosition(holder);
Label label = getEntry(position);
listener.onLabelClicked(label);
}
});
return holder;
Loading
Loading
@@ -94,6 +95,6 @@ public class AddIssueLabelAdapter extends RecyclerView.Adapter<AddLabelViewHolde
}
 
public interface Listener {
void onLabelLongClicked(Label label);
void onLabelClicked(Label label);
}
}
Loading
Loading
@@ -15,6 +15,7 @@ import okhttp3.Authenticator;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.Route;
import timber.log.Timber;
 
/**
* If it detects a 401, redirect the user to the login screen, clearing activity the stack.
Loading
Loading
@@ -33,6 +34,7 @@ public class OpenSignInAuthenticator implements Authenticator {
//Special case for if someone just put in their username or password wrong
if (!"session".equals(response.request().url().pathSegments().get(response.request().url().pathSegments().size()-1))) {
//Off the background thread
Timber.wtf(new RuntimeException("Got a 401 and showing sign in for url: " + response.request().url()));
ThreadUtil.postOnMainThread(new Runnable() {
@Override
public void run() {
Loading
Loading
Loading
Loading
@@ -52,7 +52,12 @@ public class DiffHeaderViewHolder extends RecyclerView.ViewHolder {
.into(image);
 
textAuthor.setText(commit.getAuthorName());
textTime.setText(DateUtil.getRelativeTimeSpanString(itemView.getContext(), commit.getCreatedAt()));
if (commit.getCreatedAt() == null) {
textTime.setText(null);
} else {
textTime.setText(DateUtil.getRelativeTimeSpanString(itemView.getContext(), commit.getCreatedAt()));
}
textTitle.setText(commit.getTitle());
String message = extractMessage(commit.getTitle(), commit.getMessage());
textMessage.setText(message);
Loading
Loading
Loading
Loading
@@ -148,6 +148,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:text="@string/add_labels"/>
 
</LinearLayout>
Loading
Loading
Loading
Loading
@@ -54,12 +54,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
 
<android.support.v7.widget.AppCompatAutoCompleteTextView
<android.support.design.widget.TextInputEditText
android:id="@+id/user_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:ems="10"
android:hint="@string/user_hint"
android:imeOptions="actionNext"
android:inputType="textEmailAddress" />
Loading
Loading
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/Card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp">
Loading
Loading
@@ -10,9 +10,9 @@
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:padding="8dp"
android:textSize="14sp"
tools:background="@color/red"
tools:text="Bug"/>
tools:text="Bug" />
 
</android.support.v7.widget.CardView>
\ No newline at end of file
Loading
Loading
@@ -13,7 +13,7 @@
<item name="alertDialogTheme">@style/AppDialogTheme</item>
</style>
 
<style name="Activity" parent="AppTheme"/>
<style name="Activity" parent="AppTheme" />
 
<style name="Activity.Login">
<item name="android:windowBackground">?attr/colorPrimary</item>
Loading
Loading
@@ -51,7 +51,7 @@
<item name="android:windowIsFloating">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="lollipop">true</item>
</style>
 
<!-- Widget styles -->
Loading
Loading
package com.commit451.gitlab.util;
import android.util.Log;
import com.crashlytics.android.Crashlytics;
import timber.log.Timber;
/**
* Logs all {@link timber.log.Timber#wtf(String, Object...)} calls to Crashlytics
*/
public class CrashlyticsWtfTree extends Timber.Tree {
@Override
protected void log(int priority, String tag, String message, Throwable t) {
if (priority == Log.ASSERT) {
Crashlytics.log(Log.ASSERT, tag, message);
}
}
}
Loading
Loading
@@ -7,6 +7,7 @@ import com.commit451.gitlab.BuildConfig;
import com.crashlytics.android.Crashlytics;
 
import io.fabric.sdk.android.Fabric;
import timber.log.Timber;
 
/**
* Enables Fabric
Loading
Loading
@@ -17,6 +18,7 @@ public class FabricUtil {
// Start crashlytics if enabled
if (!BuildConfig.DEBUG) {
Fabric.with(context, new Crashlytics());
Timber.plant(new CrashlyticsWtfTree());
}
}
}
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