Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c050df72 authored by tibbi's avatar tibbi
Browse files

add a conflict resolution dialog

parent 67e66016
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
package com.simplemobiletools.commons.dialogs

import android.app.Activity
import android.support.v7.app.AlertDialog
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.extensions.setupDialogStuff
import kotlinx.android.synthetic.main.dialog_file_conflict.view.*

class FileConflictDialog(val activity: Activity, val filename: String) {
    init {
        val view = activity.layoutInflater.inflate(R.layout.dialog_file_conflict, null).apply {
            conflict_dialog_title.text = String.format(activity.getString(R.string.file_already_exists), filename)
        }

        AlertDialog.Builder(activity)
                .setPositiveButton(R.string.ok, { dialog, which -> })
                .setNegativeButton(R.string.cancel, null)
                .create().apply {
            activity.setupDialogStuff(view, this)
        }
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -99,6 +99,10 @@ const val PERMISSION_READ_CALENDAR = 7
const val PERMISSION_WRITE_CALENDAR = 8
const val PERMISSION_CALL_PHONE = 9

// conflict resolving
const val CONFLICT_SKIP = 1
const val CONFLICT_OVERWRITE = 2

fun getDateFormats() = arrayListOf(
        "yyyy-MM-dd",
        "yyyyMMdd",
+56 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/conflict_dialog_holder"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:paddingLeft="@dimen/activity_margin"
    android:paddingRight="@dimen/activity_margin"
    android:paddingTop="@dimen/activity_margin">

    <com.simplemobiletools.commons.views.MyTextView
        android:id="@+id/conflict_dialog_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="@dimen/activity_margin"
        android:paddingLeft="@dimen/small_margin"
        android:paddingRight="@dimen/small_margin"
        android:paddingTop="@dimen/small_margin"
        tools:text="File already exists"/>

    <RadioGroup
        android:id="@+id/conflict_dialog_radio_group"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/medium_margin">

        <com.simplemobiletools.commons.views.MyCompatRadioButton
            android:id="@+id/conflict_dialog_radio_skip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:checked="true"
            android:paddingBottom="@dimen/normal_margin"
            android:paddingTop="@dimen/normal_margin"
            android:text="@string/skip"/>

        <com.simplemobiletools.commons.views.MyCompatRadioButton
            android:id="@+id/conflict_dialog_radio_overwrite"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="@dimen/normal_margin"
            android:paddingTop="@dimen/normal_margin"
            android:text="@string/overwrite"/>
    </RadioGroup>

    <com.simplemobiletools.commons.views.MyAppCompatCheckbox
        android:id="@+id/conflict_dialog_apply_to_all"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:checked="true"
        android:paddingBottom="@dimen/activity_margin"
        android:paddingTop="@dimen/activity_margin"
        android:text="@string/apply_to_all"/>

</LinearLayout>