move settings to drawer header

This commit is contained in:
Andrew Dolgov 2015-11-30 06:20:01 +03:00
parent 6e2b220669
commit ddb72b88ca
2 changed files with 65 additions and 91 deletions

View File

@ -43,15 +43,15 @@ public abstract class BaseFeedlistFragment extends Fragment {
server.setText(""); server.setText("");
} }
View account = view.findViewById(R.id.drawer_header_account); View settings = view.findViewById(R.id.drawer_settings_btn);
account.setOnClickListener(new View.OnClickListener() { settings.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
try { try {
Intent intent = new Intent(Intent.ACTION_VIEW, Intent intent = new Intent(getActivity(),
Uri.parse(prefs.getString("ttrss_url", ""))); PreferencesActivity.class);
startActivity(intent); startActivityForResult(intent, 0);
} catch (Exception e) { } catch (Exception e) {
} }
@ -128,29 +128,6 @@ public abstract class BaseFeedlistFragment extends Fragment {
counter.setText(R.string.blank); counter.setText(R.string.blank);
} }
// settings
footer = inflater.inflate(R.layout.feeds_row, list, false);
footer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(activity,
PreferencesActivity.class);
startActivityForResult(intent, 0);
}
});
list.addFooterView(footer);
text = (TextView) footer.findViewById(R.id.title);
text.setText(R.string.preferences);
icon = (ImageView) footer.findViewById(R.id.icon);
tv = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.ic_settings, tv, true);
icon.setImageResource(tv.resourceId);
TextView counter = (TextView) footer.findViewById(R.id.unread_counter);
counter.setText(R.string.blank);
} catch (InflateException e) { } catch (InflateException e) {
// welp couldn't inflate header i guess // welp couldn't inflate header i guess
e.printStackTrace(); e.printStackTrace();

View File

@ -1,11 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="120dp" android:layout_height="120dp"
android:orientation="vertical" android:orientation="vertical"
android:weightSum="1" android:weightSum="1"
android:clickable="false"> android:clickable="false">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView <ImageView
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -15,26 +18,17 @@
android:background="?colorPrimaryDark" android:background="?colorPrimaryDark"
android:src="?drawer_header" /> android:src="?drawer_header" />
<FrameLayout
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@drawable/circle_bg"
android:clickable="true"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="16dp"
android:elevation="8dp">
<ImageView <ImageView
android:id="@+id/drawer_header_account" android:layout_width="wrap_content"
android:background="@drawable/ripple" android:layout_height="wrap_content"
android:layout_width="36dp" android:src="@drawable/ic_settings"
android:layout_height="36dp" android:id="@+id/drawer_settings_btn"
android:tint="?colorAccent" android:layout_gravity="bottom|right"
android:src="@drawable/ic_account" android:clickable="true"
android:layout_gravity="center" /> android:focusable="true"
</FrameLayout> android:layout_marginBottom="16dp"
android:layout_marginRight="12dp"
android:background="?attr/selectableItemBackground" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -43,7 +37,8 @@
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:id="@+id/linearLayout"> android:id="@+id/linearLayout"
android:layout_gravity="center_horizontal|bottom">
<TextView <TextView
android:id="@+id/drawer_header_login" android:id="@+id/drawer_header_login"
@ -70,6 +65,7 @@
/> />
</LinearLayout> </LinearLayout>
</FrameLayout>
<ProgressBar <ProgressBar
style="?android:attr/progressBarStyleHorizontal" style="?android:attr/progressBarStyleHorizontal"
@ -79,5 +75,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/feeds_loading_bar" android:id="@+id/feeds_loading_bar"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true" /> android:layout_alignParentBottom="true"
</RelativeLayout> android:layout_gravity="bottom" />
</FrameLayout>