Skip to content

Commit

Permalink
Night mode perfection
Browse files Browse the repository at this point in the history
  • Loading branch information
j1angvei committed Sep 3, 2016
1 parent 9fcbc1f commit c4039b3
Show file tree
Hide file tree
Showing 57 changed files with 552 additions and 444 deletions.
3 changes: 3 additions & 0 deletions .idea/dictionaries/Wayne.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ android {
incremental true
javaMaxHeapSize "8g"
}
lintOptions{
abortOnError false
}
}

dependencies {
Expand Down Expand Up @@ -67,8 +70,6 @@ dependencies {
//glide
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
//picasso
compile 'com.squareup.picasso:picasso:2.5.2'
//leakCanary
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
Expand Down
15 changes: 13 additions & 2 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,20 @@ private <fields>;
#-keep public class org.jsoup.** {
#public *;
#}
##---------------Begin: proguard configuration for jsoup ----------
##---------------End: proguard configuration for jsoup ----------

##---------------Begin: proguard configuration for picasso ---------
-dontwarn com.squareup.okhttp.**
##---------------Begin: proguard configuration for picasso ----------
##---------------End: proguard configuration for picasso ----------

##---------------End: proguard configuration for Leakcanary ----------
-dontwarn com.squareup.haha.guava.**
-dontwarn com.squareup.haha.perflib.**
-dontwarn com.squareup.haha.trove.**
-dontwarn com.squareup.leakcanary.**
-keep class com.squareup.haha.** { *; }
-keep class com.squareup.leakcanary.** { *; }

# Marshmallow removed Notification.setLatestEventInfo()
-dontwarn android.app.Notification
##---------------End: proguard configuration for Leakcanary ----------
10 changes: 8 additions & 2 deletions app/src/main/assets/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,15 @@ function showImage(img) {
}

function start() {
console.log("start");
//get all img tags
handleImgTags();
console.log("night "+ isNightMode());
//modify background to fit app theme
if(isNightMode()){
console.log("it is night mode");
var body=document.getElementById("main");
body.style.backgroundColor="#313131";
body.style.color="#c7c7c7";
}
}

function openImage(obj) {
Expand Down
25 changes: 12 additions & 13 deletions app/src/main/assets/img_error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 5 additions & 7 deletions app/src/main/assets/img_holder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 61 additions & 13 deletions app/src/main/assets/img_loading.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 0 additions & 26 deletions app/src/main/assets/night.css

This file was deleted.

13 changes: 7 additions & 6 deletions app/src/main/assets/day.css → app/src/main/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@
}
body {
width:100%; height: auto;
background-color: #FFFFFF;
background-color: #FAFAFA;
color: #5B5B5B;
text-align:justify;

}
h1,h2,h3,h4,h5,h6 {
margin: 10px auto;
color: #2F2F2F;
}
#content {
font-size: 19px;
.content {
font-size: 16px;
line-height: 1.5; height: auto; width: auto;
overflow: hidden;
padding: 5px 10px;
}
#content img {
max-width: 100%; width: auto; height: auto;
.content img {
max-width: 100% !important;
width: auto !important;
height: auto;
clear: both;
display: block;
margin: 10px auto;
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/cn/j1angvei/cnbetareader/CBApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* Created by Wayne on 2016/6/29.
*/
public class CBApplication extends Application {
// static {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
// }
static {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
}

private ApplicationComponent mApplicationComponent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
}

public boolean isNightMode() {
public boolean isNightModeOn() {
int mode = getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK;
return mode == Configuration.UI_MODE_NIGHT_YES;
}

public boolean isAutoLoadImage() {
return mNetworkUtil.isWifiOn();
return !mNetworkUtil.isCellularOn();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
Expand All @@ -27,7 +26,6 @@
import cn.j1angvei.cnbetareader.bean.Comments;
import cn.j1angvei.cnbetareader.contract.ShowCmtContract;
import cn.j1angvei.cnbetareader.di.scope.PerFragment;
import cn.j1angvei.cnbetareader.util.DateUtil;

/**
* Created by Wayne on 2016/7/28.
Expand Down Expand Up @@ -79,7 +77,7 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType
switch (viewType) {
case LABEL_HOT:
case LABEL_ALL:
view = inflater.inflate(R.layout.tv_label_primary, parent, false);
view = inflater.inflate(R.layout.include_tv_label, parent, false);
viewHolder = new LabelHolder(view);
break;
case CMT_SIMPLE:
Expand Down Expand Up @@ -176,7 +174,6 @@ public boolean onMenuItemClick(MenuItem menuItem) {

private static class ViewHolder extends RecyclerView.ViewHolder {
View itemView;
ImageView ivHead;
CommentViewGroup origin;
CommentViewGroup reference;

Expand All @@ -185,7 +182,6 @@ public ViewHolder(View itemView, boolean isSimple, CommentViewGroup origin, Comm
this.itemView = itemView;
this.origin = origin;
this.reference = reference;
ivHead = (ImageView) itemView.findViewById(R.id.iv_comment_photo);
if (isSimple) {
origin.findViews(itemView, true);
} else {
Expand All @@ -206,7 +202,6 @@ private static class LabelHolder extends RecyclerView.ViewHolder {

private class CommentViewGroup {
private TextView tvUser;
private TextView tvDate;
private TextView tvContent;
private TextView tvSupport;
private TextView tvAgainst;
Expand All @@ -217,15 +212,13 @@ void findViews(View view, boolean isTogether) {
//passed view should be direct parent view
if (isTogether) {
tvUser = (TextView) view.findViewById(R.id.tv_comment_user);
tvDate = (TextView) view.findViewById(R.id.tv_comment_date);
tvContent = (TextView) view.findViewById(R.id.tv_comment_content);
tvSupport = (TextView) view.findViewById(R.id.tv_comment_support);
tvAgainst = (TextView) view.findViewById(R.id.tv_comment_against);
tvPopup = (TextView) view.findViewById(R.id.tv_comment_popup);
} else {// origin viewGroup in complex viewHolder
View header = view.findViewById(R.id.inc_comment_header);
tvUser = (TextView) header.findViewById(R.id.tv_comment_user);
tvDate = (TextView) header.findViewById(R.id.tv_comment_date);
View detail = view.findViewById(R.id.inc_comment_detail);
tvContent = (TextView) detail.findViewById(R.id.tv_comment_content);
tvSupport = (TextView) detail.findViewById(R.id.tv_comment_support);
Expand All @@ -238,8 +231,6 @@ void setComment(final CommentItem item, Context context) {
Resources resources = context.getResources();
String user = String.format(resources.getString(R.string.cmt_header), item.getUsername(), item.getLocation());
tvUser.setText(user);
String date = String.format(resources.getString(R.string.cmt_time), DateUtil.toTime(item.getDate(), context));
tvDate.setText(date);
tvContent.setText(item.getContent());
String support = String.format(resources.getString(R.string.cmt_action_up_vote), item.getSupport());
tvSupport.setText(support);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/
@Singleton
public class ArticleConverter extends NewsConverter<Article> {

@Inject
public ArticleConverter(Gson gson) {
super(gson);
Expand Down Expand Up @@ -50,13 +49,7 @@ public Observable<Article> toObservable(String json) {
.doOnNext(new Action1<Article>() {
@Override
public void call(Article article) {
String source = article.getSource();
if (source == null) {
article.setSource("null");
} else if (source.contains("@")) {
source = source.substring(0, source.indexOf('@') - 1);
article.setSource(source);
}
article.setSource(ApiUtil.removeAtChar(article.getSource()));
String summary = Html.fromHtml(article.getSummary()).toString();
article.setSummary(summary);
}
Expand Down
Loading

0 comments on commit c4039b3

Please sign in to comment.