Commit f59f7137 authored by Max Lv's avatar Max Lv

Replace CardView with normal list view

parent f4eeab05
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
<item> <item>
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="@color/material_primary_300" /> <solid android:color="@color/material_primary_300" />
<corners android:radius="4dp"/>
</shape> </shape>
</item> </item>
<item> <item>
...@@ -12,7 +11,6 @@ ...@@ -12,7 +11,6 @@
<item android:state_selected="true"> <item android:state_selected="true">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="@color/material_green_700" /> <solid android:color="@color/material_green_700" />
<corners android:radius="4dp"/>
</shape> </shape>
</item> </item>
</selector> </selector>
...@@ -20,7 +18,6 @@ ...@@ -20,7 +18,6 @@
<item android:left="8dp"> <item android:left="8dp">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="@android:color/white" /> <solid android:color="@android:color/white" />
<corners android:bottomRightRadius="4dp" android:topRightRadius="4dp"/>
</shape> </shape>
</item> </item>
</layer-list> </layer-list>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Based on: https://github.com/android/platform_frameworks_base/blob/505e3ab/core/res/res/layout/simple_list_item_2.xml --> <!-- Based on: https://github.com/android/platform_frameworks_base/blob/505e3ab/core/res/res/layout/simple_list_item_2.xml -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ads"
android:orientation="vertical"
android:focusable="false"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<com.github.shadowsocks.widget.BoundedCardView android:layout_width="match_parent" <FrameLayout android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
app:bounded_width="@dimen/profile_item_max_width"
android:id="@+id/indicator"> android:id="@+id/indicator">
<LinearLayout android:layout_width="match_parent" <LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:padding="8dp" android:paddingLeft="16dp"
android:paddingRight="4dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:focusable="true" android:focusable="true"
android:nextFocusRight="@+id/edit" android:nextFocusRight="@+id/edit"
android:id="@+id/content" android:id="@+id/content"
...@@ -31,6 +33,7 @@ ...@@ -31,6 +33,7 @@
android:layout_weight="1" android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:textStyle="bold"
android:gravity="center_vertical" android:gravity="center_vertical"
android:maxLines="2" android:maxLines="2"
android:ellipsize="end"/> android:ellipsize="end"/>
...@@ -56,8 +59,7 @@ ...@@ -56,8 +59,7 @@
</LinearLayout> </LinearLayout>
<RelativeLayout android:layout_width="match_parent" <RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp">
android:layout_marginTop="4dp">
<TextView android:id="@android:id/text2" <TextView android:id="@android:id/text2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -78,5 +80,5 @@ ...@@ -78,5 +80,5 @@
android:textColor="?android:attr/textColorSecondary"/> android:textColor="?android:attr/textColorSecondary"/>
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
</com.github.shadowsocks.widget.BoundedCardView> </FrameLayout>
</FrameLayout> </LinearLayout>
...@@ -135,15 +135,16 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic ...@@ -135,15 +135,16 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
val params = val params =
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
params.gravity = Gravity.CENTER_HORIZONTAL params.gravity = Gravity.CENTER_HORIZONTAL
params.setMargins(0, getResources.getDimensionPixelOffset(R.dimen.margin_small), 0, 0) params.setMargins(0, 0, 0, 0)
adView = new AdView(getActivity) adView = new AdView(getActivity)
adView.setLayoutParams(params) adView.setLayoutParams(params)
adView.setAdUnitId("ca-app-pub-9097031975646651/7760346322") adView.setAdUnitId("ca-app-pub-9097031975646651/7760346322")
adView.setAdSize(AdSize.LARGE_BANNER) adView.setAdSize(AdSize.SMART_BANNER)
itemView.findViewById[LinearLayout](R.id.content).addView(adView) itemView.findViewById[LinearLayout](R.id.ads).addView(adView)
// Load Ad // Load Ad
val adBuilder = new AdRequest.Builder() val adBuilder = new AdRequest.Builder()
adBuilder.addTestDevice("B08FC1764A7B250E91EA9D0D5EBEB208")
adView.loadAd(adBuilder.build()) adView.loadAd(adBuilder.build())
} else adView.setVisibility(View.VISIBLE) } else adView.setVisibility(View.VISIBLE)
} else if (adView != null) adView.setVisibility(View.GONE) } else if (adView != null) adView.setVisibility(View.GONE)
...@@ -266,7 +267,10 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic ...@@ -266,7 +267,10 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
if (app.profileManager.getFirstProfile.isEmpty) app.dataStore.profileId = app.profileManager.createProfile().id if (app.profileManager.getFirstProfile.isEmpty) app.dataStore.profileId = app.profileManager.createProfile().id
val profilesList = view.findViewById[RecyclerView](R.id.list) val profilesList = view.findViewById[RecyclerView](R.id.list)
val layoutManager = new LinearLayoutManager(getActivity, LinearLayoutManager.VERTICAL, false) val layoutManager = new LinearLayoutManager(getActivity, LinearLayoutManager.VERTICAL, false)
val dividerItemDecoration = new DividerItemDecoration(profilesList.getContext(),
layoutManager.getOrientation())
profilesList.setLayoutManager(layoutManager) profilesList.setLayoutManager(layoutManager)
profilesList.addItemDecoration(dividerItemDecoration)
layoutManager.scrollToPosition(profilesAdapter.profiles.zipWithIndex.collectFirst { layoutManager.scrollToPosition(profilesAdapter.profiles.zipWithIndex.collectFirst {
case (profile, i) if profile.id == app.dataStore.profileId => i case (profile, i) if profile.id == app.dataStore.profileId => i
}.getOrElse(-1)) }.getOrElse(-1))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment