summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Nishi <dhnishi@google.com>2016-09-28 18:00:45 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-09-28 18:00:45 +0000
commitabbb8e891a90ea6610cdc04ad0735b9658843097 (patch)
tree722a08b5873d3247e4906a1d0f9de36a3661ba16
parent03bda9d7dae8a3531a0cfd6af5ea9ef0d9d12ba6 (diff)
parent188e12180504369616c8df2c71c1d71610d32774 (diff)
downloadStorageManager-abbb8e891a90ea6610cdc04ad0735b9658843097.tar.gz
Add a warning when activating the Storage Manager.
am: 188e121805 Change-Id: I38f43fabfcd28bfe948df0021e2efa6a016621f2
-rw-r--r--AndroidManifest.xml9
-rw-r--r--res/values/strings.xml3
-rw-r--r--res/values/themes.xml6
-rw-r--r--src/com/android/storagemanager/automatic/NotificationController.java9
-rw-r--r--src/com/android/storagemanager/automatic/WarningDialogActivity.java35
-rw-r--r--src/com/android/storagemanager/automatic/WarningDialogFragment.java65
6 files changed, 127 insertions, 0 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ac51041..b7d7bd8 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -45,6 +45,15 @@
</intent-filter>
</activity>
+ <!-- Warning for activating the storage manager. -->
+ <activity android:name=".automatic.WarningDialogActivity"
+ android:excludeFromRecents="true"
+ android:label=""
+ android:noHistory="true"
+ android:taskAffinity=".WarningDialogActivity"
+ android:theme="@style/TransparentDialog">
+ </activity>
+
<!-- Automatic storage management tasks. -->
<service
android:name=".automatic.AutomaticStorageManagementJobService"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 174b7d2..1259e30 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -100,4 +100,7 @@
<!-- Message to warn the user before clearing space in the deletion helper for the first time. [CHAR LIMIT=NONE] -->
<string name="deletion_helper_clear_dialog_message_first_time"><xliff:g id="clearable_bytes" example="1.2GB">%1$s</xliff:g> will be removed from your device</string>
+ <!-- Warning when activating the automatic storage manager on legacy devices. [CHAR LIMIT=NONE] -->
+ <string name="automatic_storage_manager_activation_warning">Your storage is now being managed by the storage manager</string>
+
</resources>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index a0190bd..00e05e7 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -29,4 +29,10 @@
<item name="preferenceTheme">@style/PreferenceTheme</item>
</style>
+ <style name="TransparentDialog" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar.TranslucentDecor">
+ <item name="android:windowBackground">@android:color/transparent</item>
+ <item name="android:colorBackgroundCacheHint">@null</item>
+ <item name="android:windowIsTranslucent">true</item>
+ </style>
+
</resources> \ No newline at end of file
diff --git a/src/com/android/storagemanager/automatic/NotificationController.java b/src/com/android/storagemanager/automatic/NotificationController.java
index 9c48b43..8f50bdb 100644
--- a/src/com/android/storagemanager/automatic/NotificationController.java
+++ b/src/com/android/storagemanager/automatic/NotificationController.java
@@ -24,9 +24,12 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
+import android.os.SystemProperties;
import android.provider.Settings;
import com.android.storagemanager.R;
+import com.android.storagemanager.automatic.WarningDialogActivity;
+import com.android.storagemanager.overlay.FeatureFactory;
import java.util.concurrent.TimeUnit;
@@ -73,6 +76,7 @@ public class NotificationController extends BroadcastReceiver {
private static final String SHARED_PREFERENCES_NAME = "NotificationController";
private static final String NOTIFICATION_NEXT_SHOW_TIME = "notification_next_show_time";
private static final String NOTIFICATION_SHOWN_COUNT = "notification_shown_count";
+ private static final String STORAGE_MANAGER_PROPERTY = "ro.storage_manager.enabled";
private static final long DISMISS_DELAY = TimeUnit.DAYS.toMillis(15);
private static final long NO_THANKS_DELAY = TimeUnit.DAYS.toMillis(90);
@@ -86,6 +90,11 @@ public class NotificationController extends BroadcastReceiver {
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED,
1);
+ // Provide a warning if storage manager is not defaulted on.
+ if (!SystemProperties.getBoolean(STORAGE_MANAGER_PROPERTY, false)) {
+ Intent warningIntent = new Intent(context, WarningDialogActivity.class);
+ context.startActivity(warningIntent);
+ }
break;
case INTENT_ACTION_NO_THANKS:
delayNextNotification(context, NO_THANKS_DELAY);
diff --git a/src/com/android/storagemanager/automatic/WarningDialogActivity.java b/src/com/android/storagemanager/automatic/WarningDialogActivity.java
new file mode 100644
index 0000000..5f16b54
--- /dev/null
+++ b/src/com/android/storagemanager/automatic/WarningDialogActivity.java
@@ -0,0 +1,35 @@
+/*
+ * 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.android.storagemanager.automatic;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+/**
+ * WarningDialogActivity provide a warning for interacting with the storage manager.
+ */
+public class WarningDialogActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (getFragmentManager().findFragmentByTag(WarningDialogFragment.TAG) != null) {
+ return;
+ }
+ WarningDialogFragment dialog = WarningDialogFragment.newInstance();
+ dialog.show(getFragmentManager(), WarningDialogFragment.TAG);
+ }
+}
diff --git a/src/com/android/storagemanager/automatic/WarningDialogFragment.java b/src/com/android/storagemanager/automatic/WarningDialogFragment.java
new file mode 100644
index 0000000..e334082
--- /dev/null
+++ b/src/com/android/storagemanager/automatic/WarningDialogFragment.java
@@ -0,0 +1,65 @@
+/*
+ * 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.android.storagemanager.automatic;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.os.Bundle;
+import com.android.storagemanager.R;
+
+/**
+ * Fragment to warn the user about activating the storage manager.
+ */
+public class WarningDialogFragment extends DialogFragment implements OnClickListener {
+ public static final String TAG = "WarningDialogFragment";
+
+ /**
+ * Returns a new instance of the WarningDialogFragment.
+ */
+ public static WarningDialogFragment newInstance() {
+ return new WarningDialogFragment();
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ return new AlertDialog.Builder(getActivity())
+ .setMessage(R.string.automatic_storage_manager_activation_warning)
+ .setNegativeButton(android.R.string.ok, (OnClickListener) this)
+ .create();
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ finishActivity();
+ }
+
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ finishActivity();
+ }
+
+ private void finishActivity() {
+ Activity activity = getActivity();
+ if (activity != null) {
+ activity.finish();
+ }
+ }
+} \ No newline at end of file