Tutorial and Bug Fix

New Tutorial
And Bug Fix in SettingsActivity
This commit is contained in:
Jannik 2016-08-24 17:32:08 +02:00
commit a670230b6f
10 changed files with 161 additions and 18 deletions

View file

@ -1,5 +1,9 @@
package orgprivacy_friendly_apps.secuso.privacyfriendlybreakreminder;
import android.app.Activity;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.FragmentManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.appwidget.AppWidgetManager;
@ -15,6 +19,8 @@ import android.os.CountDownTimer;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
@ -30,7 +36,6 @@ import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
import java.util.Arrays;
public class BreakReminder extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener, View.OnClickListener {
@ -68,12 +73,16 @@ public class BreakReminder extends AppCompatActivity
String allProfiles = sharedPrefs.getString("profiles", "");
if (allProfiles.equals("")) {
System.out.println("Es gibt noch keine Profile!!");
allProfiles = "Sport,5,1,false,-1;Exams,90,15,false,-1;Pomodoro,30,5,false,-1;";
allProfiles = "Random,90,5,false,Arms.Legs.Head.Neck.Pelvis.Spinal Column.Trunk.;Upper-Body,90,15,true,Arms.Neck.Head.;Torso,30,5,true,Spinal Column.Trunk.;Under-Body,30,5,true,Legs.Pelvis.;";
editor.putString("profiles", allProfiles);
editor.apply();
WelcomeDialog welcomeDialog = new WelcomeDialog();
welcomeDialog.show(getFragmentManager(), "WelcomeDialog");
}
System.out.println("Alle Profile: " + sharedPrefs.getString("profiles", "FAIL"));
// If chosen, set screen to "stay on"
@ -482,4 +491,26 @@ public class BreakReminder extends AppCompatActivity
Intent intent = new Intent(this, BreakDeciderActivity.class);
this.startActivity(intent);
}
public static class WelcomeDialog extends DialogFragment {
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater i = getActivity().getLayoutInflater();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(i.inflate(R.layout.first_dialog, null));
builder.setIcon(R.mipmap.ic_launcher);
builder.setTitle(getActivity().getString(R.string.app_name_long));
builder.setPositiveButton("Ok", null);
return builder.create();
}
}
}

View file

@ -241,14 +241,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if(key.equals("exercise")) {
System.out.println("GOGOGOGOGOG");
System.out.println(sharedPreferences.getString("exercise", "Damn"));
}
if (key.equals("current_profile")) {
ListPreference listPref = (ListPreference) findPreference("current_profile");
int i = Integer.parseInt(listPref.getValue());
@ -259,11 +251,13 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
editor.putBoolean("change_profiles", true);
String[] allProfile = sharedPreferences.getString("profiles", "").split(";");
//FIXME Deactivate the onPrefListener in SettingsActivity
// Deactivate the onPrefListener in SettingsActivity
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
editor.putString("name_text", allProfile[i].split(",")[0]);
editor.putInt("work_value", Integer.parseInt(allProfile[i].split(",")[1]));
editor.putInt("break_value", Integer.parseInt(allProfile[i].split(",")[2]));
editor.putBoolean("cont_value", Boolean.parseBoolean(allProfile[i].split(",")[3]));
editor.putString("exercise_value", allProfile[i].split(",")[4]);
editor.apply();
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
@ -273,8 +267,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
return;
}
if(key.equals("cont_value"))
System.out.println("Cont: " + sharedPreferences.getBoolean("cont_value", false));
// Set seekbar summary :
int radius = PreferenceManager.getDefaultSharedPreferences(this.getActivity()).getInt("work_value", 50);

Binary file not shown.

After

Width:  |  Height:  |  Size: 9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/white">
<LinearLayout
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/activity_horizontal_margin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tutorial_description" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="@string/tutorial_clock"
android:layout_marginTop="20dp"
style="@style/Base.DialogWindowTitle.AppCompat"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layoutDirection="ltr"
android:orientation="horizontal">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:src="@drawable/clock"/>
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/tutorial_or"/>
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:src="@drawable/play_button"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/tutorial_clock_description"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="@string/tutorial_reset"
android:layout_marginTop="20dp"
style="@style/Base.DialogWindowTitle.AppCompat"/>
<ImageView
android:layout_width="120dp"
android:layout_height="80dp"
android:layout_gravity="center"
android:src="@drawable/reset_button"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/tutorial_reset_description"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="@string/tutorial_profiles"
android:layout_marginTop="20dp"
style="@style/Base.DialogWindowTitle.AppCompat"/>
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:src="@drawable/spinner"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/tutorial_profile_description"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/disclaimer"
android:layout_marginTop="20dp"/>
</LinearLayout>
</ScrollView>

View file

@ -26,8 +26,8 @@
android:layout_width="150dp"
android:layout_height="wrap_content"
android:inputType="text"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
android:maxLength="9"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-"
android:maxLength="10"
android:textSize="25sp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"

View file

@ -136,4 +136,23 @@
<string name="help_click_information">To see the images in real size simply click on them. To return back to this view re-click on the image!</string>
<string name="side_repetition">Side/Repetition</string>
<!-- settings for Disclaimer -->
<string name="disclaimer">DISCLAIMER PLACEHOLDER</string>
<!-- settings for TutorialActivity -->
<string name="tutorial_profiles">Select profiles</string>
<string name="tutorial_reset_description">Press the button to reset the clock</string>
<string name="tutorial_reset">Reset the clock</string>
<string name="tutorial_clock_description">By pressing one of them, the clock starts or stops</string>
<string name="tutorial_or">or</string>
<string name="tutorial_profile_description">By clicking on the current profile (sport), you will see all the currently available profiles. \nYou can add new profiles by clicking on \'New Profiles...\' and edit the current ones in the settings</string>
<string name="tutorial_clock">Start/Stop the clock</string>
<string name="tutorial_description">Welcome to the Privacy Friendly Break Reminder</string>
</resources>

View file

@ -12,10 +12,10 @@
<EditTextPreference
android:capitalize="words"
android:defaultValue="@string/pref_default_display_name"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-"
android:inputType="textCapWords"
android:key="name_text"
android:maxLength="9"
android:maxLength="10"
android:maxLines="1"
android:selectAllOnFocus="true"
android:singleLine="true"