From e169235d961d93105f210d0c3c4dc29a21008c68 Mon Sep 17 00:00:00 2001 From: Felix Bechstein Date: Wed, 2 Aug 2017 11:15:31 +0200 Subject: Fix more lint (#325) * fix/ignore lint errors, run lint on travis * fix/ignore some lint warnings --- .../java/com/zeapo/pwdstore/GitActivityTest.java | 1 - .../com/zeapo/pwdstore/RepositoryCreation.java | 10 ++---- app/src/main/AndroidManifest.xml | 13 ++++--- .../com/zeapo/pwdstore/DividerItemDecoration.java | 4 +-- .../java/com/zeapo/pwdstore/PasswordStore.java | 8 ++--- .../java/com/zeapo/pwdstore/UserPreference.java | 10 +++--- .../pwdstore/autofill/AutofillRecyclerAdapter.java | 39 ++++++++++----------- .../java/com/zeapo/pwdstore/crypto/PgpHandler.java | 4 +-- .../java/com/zeapo/pwdstore/git/GitActivity.java | 4 --- .../java/com/zeapo/pwdstore/git/GitOperation.java | 10 +++--- .../java/com/zeapo/pwdstore/git/SyncOperation.java | 10 +++--- .../java/com/zeapo/pwdstore/pwgen/PRNGFixes.java | 5 +-- .../java/com/zeapo/pwdstore/pwgen/pw_phonemes.java | 2 +- .../java/com/zeapo/pwdstore/pwgen/pw_rand.java | 2 +- .../java/com/zeapo/pwdstore/pwgen/randnum.java | 2 +- .../com/zeapo/pwdstore/pwgenDialogFragment.java | 2 ++ .../zeapo/pwdstore/utils/EntryRecyclerAdapter.java | 6 ++-- .../com/zeapo/pwdstore/utils/PasswordItem.java | 21 ++--------- .../zeapo/pwdstore/utils/PasswordRepository.java | 3 +- app/src/main/res/drawable-nodpi/autofill_ins_1.png | Bin 0 -> 11931 bytes app/src/main/res/drawable-nodpi/autofill_ins_2.png | Bin 0 -> 6851 bytes app/src/main/res/drawable-nodpi/autofill_ins_3.png | Bin 0 -> 10726 bytes app/src/main/res/drawable/autofill_ins_1.png | Bin 11931 -> 0 bytes app/src/main/res/drawable/autofill_ins_2.png | Bin 6851 -> 0 bytes app/src/main/res/drawable/autofill_ins_3.png | Bin 10726 -> 0 bytes app/src/main/res/drawable/rectangle.xml | 21 ----------- app/src/main/res/layout/activity_git_clone.xml | 16 ++++++--- app/src/main/res/layout/activity_git_config.xml | 4 ++- app/src/main/res/layout/autofill_instructions.xml | 11 +++--- app/src/main/res/layout/autofill_recycler_view.xml | 3 +- app/src/main/res/layout/autofill_row_layout.xml | 8 +++-- app/src/main/res/layout/decrypt_layout.xml | 9 +++-- app/src/main/res/layout/encrypt_layout.xml | 3 +- app/src/main/res/layout/fragment_autofill.xml | 3 +- app/src/main/res/layout/fragment_pwgen.xml | 11 +++--- app/src/main/res/layout/fragment_show_ssh_key.xml | 4 +-- app/src/main/res/layout/fragment_ssh_keygen.xml | 7 ++-- .../main/res/layout/fragment_to_clone_or_not.xml | 7 ++-- app/src/main/res/layout/password_recycler_view.xml | 3 +- app/src/main/res/layout/password_row_layout.xml | 7 ++-- app/src/main/res/values-de/strings.xml | 6 ++++ app/src/main/res/values/strings.xml | 5 +++ 42 files changed, 139 insertions(+), 145 deletions(-) create mode 100644 app/src/main/res/drawable-nodpi/autofill_ins_1.png create mode 100644 app/src/main/res/drawable-nodpi/autofill_ins_2.png create mode 100644 app/src/main/res/drawable-nodpi/autofill_ins_3.png delete mode 100644 app/src/main/res/drawable/autofill_ins_1.png delete mode 100644 app/src/main/res/drawable/autofill_ins_2.png delete mode 100644 app/src/main/res/drawable/autofill_ins_3.png delete mode 100644 app/src/main/res/drawable/rectangle.xml (limited to 'app/src') diff --git a/app/src/androidTest/java/com/zeapo/pwdstore/GitActivityTest.java b/app/src/androidTest/java/com/zeapo/pwdstore/GitActivityTest.java index 6073c211..29684755 100644 --- a/app/src/androidTest/java/com/zeapo/pwdstore/GitActivityTest.java +++ b/app/src/androidTest/java/com/zeapo/pwdstore/GitActivityTest.java @@ -55,7 +55,6 @@ public class GitActivityTest extends ActivityInstrumentationTestCase2 { - private Activity passwordStore; - Instrumentation mInstrumentation; - SharedPreferences settings; public RepositoryCreation() { super(PasswordStore.class); @@ -18,19 +15,18 @@ public class RepositoryCreation extends ActivityInstrumentationTestCase2 + xmlns:tools="http://schemas.android.com/tools" + package="com.zeapo.pwdstore"> - + @@ -57,7 +61,8 @@ + android:excludeFromRecents="true" + tools:ignore="UnusedAttribute"> diff --git a/app/src/main/java/com/zeapo/pwdstore/DividerItemDecoration.java b/app/src/main/java/com/zeapo/pwdstore/DividerItemDecoration.java index 7bc66b62..bc174318 100644 --- a/app/src/main/java/com/zeapo/pwdstore/DividerItemDecoration.java +++ b/app/src/main/java/com/zeapo/pwdstore/DividerItemDecoration.java @@ -8,7 +8,7 @@ import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; import android.view.View; -public class DividerItemDecoration extends RecyclerView.ItemDecoration { +class DividerItemDecoration extends RecyclerView.ItemDecoration { private static final int[] ATTRS = new int[]{android.R.attr.listDivider}; @@ -26,7 +26,7 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration { /** * Custom divider will be used */ - public DividerItemDecoration(Context context, int resId) { + DividerItemDecoration(Context context, int resId) { mDivider = ContextCompat.getDrawable(context, resId); } diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index fb8ec8c7..6c232ab8 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -294,7 +294,7 @@ public class PasswordStore extends AppCompatActivity { checkLocalRepository(); } - public void initializeRepositoryInfo() { + private void initializeRepositoryInfo() { if (settings.getBoolean("git_external", false) && settings.getString("git_external_repo", null) != null) { File dir = new File(settings.getString("git_external_repo", null)); @@ -521,13 +521,13 @@ public class PasswordStore extends AppCompatActivity { /** * Updates the adapter with the current view of passwords */ - public void refreshListAdapter() { + private void refreshListAdapter() { if ((null != plist)) { plist.refreshAdapter(); } } - public void filterListAdapter(String filter) { + private void filterListAdapter(String filter) { if ((null != plist)) { plist.filterAdapter(filter); } @@ -643,7 +643,7 @@ public class PasswordStore extends AppCompatActivity { } } - protected void initRepository(final int operation) { + private void initRepository(final int operation) { PasswordRepository.closeRepository(); new AlertDialog.Builder(this) diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java index 9ac88ef6..e39ad1c6 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java @@ -285,7 +285,7 @@ public class UserPreference extends AppCompatActivity { getSupportActionBar().setDisplayHomeAsUpEnabled(true); } - public void selectExternalGitRepository() { + private void selectExternalGitRepository() { final Activity activity = this; new AlertDialog.Builder(this). setTitle("Choose where to store the passwords"). @@ -332,7 +332,7 @@ public class UserPreference extends AppCompatActivity { /** * Opens a file explorer to import the private key */ - public void getSshKeyWithPermissions(boolean useDefaultPicker) { + private void getSshKeyWithPermissions(boolean useDefaultPicker) { final Activity activity = this; if (ContextCompat.checkSelfPermission(activity, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.READ_EXTERNAL_STORAGE)) { @@ -362,7 +362,7 @@ public class UserPreference extends AppCompatActivity { /** * Opens a file explorer to import the private key */ - public void getSshKey(boolean useDefaultPicker) { + private void getSshKey(boolean useDefaultPicker) { if (useDefaultPicker) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); @@ -382,7 +382,7 @@ public class UserPreference extends AppCompatActivity { } } - public void exportPasswordsWithPermissions() { + private void exportPasswordsWithPermissions() { final Activity activity = this; if (ContextCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { @@ -421,7 +421,7 @@ public class UserPreference extends AppCompatActivity { /** * Opens a key generator to generate a public/private key pair */ - public void makeSshKey(boolean fromPreferences) { + private void makeSshKey(boolean fromPreferences) { Intent intent = new Intent(getApplicationContext(), SshKeyGen.class); startActivity(intent); if (!fromPreferences) { diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java index 80942c58..b28687d8 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.java @@ -18,23 +18,23 @@ import com.zeapo.pwdstore.R; import java.util.ArrayList; import java.util.List; -public class AutofillRecyclerAdapter extends RecyclerView.Adapter { +class AutofillRecyclerAdapter extends RecyclerView.Adapter { private SortedList apps; private ArrayList allApps; // for filtering, maintain a list of all private AutofillPreferenceActivity activity; - Drawable browserIcon = null; + private Drawable browserIcon = null; - public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public View view; public TextView name; - public TextView secondary; + TextView secondary; public ImageView icon; - public String packageName; - public String appName; - public Boolean isWeb; + String packageName; + String appName; + Boolean isWeb; - public ViewHolder(View view) { + ViewHolder(View view) { super(view); this.view = view; name = (TextView) view.findViewById(R.id.app_name); @@ -50,13 +50,13 @@ public class AutofillRecyclerAdapter extends RecyclerView.Adapter allApps, final PackageManager pm + AutofillRecyclerAdapter(List allApps, final PackageManager pm , AutofillPreferenceActivity activity) { SortedList.Callback callback = new SortedListAdapterCallback(this) { // don't take into account secondary text. This is good enough @@ -92,7 +92,6 @@ public class AutofillRecyclerAdapter extends RecyclerView.Adapter(AppInfo.class, callback); this.apps.addAll(allApps); this.allApps = new ArrayList<>(allApps); - PackageManager pm1 = pm; this.activity = activity; try { browserIcon = activity.getPackageManager().getApplicationIcon("com.android.browser"); @@ -155,28 +154,28 @@ public class AutofillRecyclerAdapter extends RecyclerView.Adapter files = new ArrayList<>(Arrays.asList(path.listFiles((FileFilter) FileFilterUtils.directoryFileFilter()))); - files.addAll(new ArrayList<>((List) FileUtils.listFiles(path, new String[]{"gpg"}, false))); + files.addAll(new ArrayList<>(FileUtils.listFiles(path, new String[]{"gpg"}, false))); return new ArrayList<>(files); } diff --git a/app/src/main/res/drawable-nodpi/autofill_ins_1.png b/app/src/main/res/drawable-nodpi/autofill_ins_1.png new file mode 100644 index 00000000..56052303 Binary files /dev/null and b/app/src/main/res/drawable-nodpi/autofill_ins_1.png differ diff --git a/app/src/main/res/drawable-nodpi/autofill_ins_2.png b/app/src/main/res/drawable-nodpi/autofill_ins_2.png new file mode 100644 index 00000000..36767847 Binary files /dev/null and b/app/src/main/res/drawable-nodpi/autofill_ins_2.png differ diff --git a/app/src/main/res/drawable-nodpi/autofill_ins_3.png b/app/src/main/res/drawable-nodpi/autofill_ins_3.png new file mode 100644 index 00000000..8e423209 Binary files /dev/null and b/app/src/main/res/drawable-nodpi/autofill_ins_3.png differ diff --git a/app/src/main/res/drawable/autofill_ins_1.png b/app/src/main/res/drawable/autofill_ins_1.png deleted file mode 100644 index 56052303..00000000 Binary files a/app/src/main/res/drawable/autofill_ins_1.png and /dev/null differ diff --git a/app/src/main/res/drawable/autofill_ins_2.png b/app/src/main/res/drawable/autofill_ins_2.png deleted file mode 100644 index 36767847..00000000 Binary files a/app/src/main/res/drawable/autofill_ins_2.png and /dev/null differ diff --git a/app/src/main/res/drawable/autofill_ins_3.png b/app/src/main/res/drawable/autofill_ins_3.png deleted file mode 100644 index 8e423209..00000000 Binary files a/app/src/main/res/drawable/autofill_ins_3.png and /dev/null differ diff --git a/app/src/main/res/drawable/rectangle.xml b/app/src/main/res/drawable/rectangle.xml deleted file mode 100644 index 27546153..00000000 --- a/app/src/main/res/drawable/rectangle.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_git_clone.xml b/app/src/main/res/layout/activity_git_clone.xml index 8001f94d..e24fbf99 100644 --- a/app/src/main/res/layout/activity_git_clone.xml +++ b/app/src/main/res/layout/activity_git_clone.xml @@ -11,7 +11,7 @@ @@ -71,6 +71,7 @@ android:hint="@string/server_user_hint" android:id="@+id/server_user" android:layout_marginLeft="8dp" + android:layout_marginStart="8dp" android:layout_toEndOf="@+id/label_server_user" android:layout_toRightOf="@+id/label_server_user" android:layout_alignParentRight="true" @@ -99,11 +100,13 @@ android:hint="@string/server_url_hint" android:id="@+id/server_url" android:layout_marginLeft="8dp" + android:layout_marginStart="8dp" android:layout_toEndOf="@+id/label_server_url" android:layout_toRightOf="@+id/label_server_url" android:layout_toLeftOf="@+id/label_server_port" android:layout_toStartOf="@+id/label_server_port" - android:inputType="textWebEmailAddress" /> + android:inputType="textWebEmailAddress" + tools:ignore="TextFields" /> @@ -147,6 +151,7 @@ android:layout_height="wrap_content" android:hint="@string/server_path_hint" android:layout_marginLeft="8dp" + android:layout_marginStart="8dp" android:id="@+id/server_path" android:layout_toEndOf="@+id/label_server_path" android:layout_toRightOf="@+id/label_server_path" @@ -162,7 +167,7 @@ android:text="@string/server_resulting_url" android:textStyle="bold" style="@android:style/TextAppearance.Large" - android:gravity="left" + android:gravity="start" android:paddingBottom="6dp" android:textColor="@color/blue_grey_500" android:background="@drawable/bottom_line"/> @@ -172,7 +177,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/repository_uri" - android:inputType="textWebEmailAddress" /> + android:inputType="textWebEmailAddress" + tools:ignore="TextFields" /> @@ -47,6 +47,7 @@ android:hint="@string/git_user_name_hint" android:id="@+id/git_user_name" android:layout_marginLeft="8dp" + android:layout_marginStart="8dp" android:layout_toEndOf="@+id/label_git_user_name" android:layout_toRightOf="@+id/label_git_user_name" android:layout_alignParentRight="true" @@ -76,6 +77,7 @@ android:hint="@string/git_user_email_hint" android:id="@+id/git_user_email" android:layout_marginLeft="35dp" + android:layout_marginStart="35dp" android:layout_toEndOf="@+id/label_git_user_email" android:layout_toRightOf="@+id/label_git_user_email" android:layout_alignParentRight="true" diff --git a/app/src/main/res/layout/autofill_instructions.xml b/app/src/main/res/layout/autofill_instructions.xml index 0316dd91..333cd5fa 100644 --- a/app/src/main/res/layout/autofill_instructions.xml +++ b/app/src/main/res/layout/autofill_instructions.xml @@ -5,7 +5,7 @@ + android:src="@drawable/autofill_ins_1" + android:contentDescription="@string/autofill_ins_1_hint" /> + android:src="@drawable/autofill_ins_2" + android:contentDescription="@string/autofill_ins_2_hint" /> + android:src="@drawable/autofill_ins_3" + android:contentDescription="@string/autofill_ins_3_hint" /> + android:layout_alignParentRight="true" + android:layout_alignParentEnd="true"/> \ No newline at end of file diff --git a/app/src/main/res/layout/autofill_row_layout.xml b/app/src/main/res/layout/autofill_row_layout.xml index 117a76fc..e07a73d3 100644 --- a/app/src/main/res/layout/autofill_row_layout.xml +++ b/app/src/main/res/layout/autofill_row_layout.xml @@ -1,5 +1,6 @@ + android:layout_height="48dp" + android:contentDescription="@string/app_icon_hint"/> + android:orientation="vertical" + tools:ignore="RtlHardcoded"> - \ No newline at end of file diff --git a/app/src/main/res/layout/decrypt_layout.xml b/app/src/main/res/layout/decrypt_layout.xml index f076dbad..5d9e66ab 100644 --- a/app/src/main/res/layout/decrypt_layout.xml +++ b/app/src/main/res/layout/decrypt_layout.xml @@ -24,6 +24,7 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="16dp" + android:layout_marginStart="16dp" android:text="CATEGORY HERE" android:textColor="@color/grey_500" android:textIsSelectable="false" @@ -35,6 +36,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/activity_horizontal_margin" + android:layout_marginStart="@dimen/activity_horizontal_margin" android:text="PASSWORD FILE NAME HERE" android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium" android:textColor="@color/accent" @@ -48,7 +50,8 @@ android:layout_height="wrap_content" android:src="@drawable/divider" android:layout_marginTop="16dp" - android:layout_marginBottom="16dp" /> + android:layout_marginBottom="16dp" + tools:ignore="ContentDescription" /> @@ -140,7 +143,7 @@ android:layout_alignParentStart="true" android:layout_below="@id/crypto_username_show_label" android:layout_toLeftOf="@id/crypto_copy_username" - android:layout_toEndOf="@id/crypto_copy_username" + android:layout_toStartOf="@id/crypto_copy_username" android:textColor="@android:color/black" android:textIsSelectable="true" android:typeface="monospace" /> diff --git a/app/src/main/res/layout/encrypt_layout.xml b/app/src/main/res/layout/encrypt_layout.xml index ebb5e4dd..fffc9032 100644 --- a/app/src/main/res/layout/encrypt_layout.xml +++ b/app/src/main/res/layout/encrypt_layout.xml @@ -19,6 +19,7 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="@dimen/activity_horizontal_margin" + android:layout_marginStart="@dimen/activity_horizontal_margin" android:text="CATEGORY HERE" android:textColor="@color/grey_500" android:textIsSelectable="false" @@ -77,7 +78,7 @@ android:id="@+id/generate_password" android:text="@string/pwd_generate_button" android:onClick="handleClick" - android:layout_gravity="right" /> + android:layout_gravity="end" /> + android:layout_gravity="center_horizontal" + tools:ignore="HardcodedText" /> - + android:weightSum="2"> - - - - @@ -44,7 +45,8 @@ android:layout_marginRight="@dimen/activity_horizontal_margin" android:layout_marginEnd="@dimen/activity_horizontal_margin" android:layout_marginTop="@dimen/activity_vertical_margin" - android:textAllCaps="true"/> + android:textAllCaps="true" + tools:ignore="RelativeOverlap" /> + android:textSize="11sp" + tools:ignore="RelativeOverlap" /> diff --git a/app/src/main/res/layout/password_recycler_view.xml b/app/src/main/res/layout/password_recycler_view.xml index bef664ba..9c56210f 100644 --- a/app/src/main/res/layout/password_recycler_view.xml +++ b/app/src/main/res/layout/password_recycler_view.xml @@ -26,5 +26,6 @@ app:borderWidth="0dp" android:layout_margin="@dimen/fab_compat_margin" android:layout_alignParentBottom="true" - android:layout_alignParentRight="true"/> + android:layout_alignParentRight="true" + android:layout_alignParentEnd="true"/> diff --git a/app/src/main/res/layout/password_row_layout.xml b/app/src/main/res/layout/password_row_layout.xml index 43df2ecf..285af1cf 100644 --- a/app/src/main/res/layout/password_row_layout.xml +++ b/app/src/main/res/layout/password_row_layout.xml @@ -12,18 +12,21 @@ android:paddingBottom="8dp" android:paddingLeft="16dp" android:paddingRight="16dp" - android:gravity="left"> + android:gravity="start"> + android:paddingRight="8dp" + android:paddingEnd="8dp" + tools:ignore="RtlSymmetry" /> Passwort senden als Nur-Text mit behilfe von… Password wiedergeben Repository URI + App Icon + Verzeichnis Icon + Füge das Passwort automatisch in Apps ein (Autofill). Funktioniert nur unter Android 4.3 und höher. Dies basiert nicht auf der Zwischenablage für Android 5.0 oder höher. @@ -188,4 +191,7 @@ Einfügen Benutzername einfügen?\n\n%s Wähle ein editierbares Feld um den Benutzernamen einzufügen.\nDer Benutzername ist für %d Sekunden verfügbar. + Bildschirmfoto Accessibility Services + Bildschirmfoto des Schalters in Accessibility Services + Bildschirmfoto von Autofill in Aktion diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index edb2347c..8700a917 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -182,6 +182,8 @@ Send password as plaintext using… Show password Repository URI + App icon + Folder icon Autofills password fields in apps. Only works for Android versions 4.3 and up. Does not rely on the clipboard for Android versions 5.0 and up. @@ -196,4 +198,7 @@ Paste Paste username?\n\n%s Select an editable field to past the username.\nUsername is available for %d seconds. + Screenshot of accessibility services + Screenshot of toggle in accessibility services + Screenshot of autofill service in action -- cgit v1.2.3