From 823ab7b8d85f544351ae454a76ea5d544441ca0d Mon Sep 17 00:00:00 2001 From: vanitasvitae Date: Mon, 5 Sep 2016 18:15:29 +0200 Subject: [PATCH] AboutActivity respects intellihide settings, all coordinatorlayouts do now snap, added back button to AboutActivity and SettingsActivity --- .../activity/AboutActivity.java | 27 +++++++++++-------- .../activity/SettingsActivity.java | 24 ++++++++++++++++- app/src/main/res/layout/activity_about.xml | 3 ++- app/src/main/res/layout/main__app_bar.xml | 2 +- app/src/main/res/layout/main__content.xml | 2 -- .../res/layout/podselection__activity.xml | 6 ----- 6 files changed, 42 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java index 6bf16f76..62389689 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java @@ -18,13 +18,11 @@ */ package com.github.dfa.diaspora_android.activity; -import android.content.BroadcastReceiver; import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Bundle; +import android.support.design.widget.AppBarLayout; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; @@ -32,10 +30,10 @@ import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.LinearLayout; import android.widget.TextView; import com.github.dfa.diaspora_android.App; @@ -55,17 +53,18 @@ public class AboutActivity extends AppCompatActivity { private SectionsPagerAdapter mSectionsPagerAdapter; private ViewPager mViewPager; + @BindView(R.id.toolbar) + protected Toolbar toolbar; + + @BindView(R.id.linearlayout) + protected LinearLayout linearLayout; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); - registerReceiver(new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - Log.d("INTREC", intent.toString()); - } - }, new IntentFilter(Intent.ACTION_VIEW)); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + ButterKnife.bind(this); + setSupportActionBar(toolbar); toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24px)); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @@ -84,6 +83,12 @@ public class AboutActivity extends AppCompatActivity { TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(mViewPager); + + //Apply intellihide + if(!((App)getApplication()).getSettings().isIntellihideToolbars()) { + AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) linearLayout.getLayoutParams(); + params.setScrollFlags(0); + } } /** diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java index 67892f28..7b06e780 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java @@ -29,22 +29,44 @@ import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; import android.preference.PreferenceScreen; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.MenuItem; +import android.view.View; import com.github.dfa.diaspora_android.App; import com.github.dfa.diaspora_android.R; +import butterknife.OnEditorAction; + /** * @author vanitas */ -public class SettingsActivity extends PreferenceActivity { +public class SettingsActivity extends AppCompatActivity { private boolean activityRestartRequired; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + ActionBar toolbar = getSupportActionBar(); + if(toolbar != null) + toolbar.setDisplayHomeAsUpEnabled(true); getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit(); } + @Override + public boolean onOptionsItemSelected(MenuItem menuItem) + { + switch (menuItem.getItemId()) { + case android.R.id.home: + onBackPressed(); + return true; + default: + return super.onOptionsItemSelected(menuItem); + } + } + private void setActivityRestartRequired() { this.activityRestartRequired = true; } diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 00d9e836..c686e81e 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -17,9 +17,10 @@ diff --git a/app/src/main/res/layout/main__content.xml b/app/src/main/res/layout/main__content.xml index fad40116..06dd0e41 100644 --- a/app/src/main/res/layout/main__content.xml +++ b/app/src/main/res/layout/main__content.xml @@ -14,8 +14,6 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentEnd="true" - android:layout_alignParentLeft="true" - android:layout_alignParentRight="true" android:layout_alignParentStart="true" android:layout_centerVertical="true" /> diff --git a/app/src/main/res/layout/podselection__activity.xml b/app/src/main/res/layout/podselection__activity.xml index fbe71d01..418a66b4 100644 --- a/app/src/main/res/layout/podselection__activity.xml +++ b/app/src/main/res/layout/podselection__activity.xml @@ -45,9 +45,7 @@ android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_toEndOf="@+id/textView" - android:layout_toLeftOf="@+id/podselection__button_select_pod" android:layout_toStartOf="@+id/podselection__button_select_pod" - android:layout_toRightOf="@+id/textView" android:hint="@string/filter_hint" android:inputType="textUri|textWebEditText" /> @@ -57,7 +55,6 @@ android:layout_height="wrap_content" android:layout_above="@+id/podselection__listpods" android:layout_alignEnd="@+id/podselection__listpods" - android:layout_alignRight="@+id/podselection__listpods" android:layout_alignTop="@+id/podselection__edit_filter" android:contentDescription="@string/confirm_url" android:paddingLeft="5dp" @@ -69,7 +66,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" - android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:autoLink="web" android:text="@string/podlist_source_note" @@ -80,11 +76,9 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/podselection__listpods" - android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:layout_marginEnd="0dp" - android:layout_marginRight="0dp" android:gravity="center_vertical" android:text="@string/prefix_https" android:textAppearance="?android:attr/textAppearanceMedium" />