Skip to content
This repository was archived by the owner on May 1, 2021. It is now read-only.

Commit 2b44868

Browse files
updated to use latest Google's libraries.
also using a more official approach for the PreferenceActivity, which could help you with create your own material preferences a bit easier.
1 parent d283617 commit 2b44868

File tree

9 files changed

+184
-14
lines changed

9 files changed

+184
-14
lines changed

.idea/misc.xml

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MaterialPreferences.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</configuration>
99
</facet>
1010
</component>
11-
<component name="NewModuleRootManager" inherit-compiler-output="true">
11+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
1212
<exclude-output />
1313
<content url="file://$MODULE_DIR$">
1414
<excludeFolder url="file://$MODULE_DIR$/.gradle" />

app/app.iml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
1313
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
1414
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
15-
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
1615
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
1716
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
18-
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
17+
<afterSyncTasks>
18+
<task>generateDebugAndroidTestSources</task>
19+
<task>generateDebugSources</task>
20+
</afterSyncTasks>
1921
<option name="ALLOW_USER_CONFIGURATION" value="false" />
2022
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
2123
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
@@ -24,7 +26,7 @@
2426
</configuration>
2527
</facet>
2628
</component>
27-
<component name="NewModuleRootManager" inherit-compiler-output="false">
29+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
2830
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
2931
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
3032
<exclude-output />
@@ -69,7 +71,7 @@
6971
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
7072
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
7173
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
72-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.1.1/jars" />
74+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" />
7375
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
7476
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
7577
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
@@ -87,8 +89,8 @@
8789
</content>
8890
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
8991
<orderEntry type="sourceFolder" forTests="false" />
90-
<orderEntry type="library" exported="" name="support-annotations-22.1.1" level="project" />
91-
<orderEntry type="library" exported="" name="support-v4-22.1.1" level="project" />
92+
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
93+
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
9294
<orderEntry type="module" module-name="material_preferences_library" exported="" />
9395
</component>
9496
</module>

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ android {
2626
dependencies {
2727
compile fileTree(include: ['*.jar'], dir: 'libs')
2828
compile project(':material_preferences_library')
29-
compile 'com.android.support:support-v4:22.1.1'
29+
compile 'com.android.support:support-v4:22.2.0'
3030
}

material_preferences_library/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ android {
2525
dependencies {
2626
compile fileTree(include: ['*.jar'], dir: 'libs')
2727
// compile 'com.infstory:switch-preference-compat:1.0.0'
28-
compile 'com.android.support:appcompat-v7:22.1.1'
28+
compile 'com.android.support:appcompat-v7:22.2.0'
2929
}

material_preferences_library/material_preferences_library.iml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module external.linked.project.id=":material_preferences_library" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="MaterialPreferences" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
2+
<module external.linked.project.id=":material_preferences_library" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/../../AppManager" external.system.id="GRADLE" external.system.module.group="AppManager" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
33
<component name="FacetManager">
44
<facet type="android-gradle" name="Android-Gradle">
55
<configuration>
@@ -12,10 +12,12 @@
1212
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
1313
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
1414
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
15-
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
1615
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
1716
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
18-
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
17+
<afterSyncTasks>
18+
<task>generateDebugAndroidTestSources</task>
19+
<task>generateDebugSources</task>
20+
</afterSyncTasks>
1921
<option name="ALLOW_USER_CONFIGURATION" value="false" />
2022
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
2123
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
@@ -25,7 +27,7 @@
2527
</configuration>
2628
</facet>
2729
</component>
28-
<component name="NewModuleRootManager" inherit-compiler-output="false">
30+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
2931
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
3032
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
3133
<exclude-output />
@@ -70,6 +72,8 @@
7072
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
7173
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
7274
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
75+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.1.1/jars" />
76+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.1.1/jars" />
7377
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
7478
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
7579
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*
2+
* Copyright (C) 2014 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.lb.material_preferences_library;
18+
19+
import android.content.res.Configuration;
20+
import android.os.Bundle;
21+
import android.preference.PreferenceActivity;
22+
import android.support.annotation.LayoutRes;
23+
import android.support.annotation.Nullable;
24+
import android.support.v7.app.ActionBar;
25+
import android.support.v7.app.AppCompatDelegate;
26+
import android.support.v7.widget.Toolbar;
27+
import android.view.MenuInflater;
28+
import android.view.View;
29+
import android.view.ViewGroup;
30+
31+
/**
32+
* A {@link PreferenceActivity} which implements and proxies the necessary calls
33+
* to be used with AppCompat.
34+
*
35+
* This technique can be used with an {@link android.app.Activity} class, not just
36+
* {@link PreferenceActivity}.
37+
*/
38+
public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
39+
40+
private AppCompatDelegate mDelegate;
41+
42+
@Override
43+
protected void onCreate(Bundle savedInstanceState) {
44+
getDelegate().installViewFactory();
45+
getDelegate().onCreate(savedInstanceState);
46+
super.onCreate(savedInstanceState);
47+
}
48+
49+
@Override
50+
protected void onPostCreate(Bundle savedInstanceState) {
51+
super.onPostCreate(savedInstanceState);
52+
getDelegate().onPostCreate(savedInstanceState);
53+
}
54+
55+
public ActionBar getSupportActionBar() {
56+
return getDelegate().getSupportActionBar();
57+
}
58+
59+
public void setSupportActionBar(@Nullable Toolbar toolbar) {
60+
getDelegate().setSupportActionBar(toolbar);
61+
}
62+
63+
@Override
64+
public MenuInflater getMenuInflater() {
65+
return getDelegate().getMenuInflater();
66+
}
67+
68+
@Override
69+
public void setContentView(@LayoutRes int layoutResID) {
70+
getDelegate().setContentView(layoutResID);
71+
}
72+
73+
@Override
74+
public void setContentView(View view) {
75+
getDelegate().setContentView(view);
76+
}
77+
78+
@Override
79+
public void setContentView(View view, ViewGroup.LayoutParams params) {
80+
getDelegate().setContentView(view, params);
81+
}
82+
83+
@Override
84+
public void addContentView(View view, ViewGroup.LayoutParams params) {
85+
getDelegate().addContentView(view, params);
86+
}
87+
88+
@Override
89+
protected void onPostResume() {
90+
super.onPostResume();
91+
getDelegate().onPostResume();
92+
}
93+
94+
@Override
95+
protected void onTitleChanged(CharSequence title, int color) {
96+
super.onTitleChanged(title, color);
97+
getDelegate().setTitle(title);
98+
}
99+
100+
@Override
101+
public void onConfigurationChanged(Configuration newConfig) {
102+
super.onConfigurationChanged(newConfig);
103+
getDelegate().onConfigurationChanged(newConfig);
104+
}
105+
106+
@Override
107+
protected void onStop() {
108+
super.onStop();
109+
getDelegate().onStop();
110+
}
111+
112+
@Override
113+
protected void onDestroy() {
114+
super.onDestroy();
115+
getDelegate().onDestroy();
116+
}
117+
118+
public void invalidateOptionsMenu() {
119+
getDelegate().invalidateOptionsMenu();
120+
}
121+
122+
private AppCompatDelegate getDelegate() {
123+
if (mDelegate == null) {
124+
mDelegate = AppCompatDelegate.create(this, null);
125+
}
126+
return mDelegate;
127+
}
128+
}

material_preferences_library/src/main/java/com/lb/material_preferences_library/PreferenceActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import android.view.View;
1010
import android.view.ViewGroup;
1111

12-
public abstract class PreferenceActivity extends android.preference.PreferenceActivity
12+
public abstract class PreferenceActivity extends AppCompatPreferenceActivity
1313
{
1414
private Toolbar _toolbar;
1515

0 commit comments

Comments
 (0)