Anthony Restaino 969cab81e7 New Full-screen mode works better and doesn't hide the top of the WebView, +other
* Now using material alertdialog on all versions
* cleaned up some code
* fixed lint issues and other inspection related problems
* Attempted to fix bugs found
2015-07-18 14:30:41 -04:00

60 lines
1.8 KiB
Java

/*
* Copyright 2014 A.C.R. Development
*/
package acr.browser.lightning.activity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import java.util.ArrayList;
import java.util.List;
import acr.browser.lightning.R;
public class SettingsActivity extends ThemableSettingsActivity {
private static final List<String> fragments = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// this is a workaround for the Toolbar in PreferenceActitivty
ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
LinearLayout content = (LinearLayout) root.getChildAt(0);
LinearLayout toolbarContainer = (LinearLayout) View.inflate(this, R.layout.toolbar_settings, null);
root.removeAllViews();
toolbarContainer.addView(content);
root.addView(toolbarContainer);
// now we can set the Toolbar using AppCompatPreferenceActivity
Toolbar toolbar = (Toolbar) toolbarContainer.findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public void onBuildHeaders(List<Header> target) {
loadHeadersFromResource(R.xml.preferences_headers, target);
fragments.clear();
for (Header header : target) {
fragments.add(header.fragment);
}
}
@Override
protected boolean isValidFragment(String fragmentName) {
return fragments.contains(fragmentName);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
finish();
return true;
}
}