SettingsActivity with Drawer is just to much work. This is the farthest I have come to get it working.

This commit is contained in:
Christopher Beckmann 2017-11-01 16:59:29 +01:00
commit 2b40798857
31 changed files with 872 additions and 98 deletions

5
.idea/misc.xml generated
View file

@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY" />
<option name="OPTION_SCOPE" value="protected" />
@ -45,7 +42,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
<component name="ProjectType">
<option name="id" value="Android" />
</component>

2
.idea/modules.xml generated
View file

@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/PrivacyFriendlyBreakReminder.iml" filepath="$PROJECT_DIR$/PrivacyFriendlyBreakReminder.iml" />
<module fileurl="file://C:\Users\Christopher Beckmann\StudioProjects\privacy-friendly-break-reminder\PrivacyFriendlyBreakReminder.iml" filepath="C:\Users\Christopher Beckmann\StudioProjects\privacy-friendly-break-reminder\PrivacyFriendlyBreakReminder.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/privacy-friendly-break-reminder.iml" filepath="$PROJECT_DIR$/privacy-friendly-break-reminder.iml" />
</modules>

View file

@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "org.secuso.privacyfriendlybreakreminder"
@ -24,22 +24,24 @@ android {
}
}
repositories{
repositories {
mavenCentral()
mavenLocal()
google()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:appcompat-v7:25.4.0'
//compile 'com.android.support:preference-v7:25.4.0'
compile 'com.android.support:design:25.4.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:support-annotations:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:support-v4:25.4.0'
compile 'com.android.support:support-annotations:27.0.0'
compile 'com.android.support:cardview-v7:25.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.nex3z:flow-layout:1.0.0'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
testCompile 'junit:junit:4.12'
compile 'com.shawnlin:number-picker:2.4.4'
compile 'com.shawnlin:number-picker:2.4.4' // https://github.com/ShawnLin013/NumberPicker
}

View file

@ -2,67 +2,60 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.secuso.privacyfriendlybreakreminder">
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:largeHeap="true"
android:label="@string/app_name"
android:largeHeap="true"
android:screenOrientation="portrait"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".activities.SettingsActivity"
android:label="@string/title_activity_settings"
android:theme="@style/AppTheme.NoActionBar"
android:parentActivityName=".activities.TimerActivity"
android:screenOrientation="portrait">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.secuso.privacyfriendlybreakreminder.activities.TimerActivity" />
</activity>
<activity
android:name=".activities.SplashActivity"
android:theme="@style/SplashTheme"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.tutorial.TutorialActivity"
android:theme="@style/AppTheme.NoActionBar"
android:parentActivityName=".activities.TimerActivity"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.secuso.privacyfriendlybreakreminder.activities.TimerActivity" />
</activity>
<activity
android:name=".activities.TimerActivity"
android:label="@string/activity_title_break_reminder"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".activities.ManageExerciseSetsActivity"
android:label="@string/activity_title_manage_exercise_sets"
android:parentActivityName=".activities.TimerActivity"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait">
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.secuso.privacyfriendlybreakreminder.activities.TimerActivity" />
</activity>
<activity
android:name=".activities.ExerciseActivity"
android:label=""
@ -72,19 +65,17 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="org.secuso.privacyfriendlybreakreminder.activities.TimerActivity" />
</activity>
<activity
android:name=".activities.EditExerciseSetActivity"
android:windowSoftInputMode="adjustResize"
android:label="@string/activity_title_edit_exercise_set"
android:parentActivityName=".activities.ManageExerciseSetsActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait">
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.secuso.privacyfriendlybreakreminder.activities.ManageExerciseSetsActivity" />
</activity>
<activity
android:name=".activities.ChooseExerciseActivity"
android:label="@string/activity_title_choose_exercises"
@ -92,9 +83,9 @@
android:screenOrientation="portrait">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.secuso.privacyfriendlybreakreminder.activities.EditExerciseSetActivity" />>
android:value="org.secuso.privacyfriendlybreakreminder.activities.EditExerciseSetActivity" />
>
</activity>
<activity
android:name=".activities.AboutActivity"
android:label="@string/activity_title_about"
@ -104,13 +95,12 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="org.secuso.privacyfriendlybreakreminder.activities.TimerActivity" />
</activity>
<activity
android:name=".activities.HelpActivity"
android:label="@string/activity_title_help"
android:parentActivityName=".activities.TimerActivity"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.secuso.privacyfriendlybreakreminder.activities.TimerActivity" />
@ -121,6 +111,9 @@
android:enabled="true"
android:exported="false" />
<activity
android:name=".SettingsActivity2"
android:label="@string/title_activity_settings2"></activity>
</application>
</manifest>

View file

@ -5,9 +5,17 @@ import android.preference.PreferenceFragment;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.widget.ExpandableListView;
import org.secuso.privacyfriendlybreakreminder.R;
import org.secuso.privacyfriendlybreakreminder.activities.helper.BaseActivity;
import org.secuso.privacyfriendlybreakreminder.activities.helper.ExpandableListAdapter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
/**
* @author Christopher Beckmann
@ -20,6 +28,27 @@ public class HelpActivity extends BaseActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help);
LinkedHashMap<String, List<String>> expandableListDetail = buildData();
List<String> expandableListTitleGeneral = new ArrayList<String>(expandableListDetail.keySet());
ExpandableListView generalExpandableListView = (ExpandableListView) findViewById(R.id.generalExpandableListView);
generalExpandableListView.setAdapter(new ExpandableListAdapter(this, expandableListTitleGeneral, expandableListDetail));
}
private LinkedHashMap<String, List<String>> buildData() {
LinkedHashMap<String, List<String>> expandableListDetail = new LinkedHashMap<>();
expandableListDetail.put(getString(R.string.help_whatis), Collections.singletonList(getString(R.string.help_whatis_answer)));
//expandableListDetail.put(getString(R.string.help_feature_one), Collections.singletonList(getString(R.string.help_feature_one_answer)));
//expandableListDetail.put(getString(R.string.help_privacy), Collections.singletonList(getString(R.string.help_privacy_answer)));
expandableListDetail.put(getString(R.string.help_permission), Collections.singletonList(getString(R.string.help_permission_answer)));
return expandableListDetail;
}
@Override
@ -27,14 +56,4 @@ public class HelpActivity extends BaseActivity {
return R.id.nav_help;
}
public static class HelpFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//addPreferencesFromResource(R.xml.pref_help);
}
}
}

View file

@ -181,7 +181,6 @@ public class ManageExerciseSetsActivity extends BaseActivity implements android.
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(!enabled);
actionBar.setDefaultDisplayHomeAsUpEnabled(!enabled);
actionBar.setDisplayShowHomeEnabled(enabled);
actionBar.setHomeButtonEnabled(enabled);
}

View file

@ -2,35 +2,334 @@
package org.secuso.privacyfriendlybreakreminder.activities;
import android.annotation.TargetApi;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.Intent;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.Handler;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.design.widget.NavigationView;
import android.support.v4.app.TaskStackBuilder;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.preference.RingtonePreference;
import android.text.TextUtils;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import org.secuso.privacyfriendlybreakreminder.activities.helper.BaseActivity;
import org.secuso.privacyfriendlybreakreminder.R;
import org.secuso.privacyfriendlybreakreminder.activities.helper.AppCompatPreferenceActivity;
import org.secuso.privacyfriendlybreakreminder.activities.tutorial.TutorialActivity;
import java.util.List;
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
/**
* @author Christopher Beckmann
* @version 2.0
*/
public class SettingsActivity extends BaseActivity {
public class SettingsActivity extends AppCompatPreferenceActivity implements NavigationView.OnNavigationItemSelectedListener{
// delay to launch nav drawer item, to allow close animation to play
protected static final int NAVDRAWER_LAUNCH_DELAY = 250;
// fade in and fade out durations for the main content when switching between
// different Activities of the app through the Nav Drawer
protected static final int MAIN_CONTENT_FADEOUT_DURATION = 150;
protected static final int MAIN_CONTENT_FADEIN_DURATION = 250;
// Navigation drawer:
protected DrawerLayout mDrawerLayout;
private NavigationView mNavigationView;
protected Toolbar toolbar;
protected ActionBarDrawerToggle mDrawerToggle;
// Helper
private Handler mHandler;
protected SharedPreferences mSharedPreferences;
private boolean mDrawerEnabled;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
mHandler = new Handler();
overridePendingTransition(0, 0);
}
@Override
public void onBackPressed() {
if (mDrawerLayout != null && mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
mDrawerLayout.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
/**
* {@inheritDoc}
*/
@Override
public boolean onIsMultiPane() {
return isXLargeTablet(this);
}
/**
* Helper method to determine if the device has an extra-large screen. For
* example, 10" tablets are extra-large.
*/
private static boolean isXLargeTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
/**
* {@inheritDoc}
*/
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onBuildHeaders(List<Header> target) {
loadHeadersFromResource(R.xml.pref_headers, target);
}
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
return goToNavigationItem(item.getItemId());
}
protected boolean goToNavigationItem(final int itemId) {
if(itemId == getNavigationDrawerID()) {
// just close drawer because we are already in this activity
mDrawerLayout.closeDrawer(GravityCompat.START);
return true;
}
// delay transition so the drawer can close
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
callDrawerItem(itemId);
}
}, NAVDRAWER_LAUNCH_DELAY);
mDrawerLayout.closeDrawer(GravityCompat.START);
selectNavigationItem(itemId);
// fade out the active activity
View mainContent = findViewById(R.id.main_content);
if (mainContent != null) {
mainContent.animate().alpha(0).setDuration(MAIN_CONTENT_FADEOUT_DURATION);
}
return true;
}
// set active navigation item
private void selectNavigationItem(int itemId) {
for(int i = 0 ; i < mNavigationView.getMenu().size(); i++) {
boolean b = itemId == mNavigationView.getMenu().getItem(i).getItemId();
mNavigationView.getMenu().getItem(i).setChecked(b);
}
}
/**
* Enables back navigation for activities that are launched from the NavBar. See
* {@code AndroidManifest.xml} to find out the parent activity names for each activity.
* @param intent
*/
private void createBackStack(Intent intent) {
TaskStackBuilder builder = TaskStackBuilder.create(this);
builder.addNextIntentWithParentStack(intent);
builder.startActivities();
}
/**
* This method manages the behaviour of the navigation drawer
* Add your menu items (ids) to res/menu/activity_main_drawer.xml
* @param itemId Item that has been clicked by the user
*/
private void callDrawerItem(final int itemId) {
Intent intent;
switch(itemId) {
case R.id.nav_timer:
intent = new Intent(this, TimerActivity.class);
intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
break;
case R.id.nav_manage_exercise_sets:
intent = new Intent(this, ManageExerciseSetsActivity.class);
createBackStack(intent);
break;
case R.id.nav_tutorial:
intent = new Intent(this, TutorialActivity.class);
createBackStack(intent);
break;
case R.id.nav_about:
intent = new Intent(this, AboutActivity.class);
createBackStack(intent);
break;
case R.id.nav_help:
intent = new Intent(this, HelpActivity.class);
createBackStack(intent);
break;
case R.id.nav_settings:
intent = new Intent(this, SettingsActivity.class);
//intent.putExtra( PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.ExercisePreferenceFragment.class.getName() );
//intent.putExtra( PreferenceActivity.EXTRA_NO_HEADERS, true );
createBackStack(intent);
break;
default:
}
overridePendingTransition(0,0);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
toolbar = (Toolbar) findViewById(R.id.toolbar);
if(getSupportActionBar() == null) {
setSupportActionBar(toolbar);
}
// mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
// mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
// mDrawerLayout.addDrawerListener(mDrawerToggle);
// mDrawerToggle.syncState();
//
// mNavigationView = (NavigationView) findViewById(R.id.nav_view);
// mNavigationView.setNavigationItemSelectedListener(this);
//
// showContent();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void setDrawerEnabled(final boolean enabled) {
int lockMode = enabled ?
DrawerLayout.LOCK_MODE_UNLOCKED :
DrawerLayout.LOCK_MODE_LOCKED_CLOSED;
mDrawerEnabled = enabled;
if(mDrawerLayout == null) return;
mDrawerLayout.setDrawerLockMode(lockMode);
mDrawerToggle.setDrawerIndicatorEnabled(enabled);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(!enabled);
actionBar.setDisplayShowHomeEnabled(enabled);
actionBar.setHomeButtonEnabled(enabled);
}
mDrawerToggle.syncState();
}
@Override
protected boolean isValidFragment(String fragmentName) {
return ExercisePreferenceFragment.class.getName().equals(fragmentName)
|| TimerPreferenceFragment.class.getName().equals(fragmentName);
}
private void showContent() {
selectNavigationItem(getNavigationDrawerID());
View mainContent = findViewById(R.id.main_content);
if (mainContent != null) {
mainContent.setAlpha(0);
mainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEIN_DURATION);
}
}
@Override
protected void onResume() {
super.onResume();
//showContent();
}
/**
* Start a new fragment.
*
* @param fragment The fragment to start
* @param push If true, the current fragment will be pushed onto the back stack. If false,
* the current fragment will be replaced.
*/
@Override
public void startPreferenceFragment(Fragment fragment, boolean push) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.prefs, fragment);
if (push) {
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.addToBackStack(":android:prefs");
} else {
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
}
transaction.commitAllowingStateLoss();
}
/**
* Start a new fragment containing a preference panel. If the preferences
* are being displayed in multi-pane mode, the given fragment class will
* be instantiated and placed in the appropriate pane. If running in
* single-pane mode, a new activity will be launched in which to show the
* fragment.
*
* @param fragmentClass Full name of the class implementing the fragment.
* @param args Any desired arguments to supply to the fragment.
* @param titleRes Optional resource identifier of the title of this
* fragment.
* @param titleText Optional text of the title of this fragment.
* @param resultTo Optional fragment that result data should be sent to.
* If non-null, resultTo.onActivityResult() will be called when this
* preference panel is done. The launched panel must use
* {@link #finishPreferencePanel(Fragment, int, Intent)} when done.
* @param resultRequestCode If resultTo is non-null, this is the caller's
* request code to be received with the result.
*/
public void startPreferencePanel(String fragmentClass, Bundle args, @StringRes int titleRes,
CharSequence titleText, Fragment resultTo, int resultRequestCode) {
startWithFragment(fragmentClass, args, resultTo, resultRequestCode, titleRes, 0);
}
/**
@ -84,13 +383,12 @@ public class SettingsActivity extends BaseActivity {
.getString(preference.getKey(), ""));
}
@Override
protected int getNavigationDrawerID() {
return R.id.nav_settings;
}
public static class ExercisePreferenceFragment extends PreferenceFragment {
public static class GeneralPreferenceFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -105,13 +403,48 @@ public class SettingsActivity extends BaseActivity {
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
startActivity(new Intent(getActivity(), SettingsActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
public void onResume() {
super.onResume();
SettingsActivity settingsActivity = (SettingsActivity)getActivity();
if(settingsActivity != null) settingsActivity.setDrawerEnabled(false);
}
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// int id = item.getItemId();
// if (id == android.R.id.home) {
// Log.d("Fragment", "clicked");
// onBackPressed();
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
}
public static class TimerPreferenceFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_scheduler);
setHasOptionsMenu(true);
}
@Override
public void onDestroy() {
super.onDestroy();
Log.d("WTF", "destroy?");
}
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// int id = item.getItemId();
// if (id == android.R.id.home) {
// //startActivity(new Intent(getActivity(), SettingsActivity.class));
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
}
}

View file

@ -0,0 +1,109 @@
package org.secuso.privacyfriendlybreakreminder.activities.helper;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.Toolbar;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
* to be used with AppCompat.
*/
public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
private AppCompatDelegate mDelegate;
@Override
protected void onCreate(Bundle savedInstanceState) {
getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
getDelegate().onPostCreate(savedInstanceState);
}
public ActionBar getSupportActionBar() {
return getDelegate().getSupportActionBar();
}
public void setSupportActionBar(@Nullable Toolbar toolbar) {
getDelegate().setSupportActionBar(toolbar);
}
@Override
public MenuInflater getMenuInflater() {
return getDelegate().getMenuInflater();
}
@Override
public void setContentView(@LayoutRes int layoutResID) {
getDelegate().setContentView(layoutResID);
}
@Override
public void setContentView(View view) {
getDelegate().setContentView(view);
}
@Override
public void setContentView(View view, ViewGroup.LayoutParams params) {
getDelegate().setContentView(view, params);
}
@Override
public void addContentView(View view, ViewGroup.LayoutParams params) {
getDelegate().addContentView(view, params);
}
@Override
protected void onPostResume() {
super.onPostResume();
getDelegate().onPostResume();
}
@Override
protected void onTitleChanged(CharSequence title, int color) {
super.onTitleChanged(title, color);
getDelegate().setTitle(title);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
getDelegate().onConfigurationChanged(newConfig);
}
@Override
protected void onStop() {
super.onStop();
getDelegate().onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
getDelegate().onDestroy();
}
public void invalidateOptionsMenu() {
getDelegate().invalidateOptionsMenu();
}
private AppCompatDelegate getDelegate() {
if (mDelegate == null) {
mDelegate = AppCompatDelegate.create(this, null);
}
return mDelegate;
}
}

