Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Note that this SDK is geared towards those who need both backend data and UI fea
To install Hyperwallet UI SDK, you just need to add the dependency into your build.gradle file in Android Studio (or Gradle). For example:

```bash
api 'com.hyperwallet.android:ui-sdk:1.0.0-beta02'
api 'com.hyperwallet.android.ui:ui-sdk:1.0.0-beta02'
```

## Initialization
Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ allprojects {
subprojects {

ext {
hyperwalletGroupId = 'com.hyperwallet.android'
hyperwalletGroupId = 'com.hyperwallet.android.ui'

compileVersion = 28
minVersion = 21
Expand All @@ -45,6 +45,8 @@ subprojects {
constraintlayoutVersion = '1.1.3'
legacySupportV4Version = '1.0.0'
recycleViewVersion = '1.0.0'
lifecycleExtensionsVersion = '2.0.0'
pagingRuntimeVersion = '2.1.0'
//Testing
extJunitVerson = '1.1.1'
testRunnerVersion = '1.2.0'
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ sonarqube {
properties {
def libraries = project.android.sdkDirectory.getPath() + "/platforms/android-28/android.jar"
property "sonar.sources", "src/main/java"
property "sonar.binaries", "build/intermediates/javac/release/compileReleaseJavaWithJavac/classes/com/hyperwallet/android"
property "sonar.binaries", "build/intermediates/javac/release/compileReleaseJavaWithJavac/classes/com/hyperwallet/android/ui"
property "sonar.libraries", libraries
property "sonar.projectName", "android-ui-sdk-common"
}
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<manifest
package="com.hyperwallet.android.common"/>
package="com.hyperwallet.android.ui.common"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* The MIT License (MIT)
* Copyright (c) 2019 Hyperwallet Systems Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.hyperwallet.android.ui.common.util;

import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

/**
* Common HW-SDK UI Date Utility class, that will assist on safe presentation of date whatever the mobile device setting
* is set Locale, Timezone and etc... that dictates how that dates are being presented
*
* Moreover all date string to {@link Date} object conversion is automatically converted from
* GMT date string from API to locale Date set by the phone
*/
public final class DateUtils {

private static final String DATE_FORMAT = "yyyy-MM-dd";
private static final String DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
private static final String DATE_TIME_FORMAT_MILLISECONDS = "yyyy-MM-dd'T'HH:mm:ss.SSS";
private static final TimeZone API_TIMEZONE = TimeZone.getTimeZone("GMT");

private DateUtils() {
}

/**
* Creates a string date format: <code>yyyy-MM-dd</code>
*
* @param date Date object
* @return string date in <code>yyyy-MM-dd</code> format
*/
public static String toDateFormat(@NonNull final Date date) {
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
dateFormat.setTimeZone(TimeZone.getDefault());
return dateFormat.format(date);
}

/**
* Creates a string date in specified format
*
* @param date Date object
* @param format specify desired format of date
* @return formatted date string based on format specified
*/
public static String toDateFormat(@NonNull final Date date, @NonNull final String format) {
SimpleDateFormat dateFormat = new SimpleDateFormat(format, Locale.getDefault());
dateFormat.setTimeZone(TimeZone.getDefault());
return dateFormat.format(date);
}

/**
* Creates a string date format
*
* @param date Date object
* @return formatted string in <code>yyyy-MM-dd'T'HH:mm:ss</code> format
*/
public static String toDateTimeFormat(@NonNull final Date date) {
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT, Locale.getDefault());
dateFormat.setTimeZone(TimeZone.getDefault());
return dateFormat.format(date);
}

/**
* Creates a string date format
*
* @param date Date object
* @return formatted string in <code>yyyy-MM-dd'T'HH:mm:ss.SSS</code> format
*/
public static String toDateTimeMillisFormat(@NonNull final Date date) {
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT_MILLISECONDS, Locale.getDefault());
dateFormat.setTimeZone(TimeZone.getDefault());
return dateFormat.format(date);
}

/**
* Creates a Date object from string date using API Timezone
*
* @param dateString String date from API with GMT timezone
* @return date Date object converted to local timezone
* @throws IllegalArgumentException when string is un-parsable
*/
public static Date fromDateTimeString(@NonNull final String dateString) {
try {
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT, Locale.getDefault());
dateFormat.setTimeZone(API_TIMEZONE);
return dateFormat.parse(dateString);
} catch (ParseException e) {
throw new IllegalArgumentException("An exception occurred when attempting to parse " +
"the date " + dateString, e);
}
}

@VisibleForTesting
static Date fromDateTimeString(@NonNull final String dateString, @NonNull final String format) {
try {
SimpleDateFormat dateFormat = new SimpleDateFormat(format, Locale.getDefault());
dateFormat.setTimeZone(API_TIMEZONE);
return dateFormat.parse(dateString);
} catch (ParseException e) {
throw new IllegalArgumentException("An exception occurred when attempting to parse " +
"the date " + dateString, e);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hyperwallet.android.common.util;
package com.hyperwallet.android.ui.common.util;

import androidx.test.espresso.IdlingResource;
import androidx.test.espresso.idling.CountingIdlingResource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.hyperwallet.android.ui.view;
package com.hyperwallet.android.ui.common.view;

import android.content.Context;
import android.graphics.Canvas;
Expand All @@ -26,12 +26,12 @@
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.hyperwallet.android.hyperwallet_ui.R;
import com.hyperwallet.android.ui.common.R;

public class HorizontalDividerItemDecorator extends RecyclerView.ItemDecoration {

private final Drawable mHorizontalItemDivider;
private final int mDefaultPadding;
protected final Drawable mHorizontalItemDivider;
protected final int mDefaultPadding;

public HorizontalDividerItemDecorator(@NonNull final Context context, final boolean withHeaderDivider) {
mHorizontalItemDivider = context.getResources().getDrawable(R.drawable.horizontal_divider, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.hyperwallet.android.common.view.error;
package com.hyperwallet.android.ui.common.view.error;

import static com.hyperwallet.android.ExceptionMapper.EC_AUTHENTICATION_TOKEN_PROVIDER_EXCEPTION;
import static com.hyperwallet.android.ExceptionMapper.EC_IO_EXCEPTION;
Expand All @@ -33,8 +33,8 @@
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentManager;

import com.hyperwallet.android.common.R;
import com.hyperwallet.android.model.HyperwalletError;
import com.hyperwallet.android.ui.common.R;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.hyperwallet.android.common.view.error;
package com.hyperwallet.android.ui.common.view.error;

import android.content.res.Resources;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.hyperwallet.android.common.view.error;
package com.hyperwallet.android.ui.common.view.error;

import static com.hyperwallet.android.ExceptionMapper.EC_AUTHENTICATION_TOKEN_PROVIDER_EXCEPTION;
import static com.hyperwallet.android.ExceptionMapper.EC_IO_EXCEPTION;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hyperwallet.android.common.view.error;
package com.hyperwallet.android.ui.common.view.error;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* The MIT License (MIT)
* Copyright (c) 2019 Hyperwallet Systems Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.hyperwallet.android.ui.common.viewmodel;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
* Class that represents {@link androidx.lifecycle.LiveData} event with content
*/
public class Event<T> {

private final T content;
private boolean mIsContentConsumed;

public Event(@NonNull final T t) {
content = t;
}

/**
* @return content of this event, will also mark {@link Event#mIsContentConsumed} to <code>true</code>
* that will also mean that {@link Event#getContentIfNotConsumed()} will also return <code>true</code>
*/
@NonNull
public T getContent() {
mIsContentConsumed = true;
return content;
}

/**
* @return <code>true</code> if content assigned to event is already referenced
* from {@link Event#getContent()}; <code>false</code> otherwise.
*/
public boolean isContentConsumed() {
return mIsContentConsumed;
}

/**
* Retrieve assigned content based on if and only if content has not been referenced from {@link Event#getContent()}
*
* @return content if content is not yet consumed; otherwise null
*/
@Nullable
public T getContentIfNotConsumed() {
if (!mIsContentConsumed) {
mIsContentConsumed = true;
return content;
}
return null;
}
}
2 changes: 1 addition & 1 deletion common/src/main/res/drawable/circle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<item>
<shape android:shape="oval">
<solid android:color="@color/fontIconBackground" />
<size android:width="48dp" android:height="48dp"/>
<size android:width="@dimen/circle_icon" android:height="@dimen/circle_icon"/>
</shape>
</item>
</selector>
Expand Down
8 changes: 3 additions & 5 deletions common/src/main/res/drawable/circle_white.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
<item>

<shape android:shape="oval">


<stroke android:color="#737373" android:width="3dp"/>
<size android:width="48dp" android:height="48dp"/>

<stroke android:color="@color/iconCircleWhite"
android:width="@dimen/circle_white_density"/>
<size android:width="@dimen/circle_icon" android:height="@dimen/circle_icon"/>
</shape>
</item>

Expand Down
Binary file modified common/src/main/res/font/icomoon.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions common/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@

<!-- Icon decoration color -->
<color name="fontIconBackground">#E5F7FA</color>
<color name="iconCircleWhite">#737373</color>
</resources>

2 changes: 2 additions & 0 deletions common/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,6 @@
<dimen name="menu_icon_default_margin">4dp</dimen>
<dimen name="text_input_hint_text_padding">6dp</dimen>
<dimen name="widget_left_margin_offset">32dp</dimen>
<dimen name="circle_icon">48dp</dimen>
<dimen name="circle_white_density">3dp</dimen>
</resources>
Loading