Skip to content
Open
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
40 changes: 39 additions & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
#Migration Guide
# Migration Guide

### Release 3.1.0

* New layout shouldn't cause any issues.

* Themes no longer need to be extending a Mal prefixed theme - use MaterialComponents themes as in the following example.

* Layout no longer includes a toolbar - use a theme which includes one:

```xml
<style name="AppTheme.MaterialAboutActivity.Dark" parent="Theme.MaterialComponents">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
```

* Custom card backgrounds can be defined as so:

```xml
<style name="AppTheme.MaterialAboutActivity.Light.DarkActionBar.CustomCardView" parent="Theme.MaterialComponents.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<!-- Text colour -->
<item name="android:textColorPrimary">#ffffff</item>
<item name="android:textColorSecondary">#ffffff</item>
<!-- Customise card background and icon colour -->
<item name="colorSurface">@color/colorPrimaryDark</item>
<item name="colorOnSurface">#ffffff</item>
</style>
```

* You no longer need to define colours for your icons - let the library handle this, or set a custom colour with `colorOnSurface` attribute in your theme.



### Release 2.3.0

Expand Down
66 changes: 20 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ If you use this library in your app, please let me know and I'll add it to the l

## Screenshots

| Light with Light Action Bar | Light with Dark Action Bar | Dark with Light Action Bar | Dark with Dark Action Bar | Custom Cardview Background | Custom card & action item layout |
| ------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ |
| ![Demo App](screenshots/1.png) | ![Demo App](screenshots/2.png) | ![Demo App](screenshots/3.png) | ![Demo App](screenshots/4.png) | ![Demo App](screenshots/5.png) | ![Demo App](screenshots/6.png) |
| Light | Dark | Custom Cardview Background |
| ------------------------------ | ------------------------------ | ------------------------------ |
| ![Demo App](screenshots/1.png) | ![Demo App](screenshots/2.png) | ![Demo App](screenshots/3.png) |

## Features

Expand All @@ -30,7 +30,7 @@ If you use this library in your app, please let me know and I'll add it to the l

## Dependency