View file

@ -162,7 +162,7 @@ public abstract class BaseActivity extends AppCompatActivity implements OnNaviga
break;
case R.id.nav_settings:
intent = new Intent(this, SettingsActivity.class);
//intent.putExtra( PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.GeneralPreferenceFragment.class.getName() );
//intent.putExtra( PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.ExercisePreferenceFragment.class.getName() );
//intent.putExtra( PreferenceActivity.EXTRA_NO_HEADERS, true );
createBackStack(intent);
break;

View file

@ -0,0 +1,101 @@
package org.secuso.privacyfriendlybreakreminder.activities.helper;
import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;
import org.secuso.privacyfriendlybreakreminder.R;
import java.util.HashMap;
import java.util.List;
/**
* @author Christopher Beckmann
* @version 2.0
* @since 26.10.2017
* created 26.10.2017
*/
public class ExpandableListAdapter extends BaseExpandableListAdapter {
private Context context;
private List<String> expandableListTitle;
private HashMap<String, List<String>> expandableListDetail;
public ExpandableListAdapter(Context context, List<String> expandableListTitle,
HashMap<String, List<String>> expandableListDetail) {
this.context = context;
this.expandableListTitle = expandableListTitle;
this.expandableListDetail = expandableListDetail;
}
@Override
public Object getChild(int listPosition, int expandedListPosition) {
return this.expandableListDetail.get(this.expandableListTitle.get(listPosition)).get(expandedListPosition);
}
@Override
public long getChildId(int listPosition, int expandedListPosition) {
return expandedListPosition;
}
@Override
public View getChildView(int listPosition, final int expandedListPosition, boolean isLastChild, View convertView, ViewGroup parent) {
final String expandedListText = (String) getChild(listPosition, expandedListPosition);
if (convertView == null) {
LayoutInflater layoutInflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.help_list_item, parent);
}
TextView expandedListTextView = (TextView) convertView.findViewById(R.id.expandedListItem);
expandedListTextView.setText(expandedListText);
return convertView;
}
@Override
public int getChildrenCount(int listPosition) {
return this.expandableListDetail.get(this.expandableListTitle.get(listPosition)).size();
}
@Override
public Object getGroup(int listPosition) {
return this.expandableListTitle.get(listPosition);
}
@Override
public int getGroupCount() {
return this.expandableListTitle.size();
}
@Override
public long getGroupId(int listPosition) {
return listPosition;
}
@Override
public View getGroupView(int listPosition, boolean isExpanded, View convertView, ViewGroup parent) {
String listTitle = (String) getGroup(listPosition);
if (convertView == null) {
LayoutInflater layoutInflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.help_list_group, null);
}
TextView listTitleTextView = (TextView) convertView.findViewById(R.id.listTitle);
listTitleTextView.setTypeface(null, Typeface.BOLD);
listTitleTextView.setText(listTitle);
return convertView;
}
@Override
public boolean hasStableIds() {
return true;
}
@Override
public boolean isChildSelectable(int listPosition, int expandedListPosition) {
return true;
}
}

