diff --git a/app/build.gradle b/app/build.gradle index 6d56fc8..7dbc0ad 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,18 +4,15 @@ apply plugin: 'realm-android' apply plugin: 'com.bugtags.library.plugin' android { - compileSdkVersion 26 + compileSdkVersion 27 buildToolsVersion '27.0.3' defaultConfig { applicationId "com.dante.diary" minSdkVersion 19 targetSdkVersion 27 - versionCode 40 - versionName "1.9.0" + versionCode 46 + versionName "1.9.6" vectorDrawables.useSupportLibrary = true -// ndk { -// abiFilters 'armeabi-v7a', 'x86' -// } multiDexEnabled true manifestPlaceholders = [ JPUSH_PKGNAME: applicationId, @@ -36,6 +33,7 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + compileOptions { targetCompatibility 1.8 sourceCompatibility 1.8 @@ -55,6 +53,20 @@ android { exclude 'META-INF/NOTICE.txt' } + + flavorDimensions "default" + productFlavors { + yingyongbao { + + } + Google { + + } + } +} + +ext { + supportVersion = "27.1.1" } bugtags { @@ -75,27 +87,26 @@ dependencies { implementation 'com.bugtags.library:bugtags-lib:2.3.1' implementation 'com.github.bumptech.glide:glide:3.8.0' implementation 'com.jakewharton:butterknife:8.8.1' - implementation 'com.google.code.gson:gson:2.8.0' + implementation 'com.google.code.gson:gson:2.8.2' implementation 'com.blankj:utilcode:1.3.6' implementation 'com.hwangjr.proguard:proguardconfig:1.0.1@aar' - implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.17' + implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.34' implementation 'com.yqritc:recyclerview-flexibledivider:1.4.0' - implementation 'com.hendraanggrian:collapsingtoolbarlayout-subtitle:0.3.1' + implementation 'com.hendraanggrian:collapsingtoolbarlayout-subtitle:27.0.1' implementation 'com.ncapdevi:frag-nav:1.4.0' implementation 'com.roughike:bottom-bar:2.1.1' - implementation 'org.greenrobot:eventbus:3.0.0' + implementation 'org.greenrobot:eventbus:3.1.1' //============== Rxjava ============== - implementation 'com.artemzin.rxjava:proguard-rules:1.1.3.0' + implementation 'com.artemzin.rxjava:proguard-rules:1.3.3.0' implementation 'io.reactivex:rxandroid:1.2.1' implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0' implementation 'com.squareup.retrofit2:retrofit:2.3.0' implementation 'com.squareup.retrofit2:converter-gson:2.3.0' - implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0' - + implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0' //============== custom ============== implementation 'uk.co.samuelwall:material-tap-target-prompt:2.1.0' - + implementation 'com.github.deano2390:FlowTextView:2.0.5' implementation 'com.github.stfalcon:chatkit:0.2.1' implementation 'com.github.oxoooo:touch-image-view:1.0.1' implementation 'com.andrognito.patternlockview:patternlockview:1.0.0' @@ -105,23 +116,24 @@ dependencies { implementation 'io.github.yavski:fab-speed-dial:1.0.6' implementation 'com.classic.common:multiple-status-view:1.2' implementation 'jp.wasabeef:glide-transformations:2.0.1' - implementation('cn.leancloud.android:avoscloud-sdk:v3.+') - implementation('cn.leancloud.android:avoscloud-push:v3.+@aar') { transitive = true }// 推送与实时聊天需要的包 + implementation 'cn.leancloud.android:avoscloud-sdk:v4.6.4' + implementation('cn.leancloud.android:avoscloud-push:v4.6.4@aar') { transitive = true } +// 推送与实时聊天需要的包 //============== official ============== - implementation 'com.android.support:design:26.1.0' - implementation 'com.android.support:appcompat-v7:26.1.0' - implementation 'com.android.support:support-v4:26.1.0' - implementation 'com.android.support:cardview-v7:26.1.0' - implementation 'com.android.support:recyclerview-v7:26.1.0' - implementation 'com.android.support.constraint:constraint-layout:1.0.2' + implementation "com.android.support:design:$supportVersion" + implementation "com.android.support:appcompat-v7:$supportVersion" + implementation "com.android.support:support-v4:$supportVersion" + implementation "com.android.support:cardview-v7:$supportVersion" + implementation "com.android.support:recyclerview-v7:$supportVersion" + implementation 'com.android.support.constraint:constraint-layout:1.1.0' //============== debug ============== // implementation 'cn.jiguang.sdk:jpush:3.0.3' // implementation 'cn.jiguang.sdk:jcore:1.1.1' - implementation 'com.android.support:support-vector-drawable:26.1.0' + implementation "com.android.support:support-vector-drawable:$supportVersion" annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' // releaseimplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5' - // debugimplementation 'com.squareup.leakcanary:leakcanary-android:1.5'、 + // debugimplementation 'com.squareup.leakcanary:leakcanary-android:1.5' } diff --git a/app/release/app-armeabi-v7a-release.apk b/app/release/app-armeabi-v7a-release.apk index c72ebbc..0cdafe1 100644 Binary files a/app/release/app-armeabi-v7a-release.apk and b/app/release/app-armeabi-v7a-release.apk differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 91c85b2..e9b7ce7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -25,6 +25,7 @@ android:theme="@style/ViewerTheme.TransNav"/> = Build.VERSION_CODES.LOLLIPOP) { + if (getActivity() != null) { + if (getActivity().getWindow() == null) return; + getActivity().getWindow().setStatusBarColor( + ContextCompat.getColor(getActivity(), colorRes)); + } + } + } + @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -58,6 +69,15 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, return rootView; } + protected int initStatusBarColor() { + return R.color.colorPrimaryDark; + } + + @Override + public void onStart() { + super.onStart(); + setStatusBarColor(initStatusBarColor()); + } @TargetApi(Build.VERSION_CODES.LOLLIPOP) protected void setAnimations() { @@ -118,7 +138,7 @@ protected void onCreateView() { } public void initAppBar() { - toolbar = (Toolbar) getView().findViewById(R.id.toolbar); + toolbar = getView().findViewById(R.id.toolbar); log("initAppBar"); if (getActivity() != null && null != toolbar) { log("initAppBar set"); diff --git a/app/src/main/java/com/dante/diary/base/BottomBarActivity.java b/app/src/main/java/com/dante/diary/base/BottomBarActivity.java index 858354e..f07c3b9 100644 --- a/app/src/main/java/com/dante/diary/base/BottomBarActivity.java +++ b/app/src/main/java/com/dante/diary/base/BottomBarActivity.java @@ -118,7 +118,7 @@ private void initBottomBar() { } }); bottomBar.setOnTabReselectListener(tabId -> { - controller.clearStack(); +// controller.clearStack(); // scrollToTop(); }); } diff --git a/app/src/main/java/com/dante/diary/base/RecyclerFragment.java b/app/src/main/java/com/dante/diary/base/RecyclerFragment.java index 6da606f..987a331 100755 --- a/app/src/main/java/com/dante/diary/base/RecyclerFragment.java +++ b/app/src/main/java/com/dante/diary/base/RecyclerFragment.java @@ -29,6 +29,7 @@ public abstract class RecyclerFragment extends BaseFragment implements SwipeRefr @BindView(R.id.fab) public FloatingActionButton fab; + @Override protected int initLayoutId() { return R.layout.fragment_recycler; diff --git a/app/src/main/java/com/dante/diary/custom/NotificationUtils.java b/app/src/main/java/com/dante/diary/custom/NotificationUtils.java index 1fa20c2..2f8f014 100644 --- a/app/src/main/java/com/dante/diary/custom/NotificationUtils.java +++ b/app/src/main/java/com/dante/diary/custom/NotificationUtils.java @@ -6,8 +6,8 @@ import android.app.TaskStackBuilder; import android.content.Context; import android.content.Intent; +import android.support.v4.app.NotificationCompat; -import com.avos.avospush.notification.NotificationCompat; import com.dante.diary.R; import com.dante.diary.chat.ConversationActivity; import com.dante.diary.utils.SpUtil; @@ -22,6 +22,7 @@ */ public class NotificationUtils { + private static final String CHANNEL_ID = "CHANNEL_ID"; /** * tag list,用来标记是否应该展示 Notification * 比如已经在聊天页面了,实际就不应该再弹出 notification @@ -54,10 +55,9 @@ public static boolean isShowNotification(String tag) { public static void showNotification(int mId, String title, String content, Intent intent) { NotificationCompat.Builder mBuilder = - new NotificationCompat.Builder(context) + new NotificationCompat.Builder(context, CHANNEL_ID) .setSmallIcon(R.drawable.notification_icon) .setAutoCancel(true) - .setContentTitle(title) .setContentText(content); @@ -78,6 +78,8 @@ public static void showNotification(int mId, String title, String content, Inten NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. - mNotificationManager.notify(mId, mBuilder.build()); + if (mNotificationManager != null) { + mNotificationManager.notify(mId, mBuilder.build()); + } } } diff --git a/app/src/main/java/com/dante/diary/detail/DiaryDetailFragment.java b/app/src/main/java/com/dante/diary/detail/DiaryDetailFragment.java index f3503f0..34c9b93 100644 --- a/app/src/main/java/com/dante/diary/detail/DiaryDetailFragment.java +++ b/app/src/main/java/com/dante/diary/detail/DiaryDetailFragment.java @@ -245,7 +245,7 @@ protected void initData() { toolbar.inflateMenu(R.menu.menu_detail); toolbar.setOnClickListener(v -> scrollView.smoothScrollTo(0, 0)); fetch(); - + log("initdata" + getActivity().getLocalClassName()); } @Override @@ -408,6 +408,8 @@ private void inflateDiary() { } getActivity().supportPostponeEnterTransition(); diaryDate.setText(DateUtil.getDisplayDay(diary.getCreated())); +// content.setColor(ContextCompat.getColor(getActivity(), R.color.primaryText)); +// content.setTextSize(ConvertUtils.sp2px(16)); content.setText(diary.getContent()); diaryLayout.setOnLongClickListener(this); content.setOnLongClickListener(this); diff --git a/app/src/main/java/com/dante/diary/detail/PictureFragment.java b/app/src/main/java/com/dante/diary/detail/PictureFragment.java index faa8ad3..6bb94b7 100644 --- a/app/src/main/java/com/dante/diary/detail/PictureFragment.java +++ b/app/src/main/java/com/dante/diary/detail/PictureFragment.java @@ -60,6 +60,10 @@ public static PictureFragment newInstance(String url, boolean isGif) { return fragment; } + @Override + protected int initStatusBarColor() { + return android.R.color.transparent; + } @Override protected int initLayoutId() { diff --git a/app/src/main/java/com/dante/diary/edit/EditNotebookActivity.java b/app/src/main/java/com/dante/diary/edit/EditNotebookActivity.java index 605c4fc..c8d163d 100644 --- a/app/src/main/java/com/dante/diary/edit/EditNotebookActivity.java +++ b/app/src/main/java/com/dante/diary/edit/EditNotebookActivity.java @@ -1,5 +1,7 @@ package com.dante.diary.edit; +import android.app.DatePickerDialog; +import android.content.DialogInterface; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Color; @@ -10,21 +12,26 @@ import android.os.Bundle; import android.os.Handler; import android.support.annotation.Nullable; +import android.support.design.widget.AppBarLayout; import android.support.design.widget.TextInputEditText; import android.support.design.widget.TextInputLayout; import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewCompat; import android.support.v7.app.AppCompatDelegate; +import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; import android.transition.Slide; +import android.util.Log; import android.view.Gravity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.CalendarView; import android.widget.ImageView; +import android.widget.RadioButton; +import android.widget.RadioGroup; import android.widget.Switch; import android.widget.TextView; @@ -44,9 +51,12 @@ import com.dante.diary.utils.UiUtils; import java.io.File; +import java.util.Calendar; +import java.util.Date; import java.util.HashMap; import butterknife.BindView; +import butterknife.ButterKnife; import rx.Observable; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; @@ -67,7 +77,7 @@ public class EditNotebookActivity extends BaseActivity { TextInputLayout descWrapper; @BindView(R.id.expire) TextView expire; - @BindView(R.id.expireCalendar) + // @BindView(R.id.expireCalendar) CalendarView expireCalendar; @BindView(R.id.privacy) Switch privacy; @@ -78,6 +88,24 @@ public class EditNotebookActivity extends BaseActivity { int notebookId; @BindView(R.id.notebookCover) ImageView notebookCover; + @BindView(R.id.month) + RadioButton month; + @BindView(R.id.halfYear) + RadioButton halfYear; + @BindView(R.id.aYear) + RadioButton aYear; + @BindView(R.id.custom) + RadioButton custom; + @BindView(R.id.expireTimeGroup) + RadioGroup expireTimeGroup; + @BindView(R.id.toolbar) + Toolbar toolbar; + @BindView(R.id.appBar) + AppBarLayout appBar; + @BindView(R.id.visibility) + TextView visibility; + @BindView(R.id.noteBookExpireTime) + TextView noteBookExpireTime; // @BindView(R.id.calendarScrollView) // ScrollView calendarScrollView; private boolean isEditMode; @@ -86,6 +114,7 @@ public class EditNotebookActivity extends BaseActivity { private String expireDate; private boolean notebookChanged; private boolean coverChanged; + private DatePickerDialog pickerDialog; @Override protected int initLayoutId() { @@ -104,7 +133,7 @@ protected void initViews(@Nullable Bundle savedInstanceState) { notebookId = getIntent().getIntExtra(Constants.ID, 0); notebook = getBase().findNotebook(notebookId); if (notebook == null) { - UiUtils.showSnack(expireCalendar, R.string.unable_to_find_notebook); + UiUtils.showSnack(notebookCover, R.string.unable_to_find_notebook); return; } isEditMode = notebookId > 0; @@ -121,6 +150,57 @@ protected void initViews(@Nullable Bundle savedInstanceState) { }); } + private void initExpireTimeGroup() { + + custom.setOnCheckedChangeListener((buttonView, isChecked) -> { + if (isChecked) { + showPicker(); + } + }); + expireTimeGroup.setOnCheckedChangeListener((group, checkedId) -> { + switch (checkedId) { + case R.id.month: + expireDate = DateUtil.getDisplayDay(DateUtil.nextMonthDateOfToday()); + Log.d(TAG, "initExpireTimeGroup: checked"); + break; + case R.id.halfYear: + expireDate = DateUtil.getDisplayDay(DateUtil.nextMonthsOfToday(6)); + break; + case R.id.aYear: + expireDate = DateUtil.getDisplayDay(DateUtil.nextMonthsOfToday(12)); + break; + case R.id.custom: + showPicker(); + break; + default: + expireDate = DateUtil.getDisplayDay(DateUtil.nextMonthDateOfToday()); + break; + } + }); + } + + private void showPicker() { + if (pickerDialog == null) { + Date date = DateUtil.nextMonthDateOfToday(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + pickerDialog = new DatePickerDialog( + EditNotebookActivity.this, (view, year, month, dayOfMonth) -> { + expireDate = year + "-" + (++month) + "-" + dayOfMonth; + custom.setText(expireDate); + }, + calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); + + pickerDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), (dialog, which) -> { + if (which == DialogInterface.BUTTON_NEGATIVE) { + expireTimeGroup.check(R.id.month); + custom.setText(R.string.custom); + } + }); + } + pickerDialog.show(); + } + private void initCover() { notebookCover.setOnClickListener(v -> startActivityForResult(new Intent(getApplicationContext(), PickPictureActivity.class), REQUEST_PICK_PICTURE)); @@ -189,17 +269,18 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { private void initCalendar() { expireDate = DateUtil.getDisplayDay(DateUtil.nextMonthDateOfToday()); - expire.setText(String.format(getString(R.string.expire_time), - isEditMode ? notebook.getExpired() : expireDate)); if (isEditMode) { - expireCalendar.setVisibility(View.GONE); + expireTimeGroup.setVisibility(View.GONE); + noteBookExpireTime.setVisibility(View.VISIBLE); + noteBookExpireTime.setText(notebook.getExpired()); } else { - expireCalendar.setMinDate(DateUtil.nextMonthDateOfToday().getTime()); - expireCalendar.setDate(DateUtil.nextMonthDateOfToday().getTime()); - expireCalendar.setOnDateChangeListener((view, year, month, dayOfMonth) -> { - expireDate = year + "-" + (++month) + "-" + dayOfMonth; - expire.setText(String.format(getString(R.string.expire_time), expireDate)); - }); + initExpireTimeGroup(); +// expireCalendar.setMinDate(DateUtil.nextMonthDateOfToday().getTime()); +// expireCalendar.setDate(DateUtil.nextMonthDateOfToday().getTime()); +// expireCalendar.setOnDateChangeListener((view, year, month, dayOfMonth) -> { +// expireDate = year + "-" + (++month) + "-" + dayOfMonth; +// expire.setText(String.format(getString(R.string.expire_time), expireDate)); +// }); } } @@ -281,12 +362,12 @@ public void send() { .observeOn(AndroidSchedulers.mainThread()) .subscribe(n -> { if (isEditMode) { - UiUtils.showSnack(expireCalendar, R.string.update_success); + UiUtils.showSnack(notebookCover, R.string.update_success); } else { notebook = n; notebookId = n.getId(); String s = String.format(getString(R.string.create_notebook_success), notebookSubject); - UiUtils.showSnack(expireCalendar, s); + UiUtils.showSnack(notebookCover, s); } setResult(RESULT_OK); new Handler().postDelayed(() -> { @@ -302,9 +383,9 @@ public void call(Throwable throwable) { super.call(throwable); if (!TextUtils.isEmpty(errorMessage)) { if (isEditMode) { - UiUtils.showSnack(expireCalendar, String.format(getString(R.string.update_failed) + " ", errorMessage)); + UiUtils.showSnack(notebookCover, String.format(getString(R.string.update_failed) + " ", errorMessage)); } else { - UiUtils.showSnack(expireCalendar, getString(R.string.fail_to_create_notebook) + " " + errorMessage); + UiUtils.showSnack(notebookCover, getString(R.string.fail_to_create_notebook) + " " + errorMessage); } } } @@ -349,4 +430,11 @@ public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_send, menu); return true; } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // TODO: add setContentView(...) invocation + ButterKnife.bind(this); + } } diff --git a/app/src/main/java/com/dante/diary/main/MainDiaryFragment.java b/app/src/main/java/com/dante/diary/main/MainDiaryFragment.java index adc266c..280d96a 100644 --- a/app/src/main/java/com/dante/diary/main/MainDiaryFragment.java +++ b/app/src/main/java/com/dante/diary/main/MainDiaryFragment.java @@ -119,7 +119,12 @@ protected int initLayoutId() { return R.layout.fragment_diary_main; } -// @Override + @Override + protected int initStatusBarColor() { + return android.R.color.transparent; + } + + // @Override // protected void setAnimations() { // setReturnTransition(initTransitions()); // setReenterTransition(new Slide(Gravity.RIGHT)); @@ -131,12 +136,12 @@ protected int initLayoutId() { @Override public void onStart() { super.onStart(); - log(" onStart..."); if (topic == null) { appBar.setExpanded(false); } } + @Override protected void initViews() { super.initViews(); diff --git a/app/src/main/java/com/dante/diary/net/API.java b/app/src/main/java/com/dante/diary/net/API.java index 450214f..433ae77 100644 --- a/app/src/main/java/com/dante/diary/net/API.java +++ b/app/src/main/java/com/dante/diary/net/API.java @@ -6,7 +6,7 @@ public class API { - public static final String BASE_URL = "http://open.timepill.net/api/"; + public static final String BASE_URL = "https://open.timepill.net/api/"; public static final String GITHUB_RAW = "http://raw.githubusercontent.com/DanteAndroid/TimePill/master/"; public static final String DOWNLOAD_BASE = "https://github.com/DanteAndroid/TimeDiary/releases/download/"; } diff --git a/app/src/main/java/com/dante/diary/net/TimeApi.java b/app/src/main/java/com/dante/diary/net/TimeApi.java index ce63aa5..dd63c80 100644 --- a/app/src/main/java/com/dante/diary/net/TimeApi.java +++ b/app/src/main/java/com/dante/diary/net/TimeApi.java @@ -128,6 +128,9 @@ Observable createDiary(@Path("book_id") int notebookId, @Part("content") @GET("tip") Observable> getTips(); + @GET("tip/history") + Observable> getTipsHistory(); + @POST("tip/read/{ids}") Observable> tipsRead(@Path("ids") String ids); diff --git a/app/src/main/java/com/dante/diary/notification/NotificationListAdapter.java b/app/src/main/java/com/dante/diary/notification/NotificationListAdapter.java index 5b9a0d1..0f6d4ba 100644 --- a/app/src/main/java/com/dante/diary/notification/NotificationListAdapter.java +++ b/app/src/main/java/com/dante/diary/notification/NotificationListAdapter.java @@ -38,6 +38,9 @@ public NotificationListAdapter(List data, IOnItemClickListener listen protected void convert(BaseViewHolder helper, TipResult item) { helper.addOnClickListener(R.id.done); TextView notification = helper.getView(R.id.notification); + notification.setTextColor(ContextCompat.getColor(helper.itemView.getContext(), + item.read == 1 ? R.color.tertiaryText : R.color.primaryText)); + switch (helper.getItemViewType()) { case TipResult.TYPE_COMMENT: String user = item.content.getCommentUser().getName(); diff --git a/app/src/main/java/com/dante/diary/notification/NotificationListFragment.java b/app/src/main/java/com/dante/diary/notification/NotificationListFragment.java index 285a1cd..b6ea236 100644 --- a/app/src/main/java/com/dante/diary/notification/NotificationListFragment.java +++ b/app/src/main/java/com/dante/diary/notification/NotificationListFragment.java @@ -1,6 +1,5 @@ package com.dante.diary.notification; -import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.support.v7.widget.LinearLayoutManager; import android.view.View; @@ -11,7 +10,7 @@ import com.chad.library.adapter.base.listener.OnItemClickListener; import com.dante.diary.R; import com.dante.diary.base.RecyclerFragment; -import com.dante.diary.detail.DiaryDetailFragment; +import com.dante.diary.base.ViewActivity; import com.dante.diary.interfaces.IOnItemClickListener; import com.dante.diary.login.LoginManager; import com.dante.diary.model.TipResult; @@ -60,8 +59,8 @@ public void onItemLongClick(BaseQuickAdapter adapter, View view, int position) { // } // } }); - fab.setImageResource(R.drawable.ic_done_all_white_36dp); - fab.setOnClickListener(v -> readAllDone()); + fab.setImageResource(R.drawable.ic_done_all_white_36dp); + fab.setOnClickListener(v -> readAllDone()); } @Override @@ -118,12 +117,17 @@ protected void initData() { protected void fetch() { changeRefresh(true); - LoginManager.getApi().getTips().compose(applySchedulers()) + LoginManager.getApi().getTips() + .zipWith(LoginManager.getApi().getTipsHistory(), (t1, t2) -> { + t1.addAll(t2); + return t1; + }) + .compose(applySchedulers()) .subscribe(tipResults -> { - if (tipResults.isEmpty()) { - fab.hide(); - } else { - fab.show(); + for (int i = 0; i < tipResults.size(); i++) { + if (tipResults.get(i).read == 0) { + fab.show(); + } } adapter.setNewData(tipResults); changeRefresh(false); @@ -134,20 +138,19 @@ protected void fetch() { } private void onNotificationClicked(View view, int i) { - TextView n = (TextView) view.findViewById(R.id.notification); - n.setTextColor(ContextCompat.getColor(getContext(), R.color.tertiaryText)); - + TextView n = view.findViewById(R.id.notification); TipResult notification = adapter.getItem(i); - int type = adapter.getItem(i).getItemType(); + if (getActivity() == null || notification == null) return; + n.setTextColor(ContextCompat.getColor(getActivity(), R.color.tertiaryText)); + int type = notification.getItemType(); if (type == TipResult.TYPE_FOLLOW) { goProfile(notification.content.getFollowUser().getId()); - } else if (type == TipResult.TYPE_COMMENT) { - Fragment fragment = DiaryDetailFragment.newInstance(notification.content.getDairyId(), - notification.content.getCommentId()); - add(fragment); + ViewActivity.viewDiary(getActivity(), notification.content.getDairyId()); +// Fragment fragment = DiaryDetailFragment.newInstance(notification.content.getDairyId(), +// notification.content.getCommentId()); +// add(fragment); } - readDone(notification.id); } diff --git a/app/src/main/java/com/dante/diary/profile/NoteBookListFragment.java b/app/src/main/java/com/dante/diary/profile/NoteBookListFragment.java index f3d1d66..360796b 100644 --- a/app/src/main/java/com/dante/diary/profile/NoteBookListFragment.java +++ b/app/src/main/java/com/dante/diary/profile/NoteBookListFragment.java @@ -117,6 +117,7 @@ private void deleteNotebook(View view, int position, Notebook n) { if (TextUtils.isEmpty(error)) { adapter.remove(position); UiUtils.showSnack(barActivity.bottomBar, R.string.delete_notebook_success); + onRefresh(); } else { String errorMessage = ""; try { @@ -129,6 +130,7 @@ private void deleteNotebook(View view, int position, Notebook n) { } catch (NullPointerException e) { ToastUtils.showShortToast(getString(R.string.delete_notebook_success)); + onRefresh(); e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); diff --git a/app/src/main/java/com/dante/diary/utils/DateUtil.java b/app/src/main/java/com/dante/diary/utils/DateUtil.java index a3e2abf..f4c50a5 100644 --- a/app/src/main/java/com/dante/diary/utils/DateUtil.java +++ b/app/src/main/java/com/dante/diary/utils/DateUtil.java @@ -84,6 +84,15 @@ public static Date nextMonthDateOfToday() { return calendar.getTime(); } + public static Date nextMonthsOfToday(int month) { + Date today = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.MONTH, month); + calendar.add(Calendar.DAY_OF_MONTH, -1); + return calendar.getTime(); + } + public static Date nextWeekDateOfToday() { Date today = new Date(); Calendar calendar = Calendar.getInstance(); diff --git a/app/src/main/java/com/dante/diary/utils/ImageProgresser.java b/app/src/main/java/com/dante/diary/utils/ImageProgresser.java index defa299..3397930 100644 --- a/app/src/main/java/com/dante/diary/utils/ImageProgresser.java +++ b/app/src/main/java/com/dante/diary/utils/ImageProgresser.java @@ -18,7 +18,7 @@ public class ImageProgresser { * 给 ImageView 上层添加一个相对布局 * 然后在此相对布局中心加上 Progressbar * - * @param view 需要在中间位置添加 Progress 的view + * @param view 需要在中间添加 Progress 的view * @return 该 ProgressBar,可以用于加载后的隐藏与再次显示 */ @NonNull diff --git a/app/src/main/res/layout/activity_create_notebook.xml b/app/src/main/res/layout/activity_create_notebook.xml index 26c0add..ed4c87b 100644 --- a/app/src/main/res/layout/activity_create_notebook.xml +++ b/app/src/main/res/layout/activity_create_notebook.xml @@ -74,44 +74,103 @@ - + + + + + + + + + + + + + + + - - - + + - + android:layout_marginBottom="@dimen/activity_horizontal_margin" + android:layout_marginLeft="32dp" + android:layout_marginTop="6dp" + android:checked="false" + android:gravity="center" + android:text="@string/privacy_public" + android:textColor="@color/secondText" + android:textOff="@string/privacy_me_only" + android:textOn="@string/privacy_public"/> + + + - - - + android:textColor="@color/primaryText" + android:textSize="16sp" + android:visibility="gone" + tools:text="2018-12-24"/> + + + + + + + + + + diff --git a/app/src/main/res/layout/content_create_diary.xml b/app/src/main/res/layout/content_create_diary.xml index 44324ff..30e0b74 100644 --- a/app/src/main/res/layout/content_create_diary.xml +++ b/app/src/main/res/layout/content_create_diary.xml @@ -38,6 +38,7 @@ android:hint="@string/create_diary_hint" android:lineSpacingMultiplier="1.2" android:padding="6dp" + android:textColor="@color/primaryText" android:textColorHint="@color/tertiaryText" /> @@ -65,6 +66,7 @@ android:layout_height="wrap_content" android:background="?attr/selectableItemBackgroundBorderless" android:clickable="true" + android:focusable="true" android:paddingBottom="8dp" android:paddingTop="8dp" android:visibility="gone" @@ -77,6 +79,7 @@ android:layout_height="wrap_content" android:background="?attr/selectableItemBackgroundBorderless" android:clickable="true" + android:focusable="true" android:paddingBottom="8dp" android:paddingTop="8dp" app:srcCompat="@drawable/ic_insert_photo_black_24px"/> @@ -87,6 +90,7 @@ android:layout_height="wrap_content" android:background="?attr/selectableItemBackgroundBorderless" android:clickable="true" + android:focusable="true" android:paddingBottom="8dp" android:paddingTop="8dp" app:srcCompat="@drawable/ic_brush_black_24px"/> @@ -100,6 +104,7 @@ android:checked="true" android:gravity="end|center_vertical" android:text="@string/use_topic_pic" + android:textColor="@color/secondText" android:visibility="gone"/> diff --git a/app/src/main/res/layout/fragment_detail_content.xml b/app/src/main/res/layout/fragment_detail_content.xml index 41eeca3..40f5b67 100644 --- a/app/src/main/res/layout/fragment_detail_content.xml +++ b/app/src/main/res/layout/fragment_detail_content.xml @@ -2,9 +2,11 @@ + android:layout_below="@+id/content" + android:layout_marginTop="12dp"> + + + android:layout_height="match_parent" + android:fitsSystemWindows="true"> + app:layout_scrollFlags="scroll|exitUntilCollapsed"> diff --git a/app/src/main/res/layout/fragment_recycler.xml b/app/src/main/res/layout/fragment_recycler.xml index 76c6039..f07f367 100644 --- a/app/src/main/res/layout/fragment_recycler.xml +++ b/app/src/main/res/layout/fragment_recycler.xml @@ -12,7 +12,7 @@ android:id="@+id/swipe_refresh" android:layout_width="match_parent" android:layout_height="match_parent" - app:layout_behavior="@string/appbar_scrolling_view_behavior"> + > diff --git a/app/src/main/res/layout/list_diary_item.xml b/app/src/main/res/layout/list_diary_item.xml index 7938ff1..eed2ed4 100644 --- a/app/src/main/res/layout/list_diary_item.xml +++ b/app/src/main/res/layout/list_diary_item.xml @@ -10,17 +10,6 @@ android:foreground="?android:attr/selectableItemBackground" android:orientation="vertical" android:padding="@dimen/activity_horizontal_margin"> - + + diff --git a/app/src/main/res/layout/tab_pager_layout.xml b/app/src/main/res/layout/tab_pager_layout.xml index d448891..5aabbab 100644 --- a/app/src/main/res/layout/tab_pager_layout.xml +++ b/app/src/main/res/layout/tab_pager_layout.xml @@ -5,6 +5,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:fitsSystemWindows="true" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:showIn="@layout/fragment_profile"> @@ -12,12 +13,14 @@ android:id="@+id/appBarLayout" android:layout_width="match_parent" android:layout_height="wrap_content" + android:fitsSystemWindows="true" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> + android:layout_height="wrap_content" + android:fitsSystemWindows="true"/> diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index a993c3d..7dd3f76 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -48,7 +48,7 @@ Edit this diary Edit this notebook No email client found - Expire time: %s + Expire time: Failed to read pictures Failed to create notebook Failed to update avatar @@ -323,5 +323,11 @@ Are you sure to delete notebook %s ? Delete Notebook deleted + Privacy: + A month + Half of year + A year + Custom + Three month \ No newline at end of file diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml index 2fa1cdf..113e7f5 100644 --- a/app/src/main/res/values-v21/styles.xml +++ b/app/src/main/res/values-v21/styles.xml @@ -6,7 +6,6 @@ true true - @android:color/transparent + - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a770f42..fd2a30a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -67,7 +67,7 @@ 大家可见 可见性 创建日记本 - 过期时间:%s + 过期时间: 创建日记本失败 编辑日记本 更新成功 @@ -312,4 +312,10 @@ 删除日记本失败 确实要删除日记本 %s 吗? 日记本已删除 + 隐私性: + 一个月 + 半年 + 一年 + 自定义 + 三个月 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index fea8dae..6edf682 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -8,7 +8,6 @@ @color/colorAccent -