mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 01:28:52 -06:00
@@ -53,7 +53,7 @@ class AboutScreen(
|
|||||||
developerCountdown--
|
developerCountdown--
|
||||||
if (developerCountdown == 0) {
|
if (developerCountdown == 0) {
|
||||||
prefs.isDeveloper = true
|
prefs.isDeveloper = true
|
||||||
activity.showMessage(R.string.you_are_now_a_developer)
|
activity.showMessage(activity.resources.getString(R.string.you_are_now_a_developer))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,12 +38,13 @@ import org.isoron.uhabits.inject.*;
|
|||||||
public class ConfirmDeleteDialog extends AlertDialog
|
public class ConfirmDeleteDialog extends AlertDialog
|
||||||
{
|
{
|
||||||
protected ConfirmDeleteDialog(@Provided @ActivityContext Context context,
|
protected ConfirmDeleteDialog(@Provided @ActivityContext Context context,
|
||||||
@NonNull OnConfirmedCallback callback)
|
@NonNull OnConfirmedCallback callback,
|
||||||
|
int quantity)
|
||||||
{
|
{
|
||||||
super(context);
|
super(context);
|
||||||
setTitle(R.string.delete_habits);
|
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
setMessage(res.getString(R.string.delete_habits_message));
|
setTitle(res.getQuantityString(R.plurals.delete_habits_title, quantity));
|
||||||
|
setMessage(res.getQuantityString(R.plurals.delete_habits_message, quantity));
|
||||||
setButton(BUTTON_POSITIVE,
|
setButton(BUTTON_POSITIVE,
|
||||||
res.getString(R.string.yes),
|
res.getString(R.string.yes),
|
||||||
(dialog, which) -> callback.onConfirmed()
|
(dialog, which) -> callback.onConfirmed()
|
||||||
|
|||||||
@@ -91,9 +91,8 @@ class ListHabitsScreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCommandFinished(command: Command) {
|
override fun onCommandFinished(command: Command) {
|
||||||
val stringId = getExecuteString(command)
|
val msg = getExecuteString(command)
|
||||||
if (stringId != null)
|
if (msg != null) activity.showMessage(msg)
|
||||||
activity.showMessage(stringId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
fun onResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
@@ -113,7 +112,7 @@ class ListHabitsScreen
|
|||||||
inStream.copyTo(tempFile)
|
inStream.copyTo(tempFile)
|
||||||
onImportData(tempFile) { tempFile.delete() }
|
onImportData(tempFile) { tempFile.delete() }
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
activity.showMessage(R.string.could_not_import)
|
activity.showMessage(activity.resources.getString(R.string.could_not_import))
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,8 +142,8 @@ class ListHabitsScreen
|
|||||||
dialog.show(activity.supportFragmentManager, "habitType")
|
dialog.show(activity.supportFragmentManager, "habitType")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showDeleteConfirmationScreen(callback: OnConfirmedCallback) {
|
override fun showDeleteConfirmationScreen(callback: OnConfirmedCallback, quantity: Int) {
|
||||||
confirmDeleteDialogFactory.create(callback).show()
|
confirmDeleteDialogFactory.create(callback, quantity).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showEditHabitsScreen(habits: List<Habit>) {
|
override fun showEditHabitsScreen(habits: List<Habit>) {
|
||||||
@@ -173,7 +172,7 @@ class ListHabitsScreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showMessage(m: ListHabitsBehavior.Message) {
|
override fun showMessage(m: ListHabitsBehavior.Message) {
|
||||||
activity.showMessage(when (m) {
|
activity.showMessage(activity.resources.getString(when (m) {
|
||||||
COULD_NOT_EXPORT -> R.string.could_not_export
|
COULD_NOT_EXPORT -> R.string.could_not_export
|
||||||
IMPORT_SUCCESSFUL -> R.string.habits_imported
|
IMPORT_SUCCESSFUL -> R.string.habits_imported
|
||||||
IMPORT_FAILED -> R.string.could_not_import
|
IMPORT_FAILED -> R.string.could_not_import
|
||||||
@@ -182,7 +181,7 @@ class ListHabitsScreen
|
|||||||
FILE_NOT_RECOGNIZED -> R.string.file_not_recognized
|
FILE_NOT_RECOGNIZED -> R.string.file_not_recognized
|
||||||
SYNC_ENABLED -> R.string.sync_enabled
|
SYNC_ENABLED -> R.string.sync_enabled
|
||||||
SYNC_KEY_ALREADY_INSTALLED -> R.string.sync_key_already_installed
|
SYNC_KEY_ALREADY_INSTALLED -> R.string.sync_key_already_installed
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showSendBugReportToDeveloperScreen(log: String) {
|
override fun showSendBugReportToDeveloperScreen(log: String) {
|
||||||
@@ -217,15 +216,30 @@ class ListHabitsScreen
|
|||||||
confirmSyncKeyDialogFactory.create(callback).show()
|
confirmSyncKeyDialogFactory.create(callback).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
@StringRes
|
private fun getExecuteString(command: Command): String? {
|
||||||
private fun getExecuteString(command: Command): Int? {
|
|
||||||
when (command) {
|
when (command) {
|
||||||
is ArchiveHabitsCommand -> return R.string.toast_habit_archived
|
is ArchiveHabitsCommand -> {
|
||||||
is ChangeHabitColorCommand -> return R.string.toast_habit_changed
|
return activity.resources.getQuantityString(R.plurals.toast_habits_archived,
|
||||||
is CreateHabitCommand -> return R.string.toast_habit_created
|
command.selected.size)
|
||||||
is DeleteHabitsCommand -> return R.string.toast_habit_deleted
|
}
|
||||||
is EditHabitCommand -> return R.string.toast_habit_changed
|
is ChangeHabitColorCommand -> {
|
||||||
is UnarchiveHabitsCommand -> return R.string.toast_habit_unarchived
|
return activity.resources.getQuantityString(R.plurals.toast_habits_changed,
|
||||||
|
command.selected.size)
|
||||||
|
}
|
||||||
|
is CreateHabitCommand -> {
|
||||||
|
return activity.resources.getString(R.string.toast_habit_created)
|
||||||
|
}
|
||||||
|
is DeleteHabitsCommand -> {
|
||||||
|
return activity.resources.getQuantityString(R.plurals.toast_habits_deleted,
|
||||||
|
command.selected.size)
|
||||||
|
}
|
||||||
|
is EditHabitCommand -> {
|
||||||
|
return activity.resources.getQuantityString(R.plurals.toast_habits_changed, 1)
|
||||||
|
}
|
||||||
|
is UnarchiveHabitsCommand -> {
|
||||||
|
return activity.resources.getQuantityString(R.plurals.toast_habits_unarchived,
|
||||||
|
command.selected.size)
|
||||||
|
}
|
||||||
else -> return null
|
else -> return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,11 +248,11 @@ class ListHabitsScreen
|
|||||||
taskRunner.execute(importTaskFactory.create(file) { result ->
|
taskRunner.execute(importTaskFactory.create(file) { result ->
|
||||||
if (result == ImportDataTask.SUCCESS) {
|
if (result == ImportDataTask.SUCCESS) {
|
||||||
adapter.refresh()
|
adapter.refresh()
|
||||||
activity.showMessage(R.string.habits_imported)
|
activity.showMessage(activity.resources.getString(R.string.habits_imported))
|
||||||
} else if (result == ImportDataTask.NOT_RECOGNIZED) {
|
} else if (result == ImportDataTask.NOT_RECOGNIZED) {
|
||||||
activity.showMessage(R.string.file_not_recognized)
|
activity.showMessage(activity.resources.getString(R.string.file_not_recognized))
|
||||||
} else {
|
} else {
|
||||||
activity.showMessage(R.string.could_not_import)
|
activity.showMessage(activity.resources.getString(R.string.could_not_import))
|
||||||
}
|
}
|
||||||
onFinished()
|
onFinished()
|
||||||
})
|
})
|
||||||
@@ -247,7 +261,7 @@ class ListHabitsScreen
|
|||||||
private fun onExportDB() {
|
private fun onExportDB() {
|
||||||
taskRunner.execute(exportDBFactory.create { filename ->
|
taskRunner.execute(exportDBFactory.create { filename ->
|
||||||
if (filename != null) activity.showSendFileScreen(filename)
|
if (filename != null) activity.showSendFileScreen(filename)
|
||||||
else activity.showMessage(R.string.could_not_export)
|
else activity.showMessage(activity.resources.getString(R.string.could_not_export))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class CheckmarkButtonView(
|
|||||||
|
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
if (preferences.isShortToggleEnabled) performToggle()
|
if (preferences.isShortToggleEnabled) performToggle()
|
||||||
else showMessage(R.string.long_press_to_toggle)
|
else showMessage(resources.getString(R.string.long_press_to_toggle))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLongClick(v: View): Boolean {
|
override fun onLongClick(v: View): Boolean {
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class NumberButtonView(
|
|||||||
|
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
if (preferences.isShortToggleEnabled) onEdit()
|
if (preferences.isShortToggleEnabled) onEdit()
|
||||||
else showMessage(R.string.long_press_to_edit)
|
else showMessage(resources.getString(R.string.long_press_to_edit))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLongClick(v: View): Boolean {
|
override fun onLongClick(v: View): Boolean {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.activities.habits.show
|
package org.isoron.uhabits.activities.habits.show
|
||||||
|
|
||||||
|
import org.isoron.uhabits.*
|
||||||
import org.isoron.uhabits.activities.common.dialogs.*
|
import org.isoron.uhabits.activities.common.dialogs.*
|
||||||
import org.isoron.uhabits.core.models.*
|
import org.isoron.uhabits.core.models.*
|
||||||
import org.isoron.uhabits.core.ui.callbacks.*
|
import org.isoron.uhabits.core.ui.callbacks.*
|
||||||
@@ -64,7 +65,7 @@ class ShowHabitScreen(
|
|||||||
override fun showMessage(m: ShowHabitMenuBehavior.Message?) {
|
override fun showMessage(m: ShowHabitMenuBehavior.Message?) {
|
||||||
when (m) {
|
when (m) {
|
||||||
ShowHabitMenuBehavior.Message.COULD_NOT_EXPORT -> {
|
ShowHabitMenuBehavior.Message.COULD_NOT_EXPORT -> {
|
||||||
activity.showMessage(org.isoron.uhabits.R.string.could_not_export)
|
activity.showMessage(activity.resources.getString(R.string.could_not_export))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,7 +75,7 @@ class ShowHabitScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showDeleteConfirmationScreen(callback: OnConfirmedCallback) {
|
override fun showDeleteConfirmationScreen(callback: OnConfirmedCallback) {
|
||||||
confirmDeleteDialogFactory.create(callback).show()
|
confirmDeleteDialogFactory.create(callback, 1).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun close() {
|
override fun close() {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class SyncActivity : AppCompatActivity(), SyncBehavior.Screen {
|
|||||||
private fun copyToClipboard() {
|
private fun copyToClipboard() {
|
||||||
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
clipboard.setPrimaryClip(ClipData.newPlainText("Loop Sync Link", binding.syncLink.text))
|
clipboard.setPrimaryClip(ClipData.newPlainText("Loop Sync Link", binding.syncLink.text))
|
||||||
showMessage(R.string.copied_to_the_clipboard)
|
showMessage(resources.getString(R.string.copied_to_the_clipboard))
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun generateQR(msg: String): Bitmap = Dispatchers.IO {
|
suspend fun generateQR(msg: String): Bitmap = Dispatchers.IO {
|
||||||
|
|||||||
@@ -78,9 +78,9 @@ fun ViewGroup.buildToolbar(): Toolbar {
|
|||||||
return inflater.inflate(R.layout.toolbar, null) as Toolbar
|
return inflater.inflate(R.layout.toolbar, null) as Toolbar
|
||||||
}
|
}
|
||||||
|
|
||||||
fun View.showMessage(@StringRes stringId: Int) {
|
fun View.showMessage(msg: String) {
|
||||||
try {
|
try {
|
||||||
val snackbar = Snackbar.make(this, stringId, Snackbar.LENGTH_SHORT)
|
val snackbar = Snackbar.make(this, msg, Snackbar.LENGTH_SHORT)
|
||||||
val tvId = R.id.snackbar_text
|
val tvId = R.id.snackbar_text
|
||||||
val tv = snackbar.view.findViewById<TextView>(tvId)
|
val tv = snackbar.view.findViewById<TextView>(tvId)
|
||||||
tv?.setTextColor(Color.WHITE)
|
tv?.setTextColor(Color.WHITE)
|
||||||
@@ -90,8 +90,8 @@ fun View.showMessage(@StringRes stringId: Int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Activity.showMessage(@StringRes stringId: Int) {
|
fun Activity.showMessage(msg: String) {
|
||||||
this.findViewById<View>(android.R.id.content).showMessage(stringId)
|
this.findViewById<View>(android.R.id.content).showMessage(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Activity.showSendFileScreen(archiveFilename: String) {
|
fun Activity.showSendFileScreen(archiveFilename: String) {
|
||||||
@@ -109,7 +109,7 @@ fun Activity.startActivitySafely(intent: Intent) {
|
|||||||
try {
|
try {
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
this.showMessage(R.string.activity_not_found)
|
this.showMessage(resources.getString(R.string.activity_not_found))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,10 @@
|
|||||||
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<resources>
|
<resources
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
tools:ignore="MissingTranslation">
|
||||||
|
|
||||||
<string name="app_name" >Loop Habit Tracker</string>
|
<string name="app_name" >Loop Habit Tracker</string>
|
||||||
<string name="main_activity_title">Habits</string>
|
<string name="main_activity_title">Habits</string>
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
@@ -29,10 +32,22 @@
|
|||||||
<string name="add_habit">Add habit</string>
|
<string name="add_habit">Add habit</string>
|
||||||
<string name="color_picker_default_title">Change color</string>
|
<string name="color_picker_default_title">Change color</string>
|
||||||
<string name="toast_habit_created">Habit created</string>
|
<string name="toast_habit_created">Habit created</string>
|
||||||
<string name="toast_habit_deleted">Habits deleted</string>
|
<plurals name="toast_habits_changed">
|
||||||
<string name="toast_habit_changed">Habit changed</string>
|
<item quantity="one">Habit changed</item>
|
||||||
<string name="toast_habit_archived">Habits archived</string>
|
<item quantity="other">Habits changed</item>
|
||||||
<string name="toast_habit_unarchived">Habits unarchived</string>
|
</plurals>
|
||||||
|
<plurals name="toast_habits_deleted">
|
||||||
|
<item quantity="one">Habit deleted</item>
|
||||||
|
<item quantity="other">Habits deleted</item>
|
||||||
|
</plurals>
|
||||||
|
<plurals name="toast_habits_archived">
|
||||||
|
<item quantity="one">Habit archived</item>
|
||||||
|
<item quantity="other">Habits archived</item>
|
||||||
|
</plurals>
|
||||||
|
<plurals name="toast_habits_unarchived">
|
||||||
|
<item quantity="one">Habit unarchived</item>
|
||||||
|
<item quantity="other">Habits unarchived</item>
|
||||||
|
</plurals>
|
||||||
<string name="title_activity_show_habit" translatable="false"/>
|
<string name="title_activity_show_habit" translatable="false"/>
|
||||||
<string name="overview">Overview</string>
|
<string name="overview">Overview</string>
|
||||||
<string name="habit_strength">Habit strength</string>
|
<string name="habit_strength">Habit strength</string>
|
||||||
@@ -79,8 +94,14 @@
|
|||||||
<string name="hint_title">Did you know?</string>
|
<string name="hint_title">Did you know?</string>
|
||||||
<string name="hint_drag">To rearrange the entries, press-and-hold on the name of the habit, then drag it to the correct place.</string>
|
<string name="hint_drag">To rearrange the entries, press-and-hold on the name of the habit, then drag it to the correct place.</string>
|
||||||
<string name="hint_landscape">You can see more days by putting your phone in landscape mode.</string>
|
<string name="hint_landscape">You can see more days by putting your phone in landscape mode.</string>
|
||||||
<string name="delete_habits">Delete Habits</string>
|
<plurals name="delete_habits_title">
|
||||||
<string name="delete_habits_message">The habits will be permanently deleted. This action cannot be undone.</string>
|
<item quantity="one">Delete habit?</item>
|
||||||
|
<item quantity="other">Delete habits?</item>
|
||||||
|
</plurals>
|
||||||
|
<plurals name="delete_habits_message">
|
||||||
|
<item quantity="one">The habit will be permanently deleted. This action cannot be undone.</item>
|
||||||
|
<item quantity="other">The habits will be permanently deleted. This action cannot be undone.</item>
|
||||||
|
</plurals>
|
||||||
<string name="habit_not_found">Habit deleted / not found</string>
|
<string name="habit_not_found">Habit deleted / not found</string>
|
||||||
<string name="weekends">Weekends</string>
|
<string name="weekends">Weekends</string>
|
||||||
<string name="any_weekday">Monday to Friday</string>
|
<string name="any_weekday">Monday to Friday</string>
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class ListHabitsSelectionMenuBehavior
|
|||||||
commandRunner.run(new DeleteHabitsCommand(habitList, selected)
|
commandRunner.run(new DeleteHabitsCommand(habitList, selected)
|
||||||
);
|
);
|
||||||
adapter.clearSelection();
|
adapter.clearSelection();
|
||||||
});
|
}, selected.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEditHabits()
|
public void onEditHabits()
|
||||||
@@ -137,7 +137,8 @@ public class ListHabitsSelectionMenuBehavior
|
|||||||
@NonNull OnColorPickedCallback callback);
|
@NonNull OnColorPickedCallback callback);
|
||||||
|
|
||||||
void showDeleteConfirmationScreen(
|
void showDeleteConfirmationScreen(
|
||||||
@NonNull OnConfirmedCallback callback);
|
@NonNull OnConfirmedCallback callback,
|
||||||
|
int quantity);
|
||||||
|
|
||||||
void showEditHabitsScreen(@NonNull List<Habit> selected);
|
void showEditHabitsScreen(@NonNull List<Habit> selected);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user