View file

@ -0,0 +1,25 @@
package org.secuso.privacyfriendlybreakreminder.service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
/**
* @author Christopher Beckmann
* @version 2.0
* @since 26.10.2017
* created 26.10.2017
*/
public class NotificationDeletedReceiver extends BroadcastReceiver {
private static final String TAG = NotificationDeletedReceiver.class.getSimpleName();
@Override
public void onReceive(Context context, Intent intent) {
// TODO: Notification was swiped away.
Log.d(TAG, "Notification swiped away");
}
}

View file

@ -103,10 +103,9 @@ public class TimerService extends Service {
.setDefaults(Notification.DEFAULT_LIGHTS)
.setVibrate(new long[] { 0, 1000, 1000, 1000, 1000, 1000, 1000 })
.setSound(Settings.System.DEFAULT_NOTIFICATION_URI)
.setOnlyAlertOnce(false);
.setOnlyAlertOnce(false)
.setDeleteIntent(PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(this, NotificationDeletedReceiver.class), 0));
notificationManager.notify(NOTIFICATION_ID, builder.build());
// TODO: show decider activity?!
}
@Override

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Before After
Before After

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M11.5,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.9,2 2,2zm6.5,-6v-5.5c0,-3.07 -2.13,-5.64 -5,-6.32V3.5c0,-0.83 -0.67,-1.5 -1.5,-1.5S10,2.67 10,3.5v0.68c-2.87,0.68 -5,3.25 -5,6.32V16l-2,2v1h17v-1l-2,-2z" />
</vector>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01,-.25 1.97,-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0,-4.42,-3.58,-8,-8,-8zm0 14c-3.31 0,-6,-2.69,-6,-6 0,-1.01.25,-1.97.7,-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4,-4,-4,-4v3z" />
</vector>

