|
@ -68,6 +68,7 @@ import androidx.loader.content.Loader; |
|
|
public class FragmentAccount extends FragmentEx { |
|
|
public class FragmentAccount extends FragmentEx { |
|
|
private List<Provider> providers; |
|
|
private List<Provider> providers; |
|
|
|
|
|
|
|
|
|
|
|
private ViewGroup view; |
|
|
private EditText etName; |
|
|
private EditText etName; |
|
|
private Spinner spProfile; |
|
|
private Spinner spProfile; |
|
|
private EditText etHost; |
|
|
private EditText etHost; |
|
@ -86,8 +87,8 @@ public class FragmentAccount extends FragmentEx { |
|
|
private Button btnSave; |
|
|
private Button btnSave; |
|
|
private ProgressBar pbSave; |
|
|
private ProgressBar pbSave; |
|
|
private ImageButton ibDelete; |
|
|
private ImageButton ibDelete; |
|
|
|
|
|
private ProgressBar pbWait; |
|
|
private Group grpFolders; |
|
|
private Group grpFolders; |
|
|
// TODO: loading spinner |
|
|
|
|
|
|
|
|
|
|
|
private ExecutorService executor = Executors.newCachedThreadPool(); |
|
|
private ExecutorService executor = Executors.newCachedThreadPool(); |
|
|
|
|
|
|
|
@ -96,7 +97,7 @@ public class FragmentAccount extends FragmentEx { |
|
|
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); |
|
|
|
|
|
|
|
|
View view = inflater.inflate(R.layout.fragment_account, container, false); |
|
|
|
|
|
|
|
|
view = (ViewGroup) inflater.inflate(R.layout.fragment_account, container, false); |
|
|
|
|
|
|
|
|
// Get arguments |
|
|
// Get arguments |
|
|
Bundle args = getArguments(); |
|
|
Bundle args = getArguments(); |
|
@ -125,6 +126,7 @@ public class FragmentAccount extends FragmentEx { |
|
|
btnSave = view.findViewById(R.id.btnSave); |
|
|
btnSave = view.findViewById(R.id.btnSave); |
|
|
pbSave = view.findViewById(R.id.pbSave); |
|
|
pbSave = view.findViewById(R.id.pbSave); |
|
|
ibDelete = view.findViewById(R.id.ibDelete); |
|
|
ibDelete = view.findViewById(R.id.ibDelete); |
|
|
|
|
|
pbWait = view.findViewById(R.id.pbWait); |
|
|
grpFolders = view.findViewById(R.id.grpFolders); |
|
|
grpFolders = view.findViewById(R.id.grpFolders); |
|
|
|
|
|
|
|
|
// Wire controls |
|
|
// Wire controls |
|
@ -159,8 +161,11 @@ public class FragmentAccount extends FragmentEx { |
|
|
btnCheck.setOnClickListener(new View.OnClickListener() { |
|
|
btnCheck.setOnClickListener(new View.OnClickListener() { |
|
|
@Override |
|
|
@Override |
|
|
public void onClick(View v) { |
|
|
public void onClick(View v) { |
|
|
|
|
|
Helper.setViewsEnabled(view, false); |
|
|
btnCheck.setEnabled(false); |
|
|
btnCheck.setEnabled(false); |
|
|
pbCheck.setVisibility(View.VISIBLE); |
|
|
pbCheck.setVisibility(View.VISIBLE); |
|
|
|
|
|
btnSave.setVisibility(View.GONE); |
|
|
|
|
|
grpFolders.setVisibility(View.GONE); |
|
|
|
|
|
|
|
|
Bundle args = new Bundle(); |
|
|
Bundle args = new Bundle(); |
|
|
args.putLong("id", id); |
|
|
args.putLong("id", id); |
|
@ -180,6 +185,8 @@ public class FragmentAccount extends FragmentEx { |
|
|
btnSave.setOnClickListener(new View.OnClickListener() { |
|
|
btnSave.setOnClickListener(new View.OnClickListener() { |
|
|
@Override |
|
|
@Override |
|
|
public void onClick(View v) { |
|
|
public void onClick(View v) { |
|
|
|
|
|
Helper.setViewsEnabled(view, false); |
|
|
|
|
|
btnCheck.setEnabled(false); |
|
|
btnSave.setEnabled(false); |
|
|
btnSave.setEnabled(false); |
|
|
pbSave.setVisibility(View.VISIBLE); |
|
|
pbSave.setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
@ -251,12 +258,14 @@ public class FragmentAccount extends FragmentEx { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// Initialize |
|
|
// Initialize |
|
|
|
|
|
Helper.setViewsEnabled(view, false); |
|
|
tilPassword.setPasswordVisibilityToggleEnabled(id < 0); |
|
|
tilPassword.setPasswordVisibilityToggleEnabled(id < 0); |
|
|
|
|
|
btnCheck.setEnabled(false); |
|
|
pbCheck.setVisibility(View.GONE); |
|
|
pbCheck.setVisibility(View.GONE); |
|
|
btnSave.setVisibility(View.GONE); |
|
|
btnSave.setVisibility(View.GONE); |
|
|
pbSave.setVisibility(View.GONE); |
|
|
pbSave.setVisibility(View.GONE); |
|
|
grpFolders.setVisibility(View.GONE); |
|
|
grpFolders.setVisibility(View.GONE); |
|
|
ibDelete.setVisibility(id < 0 ? View.GONE : View.VISIBLE); |
|
|
|
|
|
|
|
|
ibDelete.setVisibility(View.GONE); |
|
|
|
|
|
|
|
|
return view; |
|
|
return view; |
|
|
} |
|
|
} |
|
@ -283,6 +292,11 @@ public class FragmentAccount extends FragmentEx { |
|
|
cbSynchronize.setChecked(account == null ? true : account.synchronize); |
|
|
cbSynchronize.setChecked(account == null ? true : account.synchronize); |
|
|
cbPrimary.setChecked(account == null ? true : account.primary); |
|
|
cbPrimary.setChecked(account == null ? true : account.primary); |
|
|
cbPrimary.setEnabled(account == null ? true : account.synchronize); |
|
|
cbPrimary.setEnabled(account == null ? true : account.synchronize); |
|
|
|
|
|
ibDelete.setVisibility(account == null ? View.GONE : View.VISIBLE); |
|
|
|
|
|
|
|
|
|
|
|
Helper.setViewsEnabled(view, true); |
|
|
|
|
|
btnCheck.setEnabled(true); |
|
|
|
|
|
pbWait.setVisibility(View.GONE); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
@ -408,6 +422,7 @@ public class FragmentAccount extends FragmentEx { |
|
|
public void onLoadFinished(@NonNull Loader<CheckData> loader, CheckData data) { |
|
|
public void onLoadFinished(@NonNull Loader<CheckData> loader, CheckData data) { |
|
|
LoaderManager.getInstance(FragmentAccount.this).destroyLoader(loader.getId()); |
|
|
LoaderManager.getInstance(FragmentAccount.this).destroyLoader(loader.getId()); |
|
|
|
|
|
|
|
|
|
|
|
Helper.setViewsEnabled(view, true); |
|
|
btnCheck.setEnabled(true); |
|
|
btnCheck.setEnabled(true); |
|
|
pbCheck.setVisibility(View.GONE); |
|
|
pbCheck.setVisibility(View.GONE); |
|
|
|
|
|
|
|
@ -462,6 +477,8 @@ public class FragmentAccount extends FragmentEx { |
|
|
} else { |
|
|
} else { |
|
|
Log.w(Helper.TAG, data.ex + "\n" + Log.getStackTraceString(data.ex)); |
|
|
Log.w(Helper.TAG, data.ex + "\n" + Log.getStackTraceString(data.ex)); |
|
|
Toast.makeText(getContext(), Helper.formatThrowable(data.ex), Toast.LENGTH_LONG).show(); |
|
|
Toast.makeText(getContext(), Helper.formatThrowable(data.ex), Toast.LENGTH_LONG).show(); |
|
|
|
|
|
grpFolders.setVisibility(View.GONE); |
|
|
|
|
|
btnSave.setVisibility(View.GONE); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -626,8 +643,10 @@ public class FragmentAccount extends FragmentEx { |
|
|
public void onLoadFinished(@NonNull Loader<Throwable> loader, Throwable ex) { |
|
|
public void onLoadFinished(@NonNull Loader<Throwable> loader, Throwable ex) { |
|
|
LoaderManager.getInstance(FragmentAccount.this).destroyLoader(loader.getId()); |
|
|
LoaderManager.getInstance(FragmentAccount.this).destroyLoader(loader.getId()); |
|
|
|
|
|
|
|
|
|
|
|
Helper.setViewsEnabled(view, true); |
|
|
|
|
|
btnCheck.setEnabled(true); |
|
|
btnSave.setEnabled(true); |
|
|
btnSave.setEnabled(true); |
|
|
btnCheck.setVisibility(View.GONE); |
|
|
|
|
|
|
|
|
pbSave.setVisibility(View.GONE); |
|
|
|
|
|
|
|
|
if (ex == null) |
|
|
if (ex == null) |
|
|
getFragmentManager().popBackStack(); |
|
|
getFragmentManager().popBackStack(); |
|
|