Skip to content

Commit

Permalink
Merge pull request #6 from kaelaela/develop
Browse files Browse the repository at this point in the history
Update v1.1.0
  • Loading branch information
kaelaela authored Jan 25, 2017
2 parents 84ec88c + 78ca788 commit ef718df
Show file tree
Hide file tree
Showing 18 changed files with 285 additions and 108 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ OpenGraphView

Rich url link view for Android.

![default](art/ogview.gif)
![default](art/ogview.gif)![default](art/ogview2.gif)

## Usage

```groovy
compile 'me.kaelaela:OpenGraphView:1.0.2'
compile 'me.kaelaela:OpenGraphView:1.1.0@aar'
```

```java
Expand All @@ -27,12 +27,12 @@ ogView.loadFrom(url);
android:layout_width="match_parent"
android:layout_height="96dp"
og:bgColor="@android:color/white"
og:cornerRadius="4dp"
og:descTextColor="@color/text_black"
og:faviconPlaceHolder="@color/light_gray"
og:imagePlaceHolder="@color/light_gray"
og:separateImage="true"
og:strokeColor="@color/light_gray"
og:strokeWidth="2dp"
og:titleColor="@color/text_black"
og:urlTextColor="@color/base_gray"
og:imagePosition="left|right"
Expand All @@ -42,6 +42,7 @@ ogView.loadFrom(url);
| Attribute | Description |
|:---|:---|
| bgColor | Set background color |
| cornerRadius | Set view corner radius |
| imagePlaceHolder | Set image or drawable to image place holder |
| faviconPlaceHolder | Set image or drawable to favicon place holder |
| separateImage | Set image separator visiblity |
Expand All @@ -57,17 +58,18 @@ ogView.loadFrom(url);
- [ ] Custom layout
- [x] View color
- [ ] View size
- [x] Text ~~size, line, style,~~ color
- [x] Text color
- [x] Image position
- [ ] Rounded view
- [x] Rounded view
- [x] Image cache
- [ ] Enable load twitter
- [ ] More metadata
- [x] Enable load twitter
- [ ] Load more metadata
- [ ] custom parser

## Me

Yuichi Maekawa(Kaelaela)
* Twitter [@Yuichi0531](https://twitter.com/Yuichi0531)
* Twitter [@kaelaela31](https://twitter.com/kaelaela31)
* [email protected]

##### Inspired
Expand Down
Binary file modified art/ogview.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/ogview2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}

Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
COMPILE_SDK_VERSION=23
BUILD_TOOLS_VERSION=23.0.2
COMPILE_SDK_VERSION=25
BUILD_TOOLS_VERSION=23.0.3
MIN_SDK_VERSION=16
TARGET_SDK_VERSION=24
SUPPORT_APP_COMPAT_VERSION=24.1.0
TARGET_SDK_VERSION=25
SUPPORT_APP_COMPAT_VERSION=25.1.0

VERSION_NAME=1.0.3
VERSION_CODE=4
VERSION_NAME=1.1.0
VERSION_CODE=5

GROUP=me.kaelaela
ARTIFACT_ID=OpenGraphView
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Dec 28 10:00:20 PST 2015
#Wed Oct 19 21:01:30 JST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
16 changes: 12 additions & 4 deletions library/src/main/java/me/kaelaela/opengraphview/OGParser.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.kaelaela.opengraphview;

import android.util.Log;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -14,6 +15,12 @@ public class OGParser {
private static final String IMAGE = "\"og:image\"";
private static final String URL = "og:url";
private static final String DESC = "og:description";

private static final String TWITTER_TITLE = "twitter:title";
private static final String TWITTER_IMAGE = "\"twitter:image\"";
private static final String TWITTER_URL = "twitter:url";
private static final String TWITTER_DESC = "twitter:description";

private static final String HEAD_START_TAG = "<head";
private static final String HEAD_END_TAG = "</head>";
private static final String META_START_TAG = "<meta";
Expand Down Expand Up @@ -57,6 +64,7 @@ public static OGData parse(InputStream inputStream) throws IOException {

if (readingHead && sourceTextLine.contains(META_START_TAG)) {
metaTags = metaTags + sourceTextLine + "\n";
setOGData(sourceTextLine);
}
}
bufferedReader.close();
Expand Down Expand Up @@ -84,13 +92,13 @@ private static String formattingMetaTags(String headText) {
private static void setOGData(String line) throws IOException {
int start = line.indexOf(CONTENT_PROPERTY) + CONTENT_PROPERTY.length();
int end = line.indexOf("\"", start);
if (line.contains(TITLE)) {
if (line.contains(TITLE) || line.contains(TWITTER_TITLE)) {
ogData.setTitle(line.substring(start, end));
} else if (line.contains(IMAGE)) {
} else if (line.contains(IMAGE) || line.contains(TWITTER_IMAGE)) {
ogData.setImage(line.substring(start, end));
} else if (line.contains(URL)) {
} else if (line.contains(URL) || line.contains(TWITTER_URL)) {
ogData.setUrl(line.substring(start, end));
} else if (line.contains(DESC)) {
} else if (line.contains(DESC) || line.contains(TWITTER_DESC)) {
ogData.setDescription(line.substring(start, end));
}
}
Expand Down
Loading

0 comments on commit ef718df

Please sign in to comment.