Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ notifications:

sudo: false

after_success:
- ./gradlew build connectedCheck

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock

Expand Down
3 changes: 1 addition & 2 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest package="com.fnp.materialpreferences">

<application />

<application/>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -28,81 +28,98 @@
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;

/**
* A {@link PreferenceActivity} which implements and proxies the necessary calls
* to be used with AppCompat.
* A {@link PreferenceActivity} which implements and proxies the necessary calls to be used with
* AppCompat.
*
* This technique can be used with an {@link android.app.Activity} class, not just
* {@link PreferenceActivity}.
* This technique can be used with an {@link android.app.Activity} class, not just {@link
* PreferenceActivity}.
*/
abstract class AppCompatPreferenceActivity extends PreferenceActivity {
private AppCompatDelegate mDelegate;

@Override
protected void onCreate(Bundle savedInstanceState) {
getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
}

@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
getDelegate().onPostCreate(savedInstanceState);
}

public ActionBar getSupportActionBar() {
return getDelegate().getSupportActionBar();
}

public void setSupportActionBar(@Nullable Toolbar toolbar) {
getDelegate().setSupportActionBar(toolbar);
}

@NonNull
@Override
public MenuInflater getMenuInflater() {
return getDelegate().getMenuInflater();
}

@Override
public void setContentView(@LayoutRes int layoutResID) {
getDelegate().setContentView(layoutResID);
}

@Override
public void setContentView(View view) {
getDelegate().setContentView(view);
}

@Override
public void setContentView(View view, ViewGroup.LayoutParams params) {
getDelegate().setContentView(view, params);
}

@Override
public void addContentView(View view, ViewGroup.LayoutParams params) {
getDelegate().addContentView(view, params);
}

@Override
protected void onPostResume() {
super.onPostResume();
getDelegate().onPostResume();
}

@Override
protected void onTitleChanged(CharSequence title, int color) {
super.onTitleChanged(title, color);
getDelegate().setTitle(title);
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
getDelegate().onConfigurationChanged(newConfig);
}

@Override
protected void onStop() {
super.onStop();
getDelegate().onStop();
}

@Override
protected void onDestroy() {
super.onDestroy();
getDelegate().onDestroy();
}

public void invalidateOptionsMenu() {
getDelegate().invalidateOptionsMenu();
}

private AppCompatDelegate getDelegate() {
if (mDelegate == null) {
mDelegate = AppCompatDelegate.create(this, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ public abstract class PreferenceActivity extends AppCompatPreferenceActivity {
public void setPreferenceFragment(PreferenceFragment preferenceFragment) {

//First check if it's already loaded (configuration change) so we don't overlap fragments
if(getFragmentManager()
.findFragmentByTag("com.fnp.materialpreferences.MainFragment") != null){
if (getFragmentManager()
.findFragmentByTag("com.fnp.materialpreferences.MainFragment") != null) {
return;
}

FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
fragmentTransaction.replace(R.id.content, preferenceFragment,
"com.fnp.materialpreferences.MainFragment");
}else{
} else {
fragmentTransaction.replace(android.R.id.content, preferenceFragment,
"com.fnp.materialpreferences.MainFragment");
}
Expand All @@ -36,7 +36,7 @@ public void onCreate(Bundle savedInstanceState) {
// Do not add custom layout for lollipop devices or we lose the widgets animation
// (app compat bug?)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
setContentView(R.layout.mp_activity_settings);;
setContentView(R.layout.mp_activity_settings);
Toolbar toolbar = (Toolbar) findViewById(R.id.mp_toolbar);
setSupportActionBar(toolbar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public void onCreate(Bundle savedInstanceState) {
//If we need to restore the state after a configuration change
if (savedInstanceState != null) {
if (getPreferenceScreen() != null) { //Main fragment will fill the HashMap
ArrayList<Preference> preferences = getAllPreferenceScreen(getPreferenceScreen(),
ArrayList<Preference> preferences = getAllPreferenceScreen(getPreferenceScreen(),
new ArrayList<Preference>());
for(Preference preference: preferences){
preferenceScreenHashMap.put(preference.getKey(), (PreferenceScreen)preference);
for (Preference preference : preferences) {
preferenceScreenHashMap.put(preference.getKey(), (PreferenceScreen) preference);
}

} else { //Nested fragments will use the HashMap to set their PreferenceScreen
Expand All @@ -59,13 +59,13 @@ public void onCreate(Bundle savedInstanceState) {
}

private ArrayList<Preference> getAllPreferenceScreen(Preference p, ArrayList<Preference> list) {
if( p instanceof PreferenceCategory || p instanceof PreferenceScreen) {
if (p instanceof PreferenceCategory || p instanceof PreferenceScreen) {
PreferenceGroup pGroup = (PreferenceGroup) p;
int pCount = pGroup.getPreferenceCount();
if(p instanceof PreferenceScreen){
if (p instanceof PreferenceScreen) {
list.add(p);
}
for(int i = 0; i < pCount; i++) {
for (int i = 0; i < pCount; i++) {
getAllPreferenceScreen(pGroup.getPreference(i), list);
}
}
Expand Down Expand Up @@ -108,7 +108,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
return v;
}

private void preferenceToMaterialPreference(Preference preference){
private void preferenceToMaterialPreference(Preference preference) {
if (preference instanceof PreferenceScreen) {
preference.setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() {
Expand Down Expand Up @@ -189,7 +189,7 @@ public boolean onPreferenceScreenClick(@NonNull PreferenceScreen preference) {
transaction.commitAllowingStateLoss();

return true;
}else if(preference.getIntent() != null) {
} else if (preference.getIntent() != null) {
startActivity(preference.getIntent());
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions library/src/main/res/drawable/toolbar_shadow.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
android:shape="rectangle">
<gradient
android:startColor="@android:color/transparent"
android:angle="90"
android:endColor="#40000000"
android:angle="90" />
android:startColor="@android:color/transparent"/>
</shape>
11 changes: 6 additions & 5 deletions library/src/main/res/layout-v17/mp_preference_category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
<!-- Android Studio warns that paddingLeft and paddingRight are redundant here but...
if your app has minSdkVersion lower than v17, some devices will not display
those properties correctly (like Samsung) -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
<TextView
android:id="@+android:id/title"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dip"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="?attr/colorAccent"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
android:paddingRight="?attr/listPreferredItemPaddingRight"
android:paddingTop="16dip" />
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingTop="16dip"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="?attr/colorAccent"/>
5 changes: 3 additions & 2 deletions library/src/main/res/layout/mp_activity_settings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout
android:id="@+id/activity_settings_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
Expand All @@ -17,6 +18,6 @@
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"/>
</FrameLayout>
</RelativeLayout>
9 changes: 5 additions & 4 deletions library/src/main/res/layout/mp_preference_category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
-->

<!-- Layout used for PreferenceCategory in a PreferenceActivity. -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
<TextView
android:id="@+android:id/title"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dip"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="?attr/colorAccent"
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
android:paddingRight="?attr/listPreferredItemPaddingRight"
android:paddingTop="16dip" />
android:paddingTop="16dip"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="?attr/colorAccent"/>
20 changes: 10 additions & 10 deletions library/src/main/res/layout/mp_preference_material.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingRight="?attr/listPreferredItemPaddingRight"
android:baselineAligned="false">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
android:paddingRight="?attr/listPreferredItemPaddingRight"
android:paddingStart="?android:attr/listPreferredItemPaddingStart">

<include layout="@layout/mp_preference_material_body" />
<include layout="@layout/mp_preference_material_body"/>
</LinearLayout>
18 changes: 9 additions & 9 deletions library/src/main/res/layout/mp_preference_material_body.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:layout_weight="1">
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="16dp"
android:paddingTop="16dp">

<TextView
android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:textAppearance="?attr/textAppearanceListItem"
android:ellipsize="marquee"
android:textColor="?android:textColorPrimary" />
android:textColor="?android:textColorPrimary"/>

<TextView
android:id="@android:id/summary"
Expand All @@ -22,9 +22,9 @@
android:layout_alignLeft="@android:id/title"
android:layout_alignStart="@android:id/title"
android:layout_below="@android:id/title"
android:maxLines="10"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textColor="?android:textColorSecondary"
android:typeface="sans"
android:maxLines="10" />
android:typeface="sans"/>

</RelativeLayout>
22 changes: 11 additions & 11 deletions library/src/main/res/layout/mp_preference_material_widget.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingRight="?attr/listPreferredItemPaddingRight"
android:baselineAligned="false">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
android:paddingRight="?attr/listPreferredItemPaddingRight"
android:paddingStart="?android:attr/listPreferredItemPaddingStart">

<include layout="@layout/mp_preference_material_body" />
<include layout="@layout/mp_preference_material_body"/>

<!-- Preference should place its actual preference widget here. -->
<LinearLayout
android:id="@android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical" />
android:orientation="vertical"/>

</LinearLayout>
7 changes: 4 additions & 3 deletions library/src/main/res/layout/mp_preference_switch.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.SwitchCompat xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v7.widget.SwitchCompat
android:id="@android:id/checkbox"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:background="@null"
android:clickable="false"
android:background="@null"/>
android:focusable="false"/>
Loading