|
|
@ -42,6 +42,9 @@ import android.text.TextUtils;
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
|
|
|
import android.view.Menu;
|
|
|
|
|
|
|
|
import android.view.MenuInflater;
|
|
|
|
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.AdapterView;
|
|
|
|
import android.widget.AdapterView;
|
|
|
@ -50,7 +53,6 @@ import android.widget.Button;
|
|
|
|
import android.widget.CheckBox;
|
|
|
|
import android.widget.CheckBox;
|
|
|
|
import android.widget.CompoundButton;
|
|
|
|
import android.widget.CompoundButton;
|
|
|
|
import android.widget.EditText;
|
|
|
|
import android.widget.EditText;
|
|
|
|
import android.widget.ImageButton;
|
|
|
|
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.ProgressBar;
|
|
|
|
import android.widget.ProgressBar;
|
|
|
|
import android.widget.ScrollView;
|
|
|
|
import android.widget.ScrollView;
|
|
|
@ -117,7 +119,6 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
private EditText etInterval;
|
|
|
|
private EditText etInterval;
|
|
|
|
|
|
|
|
|
|
|
|
private Button btnCheck;
|
|
|
|
private Button btnCheck;
|
|
|
|
private ImageButton ibDelete;
|
|
|
|
|
|
|
|
private ProgressBar pbCheck;
|
|
|
|
private ProgressBar pbCheck;
|
|
|
|
|
|
|
|
|
|
|
|
private TextView tvIdle;
|
|
|
|
private TextView tvIdle;
|
|
|
@ -155,6 +156,7 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
@Nullable
|
|
|
|
@Nullable
|
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
|
setSubtitle(R.string.title_edit_account);
|
|
|
|
setSubtitle(R.string.title_edit_account);
|
|
|
|
|
|
|
|
setHasOptionsMenu(true);
|
|
|
|
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
final boolean insecure = prefs.getBoolean("insecure", false);
|
|
|
|
final boolean insecure = prefs.getBoolean("insecure", false);
|
|
|
@ -190,7 +192,6 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
etInterval = view.findViewById(R.id.etInterval);
|
|
|
|
etInterval = view.findViewById(R.id.etInterval);
|
|
|
|
|
|
|
|
|
|
|
|
btnCheck = view.findViewById(R.id.btnCheck);
|
|
|
|
btnCheck = view.findViewById(R.id.btnCheck);
|
|
|
|
ibDelete = view.findViewById(R.id.ibDelete);
|
|
|
|
|
|
|
|
pbCheck = view.findViewById(R.id.pbCheck);
|
|
|
|
pbCheck = view.findViewById(R.id.pbCheck);
|
|
|
|
|
|
|
|
|
|
|
|
tvIdle = view.findViewById(R.id.tvIdle);
|
|
|
|
tvIdle = view.findViewById(R.id.tvIdle);
|
|
|
@ -229,7 +230,6 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
grpAdvanced.setVisibility(View.GONE);
|
|
|
|
grpAdvanced.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
btnCheck.setVisibility(position > 0 ? View.VISIBLE : View.GONE);
|
|
|
|
btnCheck.setVisibility(position > 0 ? View.VISIBLE : View.GONE);
|
|
|
|
ibDelete.setVisibility(position > 0 && id > 0 ? View.VISIBLE : View.GONE);
|
|
|
|
|
|
|
|
tvIdle.setVisibility(View.GONE);
|
|
|
|
tvIdle.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
Object tag = adapterView.getTag();
|
|
|
|
Object tag = adapterView.getTag();
|
|
|
@ -417,7 +417,6 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
Helper.setViewsEnabled(view, false);
|
|
|
|
Helper.setViewsEnabled(view, false);
|
|
|
|
btnAuthorize.setEnabled(false);
|
|
|
|
btnAuthorize.setEnabled(false);
|
|
|
|
btnCheck.setEnabled(false);
|
|
|
|
btnCheck.setEnabled(false);
|
|
|
|
ibDelete.setEnabled(false);
|
|
|
|
|
|
|
|
pbCheck.setVisibility(View.VISIBLE);
|
|
|
|
pbCheck.setVisibility(View.VISIBLE);
|
|
|
|
tvIdle.setVisibility(View.GONE);
|
|
|
|
tvIdle.setVisibility(View.GONE);
|
|
|
|
grpFolders.setVisibility(View.GONE);
|
|
|
|
grpFolders.setVisibility(View.GONE);
|
|
|
@ -539,7 +538,6 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
Helper.setViewsEnabled(view, true);
|
|
|
|
Helper.setViewsEnabled(view, true);
|
|
|
|
btnAuthorize.setEnabled(true);
|
|
|
|
btnAuthorize.setEnabled(true);
|
|
|
|
btnCheck.setEnabled(true);
|
|
|
|
btnCheck.setEnabled(true);
|
|
|
|
ibDelete.setEnabled(true);
|
|
|
|
|
|
|
|
pbCheck.setVisibility(View.GONE);
|
|
|
|
pbCheck.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
tvIdle.setVisibility(result.idle ? View.GONE : View.VISIBLE);
|
|
|
|
tvIdle.setVisibility(result.idle ? View.GONE : View.VISIBLE);
|
|
|
@ -559,7 +557,6 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
Helper.setViewsEnabled(view, true);
|
|
|
|
Helper.setViewsEnabled(view, true);
|
|
|
|
btnAuthorize.setEnabled(true);
|
|
|
|
btnAuthorize.setEnabled(true);
|
|
|
|
btnCheck.setEnabled(true);
|
|
|
|
btnCheck.setEnabled(true);
|
|
|
|
ibDelete.setEnabled(true);
|
|
|
|
|
|
|
|
pbCheck.setVisibility(View.GONE);
|
|
|
|
pbCheck.setVisibility(View.GONE);
|
|
|
|
grpFolders.setVisibility(View.GONE);
|
|
|
|
grpFolders.setVisibility(View.GONE);
|
|
|
|
btnSave.setVisibility(View.GONE);
|
|
|
|
btnSave.setVisibility(View.GONE);
|
|
|
@ -580,7 +577,6 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
Helper.setViewsEnabled(view, false);
|
|
|
|
Helper.setViewsEnabled(view, false);
|
|
|
|
btnAuthorize.setEnabled(false);
|
|
|
|
btnAuthorize.setEnabled(false);
|
|
|
|
btnCheck.setEnabled(false);
|
|
|
|
btnCheck.setEnabled(false);
|
|
|
|
ibDelete.setEnabled(false);
|
|
|
|
|
|
|
|
btnSave.setEnabled(false);
|
|
|
|
btnSave.setEnabled(false);
|
|
|
|
pbSave.setVisibility(View.VISIBLE);
|
|
|
|
pbSave.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
|
@ -828,7 +824,6 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
Helper.setViewsEnabled(view, true);
|
|
|
|
Helper.setViewsEnabled(view, true);
|
|
|
|
btnAuthorize.setEnabled(true);
|
|
|
|
btnAuthorize.setEnabled(true);
|
|
|
|
btnCheck.setEnabled(true);
|
|
|
|
btnCheck.setEnabled(true);
|
|
|
|
ibDelete.setEnabled(true);
|
|
|
|
|
|
|
|
btnSave.setEnabled(true);
|
|
|
|
btnSave.setEnabled(true);
|
|
|
|
pbSave.setVisibility(View.GONE);
|
|
|
|
pbSave.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
@ -842,53 +837,6 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
ibDelete.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
|
|
|
|
|
|
|
.setMessage(R.string.title_account_delete)
|
|
|
|
|
|
|
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
|
|
|
Helper.setViewsEnabled(view, false);
|
|
|
|
|
|
|
|
btnAuthorize.setEnabled(false);
|
|
|
|
|
|
|
|
btnCheck.setEnabled(false);
|
|
|
|
|
|
|
|
ibDelete.setEnabled(false);
|
|
|
|
|
|
|
|
btnSave.setEnabled(false);
|
|
|
|
|
|
|
|
pbWait.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
args.putLong("id", id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected Void onLoad(Context context, Bundle args) {
|
|
|
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
EntityAccount account = db.account().getAccount(id);
|
|
|
|
|
|
|
|
db.account().deleteAccount(id);
|
|
|
|
|
|
|
|
if (account.synchronize)
|
|
|
|
|
|
|
|
ServiceSynchronize.reload(getContext(), "delete account");
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onLoaded(Bundle args, Void data) {
|
|
|
|
|
|
|
|
getFragmentManager().popBackStack();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
|
|
|
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.load(FragmentAccount.this, args);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.setNegativeButton(android.R.string.cancel, null)
|
|
|
|
|
|
|
|
.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adapter = new ArrayAdapter<>(getContext(), R.layout.spinner_item1, android.R.id.text1, new ArrayList<EntityFolder>());
|
|
|
|
adapter = new ArrayAdapter<>(getContext(), R.layout.spinner_item1, android.R.id.text1, new ArrayList<EntityFolder>());
|
|
|
|
adapter.setDropDownViewResource(R.layout.spinner_item1_dropdown);
|
|
|
|
adapter.setDropDownViewResource(R.layout.spinner_item1_dropdown);
|
|
|
|
|
|
|
|
|
|
|
@ -910,7 +858,6 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
tvIdle.setVisibility(View.GONE);
|
|
|
|
tvIdle.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
btnCheck.setVisibility(View.GONE);
|
|
|
|
btnCheck.setVisibility(View.GONE);
|
|
|
|
ibDelete.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
pbCheck.setVisibility(View.GONE);
|
|
|
|
pbCheck.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
btnSave.setVisibility(View.GONE);
|
|
|
|
btnSave.setVisibility(View.GONE);
|
|
|
@ -1031,7 +978,6 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
cbPrimary.setEnabled(cbSynchronize.isChecked());
|
|
|
|
cbPrimary.setEnabled(cbSynchronize.isChecked());
|
|
|
|
|
|
|
|
|
|
|
|
// Consider previous check/save/delete as cancelled
|
|
|
|
// Consider previous check/save/delete as cancelled
|
|
|
|
ibDelete.setVisibility(account == null ? View.GONE : View.VISIBLE);
|
|
|
|
|
|
|
|
pbWait.setVisibility(View.GONE);
|
|
|
|
pbWait.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
|
|
args.putLong("account", account == null ? -1 : account.id);
|
|
|
|
args.putLong("account", account == null ? -1 : account.id);
|
|
|
@ -1064,18 +1010,70 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
}.load(this, args);
|
|
|
|
}.load(this, args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void selectAccount() {
|
|
|
|
@Override
|
|
|
|
Log.i(Helper.TAG, "Select account");
|
|
|
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
|
|
Provider provider = (Provider) spProvider.getSelectedItem();
|
|
|
|
inflater.inflate(R.menu.menu_account, menu);
|
|
|
|
if (provider.type != null)
|
|
|
|
super.onCreateOptionsMenu(menu, inflater);
|
|
|
|
startActivityForResult(newChooseAccountIntent(
|
|
|
|
}
|
|
|
|
null,
|
|
|
|
|
|
|
|
null,
|
|
|
|
@Override
|
|
|
|
new String[]{provider.type},
|
|
|
|
public void onPrepareOptionsMenu(Menu menu) {
|
|
|
|
null,
|
|
|
|
menu.findItem(R.id.menu_delete).setVisible(id > 0);
|
|
|
|
null,
|
|
|
|
super.onPrepareOptionsMenu(menu);
|
|
|
|
null,
|
|
|
|
}
|
|
|
|
null), ActivitySetup.REQUEST_CHOOSE_ACCOUNT);
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
|
|
|
|
case R.id.menu_delete:
|
|
|
|
|
|
|
|
onMenuDelete();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void onMenuDelete() {
|
|
|
|
|
|
|
|
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
|
|
|
|
|
|
|
.setMessage(R.string.title_account_delete)
|
|
|
|
|
|
|
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
|
|
|
Helper.setViewsEnabled(view, false);
|
|
|
|
|
|
|
|
btnAuthorize.setEnabled(false);
|
|
|
|
|
|
|
|
btnCheck.setEnabled(false);
|
|
|
|
|
|
|
|
btnSave.setEnabled(false);
|
|
|
|
|
|
|
|
pbWait.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
args.putLong("id", id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected Void onLoad(Context context, Bundle args) {
|
|
|
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
EntityAccount account = db.account().getAccount(id);
|
|
|
|
|
|
|
|
db.account().deleteAccount(id);
|
|
|
|
|
|
|
|
if (account.synchronize)
|
|
|
|
|
|
|
|
ServiceSynchronize.reload(getContext(), "delete account");
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onLoaded(Bundle args, Void data) {
|
|
|
|
|
|
|
|
getFragmentManager().popBackStack();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
|
|
|
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.load(FragmentAccount.this, args);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.setNegativeButton(android.R.string.cancel, null)
|
|
|
|
|
|
|
|
.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -1129,6 +1127,20 @@ public class FragmentAccount extends FragmentEx {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void selectAccount() {
|
|
|
|
|
|
|
|
Log.i(Helper.TAG, "Select account");
|
|
|
|
|
|
|
|
Provider provider = (Provider) spProvider.getSelectedItem();
|
|
|
|
|
|
|
|
if (provider.type != null)
|
|
|
|
|
|
|
|
startActivityForResult(newChooseAccountIntent(
|
|
|
|
|
|
|
|
null,
|
|
|
|
|
|
|
|
null,
|
|
|
|
|
|
|
|
new String[]{provider.type},
|
|
|
|
|
|
|
|
null,
|
|
|
|
|
|
|
|
null,
|
|
|
|
|
|
|
|
null,
|
|
|
|
|
|
|
|
null), ActivitySetup.REQUEST_CHOOSE_ACCOUNT);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void setColor(int color) {
|
|
|
|
private void setColor(int color) {
|
|
|
|
FragmentAccount.this.color = color;
|
|
|
|
FragmentAccount.this.color = color;
|
|
|
|
|
|
|
|
|
|
|
|