View file

@ -26,10 +26,14 @@
android:orientation="vertical"
tools:context=".activities.HelpActivity"
android:weightSum="1">
<fragment android:name="org.secuso.privacyfriendlybreakreminder.activities.HelpActivity$HelpFragment"
android:id="@+id/help_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ExpandableListView
android:divider="@android:color/darker_gray"
android:dividerHeight="0.5dp"
android:id="@+id/generalExpandableListView"
android:indicatorLeft="?android:attr/expandableListPreferredItemIndicatorLeft"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
</LinearLayout>

View file

@ -21,13 +21,51 @@
android:id="@+id/main_content"
android:layout_height="match_parent">
<fragment
android:name="org.secuso.privacyfriendlybreakreminder.activities.SettingsActivity$GeneralPreferenceFragment"
android:id="@+id/activity_settings_general_preference_fragment"
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="0px"
android:layout_weight="1">
<LinearLayout
android:id="@+id/headers"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:drawSelectorOnTop="false"
android:cacheColorHint="@android:color/transparent"
android:listPreferredItemHeight="48dp"
android:scrollbarAlwaysDrawVerticalTrack="true" />
<FrameLayout android:id="@+id/list_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/prefs_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible" >
<android.preference.PreferenceFrameLayout android:id="@+id/prefs"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView

