Skip to content

Commit

Permalink
Merge branch 'v4.3' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
yukuku committed Jul 16, 2015
2 parents 7d29808 + a5b8f5a commit 7a2e8b7
Show file tree
Hide file tree
Showing 29 changed files with 790 additions and 381 deletions.
14 changes: 13 additions & 1 deletion Afw/src/main/java/yuku/afw/storage/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.os.Build;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.support.annotation.BoolRes;
import android.support.annotation.IntegerRes;
import android.support.annotation.StringRes;
import android.util.Log;
Expand Down Expand Up @@ -194,7 +195,18 @@ public static int getInt(@StringRes final int keyStringResId, @IntegerRes final
return (int) value;
}
}


public static boolean getBoolean(@StringRes final int keyStringResId, @BoolRes final int defaultIntResId) {
final Resources r = App.context.getResources();
final String key = r.getString(keyStringResId);
final Object value = get(key);
if (value == null) {
return r.getBoolean(defaultIntResId);
} else {
return (boolean) value;
}
}

@TargetApi(9) private synchronized static void commitIfNotHeld() {
if (held > 0) {
// don't do anything now
Expand Down
4 changes: 2 additions & 2 deletions Alkitab/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ android {
applicationId 'yuku.alkitab.debug'
minSdkVersion 14
targetSdkVersion 22
versionCode 14000231
versionName '4.2.1'
versionCode 14000240
versionName '4.3.0-beta0'
}
buildTypes {
release {
Expand Down
7 changes: 7 additions & 0 deletions Alkitab/src/main/java/yuku/alkitab/base/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import yuku.afw.storage.Preferences;
import yuku.alkitab.base.model.SyncShadow;
import yuku.alkitab.base.model.VersionImpl;
import yuku.alkitab.base.storage.Prefkey;
import yuku.alkitab.base.sync.Gcm;
import yuku.alkitab.base.sync.Sync;
import yuku.alkitab.debug.R;
Expand Down Expand Up @@ -128,6 +130,11 @@ public synchronized static void staticInit() {

// make sure launcher do not open other variants of the app
Launcher.setAppPackageName(context.getPackageName());

// sync on app start, if we are logged in
if (Preferences.contains(Prefkey.sync_simpleToken)) {
Sync.notifySyncNeeded(SyncShadow.ALL_SYNC_SET_NAMES);
}
}

private static void forceOverflowMenu() {
Expand Down
7 changes: 0 additions & 7 deletions Alkitab/src/main/java/yuku/alkitab/base/IsiActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -556,13 +556,6 @@ public void onReceive(final Context context, final Intent intent) {

App.getLbm().registerReceiver(reloadAttributeMapReceiver, new IntentFilter(ACTION_ATTRIBUTE_MAP_CHANGED));

// sync on app start, if we are logged in
if (Preferences.contains(Prefkey.sync_simpleToken)) {
for (final String syncSetName : SyncShadow.ALL_SYNC_SET_NAMES) {
Sync.notifySyncNeeded(syncSetName);
}
}

if (!U.equals(getPackageName(), "yuku.alkitab") /* prevent self-import */
&& !U.equals(getPackageName(), "yuku.alkitab.kjv") /* prevent self-import */
&& Preferences.getInt(Prefkey.stop_import_yuku_alkitab_backups, 0) == 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ public void onReceive(final Context context, final Intent intent) {

if (marker_count == 0) {
// no markers, just delete straight away
S.getDb().deleteLabelById(label._id);
S.getDb().deleteLabelAndMarker_LabelsByLabelId(label._id);
adapter.reload();
} else {
new AlertDialogWrapper.Builder(this)
.setMessage(getString(R.string.are_you_sure_you_want_to_delete_the_label_label, label.title, marker_count))
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.delete, (dialog, which) -> {
S.getDb().deleteLabelById(label._id);
S.getDb().deleteLabelAndMarker_LabelsByLabelId(label._id);
adapter.reload();
})
.show();
Expand Down
4 changes: 4 additions & 0 deletions Alkitab/src/main/java/yuku/alkitab/base/ac/NoteActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ public void onNoMoreDetected() {
return false;
});
tCaptionReadOnly.setOnClickListener(v -> {
if (!Preferences.getBoolean(R.string.pref_tapToEditNote_key, R.bool.pref_tapToEditNote_default)) {
return;
}

if (!justClickedLink) {
setEditingMode(true);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,21 @@ public String getReadingDateHeader(final int dayNumber) {
return getString(R.string.rp_dayHeader, (dayNumber + 1), Sqlitil.toLocaleDateMedium(calendar.getTime()));
}

void one_reading_longClick(final int day, final int sequence) {
new MaterialDialog.Builder(this)
.content(R.string.rp_mark_as_read_up_to)
.positiveText(R.string.ok)
.negativeText(R.string.cancel)
.callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(final MaterialDialog dialog) {
ReadingPlanManager.markAsReadUpTo(readingPlan.info.name, readingPlan.dailyVerses, day, sequence);
reload();
}
})
.show();
}

class ReadingPlanAdapter extends EasyAdapter {
private int[] todayReadings;

Expand Down Expand Up @@ -795,14 +810,14 @@ public void bindView(final View res, final int position, final ViewGroup parent)
} else if (itemViewType == 2) {
final LinearLayout layout = V.get(res, R.id.llOneDayReadingPlan);

final int currentViewTypePosition = position - todayReadings.length / 2 - 1;
final int day = position - todayReadings.length / 2 - 1;

//Text title
TextView tTitle = V.get(res, android.R.id.text1);
tTitle.setText(getReadingDateHeader(currentViewTypePosition));
tTitle.setText(getReadingDateHeader(day));

//Text reading
int[] ariRanges = readingPlan.dailyVerses[currentViewTypePosition];
int[] ariRanges = readingPlan.dailyVerses[day];
final int checkbox_count = ariRanges.length / 2;

{ // remove extra checkboxes
Expand All @@ -816,14 +831,14 @@ public void bindView(final View res, final int position, final ViewGroup parent)
}

final boolean[] readMarks = new boolean[checkbox_count];
ReadingPlanManager.writeReadMarksByDay(readingCodes, readMarks, currentViewTypePosition);
ReadingPlanManager.writeReadMarksByDay(readingCodes, readMarks, day);

for (int i = 0; i < checkbox_count; i++) {
final int sequence = i;

CheckBox checkBox = (CheckBox) layout.findViewWithTag(i);
if (checkBox == null) {
checkBox = (CheckBox) getLayoutInflater().inflate(R.layout.item_reading_plan_one_day_checkbox, layout, false);
checkBox = (CheckBox) getLayoutInflater().inflate(R.layout.item_reading_plan_one_reading_checkbox, layout, false);
checkBox.setTag(i);
layout.addView(checkBox);
}
Expand All @@ -832,10 +847,14 @@ public void bindView(final View res, final int position, final ViewGroup parent)
checkBox.setChecked(readMarks[sequence]);
checkBox.setText(S.activeVersion.referenceRange(ariRanges[sequence * 2], ariRanges[sequence * 2 + 1]));
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
ReadingPlanManager.updateReadingPlanProgress(readingPlan.info.name, currentViewTypePosition, sequence, isChecked);
ReadingPlanManager.updateReadingPlanProgress(readingPlan.info.name, day, sequence, isChecked);
loadReadingPlanProgress();
load();
});
checkBox.setOnLongClickListener(v -> {
one_reading_longClick(day, sequence);
return true;
});
}
}
}
Expand Down
Loading

0 comments on commit 7a2e8b7

Please sign in to comment.