Skip to content

Commit

Permalink
dim pref works now, do resource id migration
Browse files Browse the repository at this point in the history
  • Loading branch information
doo committed Jan 25, 2012
1 parent c6aae96 commit 04d9d56
Show file tree
Hide file tree
Showing 19 changed files with 465 additions and 221 deletions.
250 changes: 158 additions & 92 deletions MeditationTracker/gen/com/meditationtracker/R.java

Large diffs are not rendered by default.

250 changes: 158 additions & 92 deletions MeditationTracker/gen/doo/util/root/R.java

Large diffs are not rendered by default.

Binary file added MeditationTracker/res/drawable-hdpi/ic_moon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MeditationTracker/res/drawable-hdpi/ic_sun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MeditationTracker/res/drawable-ldpi/ic_moon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MeditationTracker/res/drawable-ldpi/ic_sun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MeditationTracker/res/drawable-mdpi/ic_moon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MeditationTracker/res/drawable-mdpi/ic_sun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MeditationTracker/res/drawable-xhdpi/ic_moon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MeditationTracker/res/drawable-xhdpi/ic_sun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions MeditationTracker/res/layout/slider_pref.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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="horizontal" android:paddingLeft="10dp" android:paddingRight="15dp">

<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_moon" android:paddingLeft="10dip" android:adjustViewBounds="true" android:layout_marginTop="3dp"/>

<SeekBar
android:id="@+id/prefSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />

<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_sun" android:layout_marginTop="3dp"/>

</LinearLayout>
5 changes: 5 additions & 0 deletions MeditationTracker/res/values/attrs.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@

<declare-styleable name="ShowDialogPreferece">
</declare-styleable>

<declare-styleable name="SliderPreference">
<attr name="min" format="integer"/>
<attr name="max" format="integer"/>
</declare-styleable>
</resources>
14 changes: 8 additions & 6 deletions MeditationTracker/res/values/preference_keys.xml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="prefTimerBuzz">prefTimerBuzz</string>
<string name="sessionEndNotification">Session end notification</string>
<string name="prefTimerSound">prefTimerSound</string>
Expand All @@ -8,9 +9,10 @@
<string name="prefSessionLength">prefSessionLength</string>
<string name="prefMalaSize">prefMalaSize</string>
<string name="prefShowNgondro">prefShowNgondro</string>
<string name="prefFirstRun">prefFirstRun</string>

<string name="prefOneBeadHeptic">prefOneBeadHeptic</string>
<string name="prefDimNight">prefDimNight</string>
<string name="prefVersion">prefVersion</string>
</resources>
<string name="prefFirstRun">prefFirstRun</string>
<string name="prefOneBeadHeptic">prefOneBeadHeptic</string>
<string name="prefDimNight">prefDimNight</string>
<string name="prefDimNightValue">prefDimNightValue</string>
<string name="prefVersion">prefVersion</string>

</resources>
5 changes: 4 additions & 1 deletion MeditationTracker/res/xml/preferences.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@

<CheckBoxPreference android:key="@string/prefDimNight"
android:title="@string/dimNight" android:defaultValue="true"
android:summary="@string/dimNightSummary"></CheckBoxPreference>
android:summary="@string/dimNightSummary" android:shouldDisableView="true"></CheckBoxPreference>
<com.meditationtracker.preferences.SliderPreference android:key="@string/prefDimNightValue"
android:dependency="@string/prefDimNight" android:disableDependentsState="true"
android:defaultValue="20" doo:min="3" doo:max="100"></com.meditationtracker.preferences.SliderPreference>

<PreferenceCategory android:title="@string/sessionEndNotification">
<CheckBoxPreference android:title="@string/timerNotification"
Expand Down
13 changes: 13 additions & 0 deletions MeditationTracker/src/com/meditationtracker/PracticeDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,20 @@ public void onCreate(SQLiteDatabase db) {

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
/* R.drawable.refuge, R.drawable.icon_refuge,
R.drawable.diamond_mind_big, R.drawable.icon_diamond_mind,
R.drawable.mandala_offering_big, R.drawable.icon_mandala_offering,
R.drawable.guru_yoga_big, R.drawable.icon_guru_yoga,
R.drawable.karmapa, R.drawable.icon_karmapa*/

//TODO
}
}

public void patchBuiltInPictures(int refuge, int iconRefuge, int diamondMindBig, int iconDiamondMind,
int mandalaOfferingBig, int iconMandalaOffering, int guruYogaBig, int iconGuruYoga, int karmapa,
int iconKarmapa) {
// TODO Auto-generated method stub

}
}
6 changes: 4 additions & 2 deletions MeditationTracker/src/com/meditationtracker/SessionActivity.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ private void updateUI() {

boolean dimAtNight = preferences.getBoolean(getString(R.string.prefDimNight), true);
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
boolean isNight = hour > 18 || hour < 9;
boolean isNight = hour >= 18 || hour < 9;

if (dimAtNight && isNight) { // blind'n'night mode
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 0.03f;
float dimAtNightValue = preferences.getInt(getString(R.string.prefDimNightValue), 3);

lp.screenBrightness = dimAtNightValue/100;
getWindow().setAttributes(lp);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.meditationtracker.preferences;

import com.meditationtracker.R;

import android.content.Context;
import android.content.res.TypedArray;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class SliderPreference extends Preference {

private static final int DEFAULT = 3;
private int max;
private int cur;

public SliderPreference(Context context, AttributeSet attrs) {
super(context, attrs);

TypedArray a=getContext().obtainStyledAttributes(attrs,R.styleable.ActionPreference);
max = a.getInteger(R.styleable.SliderPreference_max, 100);
}

@Override
protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue) {
cur = restorePersistedValue ? getPersistedInt(DEFAULT) : Integer.getInteger(defaultValue.toString(), DEFAULT);
}

@Override
protected View onCreateView(ViewGroup parent) {
setLayoutResource(R.layout.slider_pref);

View result = super.onCreateView(parent);
SeekBar sb = (SeekBar) result.findViewById(R.id.prefSeekBar);
sb.setMax(max);
sb.setProgress(cur);
sb.setOnSeekBarChangeListener(seekChanged);

return result;
}

private OnSeekBarChangeListener seekChanged = new OnSeekBarChangeListener() {

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
SliderPreference.this.persistInt(progress);
}
};

}
53 changes: 26 additions & 27 deletions dootil/gen/doo/util/root/R.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/

package doo.util.root;

public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int prefTimePicker=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
public static final int timepicker=0x7f030001;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/

package doo.util.root;

public final class R {
public static final class attr {
}
public static final class drawable {
public static int icon=0x7f020000;
}
public static final class id {
public static int prefTimePicker=0x7f050000;
}
public static final class layout {
public static int timepicker=0x7f030000;
}
public static final class string {
public static int app_name=0x7f040001;
public static int hello=0x7f040000;
}
}
2 changes: 1 addition & 1 deletion dootil/project.properties
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

android.library=true
# Project target.
target=android-3
target=android-15

0 comments on commit 04d9d56

Please sign in to comment.