_material-about-library_ is available on [**jitpack.io**][1] and has support for different support library versions. See the full list [here](https://jitpack.io/#daniel-stoneuk/material-about-library).
_material-about-library_ is available on [**jitpack.io**][1].

**Gradle dependency:**

Expand All @@ -44,12 +44,10 @@ allprojects {

```gradle
dependencies {
compile 'com.github.daniel-stoneuk:material-about-library:2.4.2'
implementation 'com.github.daniel-stoneuk:material-about-library:3.1.2'
}
```

Releases from 2.4.2 onwards will be using the AndroidX libraries. Use an older release if you wish to continue using the support library version.

## Migration

View the migration guide [here](/MIGRATION.md)
Expand Down Expand Up @@ -78,12 +76,7 @@ public class ExampleMaterialAboutActivity extends MaterialAboutActivity {
}
```

Ensure that the theme extends either of these themes, and apply primary & accent colours:

- `Theme.Mal.Light` (light theme with light toolbar)
- `Theme.Mal.Light.DarkActionBar` (light theme with dark toolbar)
- `Theme.Mal.Dark` (dark theme with dark toolbar)
- `Theme.Mal.Dark.LightActionBar` (dark theme with light toolbar)
Ensure that the theme extends a `MaterialComponents` theme, and apply primary & secondary colours:

```xml
<manifest ...>
Expand All @@ -95,10 +88,9 @@ Ensure that the theme extends either of these themes, and apply primary & accent
```

```xml
<style name="AppTheme.MaterialAboutActivity" parent="Theme.Mal.Light">
<style name="AppTheme.MaterialAboutActivity" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
```

Expand All @@ -114,24 +106,11 @@ public class ExampleMaterialAboutFragment extends MaterialAboutFragment {
return new MaterialAboutList.Builder()
.build(); // This creates an empty screen, add cards with .addCard()
}

@Override
protected int getTheme() {
return R.style.AppTheme_MaterialAboutActivity_Fragment;
}


}
```

Pass in a theme that extends one of the styles above

```xml
<style name="AppTheme.MaterialAboutActivity.Fragment" parent="Theme.Mal.Light">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
```
Theming will follow the activity theme.

### Add Cards:

Expand Down Expand Up @@ -221,20 +200,15 @@ Check out a working example in [`Demo.java`][3].
**Tip:** Customise text colour and card colour in your styles. Example below:

```xml
<style name="AppTheme.MaterialAboutActivity.Light.CustomCardView" parent="Theme.Mal.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="mal_card_background">@color/colorPrimaryDark</item>
<item name="android:textColorPrimary">#eee</item>
<item name="android:textColorSecondary">#ffe0e0e0</item>
<item name="mal_color_primary">#eee</item>
<item name="mal_color_secondary">#ffe0e0e0</item>
<!-- You can specify custom theme for toolbar and toolbarPopup. -->
<item name="mal_toolbarTheme">@style/Theme.Mal.Toolbar.Dark</item>
<item name="mal_toolbarPopupTheme">@style/Theme.Mal.Toolbar.Dark</item>
</style>
<style name="AppTheme.MaterialAboutActivity.Light.DarkActionBar.CustomCardView" parent="Theme.MaterialComponents.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:textColorPrimary">#ffffff</item>
<item name="android:textColorSecondary">#ffffff</item>
<item name="colorSurface">@color/colorPrimaryDark</item>
<item name="colorOnSurface">#ffffff</item>
</style>
```

### Custom Adapters:
Expand Down Expand Up @@ -300,7 +274,7 @@ To get a layout that is similar to the 6th screenshot above simply override the
## License

```
Copyright 2016-2018 Daniel Stone
Copyright 2016-2020 Daniel Stone

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -315,7 +289,7 @@ See the License for the specific language governing permissions and
limitations under the License.
```

[1]: https://jitpack.io
[1]: https://jitpack.io/#daniel-stoneuk/material-about-library
[2]: http://i.imgur.com/xXWDmLb.png
[3]: https://github.com/daniel-stoneuk/material-about-library/blob/master/app/src/main/java/com/danielstone/materialaboutlibrarydemo/Demo.java
[4]: http://i.imgur.com/HEm08Ax.png
Expand Down
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

def versionMajor = 2
def versionMinor = 3
def versionPatch = 0
def versionMajor = 3
def versionMinor = 1
def versionPatch = 2
def versionBuild = 0 // bump for dogfood builds, public betas, etc.

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion '28.0.3'

defaultConfig {
applicationId "com.danielstone.materialaboutlibrarydemo"
minSdkVersion 15
Expand Down
1 change: 1 addition & 0 deletions app/release/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":30000,"versionName":"3.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release","dirName":""},"path":"app-release.apk","properties":{}}]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import androidx.core.content.ContextCompat;

import com.danielstone.materialaboutlibrary.ConvenienceBuilder;
import com.danielstone.materialaboutlibrary.items.MaterialAboutActionCheckBoxItem;
import com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem;
import com.danielstone.materialaboutlibrary.items.MaterialAboutActionSwitchItem;
import com.danielstone.materialaboutlibrary.items.MaterialAboutCheckBoxItem;
import com.danielstone.materialaboutlibrary.items.MaterialAboutCheckableItem;
import com.danielstone.materialaboutlibrary.items.MaterialAboutItemOnClickAction;
Expand Down Expand Up @@ -52,9 +54,12 @@ public static MaterialAboutList createMaterialAboutList(final Context c, final i

appCardBuilder.addItem(new MaterialAboutCheckBoxItem.Builder()
.text("Checkbox")
.subText("Sub Text unchecked")
.subTextChecked("Sub Text checked")
.icon(new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_checkbox_marked_outline)
.sizeDp(18))
.setChecked(true)
.setOnCheckedChanged(new MaterialAboutOnCheckedChangedAction() {
@Override
public boolean onCheckedChanged(MaterialAboutCheckableItem item, boolean isChecked) {
Expand All @@ -67,9 +72,72 @@ public boolean onCheckedChanged(MaterialAboutCheckableItem item, boolean isCheck

appCardBuilder.addItem(new MaterialAboutSwitchItem.Builder()
.text("Switch")
.subText("Sub Text unchecked")
.subTextChecked("Sub Text checked")
.icon(new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_toggle_switch)
.sizeDp(18))
.setChecked(false)
.setOnCheckedChanged(new MaterialAboutOnCheckedChangedAction() {
@Override
public boolean onCheckedChanged(MaterialAboutCheckableItem item, boolean isChecked) {
Toast.makeText(c, "switch: " + isChecked, Toast.LENGTH_SHORT).show();
return true;
}
})
.build()
);

appCardBuilder.addItem(new MaterialAboutActionCheckBoxItem.Builder()
.text("Action Checkbox")
.subText("Sub Text unchecked")
.subTextChecked("Sub Text checked")
.icon(new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_checkbox_marked_outline)
.sizeDp(18))
.setChecked(true)
.setOnClickAction(new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
Toast.makeText(c, "action checkbox clicked", Toast.LENGTH_SHORT).show();
}
})
.setOnLongClickAction(new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
Toast.makeText(c, "action checkbox long clicked", Toast.LENGTH_SHORT).show();
}
})
.setOnCheckedChanged(new MaterialAboutOnCheckedChangedAction() {
@Override
public boolean onCheckedChanged(MaterialAboutCheckableItem item, boolean isChecked) {
Toast.makeText(c, "checked: " + isChecked, Toast.LENGTH_SHORT).show();
return true;
}
})
.build()
);

appCardBuilder.addItem(new MaterialAboutActionSwitchItem.Builder()
.text("Action Switch")
.subText("Sub Text unchecked")
.subTextChecked("Sub Text checked")
.icon(new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_toggle_switch)
.sizeDp(18))
.setChecked(false)
.setOnClickAction(new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
Toast.makeText(c, "action switch clicked", Toast.LENGTH_SHORT).show();
}
})
.setOnLongClickAction(new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
Toast.makeText(c, "action switch long clicked", Toast.LENGTH_SHORT).show();
}
})
.setOnCheckedChanged(new MaterialAboutOnCheckedChangedAction() {
@Override
public boolean onCheckedChanged(MaterialAboutCheckableItem item, boolean isChecked) {
Expand Down Expand Up @@ -227,4 +295,4 @@ public static MaterialAboutList createMaterialAboutLicenseList(final Context c)
mitLicenseCard,
gplLicenseCard);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected MaterialAboutList getMaterialAboutList(@NonNull final Context c) {
.setOnClickAction(new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
Snackbar.make(((ExampleMaterialAboutActivity) c).findViewById(R.id.mal_material_about_activity_coordinator_layout), "Test", Snackbar.LENGTH_SHORT).show();
Snackbar.make(getRecyclerView(), "Test", Snackbar.LENGTH_SHORT).show();
}
})
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import android.view.View;

import com.danielstone.materialaboutlibrary.holders.MaterialAboutItemViewHolder;
import com.danielstone.materialaboutlibrary.items.MaterialAboutActionCheckBoxItem;
import com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem;
import com.danielstone.materialaboutlibrary.items.MaterialAboutActionSwitchItem;
import com.danielstone.materialaboutlibrary.items.MaterialAboutCheckBoxItem;
import com.danielstone.materialaboutlibrary.items.MaterialAboutItem;
import com.danielstone.materialaboutlibrary.items.MaterialAboutSwitchItem;
Expand All @@ -24,6 +26,8 @@ public static final class ItemType {
public static final int TITLE_ITEM = ViewTypeManager.ItemType.TITLE_ITEM;
public static final int CHECKBOX_ITEM = ViewTypeManager.ItemType.CHECKBOX_ITEM;
public static final int SWITCH_ITEM = ViewTypeManager.ItemType.SWITCH_ITEM;
public static final int ACTION_CHECKBOX_ITEM = ViewTypeManager.ItemType.ACTION_CHECKBOX_ITEM;
public static final int ACTION_SWITCH_ITEM = ViewTypeManager.ItemType.ACTION_SWITCH_ITEM;
public static final int CUSTOM_ITEM = 10;
}

Expand All @@ -32,6 +36,8 @@ public static final class ItemLayout {
public static final int TITLE_LAYOUT = ViewTypeManager.ItemLayout.TITLE_LAYOUT;
public static final int CHECKBOX_LAYOUT = ViewTypeManager.ItemLayout.CHECKBOX_LAYOUT;
public static final int SWITCH_LAYOUT = ViewTypeManager.ItemLayout.SWITCH_LAYOUT;
public static final int ACTION_CHECKBOX_LAYOUT = ViewTypeManager.ItemLayout.ACTION_CHECKBOX_LAYOUT;
public static final int ACTION_SWITCH_LAYOUT = ViewTypeManager.ItemLayout.ACTION_SWITCH_LAYOUT;
public static final int CUSTOM_LAYOUT = R.layout.custom_item;
}

Expand All @@ -46,6 +52,10 @@ public int getLayout(int itemType) {
return CHECKBOX_LAYOUT;
case SWITCH_ITEM:
return SWITCH_LAYOUT;
case ACTION_CHECKBOX_ITEM:
return ACTION_CHECKBOX_LAYOUT;
case ACTION_SWITCH_ITEM:
return ACTION_SWITCH_LAYOUT;
case CUSTOM_ITEM:
return CUSTOM_LAYOUT;
default:
Expand All @@ -63,6 +73,10 @@ public MaterialAboutItemViewHolder getViewHolder(int itemType, View view) {
return MaterialAboutCheckBoxItem.getViewHolder(view);
case SWITCH_ITEM:
return MaterialAboutSwitchItem.getViewHolder(view);
case ACTION_CHECKBOX_ITEM:
return MaterialAboutActionCheckBoxItem.getViewHolder(view);
case ACTION_SWITCH_ITEM:
return MaterialAboutActionSwitchItem.getViewHolder(view);
case CUSTOM_ITEM:
return MyCustomItem.getViewHolder(view);
default:
Expand All @@ -87,6 +101,12 @@ public void setupItem(int itemType, MaterialAboutItemViewHolder holder, Material
case SWITCH_ITEM:
MaterialAboutSwitchItem.setupItem((MaterialAboutSwitchItem.MaterialAboutSwitchItemViewHolder) holder, (MaterialAboutSwitchItem) item, context);
break;
case ACTION_CHECKBOX_ITEM:
MaterialAboutActionCheckBoxItem.setupItem((MaterialAboutActionCheckBoxItem.MaterialAboutActionCheckBoxItemViewHolder) holder, (MaterialAboutActionCheckBoxItem) item, context);
break;
case ACTION_SWITCH_ITEM:
MaterialAboutActionSwitchItem.setupItem((MaterialAboutActionSwitchItem.MaterialAboutActionSwitchItemViewHolder) holder, (MaterialAboutActionSwitchItem) item, context);
break;
}
}
}
Loading