Skip to content
This repository has been archived by the owner on Jan 26, 2020. It is now read-only.

Commit

Permalink
Add DayNight mode
Browse files Browse the repository at this point in the history
Fix WebView can't back
Hide Google's divider in PreferenceFragment added in support 23.2.0
  • Loading branch information
RikkaW committed Mar 3, 2016
1 parent b86422d commit ad3057a
Show file tree
Hide file tree
Showing 29 changed files with 76 additions and 38 deletions.
6 changes: 3 additions & 3 deletions SettingsUI/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:preference-v7:23.1.1'
compile 'com.android.support:preference-v14:23.1.1'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:preference-v7:23.2.0'
compile 'com.android.support:preference-v14:23.2.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,26 @@
* Created by Rikka on 2016/2/19.
*/
public abstract class PreferenceFragment extends android.support.v14.preference.PreferenceFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
public void addDefaultListDivider() {

// hide Google's divider added in 23.2.0
setDivider(null);

RecyclerView listView = getListView();
listView.addItemDecoration(new BaseRecyclerViewItemDecoration(container.getContext()) {
listView.addItemDecoration(new BaseRecyclerViewItemDecoration(getActivity()) {
@Override
public boolean canDraw(RecyclerView parent, View child, int childCount, int position) {
return ((position < childCount - 1)
return (position < childCount - 1
&& parent.getChildAt(position + 1).findViewById(android.R.id.summary) != null
&& child.findViewById(android.R.id.summary) != null);
}
});
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
addDefaultListDivider();
return view;
}
}
12 changes: 7 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {
}

productFlavors {
def String name = "1.4.4"
def String name = "1.4.5"

COOLAPK {
applicationId "rikka.searchbyimage"
Expand Down Expand Up @@ -51,11 +51,13 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile "com.android.support:customtabs:23.1.1"
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.2.0'
compile "com.android.support:customtabs:23.2.0"
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:support-v4:23.2.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.squareup.okhttp3:okhttp:3.0.1'
compile 'com.github.RikkaW:DayNight-Theme:v1.0.4'

compile project(':SettingsUI')
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
</intent-filter>
</activity>
<activity android:name=".ui.EditSitesActivity"
android:theme="@style/AppTheme.NoActionBar"
android:label="@string/edit_sites"/>
<activity android:name=".ui.EditSiteInfoActivity"
android:windowSoftInputMode="adjustResize"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.io.InputStream;

import moe.xing.daynightmode.DayNightMode;
import rikka.searchbyimage.support.CrashHandler;

/**
Expand All @@ -25,6 +26,8 @@ public void setImageInputStream(InputStream imageInputStream) {
public void onCreate() {
super.onCreate();

DayNightMode.setDefaultNightMode(this, DayNightMode.MODE_NIGHT_AUTO);

if (!BuildConfig.hideOtherEngine && !BuildConfig.DEBUG) {
CrashHandler.init(getApplicationContext());
CrashHandler.register();
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/rikka/searchbyimage/ui/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package rikka.searchbyimage.ui;

import moe.xing.daynightmode.BaseDayNightModeActivity;

/**
* Created by Rikka on 2016/3/3.
*/
public class BaseActivity extends BaseDayNightModeActivity {
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import rikka.searchbyimage.staticdata.CustomEngine;
import rikka.searchbyimage.utils.URLUtils;

public class ChromeCustomTabsActivity extends AppCompatActivity {
public class ChromeCustomTabsActivity extends BaseActivity {
public static final String EXTRA_URL =
"rikka.searchbyimage.ui.ChromeCustomTabsActivity.EXTRA_URL";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import rikka.searchbyimage.utils.ParcelableUtils;
import rikka.searchbyimage.utils.URLUtils;

public class EditSiteInfoActivity extends AppCompatActivity {
public class EditSiteInfoActivity extends BaseActivity {
public static final String EXTRA_EDIT_LOCATION =
"rikka.searchbyimage.ui.EditSiteInfoActivity.EXTRA_EDIT_LOCATION";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import rikka.searchbyimage.staticdata.CustomEngine;
import rikka.searchbyimage.ui.apdater.SearchEngineAdapter;

public class EditSitesActivity extends AppCompatActivity {
public class EditSitesActivity extends BaseActivity {
Activity mActivity;

DatabaseHelper mDbHelper;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/rikka/searchbyimage/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import rikka.searchbyimage.ui.fragment.SettingsFragment;


public class MainActivity extends AppCompatActivity {
public class MainActivity extends BaseActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import rikka.searchbyimage.R;
import rikka.searchbyimage.ui.fragment.SettingsFragment;

public class PopupSettingsActivity extends AppCompatActivity {
public class PopupSettingsActivity extends BaseActivity {
public static final String EXTRA_URI =
"rikka.searchbyimage.ui.ResultActivity.EXTRA_URI";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import rikka.searchbyimage.utils.URLUtils;
import me.qixingchen.settings.BaseRecyclerViewItemDecoration;

public class ResultActivity extends AppCompatActivity {
public class ResultActivity extends BaseActivity {

public static final String EXTRA_FILE =
"rikka.searchbyimage.ui.ResultActivity.EXTRA_FILE";
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/rikka/searchbyimage/ui/UploadActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import rikka.searchbyimage.utils.ResponseUtils;
import rikka.searchbyimage.utils.Utils;

public class UploadActivity extends AppCompatActivity {
public class UploadActivity extends BaseActivity {
public final static int SITE_GOOGLE = 0;
public final static int SITE_BAIDU = 1;
public final static int SITE_IQDB = 2;
Expand Down Expand Up @@ -325,7 +325,7 @@ private ProgressDialog showDialog() {
ProgressDialog progressDialog;

if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP || Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1)
progressDialog = new ProgressDialog(this, R.style.DialogStyle);
progressDialog = new ProgressDialog(this, R.style.ProgressDialog);
else
progressDialog = new ProgressDialog(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import rikka.searchbyimage.view.WebViewToolBar;
import rikka.searchbyimage.widget.InfoBar;

public class WebViewActivity extends AppCompatActivity {
public class WebViewActivity extends BaseActivity {
public static final String EXTRA_URL =
"rikka.searchbyimage.ui.WebViewActivity.EXTRA_URL";

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_add_engine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/scrollView"
android:background="#FAFAFA"
android:background="@color/backgourd"
android:theme="@style/EditInfoEditText"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_edit_sites.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".ui.EditSitesActivity"
tools:showIn="@layout/activity_edit_sites">
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

<FrameLayout
android:id="@+id/settings_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".ui.MainActivity"
tools:showIn="@layout/activity_main">
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/list_item_edit_sites.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:background="@color/list_item_background"
android:elevation="2dp"
android:orientation="vertical">

Expand All @@ -46,7 +46,6 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@android:color/white"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
Expand Down
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="list_item_background">#212121</color>
<color name="backgourd">@color/material_grey_850</color>
<color name="dividerSearchEngineList">#20ffffff</color>
<color name="contextMenuTitle">#FFF</color>

</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat" />
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ProgressDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert">
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@

<color name="preference_fallback_accent_color">@color/colorAccent</color>

<color name="list_item_background">#FFF</color>
<color name="backgourd">@color/material_grey_50</color>
</resources>
15 changes: 6 additions & 9 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
<item name="preferenceTheme">@style/PreferenceTheme.Material</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
Expand All @@ -10,34 +10,31 @@
<!--<item name="android:windowContentTransitions">true</item>-->
</style>

<style name="AppTheme.UseColorControlActivated" parent="AppTheme">
<style name="AppTheme.UseColorControlActivated" parent="AppTheme.NoActionBar">
<item name="colorControlActivated">@color/colorPrimary</item>
</style>

<style name="AppTheme.NoActionBar" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="titleTextColor">#FFFFFF</item>

<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="PopupTheme" parent="Theme.AppCompat.Light.Dialog">
<style name="PopupTheme" parent="Theme.AppCompat.DayNight.Dialog">
<item name="preferenceTheme">@style/PreferenceTheme.Material</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowNoTitle">true</item>
</style>


<style name="DialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="Transparent" parent="AppTheme">
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowIsFloating">true</item>

</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ buildscript {
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}

Expand Down

0 comments on commit ad3057a

Please sign in to comment.