|
|
@ -29,6 +29,7 @@ import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.graphics.Paint;
|
|
|
|
import android.graphics.Paint;
|
|
|
|
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.text.Editable;
|
|
|
|
import android.text.Editable;
|
|
|
@ -89,6 +90,9 @@ public class FragmentPop extends FragmentBase {
|
|
|
|
private ViewButtonColor btnColor;
|
|
|
|
private ViewButtonColor btnColor;
|
|
|
|
private TextView tvColorPro;
|
|
|
|
private TextView tvColorPro;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Button btnAvatar;
|
|
|
|
|
|
|
|
private TextView tvAvatarPro;
|
|
|
|
|
|
|
|
|
|
|
|
private Button btnCalendar;
|
|
|
|
private Button btnCalendar;
|
|
|
|
private TextView tvCalendarPro;
|
|
|
|
private TextView tvCalendarPro;
|
|
|
|
|
|
|
|
|
|
|
@ -126,13 +130,15 @@ public class FragmentPop extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
|
|
private long id = -1;
|
|
|
|
private long id = -1;
|
|
|
|
private int auth = AUTH_TYPE_PASSWORD;
|
|
|
|
private int auth = AUTH_TYPE_PASSWORD;
|
|
|
|
|
|
|
|
private String avatar = null;
|
|
|
|
private String calendar = null;
|
|
|
|
private String calendar = null;
|
|
|
|
private boolean saving = false;
|
|
|
|
private boolean saving = false;
|
|
|
|
|
|
|
|
|
|
|
|
private static final int REQUEST_COLOR = 1;
|
|
|
|
private static final int REQUEST_COLOR = 1;
|
|
|
|
private static final int REQUEST_CALENDAR = 2;
|
|
|
|
private static final int REQUEST_AVATAR = 2;
|
|
|
|
private static final int REQUEST_SAVE = 3;
|
|
|
|
private static final int REQUEST_CALENDAR = 3;
|
|
|
|
private static final int REQUEST_DELETE = 4;
|
|
|
|
private static final int REQUEST_SAVE = 4;
|
|
|
|
|
|
|
|
private static final int REQUEST_DELETE = 5;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
@ -169,6 +175,9 @@ public class FragmentPop extends FragmentBase {
|
|
|
|
btnColor = view.findViewById(R.id.btnColor);
|
|
|
|
btnColor = view.findViewById(R.id.btnColor);
|
|
|
|
tvColorPro = view.findViewById(R.id.tvColorPro);
|
|
|
|
tvColorPro = view.findViewById(R.id.tvColorPro);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
btnAvatar = view.findViewById(R.id.btnAvatar);
|
|
|
|
|
|
|
|
tvAvatarPro = view.findViewById(R.id.tvAvatarPro);
|
|
|
|
|
|
|
|
|
|
|
|
btnCalendar = view.findViewById(R.id.btnCalendar);
|
|
|
|
btnCalendar = view.findViewById(R.id.btnCalendar);
|
|
|
|
tvCalendarPro = view.findViewById(R.id.tvCalendarPro);
|
|
|
|
tvCalendarPro = view.findViewById(R.id.tvCalendarPro);
|
|
|
|
|
|
|
|
|
|
|
@ -281,6 +290,21 @@ public class FragmentPop extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
|
|
Helper.linkPro(tvColorPro);
|
|
|
|
Helper.linkPro(tvColorPro);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
btnAvatar.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
|
|
|
|
|
|
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
|
|
|
|
|
intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
|
|
|
|
|
|
|
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
|
|
|
|
|
|
intent.setType("image/*");
|
|
|
|
|
|
|
|
Helper.openAdvanced(v.getContext(), intent);
|
|
|
|
|
|
|
|
startActivityForResult(intent, REQUEST_AVATAR);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Helper.linkPro(tvAvatarPro);
|
|
|
|
|
|
|
|
|
|
|
|
grpCalendar.setVisibility(BuildConfig.PLAY_STORE_RELEASE ? View.GONE : View.VISIBLE);
|
|
|
|
grpCalendar.setVisibility(BuildConfig.PLAY_STORE_RELEASE ? View.GONE : View.VISIBLE);
|
|
|
|
btnCalendar.setEnabled(Helper.hasPermission(getContext(), Manifest.permission.WRITE_CALENDAR));
|
|
|
|
btnCalendar.setEnabled(Helper.hasPermission(getContext(), Manifest.permission.WRITE_CALENDAR));
|
|
|
|
btnCalendar.setOnClickListener(new View.OnClickListener() {
|
|
|
|
btnCalendar.setOnClickListener(new View.OnClickListener() {
|
|
|
@ -414,6 +438,7 @@ public class FragmentPop extends FragmentBase {
|
|
|
|
args.putString("name", etName.getText().toString());
|
|
|
|
args.putString("name", etName.getText().toString());
|
|
|
|
args.putString("category", etCategory.getText().toString());
|
|
|
|
args.putString("category", etCategory.getText().toString());
|
|
|
|
args.putInt("color", btnColor.getColor());
|
|
|
|
args.putInt("color", btnColor.getColor());
|
|
|
|
|
|
|
|
args.putString("avatar", avatar);
|
|
|
|
args.putString("calendar", calendar);
|
|
|
|
args.putString("calendar", calendar);
|
|
|
|
|
|
|
|
|
|
|
|
args.putBoolean("synchronize", cbSynchronize.isChecked());
|
|
|
|
args.putBoolean("synchronize", cbSynchronize.isChecked());
|
|
|
@ -473,6 +498,7 @@ public class FragmentPop extends FragmentBase {
|
|
|
|
String name = args.getString("name");
|
|
|
|
String name = args.getString("name");
|
|
|
|
String category = args.getString("category");
|
|
|
|
String category = args.getString("category");
|
|
|
|
Integer color = args.getInt("color");
|
|
|
|
Integer color = args.getInt("color");
|
|
|
|
|
|
|
|
String avatar = args.getString("avatar");
|
|
|
|
String calendar = args.getString("calendar");
|
|
|
|
String calendar = args.getString("calendar");
|
|
|
|
|
|
|
|
|
|
|
|
boolean synchronize = args.getBoolean("synchronize");
|
|
|
|
boolean synchronize = args.getBoolean("synchronize");
|
|
|
@ -566,6 +592,8 @@ public class FragmentPop extends FragmentBase {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
if (!Objects.equals(account.color, color))
|
|
|
|
if (!Objects.equals(account.color, color))
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!Objects.equals(account.avatar, avatar))
|
|
|
|
|
|
|
|
return true;
|
|
|
|
if (!Objects.equals(account.calendar, calendar))
|
|
|
|
if (!Objects.equals(account.calendar, calendar))
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
if (!Objects.equals(account.synchronize, synchronize))
|
|
|
|
if (!Objects.equals(account.synchronize, synchronize))
|
|
|
@ -669,6 +697,7 @@ public class FragmentPop extends FragmentBase {
|
|
|
|
account.name = name;
|
|
|
|
account.name = name;
|
|
|
|
account.category = category;
|
|
|
|
account.category = category;
|
|
|
|
account.color = color;
|
|
|
|
account.color = color;
|
|
|
|
|
|
|
|
account.avatar = avatar;
|
|
|
|
account.calendar = calendar;
|
|
|
|
account.calendar = calendar;
|
|
|
|
|
|
|
|
|
|
|
|
account.synchronize = synchronize;
|
|
|
|
account.synchronize = synchronize;
|
|
|
@ -816,6 +845,7 @@ public class FragmentPop extends FragmentBase {
|
|
|
|
public void onSaveInstanceState(Bundle outState) {
|
|
|
|
public void onSaveInstanceState(Bundle outState) {
|
|
|
|
outState.putString("fair:password", tilPassword == null ? null : tilPassword.getEditText().getText().toString());
|
|
|
|
outState.putString("fair:password", tilPassword == null ? null : tilPassword.getEditText().getText().toString());
|
|
|
|
outState.putInt("fair:auth", auth);
|
|
|
|
outState.putInt("fair:auth", auth);
|
|
|
|
|
|
|
|
outState.putString("fair:avatar", avatar);
|
|
|
|
outState.putString("fair:calendar", calendar);
|
|
|
|
outState.putString("fair:calendar", calendar);
|
|
|
|
super.onSaveInstanceState(outState);
|
|
|
|
super.onSaveInstanceState(outState);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -921,6 +951,7 @@ public class FragmentPop extends FragmentBase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auth = (account == null ? AUTH_TYPE_PASSWORD : account.auth_type);
|
|
|
|
auth = (account == null ? AUTH_TYPE_PASSWORD : account.auth_type);
|
|
|
|
|
|
|
|
avatar = (account == null ? null : account.avatar);
|
|
|
|
calendar = (account == null ? null : account.calendar);
|
|
|
|
calendar = (account == null ? null : account.calendar);
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<EntityAccount>() {
|
|
|
|
new SimpleTask<EntityAccount>() {
|
|
|
@ -943,6 +974,7 @@ public class FragmentPop extends FragmentBase {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
tilPassword.getEditText().setText(savedInstanceState.getString("fair:password"));
|
|
|
|
tilPassword.getEditText().setText(savedInstanceState.getString("fair:password"));
|
|
|
|
auth = savedInstanceState.getInt("fair:auth");
|
|
|
|
auth = savedInstanceState.getInt("fair:auth");
|
|
|
|
|
|
|
|
avatar = savedInstanceState.getString("fair:avatar");
|
|
|
|
calendar = savedInstanceState.getString("fair:calendar");
|
|
|
|
calendar = savedInstanceState.getString("fair:calendar");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1017,6 +1049,12 @@ public class FragmentPop extends FragmentBase {
|
|
|
|
startActivity(new Intent(getContext(), ActivityBilling.class));
|
|
|
|
startActivity(new Intent(getContext(), ActivityBilling.class));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REQUEST_AVATAR:
|
|
|
|
|
|
|
|
if (resultCode == RESULT_OK && data != null)
|
|
|
|
|
|
|
|
onImageSelected(data.getData());
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
avatar = null;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case REQUEST_CALENDAR:
|
|
|
|
case REQUEST_CALENDAR:
|
|
|
|
if (resultCode == RESULT_OK && data != null) {
|
|
|
|
if (resultCode == RESULT_OK && data != null) {
|
|
|
|
if (ActivityBilling.isPro(getContext())) {
|
|
|
|
if (ActivityBilling.isPro(getContext())) {
|
|
|
@ -1055,6 +1093,23 @@ public class FragmentPop extends FragmentBase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void onImageSelected(Uri uri) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
final Context context = getContext();
|
|
|
|
|
|
|
|
NoStreamException.check(uri, context);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
|
|
|
|
|
|
if (!Helper.isPersisted(context, uri, true, false))
|
|
|
|
|
|
|
|
throw new IllegalStateException("No permission granted to access selected image " + uri);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
avatar = uri.toString();
|
|
|
|
|
|
|
|
} catch (NoStreamException ex) {
|
|
|
|
|
|
|
|
ex.report(getActivity());
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onDelete() {
|
|
|
|
private void onDelete() {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putLong("id", id);
|
|
|
|
args.putLong("id", id);
|
|
|
|