View file

@ -3,6 +3,7 @@
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:padding="8dp"
android:layout_width="match_parent"
android:layout_height="match_parent">

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/listTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft"
android:textColor="@android:color/black"
android:paddingTop="10dp"
android:paddingBottom="10dp" />
</LinearLayout>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/expandedListItem"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp" />
</LinearLayout>

View file

@ -42,7 +42,7 @@
<string name="pref_current_exercises">Auswahl der Übungen</string>
<string name="pref_current_profile">Auswahl des Profils</string>
<string name="pref_default_display_name">Zufall</string>
<string name="pref_header_general">Profile bearbeiten</string>
<string name="pref_header_exercises">Profile bearbeiten</string>
<string name="pref_header_notifications">Benachrichtigungen</string>
<string name="pref_ringtone_silent">Lautlos</string>
<string name="pref_title_display_name">Profil Name</string>

View file

@ -32,7 +32,7 @@
<string name="pref_current_exercises">Choisissez des exercices</string>
<string name="pref_current_profile">Choisissez un profil</string>
<string name="pref_default_display_name">Hasard</string>
<string name="pref_header_general">Modifier les profils</string>
<string name="pref_header_exercises">Modifier les profils</string>
<string name="pref_header_notifications">Notifications</string>
<string name="pref_ringtone_silent">Silencieux</string>
<string name="pref_title_display_name">Nom du profil</string>

