Skip to content

Commit

Permalink
Log: Add basic "info" level logging
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-stephenson committed Jan 5, 2023
1 parent 5e9d85e commit e4fd3bb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mobile/src/main/java/org/fedorahosted/freeotp/Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.fedorahosted.freeotp;

import android.net.Uri;
import android.util.Log;
import android.util.Pair;

import com.google.gson.Gson;
Expand Down Expand Up @@ -338,6 +339,7 @@ public Code getCode(Key key) throws InvalidKeyException {
Mac mac;

// Prepare the input.
Log.i("Token", String.format("token.GetCode(): prepare input"));
ByteBuffer bb = ByteBuffer.allocate(8);
bb.order(ByteOrder.BIG_ENDIAN);
switch (mType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public void onItemRangeRemoved(int positionStart, int itemCount) {

private void onActivate(ViewHolder vh) {
try {
Log.i(LOGTAG, String.format("onActivate: adapter.getCode()"));
Code code = mTokenAdapter.getCode(vh.getAdapterPosition());
if (mSettings.getBoolean(AUTO_COPY_CLIPBOARD, false)) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
Expand All @@ -141,6 +142,7 @@ private void onActivate(ViewHolder vh) {
}

Token.Type type = mTokenAdapter.getTokenType(vh.getAdapterPosition());
Log.i(LOGTAG, String.format("onActivate: vh.displayCode()"));
vh.displayCode(code, type);

} catch (UserNotAuthenticatedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
Token token = Token.deserialize(mSharedPreferences.getString(uuid, null));
TokenIcon token_icon = new TokenIcon(token, mContext);
Pair <Integer, String> image = token_icon.mImage;
Log.i(LOGTAG, String.format("Bind to view token [%s][%s]", token.getIssuer(), token.getLabel()));
holder.bind(token, token_icon.mColor, image.first, image.second,
mActive.get(getItemId(position)), isSelected(position), token.getType());
}
Expand Down Expand Up @@ -216,7 +217,6 @@ private int add(SecretKey key, Token token, boolean lock, String existingUuid) t
}

Log.i(LOGTAG, String.format("Token added uuid [%s]", uuid));

this.notifyItemInserted(mItems.size() - 1);
return mItems.size() - 1;
}
Expand Down Expand Up @@ -280,11 +280,13 @@ public Code getCode(int position)
Code code;

try {
Log.i(LOGTAG, String.format("getCode: deserialize token"));
Token token = Token.deserialize(mSharedPreferences.getString(uuid, null));
Key key = mKeyStore.getKey(uuid, null);
code = token.getCode(key);
mSharedPreferences.edit().putString(uuid, token.serialize()).apply();
} catch (UserNotAuthenticatedException | KeyPermanentlyInvalidatedException e) {
Log.e(LOGTAG, "Exception", e);
throw e;
} catch (GeneralSecurityException e) {
Log.e(LOGTAG, "Exception", e);
Expand All @@ -307,6 +309,8 @@ public void run() {
}
}, code.timeLeft());

Log.i(LOGTAG, String.format("getCode: returning code"));

return code;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
Expand All @@ -48,6 +49,7 @@ interface EventListener {
void onActivated(ViewHolder holder);
void onShare(String code);
}
private static final String LOGTAG = "Adapter";

private EventListener mEventListener;
private ObjectAnimator mCountdown;
Expand Down Expand Up @@ -123,6 +125,7 @@ private void displayCode(Code code, Token.Type type, int animationDuration) {
return;

String text = code.getCode();
Log.i(LOGTAG, String.format("displaying Code"));
/* Add spaces for readability */
for (int segment : new int[] { 7, 5, 4, 3 }) {
if (text.length() % segment != 0)
Expand Down Expand Up @@ -191,13 +194,16 @@ public void onAnimationCancel(Animator animation) {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);

/* Fade in */
Log.i(LOGTAG, String.format("onAnimationStart: fade"));
fade(mPassive, false, 500);
fade(mActive, true, 500);
}

@Override
public void onAnimationEnd(Animator animation) {
Log.i(LOGTAG, String.format("onAnimationEnd: fade"));
/* Fade out */
fade(mPassive, true, 500);
fade(mActive, false, 500);
Expand Down

0 comments on commit e4fd3bb

Please sign in to comment.