Skip to content
Snippets Groups Projects
Commit 4979f47a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Refactor AppPreference & AppSwitchPreference"

parents 335388de c5753815
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (C) 2018 The Android Open Source Project
* Copyright (C) 2021 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.
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.settingslib.widget.apppreference;
package com.android.settingslib.widget;
import android.content.Context;
import android.util.AttributeSet;
......@@ -24,13 +24,24 @@ import android.widget.ProgressBar;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
import com.android.settingslib.widget.R;
/**
* The Preference for the pages need to show apps icon.
*/
public class AppPreference extends Preference {
private int mProgress;
private boolean mProgressVisible;
public AppPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
setLayoutResource(R.layout.preference_app);
}
public AppPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setLayoutResource(R.layout.preference_app);
}
public AppPreference(Context context) {
super(context);
setLayoutResource(R.layout.preference_app);
......@@ -41,6 +52,12 @@ public class AppPreference extends Preference {
setLayoutResource(R.layout.preference_app);
}
/**
* Sets the current progress.
* @param amount the current progress
*
* @see ProgressBar#setProgress(int)
*/
public void setProgress(int amount) {
mProgress = amount;
mProgressVisible = true;
......@@ -59,4 +76,4 @@ public class AppPreference extends Preference {
progress.setVisibility(View.GONE);
}
}
}
\ No newline at end of file
}
/*
* Copyright (C) 2021 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.android.settingslib.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import androidx.preference.PreferenceViewHolder;
import androidx.preference.SwitchPreference;
/**
* The SwitchPreference for the pages need to show apps icon.
*/
public class AppSwitchPreference extends SwitchPreference {
public AppSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
setLayoutResource(R.layout.preference_app);
}
public AppSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setLayoutResource(R.layout.preference_app);
}
public AppSwitchPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setLayoutResource(R.layout.preference_app);
}
public AppSwitchPreference(Context context) {
super(context);
setLayoutResource(R.layout.preference_app);
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
final View switchView = holder.findViewById(android.R.id.switch_widget);
if (switchView != null) {
final View rootView = switchView.getRootView();
rootView.setFilterTouchesWhenObscured(true);
}
}
}
/*
* Copyright (C) 2018 The Android Open Source Project
* Copyright (C) 2021 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.
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.settingslib.widget.apppreference;
package com.android.settingslib.widget;
import static com.google.common.truth.Truth.assertThat;
......@@ -23,8 +23,6 @@ import android.view.View;
import androidx.preference.PreferenceViewHolder;
import com.android.settingslib.widget.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment