diff --git a/app/build.gradle b/app/build.gradle
index e8426bb..2faf603 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -8,7 +8,7 @@ android {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
- versionName "1.1"
+ versionName '1.2'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -31,21 +31,21 @@ android {
debuggable true
}
}
+ productFlavors {
+ }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
- androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
- exclude group: 'com.android.support', module: 'support-annotations'
- })
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:cardview-v7:25.0.1'
compile 'com.android.support:support-v4:25.0.1'
+ compile 'com.afollestad.material-dialogs:commons:0.9.1.0'
compile 'com.squareup.okhttp3:okhttp:3.4.2'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
- compile 'com.afollestad.material-dialogs:core:0.9.1.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
+ compile 'de.psdev.licensesdialog:licensesdialog:1.8.1'
}
diff --git a/app/src/main/java/com/meiji/daily/BaseActivity.java b/app/src/main/java/com/meiji/daily/BaseActivity.java
new file mode 100644
index 0000000..bd99947
--- /dev/null
+++ b/app/src/main/java/com/meiji/daily/BaseActivity.java
@@ -0,0 +1,34 @@
+package com.meiji.daily;
+
+import android.graphics.drawable.ColorDrawable;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+
+import com.afollestad.materialdialogs.color.CircleView;
+import com.meiji.daily.utils.ColorUtil;
+
+/**
+ * Created by Meiji on 2016/11/27.
+ */
+
+public class BaseActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ int color = ColorUtil.getColor(this);
+ if (getSupportActionBar() != null)
+ getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ getWindow().setStatusBarColor(CircleView.shiftColorDown(color));
+ getWindow().setNavigationBarColor(color);
+ }
+ }
+}
diff --git a/app/src/main/java/com/meiji/daily/MainActivity.java b/app/src/main/java/com/meiji/daily/MainActivity.java
index da56bda..c7f58d7 100644
--- a/app/src/main/java/com/meiji/daily/MainActivity.java
+++ b/app/src/main/java/com/meiji/daily/MainActivity.java
@@ -1,25 +1,36 @@
package com.meiji.daily;
import android.content.res.Configuration;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Build;
import android.os.Bundle;
+import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
-import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
+import com.afollestad.materialdialogs.color.CircleView;
+import com.afollestad.materialdialogs.color.ColorChooserDialog;
import com.meiji.daily.mvp.zhuanlan.ZhuanlanModel;
import com.meiji.daily.mvp.zhuanlan.ZhuanlanView;
+import com.meiji.daily.utils.ColorUtil;
-public class MainActivity extends AppCompatActivity
- implements NavigationView.OnNavigationItemSelectedListener {
+import de.psdev.licensesdialog.LicensesDialog;
+import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20;
+import de.psdev.licensesdialog.licenses.MITLicense;
+import de.psdev.licensesdialog.model.Notice;
+import de.psdev.licensesdialog.model.Notices;
+
+public class MainActivity extends BaseActivity
+ implements NavigationView.OnNavigationItemSelectedListener, ColorChooserDialog.ColorCallback {
private DrawerLayout drawerLayout;
private NavigationView navigationView;
@@ -122,7 +133,11 @@ public boolean onNavigationItemSelected(MenuItem item) {
} else if (id == R.id.nav_user_define) {
+ } else if (id == R.id.nav_color_chooser) {
+ createColorChooserDialog();
+
} else if (id == R.id.nav_about) {
+ createLicenseDialog();
}
@@ -132,7 +147,6 @@ public boolean onNavigationItemSelected(MenuItem item) {
private void replaceFragment(int type) {
ZhuanlanView fragment = ZhuanlanView.newInstance(type);
-// getSupportFragmentManager().beginTransaction().replace(R.id.content_main, fragment).commit();
getSupportFragmentManager().beginTransaction().replace(R.id.app_bar_main, fragment).commit();
}
@@ -140,4 +154,41 @@ private void replaceFragment(int type) {
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
+
+ private void createColorChooserDialog() {
+ new ColorChooserDialog.Builder(this, R.string.color_chooser_title)
+ .doneButton(R.string.md_done)
+ .cancelButton(R.string.md_cancel)
+ .allowUserColorInput(true)
+ .customButton(R.string.md_custom)
+ .show();
+ }
+
+ @Override
+ public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
+ if (getSupportActionBar() != null)
+ getSupportActionBar().setBackgroundDrawable(new ColorDrawable(selectedColor));
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ getWindow().setStatusBarColor(CircleView.shiftColorDown(selectedColor));
+ getWindow().setNavigationBarColor(selectedColor);
+ }
+ if (!dialog.isAccentMode()) {
+ ColorUtil.setColor(this, selectedColor);
+ }
+ }
+
+ private void createLicenseDialog() {
+ Notices notices = new Notices();
+ notices.addNotice(new Notice("material-dialogs", "https://github.com/afollestad/material-dialogs", "Copyright (c) 2014-2016 Aidan Michael Follestad", new MITLicense()));
+ notices.addNotice(new Notice("okhttp", "https://github.com/square/okhttp", "Copyright 2016 Square, Inc.", new ApacheSoftwareLicense20()));
+ notices.addNotice(new Notice("gson", "https://github.com/google/gson", "Copyright 2008 Google Inc.", new ApacheSoftwareLicense20()));
+ notices.addNotice(new Notice("glide", "https://github.com/bumptech/glide", "Sam Judd - @sjudd on GitHub, @samajudd on Twitter", new ApacheSoftwareLicense20()));
+ notices.addNotice(new Notice("CircleImageView", "https://github.com/hdodenhof/CircleImageView", "Copyright 2014 - 2016 Henning Dodenhof", new ApacheSoftwareLicense20()));
+
+ new LicensesDialog.Builder(this)
+ .setNotices(notices)
+ .setIncludeOwnLicense(true)
+ .build()
+ .show();
+ }
}
diff --git a/app/src/main/java/com/meiji/daily/mvp/postscontent/PostsContentView.java b/app/src/main/java/com/meiji/daily/mvp/postscontent/PostsContentView.java
index 4881cd6..f5673c3 100644
--- a/app/src/main/java/com/meiji/daily/mvp/postscontent/PostsContentView.java
+++ b/app/src/main/java/com/meiji/daily/mvp/postscontent/PostsContentView.java
@@ -8,7 +8,6 @@
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
-import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.KeyEvent;
@@ -21,6 +20,7 @@
import com.afollestad.materialdialogs.MaterialDialog;
import com.bumptech.glide.Glide;
+import com.meiji.daily.BaseActivity;
import com.meiji.daily.R;
import com.meiji.daily.utils.Api;
@@ -32,7 +32,7 @@
* Created by Meiji on 2016/11/22.
*/
-public class PostsContentView extends AppCompatActivity implements View.OnClickListener, IPostsContent.View {
+public class PostsContentView extends BaseActivity implements View.OnClickListener, IPostsContent.View {
private ImageView iv_header;
private Toolbar toolbar_title;
diff --git a/app/src/main/java/com/meiji/daily/mvp/postslist/PostsListView.java b/app/src/main/java/com/meiji/daily/mvp/postslist/PostsListView.java
index eace8c0..a03e1d7 100644
--- a/app/src/main/java/com/meiji/daily/mvp/postslist/PostsListView.java
+++ b/app/src/main/java/com/meiji/daily/mvp/postslist/PostsListView.java
@@ -5,13 +5,13 @@
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout;
-import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
+import com.meiji.daily.BaseActivity;
import com.meiji.daily.R;
import com.meiji.daily.adapter.PostsListAdapter;
import com.meiji.daily.interfaces.IOnItemClickListener;
@@ -27,7 +27,7 @@
* Created by Meiji on 2016/11/18.
*/
-public class PostsListView extends AppCompatActivity implements IPostsList.View, SwipeRefreshLayout.OnRefreshListener {
+public class PostsListView extends BaseActivity implements IPostsList.View, SwipeRefreshLayout.OnRefreshListener {
private Toolbar toolbar; // 双击 toolbar 返回顶部 待写
private SwipeRefreshLayout refresh_layout;
diff --git a/app/src/main/java/com/meiji/daily/utils/ColorUtil.java b/app/src/main/java/com/meiji/daily/utils/ColorUtil.java
new file mode 100644
index 0000000..f6b40b9
--- /dev/null
+++ b/app/src/main/java/com/meiji/daily/utils/ColorUtil.java
@@ -0,0 +1,24 @@
+package com.meiji.daily.utils;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+import static android.content.Context.MODE_PRIVATE;
+
+/**
+ * Created by Meiji on 2016/11/26.
+ */
+
+public class ColorUtil {
+
+ public static void setColor(Context context, int color) {
+ SharedPreferences prefs = context.getSharedPreferences(context.getPackageName(), MODE_PRIVATE);
+ prefs.edit().putInt("color", color).apply();
+ }
+
+ public static int getColor(Context context) {
+ SharedPreferences prefs = context.getSharedPreferences(context.getPackageName(), MODE_PRIVATE);
+ int defaultColor = -14776091;
+ return prefs.getInt("color", defaultColor);
+ }
+}
diff --git a/app/src/main/res/drawable-v21/ic_photo_color_chooser.xml b/app/src/main/res/drawable-v21/ic_photo_color_chooser.xml
new file mode 100644
index 0000000..5809f6c
--- /dev/null
+++ b/app/src/main/res/drawable-v21/ic_photo_color_chooser.xml
@@ -0,0 +1,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_postscontent.xml b/app/src/main/res/layout/activity_postscontent.xml
index cf905cf..1762752 100644
--- a/app/src/main/res/layout/activity_postscontent.xml
+++ b/app/src/main/res/layout/activity_postscontent.xml
@@ -21,7 +21,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
- app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
-
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
index ff562eb..caecc60 100644
--- a/app/src/main/res/values-v21/styles.xml
+++ b/app/src/main/res/values-v21/styles.xml
@@ -9,9 +9,8 @@
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d13e5b9..e9fd73b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -93,5 +93,11 @@
Hello blank fragment
网络不给力
title image
+ 选择颜色
+ 切换主题
+ 选择主题颜色
+ 完成
+ 取消
+ 自定义
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 8f52f3f..d8d27bb 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -3,10 +3,9 @@