|
|
@ -33,10 +33,9 @@ import android.widget.CheckBox;
|
|
|
|
import android.widget.CompoundButton;
|
|
|
|
import android.widget.CompoundButton;
|
|
|
|
import android.widget.ProgressBar;
|
|
|
|
import android.widget.ProgressBar;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
@ -56,13 +55,9 @@ public class FragmentSetup extends FragmentEx {
|
|
|
|
private Button btnPermissions;
|
|
|
|
private Button btnPermissions;
|
|
|
|
private TextView tvPermissionsDone;
|
|
|
|
private TextView tvPermissionsDone;
|
|
|
|
|
|
|
|
|
|
|
|
private Button btnMessages;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private CheckBox cbDarkTheme;
|
|
|
|
private CheckBox cbDarkTheme;
|
|
|
|
private CheckBox cbDebug;
|
|
|
|
private CheckBox cbDebug;
|
|
|
|
|
|
|
|
|
|
|
|
private ExecutorService executor = Executors.newCachedThreadPool();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String[] permissions = new String[]{
|
|
|
|
private static final String[] permissions = new String[]{
|
|
|
|
Manifest.permission.READ_CONTACTS
|
|
|
|
Manifest.permission.READ_CONTACTS
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -86,8 +81,6 @@ public class FragmentSetup extends FragmentEx {
|
|
|
|
btnPermissions = view.findViewById(R.id.btnPermissions);
|
|
|
|
btnPermissions = view.findViewById(R.id.btnPermissions);
|
|
|
|
tvPermissionsDone = view.findViewById(R.id.tvPermissionsDone);
|
|
|
|
tvPermissionsDone = view.findViewById(R.id.tvPermissionsDone);
|
|
|
|
|
|
|
|
|
|
|
|
btnMessages = view.findViewById(R.id.btnMessages);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cbDarkTheme = view.findViewById(R.id.cbDarkTheme);
|
|
|
|
cbDarkTheme = view.findViewById(R.id.cbDarkTheme);
|
|
|
|
cbDebug = view.findViewById(R.id.cbDebug);
|
|
|
|
cbDebug = view.findViewById(R.id.cbDebug);
|
|
|
|
|
|
|
|
|
|
|
@ -119,14 +112,6 @@ public class FragmentSetup extends FragmentEx {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
btnMessages.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
|
|
|
startActivity(new Intent(getContext(), ActivityView.class));
|
|
|
|
|
|
|
|
getFragmentManager().popBackStack();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
|
|
|
|
|
|
|
String theme = prefs.getString("theme", "light");
|
|
|
|
String theme = prefs.getString("theme", "light");
|
|
|
@ -159,7 +144,6 @@ public class FragmentSetup extends FragmentEx {
|
|
|
|
tvAccountDone.setVisibility(View.INVISIBLE);
|
|
|
|
tvAccountDone.setVisibility(View.INVISIBLE);
|
|
|
|
tvIdentityDone.setVisibility(View.INVISIBLE);
|
|
|
|
tvIdentityDone.setVisibility(View.INVISIBLE);
|
|
|
|
tvPermissionsDone.setVisibility(View.INVISIBLE);
|
|
|
|
tvPermissionsDone.setVisibility(View.INVISIBLE);
|
|
|
|
btnMessages.setEnabled(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int[] grantResults = new int[permissions.length];
|
|
|
|
int[] grantResults = new int[permissions.length];
|
|
|
|
for (int i = 0; i < permissions.length; i++)
|
|
|
|
for (int i = 0; i < permissions.length; i++)
|
|
|
@ -168,9 +152,9 @@ public class FragmentSetup extends FragmentEx {
|
|
|
|
onRequestPermissionsResult(0, permissions, grantResults);
|
|
|
|
onRequestPermissionsResult(0, permissions, grantResults);
|
|
|
|
|
|
|
|
|
|
|
|
// Create outbox
|
|
|
|
// Create outbox
|
|
|
|
executor.submit(new Runnable() {
|
|
|
|
new SimpleLoader<Void>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public Void onLoad(Bundle args) throws Throwable {
|
|
|
|
DB db = DB.getInstance(getContext());
|
|
|
|
DB db = DB.getInstance(getContext());
|
|
|
|
EntityFolder outbox = db.folder().getOutbox();
|
|
|
|
EntityFolder outbox = db.folder().getOutbox();
|
|
|
|
if (outbox == null) {
|
|
|
|
if (outbox == null) {
|
|
|
@ -181,8 +165,14 @@ public class FragmentSetup extends FragmentEx {
|
|
|
|
outbox.after = 0;
|
|
|
|
outbox.after = 0;
|
|
|
|
outbox.id = db.folder().insertFolder(outbox);
|
|
|
|
outbox.id = db.folder().insertFolder(outbox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onException(Bundle args, Throwable ex) {
|
|
|
|
|
|
|
|
Toast.makeText(getContext(), ex.toString(), Toast.LENGTH_LONG).show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.load(this, ActivitySetup.LOADER_CREATE_OUTBOX, new Bundle());
|
|
|
|
|
|
|
|
|
|
|
|
return view;
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -197,7 +187,6 @@ public class FragmentSetup extends FragmentEx {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onChanged(@Nullable List<EntityAccount> accounts) {
|
|
|
|
public void onChanged(@Nullable List<EntityAccount> accounts) {
|
|
|
|
tvAccountDone.setVisibility(accounts.size() > 0 ? View.VISIBLE : View.INVISIBLE);
|
|
|
|
tvAccountDone.setVisibility(accounts.size() > 0 ? View.VISIBLE : View.INVISIBLE);
|
|
|
|
btnMessages.setEnabled(accounts.size() > 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -209,6 +198,13 @@ public class FragmentSetup extends FragmentEx {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onDestroy() {
|
|
|
|
|
|
|
|
if (tvAccountDone.getVisibility() == View.VISIBLE)
|
|
|
|
|
|
|
|
startActivity(new Intent(getContext(), ActivityView.class).putExtra("setup", true));
|
|
|
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
|
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
|
|
boolean has = (grantResults.length > 0);
|
|
|
|
boolean has = (grantResults.length > 0);
|
|
|
|