summaryrefslogtreecommitdiffstats
path: root/src/com/android/packageinstaller/permission/ui/wear/settings
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/packageinstaller/permission/ui/wear/settings')
-rw-r--r--src/com/android/packageinstaller/permission/ui/wear/settings/ExtendedOnCenterProximityListener.java30
-rw-r--r--src/com/android/packageinstaller/permission/ui/wear/settings/ExtendedViewHolder.java84
-rw-r--r--src/com/android/packageinstaller/permission/ui/wear/settings/PermissionsSettingsAdapter.java101
-rw-r--r--src/com/android/packageinstaller/permission/ui/wear/settings/SettingsAdapter.java276
-rw-r--r--src/com/android/packageinstaller/permission/ui/wear/settings/ViewUtils.java48
5 files changed, 0 insertions, 539 deletions
diff --git a/src/com/android/packageinstaller/permission/ui/wear/settings/ExtendedOnCenterProximityListener.java b/src/com/android/packageinstaller/permission/ui/wear/settings/ExtendedOnCenterProximityListener.java
deleted file mode 100644
index 02c203b3..00000000
--- a/src/com/android/packageinstaller/permission/ui/wear/settings/ExtendedOnCenterProximityListener.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2015 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.packageinstaller.permission.ui.wear.settings;
-
-import android.support.wearable.view.WearableListView;
-
-public interface ExtendedOnCenterProximityListener
- extends WearableListView.OnCenterProximityListener {
- float getProximityMinValue();
-
- float getProximityMaxValue();
-
- float getCurrentProximityValue();
-
- void setScalingAnimatorValue(float value);
-}
diff --git a/src/com/android/packageinstaller/permission/ui/wear/settings/ExtendedViewHolder.java b/src/com/android/packageinstaller/permission/ui/wear/settings/ExtendedViewHolder.java
deleted file mode 100644
index 6b725419..00000000
--- a/src/com/android/packageinstaller/permission/ui/wear/settings/ExtendedViewHolder.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2015 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.packageinstaller.permission.ui.wear.settings;
-
-import android.animation.ObjectAnimator;
-import android.support.wearable.view.WearableListView;
-import android.view.View;
-
-
-public class ExtendedViewHolder extends WearableListView.ViewHolder {
- public static final long DEFAULT_ANIMATION_DURATION = 150;
-
- private ObjectAnimator mScalingUpAnimator;
-
- private ObjectAnimator mScalingDownAnimator;
-
- private float mMinValue;
-
- private float mMaxValue;
-
- public ExtendedViewHolder(View itemView) {
- super(itemView);
- if (itemView instanceof ExtendedOnCenterProximityListener) {
- ExtendedOnCenterProximityListener item =
- (ExtendedOnCenterProximityListener) itemView;
- mMinValue = item.getProximityMinValue();
- item.setScalingAnimatorValue(mMinValue);
- mMaxValue = item.getProximityMaxValue();
- mScalingUpAnimator = ObjectAnimator.ofFloat(item, "scalingAnimatorValue", mMinValue,
- mMaxValue);
- mScalingUpAnimator.setDuration(DEFAULT_ANIMATION_DURATION);
- mScalingDownAnimator = ObjectAnimator.ofFloat(item, "scalingAnimatorValue",
- mMaxValue, mMinValue);
- mScalingDownAnimator.setDuration(DEFAULT_ANIMATION_DURATION);
- }
- }
-
- public void onCenterProximity(boolean isCentralItem, boolean animate) {
- if (!(itemView instanceof ExtendedOnCenterProximityListener)) {
- return;
- }
- ExtendedOnCenterProximityListener item = (ExtendedOnCenterProximityListener) itemView;
- if (isCentralItem) {
- if (animate) {
- mScalingDownAnimator.cancel();
- if (!mScalingUpAnimator.isRunning()) {
- mScalingUpAnimator.setFloatValues(item.getCurrentProximityValue(),
- mMaxValue);
- mScalingUpAnimator.start();
- }
- } else {
- mScalingUpAnimator.cancel();
- item.setScalingAnimatorValue(item.getProximityMaxValue());
- }
- } else {
- mScalingUpAnimator.cancel();
- if (animate) {
- if (!mScalingDownAnimator.isRunning()) {
- mScalingDownAnimator.setFloatValues(item.getCurrentProximityValue(),
- mMinValue);
- mScalingDownAnimator.start();
- }
- } else {
- mScalingDownAnimator.cancel();
- item.setScalingAnimatorValue(item.getProximityMinValue());
- }
- }
- super.onCenterProximity(isCentralItem, animate);
- }
-}
diff --git a/src/com/android/packageinstaller/permission/ui/wear/settings/PermissionsSettingsAdapter.java b/src/com/android/packageinstaller/permission/ui/wear/settings/PermissionsSettingsAdapter.java
deleted file mode 100644
index 0e0adcbb..00000000
--- a/src/com/android/packageinstaller/permission/ui/wear/settings/PermissionsSettingsAdapter.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2015 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.packageinstaller.permission.ui.wear.settings;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.wearable.view.WearableListView;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import com.android.packageinstaller.R;
-import com.android.packageinstaller.permission.model.AppPermissionGroup;
-
-public final class PermissionsSettingsAdapter extends SettingsAdapter<AppPermissionGroup> {
- private Resources mRes;
-
- public PermissionsSettingsAdapter(Context context) {
- super(context, R.layout.permissions_settings_item);
- mRes = context.getResources();
- }
-
- @Override
- public WearableListView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- return new PermissionsViewHolder(new PermissionsSettingsItem(parent.getContext()));
- }
-
- @Override
- public void onBindViewHolder(WearableListView.ViewHolder holder, int position) {
- super.onBindViewHolder(holder, position);
- PermissionsViewHolder viewHolder = (PermissionsViewHolder) holder;
- AppPermissionGroup group = get(position).data;
-
- if (group.isPolicyFixed()) {
- viewHolder.imageView.setEnabled(false);
- viewHolder.textView.setEnabled(false);
- viewHolder.state.setEnabled(false);
- viewHolder.state.setText(
- mRes.getString(R.string.permission_summary_enforced_by_policy));
- } else {
- viewHolder.imageView.setEnabled(true);
- viewHolder.textView.setEnabled(true);
- viewHolder.state.setEnabled(true);
-
- if (group.areRuntimePermissionsGranted()) {
- viewHolder.state.setText(R.string.generic_enabled);
- } else {
- viewHolder.state.setText(R.string.generic_disabled);
- }
- }
- }
-
- private static final class PermissionsViewHolder extends SettingsAdapter.SettingsItemHolder {
- public final TextView state;
-
- public PermissionsViewHolder(View view) {
- super(view);
- state = (TextView) view.findViewById(R.id.state);
- }
- }
-
- private class PermissionsSettingsItem extends SettingsItem {
- private final TextView mState;
- private final float mCenteredAlpha = 1.0f;
- private final float mNonCenteredAlpha = 0.5f;
-
- public PermissionsSettingsItem (Context context) {
- super(context);
- mState = (TextView) findViewById(R.id.state);
- }
-
- @Override
- public void onCenterPosition(boolean animate) {
- mImage.setAlpha(mImage.isEnabled() ? mCenteredAlpha : mNonCenteredAlpha);
- mText.setAlpha(mText.isEnabled() ? mCenteredAlpha : mNonCenteredAlpha);
- mState.setAlpha(mState.isEnabled() ? mCenteredAlpha : mNonCenteredAlpha);
- }
-
- @Override
- public void onNonCenterPosition(boolean animate) {
- mImage.setAlpha(mNonCenteredAlpha);
- mText.setAlpha(mNonCenteredAlpha);
- mState.setAlpha(mNonCenteredAlpha);
- }
- }
-}
-
diff --git a/src/com/android/packageinstaller/permission/ui/wear/settings/SettingsAdapter.java b/src/com/android/packageinstaller/permission/ui/wear/settings/SettingsAdapter.java
deleted file mode 100644
index baf1a2b4..00000000
--- a/src/com/android/packageinstaller/permission/ui/wear/settings/SettingsAdapter.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Copyright (C) 2015 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.packageinstaller.permission.ui.wear.settings;
-
-import android.content.Context;
-import android.support.wearable.view.CircledImageView;
-import android.support.wearable.view.WearableListView;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.FrameLayout;
-import android.widget.TextView;
-
-import com.android.packageinstaller.R;
-
-import java.util.ArrayList;
-
-/**
- * Common adapter for settings views. Maintains a list of 'Settings', consisting of a name,
- * icon and optional activity-specific data.
- */
-public class SettingsAdapter<T> extends WearableListView.Adapter {
- private static final String TAG = "SettingsAdapter";
- private final Context mContext;
-
- public static final class Setting<S> {
- public static final int ID_INVALID = -1;
-
- public final int id;
- public int nameResourceId;
- public CharSequence name;
- public int iconResource;
- public boolean inProgress;
- public S data;
-
- public Setting(CharSequence name, int iconResource, S data) {
- this(name, iconResource, data, ID_INVALID);
- }
-
- public Setting(CharSequence name, int iconResource, S data, int id) {
- this.name = name;
- this.iconResource = iconResource;
- this.data = data;
- this.inProgress = false;
- this.id = id;
- }
-
- public Setting(int nameResource, int iconResource, S data, int id) {
- this.nameResourceId = nameResource;
- this.iconResource = iconResource;
- this.data = data;
- this.inProgress = false;
- this.id = id;
- }
-
- public Setting(int nameResource, int iconResource, int id) {
- this.nameResourceId = nameResource;
- this.iconResource = iconResource;
- this.data = null;
- this.inProgress = false;
- this.id = id;
- }
-
- public Setting(CharSequence name, int iconResource, int id) {
- this(name, iconResource, null, id);
- }
-
- }
-
- private final int mItemLayoutId;
- private final float mDefaultCircleRadiusPercent;
- private final float mSelectedCircleRadiusPercent;
-
- protected ArrayList<Setting<T>> mSettings = new ArrayList<Setting<T>>();
-
- public SettingsAdapter(Context context, int itemLayoutId) {
- mContext = context;
- mItemLayoutId = itemLayoutId;
- mDefaultCircleRadiusPercent = context.getResources().getFraction(
- R.dimen.default_settings_circle_radius_percent, 1, 1);
- mSelectedCircleRadiusPercent = context.getResources().getFraction(
- R.dimen.selected_settings_circle_radius_percent, 1, 1);
- }
-
- @Override
- public WearableListView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- return new SettingsItemHolder(new SettingsItem(parent.getContext()));
- }
-
- @Override
- public void onBindViewHolder(WearableListView.ViewHolder holder, int position) {
- Setting<T> setting = mSettings.get(position);
- if (setting.iconResource == -1) {
- ((SettingsItemHolder) holder).imageView.setVisibility(View.GONE);
- } else {
- ((SettingsItemHolder) holder).imageView.setVisibility(View.VISIBLE);
- ((SettingsItemHolder) holder).imageView.setImageResource(
- mSettings.get(position).iconResource);
- }
- Log.d(TAG, "onBindViewHolder " + setting.name + " " + setting.id + " " + setting
- .nameResourceId);
- if (setting.name == null && setting.nameResourceId != 0) {
- setting.name = mContext.getString(setting.nameResourceId);
- }
- ((SettingsItemHolder) holder).textView.setText(setting.name);
- }
-
- @Override
- public int getItemCount() {
- return mSettings.size();
- }
-
- public void addSetting(CharSequence name, int iconResource) {
- addSetting(name, iconResource, null);
- }
-
- public void addSetting(CharSequence name, int iconResource, T intent) {
- addSetting(mSettings.size(), name, iconResource, intent);
- }
-
- public void addSetting(int index, CharSequence name, int iconResource, T intent) {
- addSetting(Setting.ID_INVALID, index, name, iconResource, intent);
- }
-
- public void addSetting(int id, int index, CharSequence name, int iconResource, T intent) {
- mSettings.add(index, new Setting<T>(name, iconResource, intent, id));
- notifyItemInserted(index);
- }
-
- public void addSettingDontNotify(Setting<T> setting) {
- mSettings.add(setting);
- }
-
- public void addSetting(Setting<T> setting) {
- mSettings.add(setting);
- notifyItemInserted(mSettings.size() - 1);
- }
-
- public void addSetting(int index, Setting<T> setting) {
- mSettings.add(index, setting);
- notifyItemInserted(index);
- }
-
- /**
- * Returns the index of the setting in the adapter based on the ID supplied when it was
- * originally added.
- * @param id the setting's id
- * @return index in the adapter of the setting. -1 if not found.
- */
- public int findSetting(int id) {
- for (int i = mSettings.size() - 1; i >= 0; --i) {
- Setting setting = mSettings.get(i);
-
- if (setting.id == id) {
- return i;
- }
- }
-
- return -1;
- }
-
- /**
- * Removes a setting at the given index.
- * @param index the index of the setting to be removed
- */
- public void removeSetting(int index) {
- mSettings.remove(index);
- notifyDataSetChanged();
- }
-
- public void clearSettings() {
- mSettings.clear();
- notifyDataSetChanged();
- }
-
- /**
- * Updates a setting in place.
- * @param index the index of the setting
- * @param name the updated setting name
- * @param iconResource the update setting icon
- * @param intent the updated intent for the setting
- */
- public void updateSetting(int index, CharSequence name, int iconResource, T intent) {
- Setting<T> setting = mSettings.get(index);
- setting.iconResource = iconResource;
- setting.name = name;
- setting.data = intent;
- notifyItemChanged(index);
- }
-
- public Setting<T> get(int position) {
- return mSettings.get(position);
- }
-
- protected static class SettingsItemHolder extends ExtendedViewHolder {
- public final CircledImageView imageView;
- public final TextView textView;
-
- public SettingsItemHolder(View itemView) {
- super(itemView);
-
- imageView = ((CircledImageView) itemView.findViewById(R.id.image));
- textView = ((TextView) itemView.findViewById(R.id.text));
- }
- }
-
- protected class SettingsItem extends FrameLayout implements ExtendedOnCenterProximityListener {
-
- protected final CircledImageView mImage;
- protected final TextView mText;
-
- public SettingsItem(Context context) {
- super(context);
- View view = View.inflate(context, mItemLayoutId, null);
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
- FrameLayout.LayoutParams.MATCH_PARENT,
- FrameLayout.LayoutParams.MATCH_PARENT);
- params.gravity = Gravity.CENTER_VERTICAL;
- addView(view, params);
- mImage = (CircledImageView) findViewById(R.id.image);
- mText = (TextView) findViewById(R.id.text);
- }
-
- @Override
- public float getProximityMinValue() {
- return mDefaultCircleRadiusPercent;
- }
-
- @Override
- public float getProximityMaxValue() {
- return mSelectedCircleRadiusPercent;
- }
-
- @Override
- public float getCurrentProximityValue() {
- return mImage.getCircleRadiusPressedPercent();
- }
-
- @Override
- public void setScalingAnimatorValue(float value) {
- mImage.setCircleRadiusPercent(value);
- mImage.setCircleRadiusPressedPercent(value);
- }
-
- @Override
- public void onCenterPosition(boolean animate) {
- mImage.setAlpha(1f);
- mText.setAlpha(1f);
- }
-
- @Override
- public void onNonCenterPosition(boolean animate) {
- mImage.setAlpha(0.5f);
- mText.setAlpha(0.5f);
- }
-
- TextView getTextView() {
- return mText;
- }
- }
-}
diff --git a/src/com/android/packageinstaller/permission/ui/wear/settings/ViewUtils.java b/src/com/android/packageinstaller/permission/ui/wear/settings/ViewUtils.java
deleted file mode 100644
index cf1c0fd0..00000000
--- a/src/com/android/packageinstaller/permission/ui/wear/settings/ViewUtils.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2015 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.packageinstaller.permission.ui.wear.settings;
-
-import android.content.Context;
-import android.view.View;
-import android.view.ViewGroup;
-
-/**
- * Utility to determine screen shape
- */
-public class ViewUtils {
-
- public static boolean getIsCircular(Context context) {
- return context.getResources().getConfiguration().isScreenRound();
- }
-
- /**
- * Set the given {@code view} and all descendants to the given {@code enabled} state.
- *
- * @param view the parent view of a subtree of components whose enabled state must be set
- * @param enabled the new enabled state of the subtree of components
- */
- public static void setEnabled(View view, boolean enabled) {
- view.setEnabled(enabled);
-
- if (view instanceof ViewGroup) {
- final ViewGroup viewGroup = (ViewGroup) view;
- for (int i = 0; i < viewGroup.getChildCount(); i++) {
- setEnabled(viewGroup.getChildAt(i), enabled);
- }
- }
- }
-}