Replace CardView with normal list view
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/material_primary_300" />
|
||||
<corners android:radius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
@@ -12,7 +11,6 @@
|
||||
<item android:state_selected="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/material_green_700" />
|
||||
<corners android:radius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -20,7 +18,6 @@
|
||||
<item android:left="8dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@android:color/white" />
|
||||
<corners android:bottomRightRadius="4dp" android:topRightRadius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
<?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 -->
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<com.github.shadowsocks.widget.BoundedCardView android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:bounded_width="@dimen/profile_item_max_width"
|
||||
android:id="@+id/indicator">
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
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_height="wrap_content">
|
||||
<FrameLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/indicator">
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="4dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:focusable="true"
|
||||
android:nextFocusRight="@+id/edit"
|
||||
android:id="@+id/content"
|
||||
@@ -31,6 +33,7 @@
|
||||
android:layout_weight="1"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"/>
|
||||
@@ -56,8 +59,7 @@
|
||||
</LinearLayout>
|
||||
<RelativeLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp">
|
||||
android:layout_marginStart="8dp">
|
||||
<TextView android:id="@android:id/text2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -78,5 +80,5 @@
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</com.github.shadowsocks.widget.BoundedCardView>
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -135,15 +135,16 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
|
||||
val params =
|
||||
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
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.setLayoutParams(params)
|
||||
adView.setAdUnitId("ca-app-pub-9097031975646651/7760346322")
|
||||
adView.setAdSize(AdSize.LARGE_BANNER)
|
||||
itemView.findViewById[LinearLayout](R.id.content).addView(adView)
|
||||
adView.setAdSize(AdSize.SMART_BANNER)
|
||||
itemView.findViewById[LinearLayout](R.id.ads).addView(adView)
|
||||
|
||||
// Load Ad
|
||||
val adBuilder = new AdRequest.Builder()
|
||||
adBuilder.addTestDevice("B08FC1764A7B250E91EA9D0D5EBEB208")
|
||||
adView.loadAd(adBuilder.build())
|
||||
} else adView.setVisibility(View.VISIBLE)
|
||||
} else if (adView != null) adView.setVisibility(View.GONE)
|
||||
@@ -266,7 +267,10 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
|
||||
if (app.profileManager.getFirstProfile.isEmpty) app.dataStore.profileId = app.profileManager.createProfile().id
|
||||
val profilesList = view.findViewById[RecyclerView](R.id.list)
|
||||
val layoutManager = new LinearLayoutManager(getActivity, LinearLayoutManager.VERTICAL, false)
|
||||
val dividerItemDecoration = new DividerItemDecoration(profilesList.getContext(),
|
||||
layoutManager.getOrientation())
|
||||
profilesList.setLayoutManager(layoutManager)
|
||||
profilesList.addItemDecoration(dividerItemDecoration)
|
||||
layoutManager.scrollToPosition(profilesAdapter.profiles.zipWithIndex.collectFirst {
|
||||
case (profile, i) if profile.id == app.dataStore.profileId => i
|
||||
}.getOrElse(-1))
|
||||
|
||||
Reference in New Issue
Block a user