Skip to content

Commit

Permalink
Removed separate activity for choosing an account type and added a FA…
Browse files Browse the repository at this point in the history
…B menu instead
  • Loading branch information
wilco375 committed Jul 28, 2018
1 parent 8230766 commit 6e235f3
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 158 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ dependencies {

implementation 'com.github.wilco375:SlideAndDragListView:0.7.9'

implementation 'com.github.clans:fab:1.6.4'

androidTestImplementation 'org.mockito:mockito-core:1.9.5'
androidTestImplementation 'com.google.dexmaker:dexmaker:1.2'
androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.2'
Expand Down

This file was deleted.

4 changes: 0 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@
android:name=".activity.SettingsAboutActivity"
android:label="@string/about_preference_screen_title" />

<activity
android:name=".activity.AddOtherAccountActivity"
android:label="@string/add_account_menu_item" />

<activity
android:name=".activity.EnterKeyActivity"
android:label="@string/enter_key_title" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;

import com.wilco375.onetwoauthenticate.activity.AddOtherAccountActivity;
import com.wilco375.onetwoauthenticate.activity.AuthenticatorActivity;
import com.wilco375.onetwoauthenticate.database.AccountDb;
import com.wilco375.onetwoauthenticate.otp.OtpProvider;
Expand Down Expand Up @@ -80,9 +78,4 @@ public void onAuthenticatorActivityGetNextOtpFailed(
public Dialog onAuthenticatorActivityCreateDialog(AuthenticatorActivity activity, int id) {
return null;
}

@Override
public void onAuthenticatorActivityAddAccount(AuthenticatorActivity activity) {
activity.startActivity(new Intent(activity, AddOtherAccountActivity.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ void onAuthenticatorActivityGetNextOtpFailed(
*/
Dialog onAuthenticatorActivityCreateDialog(AuthenticatorActivity activity, int id);

/**
* Invoked when {@link AuthenticatorActivity} was asked to initiate the Add Account flow.
*/
void onAuthenticatorActivityAddAccount(AuthenticatorActivity activity);

/**
* Invoked when a URI has been scanned.
*
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,6 @@ public void onCreate(Bundle savedInstanceState) {
mContentNoAccounts.setVisibility((mUsers.size() > 0) ? View.GONE : View.VISIBLE);
mContentAccountsPresent.setVisibility((mUsers.size() > 0) ? View.VISIBLE : View.GONE);

findViewById(R.id.add_account_button).setOnClickListener(v -> addAccount());

mUserAdapter = new PinListAdapter(this, R.layout.user_row, mUsers);

mUserList.setVisibility(View.GONE);
Expand Down Expand Up @@ -324,7 +322,8 @@ public void onDragViewDown(int finalPosition) {
}
});

findViewById(R.id.add_account_fab).setOnClickListener(view -> addAccount());
findViewById(R.id.add_account_manual).setOnClickListener(view -> manuallyEnterAccountDetails());
findViewById(R.id.add_account_scan).setOnClickListener(view -> scanBarcode());

if (savedInstanceState == null) {
// This is the first time this Activity is starting (i.e., not restoring previous state which
Expand Down Expand Up @@ -942,8 +941,11 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) {
}
}

private void addAccount() {
DependencyInjector.getOptionalFeatures().onAuthenticatorActivityAddAccount(this);

private void manuallyEnterAccountDetails() {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClass(this, EnterKeyActivity.class);
startActivity(intent);
}

private void scanBarcode() {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_keyboard_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M20,5L4,5c-1.1,0 -1.99,0.9 -1.99,2L2,17c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,7c0,-1.1 -0.9,-2 -2,-2zM11,8h2v2h-2L11,8zM11,11h2v2h-2v-2zM8,8h2v2L8,10L8,8zM8,11h2v2L8,13v-2zM7,13L5,13v-2h2v2zM7,10L5,10L5,8h2v2zM16,17L8,17v-2h8v2zM16,13h-2v-2h2v2zM16,10h-2L14,8h2v2zM19,13h-2v-2h2v2zM19,10h-2L17,8h2v2z"/>
</vector>
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/ic_scanner_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="20dp"
android:width="20dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#fff" android:pathData="M4,6H6V18H4V6M7,6H8V18H7V6M9,6H12V18H9V6M13,6H14V18H13V6M16,6H18V18H16V6M19,6H20V18H19V6M2,4V8H0V4A2,2 0 0,1 2,2H6V4H2M22,2A2,2 0 0,1 24,4V8H22V4H18V2H22M2,16V20H6V22H2A2,2 0 0,1 0,20V16H2M22,20V16H24V20A2,2 0 0,1 22,22H18V20H22Z" />
</vector>
35 changes: 33 additions & 2 deletions app/src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
-->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:clipToPadding="true">
Expand Down Expand Up @@ -83,7 +84,7 @@
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true" />

<android.support.design.widget.FloatingActionButton
<!--<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -95,5 +96,35 @@
android:id="@+id/add_account_fab"
app:backgroundTint="@color/theme_color"
android:layout_alignParentEnd="true"
android:layout_marginEnd="15sp" />
android:layout_marginEnd="15sp" />-->

<com.github.clans.fab.FloatingActionMenu
android:id="@+id/add_account_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="15sp"
android:layout_marginRight="15sp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="15sp"
fab:menu_animationDelayPerItem="0"
fab:menu_shadowColor="#444"
fab:menu_colorNormal="@color/theme_color">

<com.github.clans.fab.FloatingActionButton
android:id="@+id/add_account_scan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_scanner_white_24dp"
fab:fab_size="mini" />

<com.github.clans.fab.FloatingActionButton
android:id="@+id/add_account_manual"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_keyboard_white_24dp"
fab:fab_size="mini" />

</com.github.clans.fab.FloatingActionMenu>
</RelativeLayout>

0 comments on commit 6e235f3

Please sign in to comment.