View file

@ -36,7 +36,7 @@
<string name="tutorial_clock">Запустить/Остановить часы</string>
<string name="pref_default_display_name">Случайный</string>
<string name="pref_header_notifications">Уведомления</string>
<string name="pref_header_general">Редактирование профилей</string>
<string name="pref_header_exercises">Редактирование профилей</string>
<string name="standard_profile">Случайный,90,5,false,Руки.Ноги.Голова.Шея.Таз.Позвоночник.Туловище.;Талия вверх,90,15,true,Руки.Шея.Голова.;Корпус,30,5,true,Позвоночник.Туловище.;Нижний Корпус,30,5,true,Ноги.Таз.;</string>
<string name="pref_ringtone_silent">Без звука</string>
<string name="pref_title_display_name">Имя профиля</string>

View file

@ -156,6 +156,81 @@
<string name="numberpicker_formatter" translatable="false">%02d</string>
<string name="pref_exercise_time">Exercise time (in Seconds)</string>
<string name="pref_keep_screen_on_during_exercise">Keep screen on during exercise</string>
<string name="pref_category_exercise">exercise settings</string>
<string name="pref_category_schedule">schedule an exercise</string>
<string name="pref_schedule_exercise_switch">enable exercise schedule</string>
<string name="pref_schedule_exercise_time">Schedule Time</string>
<string name="help_whatis">What is Privacy Friendly Break Reminder?</string>
<string name="help_whatis_answer">Privacy Friendly Break Reminder is an app, that reminds you to take breaks during your work sessions. It allows you to select exercises, that are then shown during your break time.</string>
<string name="help_permission">Which permissions does the app require?</string>
<string name="help_permission_answer">The app only requests permission to control the vibration of the device to make the break alarm more distinct.</string>
<string name="pref_header_schedule">Schedule Times</string>
<string name="pref_header_exercises">Exercise Settings</string>
<string name="title_activity_settings2">Settings</string>
<!-- Strings related to Settings -->
<!-- Example General settings -->
<string name="pref_header_general">General</string>
<string name="pref_title_social_recommendations">Enable social recommendations</string>
<string name="pref_description_social_recommendations">Recommendations for people to contact
based on your message history
</string>
<string name="pref_title_display_name">Display name</string>
<string name="pref_default_display_name">John Smith</string>
<string name="pref_title_add_friends_to_messages">Add friends to messages</string>
<string-array name="pref_example_list_titles">
<item>Always</item>
<item>When possible</item>
<item>Never</item>
</string-array>
<string-array name="pref_example_list_values">
<item>1</item>
<item>0</item>
<item>-1</item>
</string-array>
<!-- Example settings for Data & Sync -->
<string name="pref_header_data_sync">Data &amp; sync</string>
<string name="pref_title_sync_frequency">Sync frequency</string>
<string-array name="pref_sync_frequency_titles">
<item>15 minutes</item>
<item>30 minutes</item>
<item>1 hour</item>
<item>3 hours</item>
<item>6 hours</item>
<item>Never</item>
</string-array>
<string-array name="pref_sync_frequency_values">
<item>15</item>
<item>30</item>
<item>60</item>
<item>180</item>
<item>360</item>
<item>-1</item>
</string-array>
<string-array name="list_preference_entries">
<item>Entry 1</item>
<item>Entry 2</item>
<item>Entry 3</item>
</string-array>
<string-array name="list_preference_entry_values">
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>
<string-array name="multi_select_list_preference_default_value" />
<string name="pref_title_system_sync_settings">System sync settings</string>
<string name="pref_title_new_message_notifications">New message notifications</string>
</resources>

