GithubHelp home page GithubHelp logo

harris-fork / materialsettings Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kenumir/materialsettings

0.0 1.0 0.0 1.26 MB

MaterialSettings - small library to create settings activity

License: Other

Java 100.00%

materialsettings's Introduction

MaterialSettings

MaterialSettings - small library to create settings activity

Android app on Google Play

Add to project

Repo:

repositories {
	maven {
		url "https://jitpack.io"
	}
}

Dependences:

dependencies {
	compile 'com.github.kenumir:MaterialSettings:v.1.2.2'
}

###Simple code:

public class Settings1Activity extends MaterialSettings {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addItem(new HeaderItem(this).setTitle("Sample title 1"));
		addItem(new CheckboxItem(this, "key1").setTitle("Checkbox item 1").setSubtitle("Subtitle text 1").setOnCheckedChangeListener(new CheckboxItem.OnCheckedChangeListener() {
			@Override
			public void onCheckedChange(CheckboxItem cbi, boolean isChecked) {
				Toast.makeText(Settings1Activity.this, "CHECKED: " + isChecked, Toast.LENGTH_SHORT).show();
			}
		}));
	}
	@Override
    public StorageInterface initStorageInterface() {
    	return new PreferencesStorageInterface(this);
    }
}

Important

If in your app has layout named "activity_material_settings.xml" will occur error "NoSuchFieldError: No static field" - issue #2

Style attrs

  • msToolbarTheme
  • msToolbarThemePopup
  • msColorPrimary - primary color
  • msColorPrimaryDark - color of status bar (api 21+)
  • msColorAccent - accent color
  • msWindowBg - default window bg color
  • msColorHeader - headers text color (usually same as msColorAccent)
  • msColorTextTitle - item title color
  • msColorTextSubTitle - subtitle text color
  • msDivider - divider drawable
  • msItem - whole item color
  • msTextStyle - reference to text title style (TextView)
  • msSubTextStyle - reference to text sub title style (TextView)
  • msHeaderStyle - reference to text title style (TextView)

Same style

<style name="MaterialSettings.Red" parent="MaterialSettingsTheme">
<item name="msColorPrimary">@color/redPrimary</item>
    <item name="msColorPrimaryDark">@color/redPrimaryDark</item>
    <item name="msColorAccent">@color/redAccent</item>
    <item name="msColorHeader">@color/redAccent</item>
</style>

StorageInterface

Easiest way to save/load settings

  • PreferencesStorageInterface - in shared preferences
  • SimpleStorageInterface - in memory
  • or write own interface to save data (sqlite, content provider or to file)

Interface:

    public abstract class StorageInterface {
        public StorageInterface() {}

        public abstract void save(String key, Boolean value);
        public abstract boolean load(String key, Boolean defaultValue);

        public abstract void save(String key, String value);
        public abstract String load(String key, String defaultValue);

        public abstract void save(String key, Integer value);
        public abstract Integer load(String key, Integer defaultValue);

        public abstract void save(String key, Float value);
        public abstract Float load(String key, Float defaultValue);

        public abstract void save(String key, Long value);
        public abstract Long load(String key, Long defaultValue);

        public abstract Map<String, ?> getAll();
    }

Extend and write own methods.

Screens

Default Rec Dark

###License

Copyright 2013-2015 Michał Szwarc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

materialsettings's People

Contributors

harris2012 avatar kenumir avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.