mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-19 00:26:45 -06:00
Hide actionbar on scroll (#135)
This commit is contained in:
parent
8d014ab7e9
commit
81d177c270
@ -5,6 +5,7 @@ import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
@ -41,6 +42,9 @@ public class MainActivity extends BaseActivity implements MainContract.View,
|
||||
@BindView(R.id.main_activity_progress_bar)
|
||||
View progressBar;
|
||||
|
||||
@BindView(R.id.main_activity_appbar)
|
||||
AppBarLayout appBar;
|
||||
|
||||
@Named("Main")
|
||||
@Inject
|
||||
BasePagerAdapter pagerAdapter;
|
||||
@ -56,7 +60,7 @@ public class MainActivity extends BaseActivity implements MainContract.View,
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
|
||||
setSupportActionBar((Toolbar) findViewById(R.id.main_activity_toolbar));
|
||||
injectViews();
|
||||
|
||||
presenter.attachView(this, getIntent().getIntExtra(EXTRA_CARD_ID_KEY, -1));
|
||||
@ -88,6 +92,7 @@ public class MainActivity extends BaseActivity implements MainContract.View,
|
||||
@Override
|
||||
public boolean onTabSelected(int position, boolean wasSelected) {
|
||||
presenter.onTabSelected(position, wasSelected);
|
||||
appBar.setExpanded(true, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,67 +0,0 @@
|
||||
package io.github.wulkanowy.ui.main.settings;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity;
|
||||
|
||||
import io.github.wulkanowy.BuildConfig;
|
||||
import io.github.wulkanowy.R;
|
||||
import io.github.wulkanowy.utils.AppConstant;
|
||||
|
||||
public class AboutScreen extends SettingsFragment {
|
||||
|
||||
public static final String SHARED_KEY_ABOUT_VERSION = "about_version";
|
||||
|
||||
public static final String SHARED_KEY_ABOUT_LICENSES = "about_osl";
|
||||
|
||||
public static final String SHARED_KEY_ABOUT_REPO = "about_repo";
|
||||
|
||||
private Preference.OnPreferenceClickListener onProgrammerListener = new Preference.OnPreferenceClickListener() {
|
||||
private int clicks = 0;
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Toast.makeText(getActivity(), getVersionToast(clicks++), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
private int getVersionToast(int click) {
|
||||
if (0 == click) {
|
||||
return R.string.about_programmer_step1;
|
||||
}
|
||||
|
||||
if (1 == click) {
|
||||
return R.string.about_programmer_step2;
|
||||
}
|
||||
|
||||
if (9 > click) {
|
||||
return R.string.about_programmer_step3;
|
||||
}
|
||||
|
||||
return R.string.about_programmer;
|
||||
}
|
||||
};
|
||||
|
||||
public AboutScreen() {
|
||||
// silence is golden
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
findPreference(SHARED_KEY_ABOUT_VERSION).setSummary(BuildConfig.VERSION_NAME);
|
||||
findPreference(SHARED_KEY_ABOUT_VERSION).setOnPreferenceClickListener(onProgrammerListener);
|
||||
findPreference(SHARED_KEY_ABOUT_REPO).setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(AppConstant.REPO_URL)));
|
||||
findPreference(SHARED_KEY_ABOUT_LICENSES).setIntent(new Intent(getActivity(), OssLicensesMenuActivity.class)
|
||||
.putExtra("title", getString(R.string.pref_about_osl)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle bundle, String rootKey) {
|
||||
setPreferencesFromResource(R.xml.preferences, rootKey);
|
||||
}
|
||||
}
|
@ -1,18 +1,23 @@
|
||||
package io.github.wulkanowy.ui.main.settings;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceFragmentCompat;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity;
|
||||
|
||||
import io.github.wulkanowy.BuildConfig;
|
||||
import io.github.wulkanowy.R;
|
||||
import io.github.wulkanowy.services.jobs.SyncJob;
|
||||
import io.github.wulkanowy.utils.AppConstant;
|
||||
|
||||
public class SettingsFragment extends PreferenceFragmentCompat
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener,
|
||||
PreferenceFragmentCompat.OnPreferenceStartScreenCallback{
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
public static final String SHARED_KEY_START_TAB = "startup_tab";
|
||||
|
||||
@ -28,6 +33,38 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
|
||||
public static final String SHARED_KEY_SERVICES_MOBILE_DISABLED = "services_disable_mobile";
|
||||
|
||||
public static final String SHARED_KEY_ABOUT_VERSION = "about_version";
|
||||
|
||||
public static final String SHARED_KEY_ABOUT_LICENSES = "about_osl";
|
||||
|
||||
public static final String SHARED_KEY_ABOUT_REPO = "about_repo";
|
||||
|
||||
private Preference.OnPreferenceClickListener onProgrammerListener = new Preference.OnPreferenceClickListener() {
|
||||
private int clicks = 0;
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Toast.makeText(getActivity(), getVersionToast(clicks++), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
private int getVersionToast(int click) {
|
||||
if (0 == click) {
|
||||
return R.string.about_programmer_step1;
|
||||
}
|
||||
|
||||
if (1 == click) {
|
||||
return R.string.about_programmer_step2;
|
||||
}
|
||||
|
||||
if (9 > click) {
|
||||
return R.string.about_programmer_step3;
|
||||
}
|
||||
|
||||
return R.string.about_programmer;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
@ -36,6 +73,12 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
findPreference(SHARED_KEY_ABOUT_VERSION).setSummary(BuildConfig.VERSION_NAME);
|
||||
findPreference(SHARED_KEY_ABOUT_VERSION).setOnPreferenceClickListener(onProgrammerListener);
|
||||
findPreference(SHARED_KEY_ABOUT_REPO).setIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(AppConstant.REPO_URL)));
|
||||
findPreference(SHARED_KEY_ABOUT_LICENSES).setIntent(new Intent(getActivity(), OssLicensesMenuActivity.class)
|
||||
.putExtra("title", getString(R.string.pref_about_osl)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -43,21 +86,6 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceStartScreen(PreferenceFragmentCompat preferenceFragmentCompat,
|
||||
PreferenceScreen preferenceScreen) {
|
||||
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
|
||||
AboutScreen fragment = new AboutScreen();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, preferenceScreen.getKey());
|
||||
fragment.setArguments(args);
|
||||
ft.add(R.id.main_activity_container, fragment, preferenceScreen.getKey());
|
||||
ft.addToBackStack(preferenceScreen.getKey());
|
||||
ft.commit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (key.equals(SHARED_KEY_SERVICES_ENABLE) || key.equals(SHARED_KEY_SERVICES_INTERVAL)
|
||||
|
@ -1,37 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main_activity_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:weightSum="1"
|
||||
tools:context="io.github.wulkanowy.ui.main.MainActivity"
|
||||
>
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
>
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||
/>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
android:baselineAligned="false"
|
||||
android:weightSum="1">
|
||||
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
|
||||
>
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/main_activity_appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/main_activity_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:layout_scrollFlags="scroll|enterAlways" />
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/main_activity_progress_bar"
|
||||
@ -49,7 +40,8 @@
|
||||
android:id="@+id/main_activity_view_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/bottom_navigation_height" />
|
||||
android:layout_marginBottom="@dimen/bottom_navigation_height"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
<com.aurelhubert.ahbottomnavigation.AHBottomNavigation
|
||||
android:id="@+id/main_activity_nav"
|
||||
@ -58,5 +50,4 @@
|
||||
android:layout_gravity="bottom" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
@ -11,13 +11,13 @@
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="grades_summary"
|
||||
android:title="@string/pref_grades_summary_line_show"
|
||||
android:summary="@string/required_restart" />
|
||||
android:summary="@string/required_restart"
|
||||
android:title="@string/pref_grades_summary_line_show" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="attendance_present"
|
||||
android:title="@string/pref_attendance_present_show"
|
||||
android:summary="@string/required_restart" />
|
||||
android:summary="@string/required_restart"
|
||||
android:title="@string/pref_attendance_present_show" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_services_header">
|
||||
<SwitchPreference
|
||||
@ -34,9 +34,9 @@
|
||||
android:title="@string/pref_services_interval" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="services_enable"
|
||||
android:key="services_disable_mobile"
|
||||
android:title="@string/pref_services_mobile_data"
|
||||
android:dependency="services_enable" />
|
||||
android:title="@string/pref_services_mobile_data" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_notify_header">
|
||||
<SwitchPreference
|
||||
@ -45,27 +45,16 @@
|
||||
android:key="notify_enable"
|
||||
android:title="@string/pref_notify_switch" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_about_header">
|
||||
<PreferenceScreen
|
||||
android:key="pref_about"
|
||||
android:title="@string/pref_about"
|
||||
android:persistent="false">
|
||||
<PreferenceCategory android:title="@string/pref_about">
|
||||
<Preference
|
||||
android:selectable="false"
|
||||
android:summary="@string/pref_about_summary"/>
|
||||
<Preference
|
||||
android:key="about_version"
|
||||
android:title="@string/pref_about_version"/>
|
||||
<Preference
|
||||
android:key="about_osl"
|
||||
android:title="@string/pref_about_osl"
|
||||
android:summary="@string/pref_about_osl_summary"/>
|
||||
<Preference
|
||||
android:key="about_repo"
|
||||
android:title="@string/pref_about_support">
|
||||
</Preference>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
<PreferenceCategory android:title="@string/pref_about">
|
||||
<Preference
|
||||
android:key="about_version"
|
||||
android:title="@string/pref_about_version" />
|
||||
<Preference
|
||||
android:key="about_osl"
|
||||
android:summary="@string/pref_about_osl_summary"
|
||||
android:title="@string/pref_about_osl" />
|
||||
<Preference
|
||||
android:key="about_repo"
|
||||
android:title="@string/pref_about_support" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
@ -1,12 +1,12 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
google()
|
||||
jcenter()
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.1.2'
|
||||
classpath 'com.android.tools.build:gradle:3.1.3'
|
||||
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2"
|
||||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
|
||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
|
||||
@ -70,9 +70,9 @@ ext {
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
google()
|
||||
jcenter()
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user