Preference acitivty
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
// This does not break the build when Android Studio is missing the JRebel for Android plugin.
|
||||||
|
apply plugin: 'com.zeroturnaround.jrebel.android'
|
||||||
apply plugin: 'com.neenbedankt.android-apt'
|
apply plugin: 'com.neenbedankt.android-apt'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name=".PreferenceActivity"
|
||||||
|
android:parentActivityName=".MainActivity"/>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package net.headlezz.notificationlogger;
|
package net.headlezz.notificationlogger;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
@@ -22,14 +22,15 @@ public class MainActivity extends AppCompatActivity implements Toolbar.OnMenuIte
|
|||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
mToolbar.inflateMenu(R.menu.main_activity);
|
mToolbar.inflateMenu(R.menu.main_activity);
|
||||||
|
mToolbar.setTitle(getString(R.string.app_name));
|
||||||
mToolbar.setOnMenuItemClickListener(this);
|
mToolbar.setOnMenuItemClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
if(item.getItemId() == R.id.menu_settings) {
|
if(item.getItemId() == R.id.menu_settings) {
|
||||||
Toast.makeText(this, "Not implemented", Toast.LENGTH_SHORT).show();
|
Intent intent = new Intent(this, PreferenceActivity.class);
|
||||||
return true;
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package net.headlezz.notificationlogger;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
|
|
||||||
|
import com.mikepenz.aboutlibraries.LibsBuilder;
|
||||||
|
import com.mikepenz.aboutlibraries.ui.LibsSupportFragment;
|
||||||
|
|
||||||
|
import butterknife.Bind;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
|
public class PreferenceActivity extends AppCompatActivity implements PreferenceFragment.PreferenceCallbacks {
|
||||||
|
|
||||||
|
@Bind(R.id.toolbar)
|
||||||
|
Toolbar mToolbar;
|
||||||
|
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.preference_activity);
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
setSupportActionBar(mToolbar);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
getSupportActionBar().setTitle(R.string.title_settings);
|
||||||
|
|
||||||
|
if(getSupportFragmentManager().findFragmentById(R.id.fragment_holder) == null) {
|
||||||
|
PreferenceFragment pf = new PreferenceFragment();
|
||||||
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
.add(R.id.fragment_holder, pf)
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showAboutScreen() {
|
||||||
|
// TODO add other libraries
|
||||||
|
LibsSupportFragment aboutFrag = new LibsBuilder()
|
||||||
|
.withAboutAppName(getString(R.string.app_name))
|
||||||
|
.withAboutIconShown(true)
|
||||||
|
.withAboutVersionShown(true)
|
||||||
|
.withAboutVersionShownCode(true)
|
||||||
|
.supportFragment();
|
||||||
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
.replace(R.id.fragment_holder, aboutFrag)
|
||||||
|
.addToBackStack("about")
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package net.headlezz.notificationlogger;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.preference.Preference;
|
||||||
|
import android.support.v7.preference.PreferenceFragmentCompat;
|
||||||
|
|
||||||
|
public class PreferenceFragment extends PreferenceFragmentCompat implements Preference.OnPreferenceClickListener {
|
||||||
|
|
||||||
|
private PreferenceCallbacks mCallbacks;
|
||||||
|
|
||||||
|
final String PREF_ABOUT = "pref_about";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
interface PreferenceCallbacks {
|
||||||
|
void showAboutScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreatePreferences(Bundle bundle, String s) {
|
||||||
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
|
findPreference(PREF_ABOUT).setOnPreferenceClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
if(preference.getKey().equals(PREF_ABOUT)) {
|
||||||
|
mCallbacks.showAboutScreen();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Activity activity) {
|
||||||
|
super.onAttach(activity);
|
||||||
|
mCallbacks = (PreferenceCallbacks) activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetach() {
|
||||||
|
super.onDetach();
|
||||||
|
mCallbacks = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout 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="match_parent"
|
android:layout_height="match_parent">
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<include layout="@layout/toolbar" />
|
||||||
android:background="?attr/colorPrimary"
|
|
||||||
android:id="@+id/toolbar"
|
|
||||||
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
|
||||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?attr/actionBarSize" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
14
app/src/main/res/layout/preference_activity.xml
Normal file
14
app/src/main/res/layout/preference_activity.xml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<include layout="@layout/toolbar" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/fragment_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
10
app/src/main/res/layout/toolbar.xml
Normal file
10
app/src/main/res/layout/toolbar.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
app:elevation="?attr/elevation"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||||
|
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize" />
|
||||||
@@ -1,4 +1,16 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Notification Logger</string>
|
<string name="app_name">Notification Logger</string>
|
||||||
<string name="menu_item_settings">Settings</string>
|
<string name="menu_item_settings">Settings</string>
|
||||||
|
<string name="title_settings">Settings</string>
|
||||||
|
|
||||||
|
<string name="pref_category_notification_settings">Notification Settings</string>
|
||||||
|
<string name="pref_category_support">Support</string>
|
||||||
|
<string name="pref_logging_enabled_title">Notification Logging</string>
|
||||||
|
<string name="pref_logging_enabled_summary">Enable/Disable notification logging</string>
|
||||||
|
<string name="pref_blacklist_title">Blacklist</string>
|
||||||
|
<string name="pref_blacklist_summary">Exclude apps from being logged</string>
|
||||||
|
<string name="pref_clear_database_title">Clear database</string>
|
||||||
|
<string name="pref_clear_database_summary">Remove all logged notifications</string>
|
||||||
|
<string name="pref_export_title">Export to sdcard</string>
|
||||||
|
<string name="pref_about_title">About</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<item name="colorPrimary">@color/colorPrimary</item>
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
<item name="colorAccent">@color/colorAccent</item>
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
|
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
32
app/src/main/res/xml/preferences.xml
Normal file
32
app/src/main/res/xml/preferences.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="screen_notification_settings"
|
||||||
|
android:title="@string/pref_category_notification_settings">
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="pref_logging_enabled"
|
||||||
|
android:summary="@string/pref_logging_enabled_summary"
|
||||||
|
android:title="@string/pref_logging_enabled_title" />
|
||||||
|
<Preference
|
||||||
|
android:key="pref_blacklist"
|
||||||
|
android:summary="@string/pref_blacklist_summary"
|
||||||
|
android:title="@string/pref_blacklist_title" />
|
||||||
|
<Preference
|
||||||
|
android:key="pref_clear_database"
|
||||||
|
android:summary="@string/pref_clear_database_summary"
|
||||||
|
android:title="@string/pref_clear_database_title" />
|
||||||
|
<Preference
|
||||||
|
android:key="pref_export"
|
||||||
|
android:title="@string/pref_export_title" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="screen_support"
|
||||||
|
android:title="@string/pref_category_support">
|
||||||
|
<Preference
|
||||||
|
android:key="pref_about"
|
||||||
|
android:title="@string/pref_about_title" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
</PreferenceScreen>
|
||||||
@@ -3,9 +3,14 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url 'https://repos.zeroturnaround.com/nexus/content/repositories/zt-public-releases'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
|
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
|
||||||
|
// This does not break the build when Android Studio is missing the JRebel for Android plugin.
|
||||||
|
classpath 'com.zeroturnaround.jrebel.android:jr-android-gradle:1.0.+'
|
||||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.6'
|
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.6'
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
|||||||
Reference in New Issue
Block a user