View file

@ -1,16 +1,20 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
android:defaultValue="true"
android:key="pref_keep_screen_on_during_exercise"
android:title="@string/pref_keep_screen_on_during_exercise" />
<PreferenceCategory android:title="@string/pref_category_exercise">
<EditTextPreference
android:defaultValue="30"
android:inputType="number"
android:numeric="integer"
android:maxLength="2"
android:key="pref_exercise_time"
android:title="@string/pref_exercise_time"/>
<SwitchPreference
android:defaultValue="true"
android:key="pref_keep_screen_on_during_exercise"
android:title="@string/pref_keep_screen_on_during_exercise" />
<EditTextPreference
android:defaultValue="30"
android:inputType="number"
android:numeric="integer"
android:maxLength="2"
android:key="pref_exercise_time"
android:title="@string/pref_exercise_time"/>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -3,8 +3,13 @@
<!-- These settings headers are only used on tablets. -->
<header
android:fragment="org.secuso.privacyfriendlybreakreminder.activities.SettingsActivity$GeneralPreferenceFragment"
android:fragment="org.secuso.privacyfriendlybreakreminder.activities.SettingsActivity$ExercisePreferenceFragment"
android:icon="@drawable/ic_info_black"
android:title="@string/pref_header_general" />
android:title="@string/pref_header_exercises" />
<header
android:fragment="org.secuso.privacyfriendlybreakreminder.activities.SettingsActivity$TimerPreferenceFragment"
android:icon="@drawable/ic_alarm_black"
android:title="@string/pref_header_schedule" />
</preference-headers>

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/pref_category_schedule">
<SwitchPreference
android:title="@string/pref_schedule_exercise_switch"
android:defaultValue="false"
android:key="pref_schedule_exercise"/>
<EditTextPreference
android:defaultValue="30"
android:inputType="number"
android:numeric="integer"
android:maxLength="2"
android:dependency="pref_schedule_exercise"
android:key="pref_schedule_exercise_time"
android:title="@string/pref_schedule_exercise_time"/>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -3,9 +3,13 @@
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View file

@ -1,6 +1,6 @@
#Sat Aug 12 14:48:24 CEST 2017
#Fri Oct 27 05:33:03 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip