-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,531 additions
and
691 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
app/src/main/java/com/afwsamples/testdpc/common/preference/DpcEditTextPreference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* | ||
* Copyright (C) 2016 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.afwsamples.testdpc.common.preference; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.StringRes; | ||
import android.support.v7.preference.EditTextPreference; | ||
import android.support.v7.preference.PreferenceManager; | ||
import android.support.v7.preference.PreferenceViewHolder; | ||
import android.util.AttributeSet; | ||
|
||
/** | ||
* An {@link EditTextPreference} which can be disabled via XML declared constraints. | ||
* | ||
* See {@link DpcPreferenceHelper} for details about constraints. | ||
*/ | ||
public class DpcEditTextPreference extends EditTextPreference implements DpcPreferenceBase { | ||
private DpcPreferenceHelper mHelper; | ||
|
||
public DpcEditTextPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||
super(context, attrs, defStyleAttr, defStyleRes); | ||
mHelper = new DpcPreferenceHelper(context, this, attrs); | ||
} | ||
|
||
public DpcEditTextPreference(Context context, AttributeSet attrs, int defStyleAttr) { | ||
this(context, attrs, defStyleAttr, 0); | ||
} | ||
|
||
public DpcEditTextPreference(Context context, AttributeSet attrs) { | ||
this(context, attrs, android.support.v7.preference.R.attr.editTextPreferenceStyle); | ||
} | ||
|
||
public DpcEditTextPreference(Context context) { | ||
this(context, null); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(PreferenceViewHolder holder) { | ||
super.onBindViewHolder(holder); | ||
mHelper.onBindViewHolder(holder); | ||
} | ||
|
||
@Override | ||
protected void onAttachedToHierarchy(PreferenceManager preferenceManager) { | ||
mHelper.onAttachedToHierarchy(); | ||
super.onAttachedToHierarchy(preferenceManager); | ||
} | ||
|
||
@Override | ||
public void setEnabled(boolean enabled) { | ||
if (enabled && !mHelper.constraintsMet()) { | ||
return; // ignore | ||
} | ||
super.setEnabled(enabled); | ||
} | ||
|
||
@Override | ||
public void setMinSdkVersion(int version) { | ||
mHelper.setMinSdkVersion(version); | ||
} | ||
|
||
@Override | ||
public void setAdminConstraint(@DpcPreferenceHelper.AdminKind int adminConstraint) { | ||
mHelper.setAdminConstraint(adminConstraint); | ||
} | ||
|
||
@Override | ||
public void clearAdminConstraint() { | ||
mHelper.clearAdminConstraint(); | ||
} | ||
|
||
@Override | ||
public void setUserConstraint(@DpcPreferenceHelper.UserKind int userConstraints) { | ||
mHelper.setUserConstraint(userConstraints); | ||
} | ||
|
||
@Override | ||
public void clearUserConstraint() { | ||
mHelper.clearUserConstraint(); | ||
} | ||
|
||
@Override | ||
public void clearNonCustomConstraints() { | ||
mHelper.clearNonCustomConstraints(); | ||
} | ||
|
||
@Override | ||
public void setCustomConstraint(CharSequence constraintSummary) { | ||
mHelper.setCustomConstraint(constraintSummary); | ||
} | ||
|
||
@Override | ||
public void setCustomConstraint(@StringRes int constraintSummaryRes) { | ||
mHelper.setCustomConstraint(getContext().getString(constraintSummaryRes)); | ||
} | ||
|
||
@Override | ||
public void clearCustomConstraint() { | ||
mHelper.clearCustomConstraint(); | ||
} | ||
} | ||
|
116 changes: 116 additions & 0 deletions
116
app/src/main/java/com/afwsamples/testdpc/common/preference/DpcListPreference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* | ||
* Copyright (C) 2016 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.afwsamples.testdpc.common.preference; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.StringRes; | ||
import android.support.v7.preference.ListPreference; | ||
import android.support.v7.preference.PreferenceManager; | ||
import android.support.v7.preference.PreferenceViewHolder; | ||
import android.util.AttributeSet; | ||
|
||
/** | ||
* An {@link ListPreference} which can be disabled via XML declared constraints. | ||
* | ||
* See {@link DpcPreferenceHelper} for details about constraints. | ||
*/ | ||
public class DpcListPreference extends ListPreference implements DpcPreferenceBase { | ||
private DpcPreferenceHelper mHelper; | ||
|
||
public DpcListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||
super(context, attrs, defStyleAttr, defStyleRes); | ||
mHelper = new DpcPreferenceHelper(context, this, attrs); | ||
} | ||
|
||
public DpcListPreference(Context context, AttributeSet attrs, int defStyleAttr) { | ||
this(context, attrs, defStyleAttr, 0); | ||
} | ||
|
||
public DpcListPreference(Context context, AttributeSet attrs) { | ||
this(context, attrs, android.support.v7.preference.R.attr.dialogPreferenceStyle); | ||
} | ||
|
||
public DpcListPreference(Context context) { | ||
this(context, null); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(PreferenceViewHolder holder) { | ||
super.onBindViewHolder(holder); | ||
mHelper.onBindViewHolder(holder); | ||
} | ||
|
||
@Override | ||
protected void onAttachedToHierarchy(PreferenceManager preferenceManager) { | ||
mHelper.onAttachedToHierarchy(); | ||
super.onAttachedToHierarchy(preferenceManager); | ||
} | ||
|
||
@Override | ||
public void setEnabled(boolean enabled) { | ||
if (enabled && !mHelper.constraintsMet()) { | ||
return; // ignore | ||
} | ||
super.setEnabled(enabled); | ||
} | ||
|
||
@Override | ||
public void setMinSdkVersion(int version) { | ||
mHelper.setMinSdkVersion(version); | ||
} | ||
|
||
@Override | ||
public void setAdminConstraint(@DpcPreferenceHelper.AdminKind int adminConstraint) { | ||
mHelper.setAdminConstraint(adminConstraint); | ||
} | ||
|
||
@Override | ||
public void clearAdminConstraint() { | ||
mHelper.clearAdminConstraint(); | ||
} | ||
|
||
@Override | ||
public void setUserConstraint(@DpcPreferenceHelper.UserKind int userConstraints) { | ||
mHelper.setUserConstraint(userConstraints); | ||
} | ||
|
||
@Override | ||
public void clearUserConstraint() { | ||
mHelper.clearUserConstraint(); | ||
} | ||
|
||
@Override | ||
public void clearNonCustomConstraints() { | ||
mHelper.clearNonCustomConstraints(); | ||
} | ||
|
||
@Override | ||
public void setCustomConstraint(CharSequence constraintSummary) { | ||
mHelper.setCustomConstraint(constraintSummary); | ||
} | ||
|
||
@Override | ||
public void setCustomConstraint(@StringRes int constraintSummaryRes) { | ||
mHelper.setCustomConstraint(getContext().getString(constraintSummaryRes)); | ||
} | ||
|
||
@Override | ||
public void clearCustomConstraint() { | ||
mHelper.clearCustomConstraint(); | ||
} | ||
} | ||
|
Oops, something went wrong.