- refact to use fragments
- use AppCompatActivity so the app bar is more customizable
- switch couple more setting page to use pagedList pattern
Test: manually verified
Change-Id: I936006c07c79e43cc02640916450493a90bcfe3b
diff --git a/src/com/android/car/settings/system/AboutSettingsActivity.java b/src/com/android/car/settings/system/AboutSettingsFragment.java
similarity index 78%
rename from src/com/android/car/settings/system/AboutSettingsActivity.java
rename to src/com/android/car/settings/system/AboutSettingsFragment.java
index 8f630f7..a4976a2 100644
--- a/src/com/android/car/settings/system/AboutSettingsActivity.java
+++ b/src/com/android/car/settings/system/AboutSettingsFragment.java
@@ -17,8 +17,9 @@
package com.android.car.settings.system;
import android.os.Build;
+import android.os.Bundle;
-import com.android.car.settings.common.ListSettingsActivity;
+import com.android.car.settings.common.ListSettingsFragment;
import com.android.car.settings.common.NoDividerItemDecoration;
import com.android.car.settings.common.SimpleTextLineItem;
import com.android.car.settings.common.TypedPagedListAdapter;
@@ -31,7 +32,15 @@
/**
* Shows basic info about the system and provide some actions like update, reset etc.
*/
-public class AboutSettingsActivity extends ListSettingsActivity {
+public class AboutSettingsFragment extends ListSettingsFragment {
+
+ public static AboutSettingsFragment getInstance() {
+ AboutSettingsFragment aboutSettingsFragment = new AboutSettingsFragment();
+ Bundle bundle = ListSettingsFragment.getBundle();
+ bundle.putInt(EXTRA_TITLE_ID, R.string.about_settings);
+ aboutSettingsFragment.setArguments(bundle);
+ return aboutSettingsFragment;
+ }
@Override
public ArrayList<TypedPagedListAdapter.LineItem> getLineItems() {
@@ -52,6 +61,6 @@
@Override
public PagedListView.Decoration getDecoration() {
- return new NoDividerItemDecoration(this);
+ return new NoDividerItemDecoration(getContext());
}
}
diff --git a/src/com/android/car/settings/system/AboutSystemLineItem.java b/src/com/android/car/settings/system/AboutSystemLineItem.java
index 2d240de..f8c4537 100644
--- a/src/com/android/car/settings/system/AboutSystemLineItem.java
+++ b/src/com/android/car/settings/system/AboutSystemLineItem.java
@@ -17,12 +17,11 @@
package com.android.car.settings.system;
import android.content.Context;
-import android.content.Intent;
import android.os.Build;
import android.widget.ImageView;
import com.android.car.settings.R;
-import com.android.car.settings.common.AnimationUtil;
+import com.android.car.settings.common.BaseFragment;
import com.android.car.settings.common.IconTextLineItem;
@@ -30,12 +29,13 @@
* A LineItem that displays info about system.
*/
class AboutSystemLineItem extends IconTextLineItem {
-
private final Context mContext;
+ private final BaseFragment.FragmentController mFragmentController;
- public AboutSystemLineItem(Context context) {
+ public AboutSystemLineItem(Context context, BaseFragment.FragmentController fragmentController) {
super(context.getString(R.string.about_settings));
mContext = context;
+ mFragmentController = fragmentController;
}
@Override
@@ -50,8 +50,7 @@
@Override
public void onClick() {
- Intent intent = new Intent(mContext, AboutSettingsActivity.class);
- mContext.startActivity(intent, AnimationUtil.slideInFromRightOption(mContext).toBundle());
+ mFragmentController.launchFragment(AboutSettingsFragment.getInstance());
}
@Override
diff --git a/src/com/android/car/settings/system/SystemSettingsActivity.java b/src/com/android/car/settings/system/SystemSettingsActivity.java
deleted file mode 100644
index 37d1614..0000000
--- a/src/com/android/car/settings/system/SystemSettingsActivity.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2017 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.car.settings.system;
-
-import com.android.car.settings.R;
-import com.android.car.settings.common.ListSettingsActivity;
-import com.android.car.settings.common.TypedPagedListAdapter;
-
-import java.util.ArrayList;
-
-/**
- * Shows basic info about the system and provide some actions like update, reset etc.
- */
-public class SystemSettingsActivity extends ListSettingsActivity {
-
- @Override
- public ArrayList<TypedPagedListAdapter.LineItem> getLineItems() {
- ArrayList<TypedPagedListAdapter.LineItem> lineItems = new ArrayList<>();
- lineItems.add(new SystemUpdatesLineItem(this));
- lineItems.add(new AboutSystemLineItem(this));
- lineItems.add(new LegalInfoLineItem(this));
- return lineItems;
- }
-}
diff --git a/src/com/android/car/settings/system/SystemSettingsFragment.java b/src/com/android/car/settings/system/SystemSettingsFragment.java
new file mode 100644
index 0000000..0e3a68c
--- /dev/null
+++ b/src/com/android/car/settings/system/SystemSettingsFragment.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2017 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.car.settings.system;
+
+import android.os.Bundle;
+
+import com.android.car.settings.R;
+import com.android.car.settings.common.ListSettingsFragment;
+import com.android.car.settings.common.TypedPagedListAdapter;
+
+import java.util.ArrayList;
+
+/**
+ * Shows basic info about the system and provide some actions like update, reset etc.
+ */
+public class SystemSettingsFragment extends ListSettingsFragment {
+
+ public static SystemSettingsFragment getInstance() {
+ SystemSettingsFragment systemSettingsFragment = new SystemSettingsFragment();
+ Bundle bundle = ListSettingsFragment.getBundle();
+ bundle.putInt(EXTRA_TITLE_ID, R.string.system_setting_title);
+ systemSettingsFragment.setArguments(bundle);
+ return systemSettingsFragment;
+ }
+
+ @Override
+ public ArrayList<TypedPagedListAdapter.LineItem> getLineItems() {
+ ArrayList<TypedPagedListAdapter.LineItem> lineItems = new ArrayList<>();
+ lineItems.add(new SystemUpdatesLineItem(getContext()));
+ lineItems.add(new AboutSystemLineItem(getContext(), mFragmentController));
+ lineItems.add(new LegalInfoLineItem(getContext()));
+ return lineItems;
+ }
+}