Removed unused methods and imports
This commit is contained in:
@@ -6,17 +6,10 @@ import android.accounts.AccountManager;
|
|||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.LoaderManager.LoaderCallbacks;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.CursorLoader;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.Loader;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.ContactsContract;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
@@ -24,7 +17,6 @@ import android.view.inputmethod.InputMethodManager;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import de.sebse.fuplanner.R;
|
import de.sebse.fuplanner.R;
|
||||||
|
|
||||||
import static de.sebse.fuplanner.services.fulogin.UserLoginTask.PARAM_USER_PASS;
|
import static de.sebse.fuplanner.services.fulogin.UserLoginTask.PARAM_USER_PASS;
|
||||||
@@ -32,7 +24,7 @@ import static de.sebse.fuplanner.services.fulogin.UserLoginTask.PARAM_USER_PASS;
|
|||||||
/**
|
/**
|
||||||
* A login screen that offers login via email/password.
|
* A login screen that offers login via email/password.
|
||||||
*/
|
*/
|
||||||
public class FUAuthenticatorActivity extends AccountAuthenticatorActivity implements LoaderCallbacks<Cursor> {
|
public class FUAuthenticatorActivity extends AccountAuthenticatorActivity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Id to identity READ_CONTACTS permission request.
|
* Id to identity READ_CONTACTS permission request.
|
||||||
@@ -71,7 +63,6 @@ public class FUAuthenticatorActivity extends AccountAuthenticatorActivity implem
|
|||||||
setContentView(R.layout.activity_fu_authenticator);
|
setContentView(R.layout.activity_fu_authenticator);
|
||||||
// Set up the login form.
|
// Set up the login form.
|
||||||
mEmailView = findViewById(R.id.input_username);
|
mEmailView = findViewById(R.id.input_username);
|
||||||
populateAutoComplete();
|
|
||||||
|
|
||||||
mPasswordView = findViewById(R.id.input_password);
|
mPasswordView = findViewById(R.id.input_password);
|
||||||
mPasswordView.setOnEditorActionListener((textView, id, keyEvent) -> {
|
mPasswordView.setOnEditorActionListener((textView, id, keyEvent) -> {
|
||||||
@@ -89,49 +80,6 @@ public class FUAuthenticatorActivity extends AccountAuthenticatorActivity implem
|
|||||||
mProgressView = findViewById(R.id.login_progress);
|
mProgressView = findViewById(R.id.login_progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateAutoComplete() {
|
|
||||||
if (!mayRequestContacts()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
getLoaderManager().initLoader(0, null, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean mayRequestContacts() {
|
|
||||||
/*if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (checkSelfPermission(READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (shouldShowRequestPermissionRationale(READ_CONTACTS)) {
|
|
||||||
Snackbar.make(mEmailView, R.string.permission_rationale, Snackbar.LENGTH_INDEFINITE)
|
|
||||||
.setAction(android.R.string.ok, new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
@TargetApi(Build.VERSION_CODES.M)
|
|
||||||
public void onClick(View v) {
|
|
||||||
requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS);
|
|
||||||
}*/
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback received when a permissions request has been completed.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
|
||||||
@NonNull int[] grantResults) {
|
|
||||||
if (requestCode == REQUEST_READ_CONTACTS) {
|
|
||||||
if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
populateAutoComplete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to sign in or register the account specified by the login form.
|
* Attempts to sign in or register the account specified by the login form.
|
||||||
@@ -218,43 +166,6 @@ public class FUAuthenticatorActivity extends AccountAuthenticatorActivity implem
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
|
|
||||||
return new CursorLoader(this,
|
|
||||||
// Retrieve data rows for the device user's 'profile' contact.
|
|
||||||
Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
|
|
||||||
ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,
|
|
||||||
|
|
||||||
// Select only email addresses.
|
|
||||||
ContactsContract.Contacts.Data.MIMETYPE +
|
|
||||||
" = ?", new String[]{ContactsContract.CommonDataKinds.Email
|
|
||||||
.CONTENT_ITEM_TYPE},
|
|
||||||
|
|
||||||
// Show primary email addresses first. Note that there won't be
|
|
||||||
// a primary email address if the user hasn't specified one.
|
|
||||||
ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoaderReset(Loader<Cursor> cursorLoader) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private interface ProfileQuery {
|
|
||||||
String[] PROJECTION = {
|
|
||||||
ContactsContract.CommonDataKinds.Email.ADDRESS,
|
|
||||||
ContactsContract.CommonDataKinds.Email.IS_PRIMARY,
|
|
||||||
};
|
|
||||||
|
|
||||||
int ADDRESS = 0;
|
|
||||||
int IS_PRIMARY = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void finishLogin(Intent intent) {
|
void finishLogin(Intent intent) {
|
||||||
String accountName = intent.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
|
String accountName = intent.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
|
||||||
String accountPassword = intent.getStringExtra(PARAM_USER_PASS);
|
String accountPassword = intent.getStringExtra(PARAM_USER_PASS);
|
||||||
|
|||||||
Reference in New Issue
Block a user