Honour media default privacy for accounts + add option in settings
This commit is contained in:
parent
e5391f6ed2
commit
7a67b672e8
|
@ -93,12 +93,13 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
||||||
private ImageView set_profile_picture, set_header_picture;
|
private ImageView set_profile_picture, set_header_picture;
|
||||||
private Button set_change_profile_picture, set_change_header_picture, set_profile_save;
|
private Button set_change_profile_picture, set_change_header_picture, set_profile_save;
|
||||||
private TextView set_header_picture_overlay;
|
private TextView set_header_picture_overlay;
|
||||||
private CheckBox set_lock_account;
|
private CheckBox set_lock_account, set_sensitive_content;
|
||||||
private static final int PICK_IMAGE_HEADER = 4565;
|
private static final int PICK_IMAGE_HEADER = 4565;
|
||||||
private static final int PICK_IMAGE_PROFILE = 6545;
|
private static final int PICK_IMAGE_PROFILE = 6545;
|
||||||
private String profile_username, profile_note;
|
private String profile_username, profile_note;
|
||||||
private ByteArrayInputStream profile_picture, header_picture;
|
private ByteArrayInputStream profile_picture, header_picture;
|
||||||
private API.accountPrivacy profile_privacy;
|
private API.accountPrivacy profile_privacy;
|
||||||
|
private boolean sensitive;
|
||||||
private Bitmap profile_picture_bmp, profile_header_bmp;
|
private Bitmap profile_picture_bmp, profile_header_bmp;
|
||||||
private ImageView pp_actionBar;
|
private ImageView pp_actionBar;
|
||||||
private final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE_HEADER = 754;
|
private final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE_HEADER = 754;
|
||||||
|
@ -173,22 +174,26 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
||||||
set_profile_save = findViewById(R.id.set_profile_save);
|
set_profile_save = findViewById(R.id.set_profile_save);
|
||||||
set_header_picture_overlay = findViewById(R.id.set_header_picture_overlay);
|
set_header_picture_overlay = findViewById(R.id.set_header_picture_overlay);
|
||||||
set_lock_account = findViewById(R.id.set_lock_account);
|
set_lock_account = findViewById(R.id.set_lock_account);
|
||||||
|
set_sensitive_content = findViewById(R.id.set_sensitive_content);
|
||||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
|
||||||
String instanceVersion = sharedpreferences.getString(Helper.INSTANCE_VERSION + userId + instance, null);
|
String instanceVersion = sharedpreferences.getString(Helper.INSTANCE_VERSION + userId + instance, null);
|
||||||
Version currentVersion = new Version(instanceVersion);
|
Version currentVersion = new Version(instanceVersion);
|
||||||
Version minVersion = new Version("2.3");
|
Version minVersion = new Version("2.3");
|
||||||
if(currentVersion.compareTo(minVersion) == 1)
|
if(currentVersion.compareTo(minVersion) == 1) {
|
||||||
set_lock_account.setVisibility(View.VISIBLE);
|
set_lock_account.setVisibility(View.VISIBLE);
|
||||||
else
|
set_sensitive_content.setVisibility(View.VISIBLE);
|
||||||
|
}else {
|
||||||
set_lock_account.setVisibility(View.GONE);
|
set_lock_account.setVisibility(View.GONE);
|
||||||
|
set_sensitive_content.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
set_profile_save.setEnabled(false);
|
set_profile_save.setEnabled(false);
|
||||||
set_change_header_picture.setEnabled(false);
|
set_change_header_picture.setEnabled(false);
|
||||||
set_change_profile_picture.setEnabled(false);
|
set_change_profile_picture.setEnabled(false);
|
||||||
set_profile_name.setEnabled(false);
|
set_profile_name.setEnabled(false);
|
||||||
set_profile_description.setEnabled(false);
|
set_profile_description.setEnabled(false);
|
||||||
set_lock_account.setEnabled(false);
|
set_lock_account.setEnabled(false);
|
||||||
|
set_sensitive_content.setEnabled(false);
|
||||||
new RetrieveAccountInfoAsyncTask(getApplicationContext(), EditProfileActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new RetrieveAccountInfoAsyncTask(getApplicationContext(), EditProfileActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -231,10 +236,15 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
||||||
set_profile_name.setEnabled(true);
|
set_profile_name.setEnabled(true);
|
||||||
set_profile_description.setEnabled(true);
|
set_profile_description.setEnabled(true);
|
||||||
set_lock_account.setEnabled(true);
|
set_lock_account.setEnabled(true);
|
||||||
|
set_sensitive_content.setEnabled(true);
|
||||||
if( account.isLocked())
|
if( account.isLocked())
|
||||||
set_lock_account.setChecked(true);
|
set_lock_account.setChecked(true);
|
||||||
else
|
else
|
||||||
set_lock_account.setChecked(false);
|
set_lock_account.setChecked(false);
|
||||||
|
if( account.isSensitive())
|
||||||
|
set_sensitive_content.setChecked(true);
|
||||||
|
else
|
||||||
|
set_sensitive_content.setChecked(false);
|
||||||
set_profile_description.addTextChangedListener(new TextWatcher() {
|
set_profile_description.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||||
|
@ -438,6 +448,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
profile_privacy = set_lock_account.isChecked()?API.accountPrivacy.LOCKED:API.accountPrivacy.PUBLIC;
|
profile_privacy = set_lock_account.isChecked()?API.accountPrivacy.LOCKED:API.accountPrivacy.PUBLIC;
|
||||||
|
sensitive = set_sensitive_content.isChecked();
|
||||||
dialogBuilder.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
|
dialogBuilder.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
@ -467,7 +478,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
|
||||||
newCustomFields.put(key3,val3);
|
newCustomFields.put(key3,val3);
|
||||||
newCustomFields.put(key4,val4);
|
newCustomFields.put(key4,val4);
|
||||||
|
|
||||||
new UpdateCredentialAsyncTask(getApplicationContext(), newCustomFields, profile_username, profile_note, profile_picture, avatarName, header_picture, headerName, profile_privacy, EditProfileActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new UpdateCredentialAsyncTask(getApplicationContext(), newCustomFields, profile_username, profile_note, profile_picture, avatarName, header_picture, headerName, profile_privacy, sensitive, EditProfileActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
|
|
@ -1771,6 +1771,9 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
|
||||||
toot_picture.setEnabled(true);
|
toot_picture.setEnabled(true);
|
||||||
toot_it.setEnabled(true);
|
toot_it.setEnabled(true);
|
||||||
toot_sensitive.setVisibility(View.VISIBLE);
|
toot_sensitive.setVisibility(View.VISIBLE);
|
||||||
|
if( account.isSensitive()){
|
||||||
|
toot_sensitive.setChecked(true);
|
||||||
|
}
|
||||||
picture_scrollview.setVisibility(View.VISIBLE);
|
picture_scrollview.setVisibility(View.VISIBLE);
|
||||||
}else {
|
}else {
|
||||||
if( attachments.size() > index && attachment.getDescription() != null) {
|
if( attachments.size() > index && attachment.getDescription() != null) {
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class UpdateAccountInfoAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
editor.putString(Helper.PREF_INSTANCE, instance);
|
editor.putString(Helper.PREF_INSTANCE, instance);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
if( userExists)
|
if( userExists)
|
||||||
new AccountDAO(this.contextReference.get(), db).updateAccount(account);
|
new AccountDAO(this.contextReference.get(), db).updateAccountCredential(account);
|
||||||
else {
|
else {
|
||||||
if( account.getUsername() != null && account.getCreated_at() != null)
|
if( account.getUsername() != null && account.getCreated_at() != null)
|
||||||
new AccountDAO(this.contextReference.get(), db).insertAccount(account);
|
new AccountDAO(this.contextReference.get(), db).insertAccount(account);
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class UpdateAccountInfoByIDAsyncTask extends AsyncTask<Void, Void, Void>
|
||||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
Account account = null;
|
Account account = null;
|
||||||
if( social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)
|
||||||
account = new API(this.contextReference.get()).getAccount(userId);
|
account = new API(this.contextReference.get()).verifyCredentials();
|
||||||
else if( social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
|
else if( social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
|
||||||
account = new PeertubeAPI(this.contextReference.get()).verifyCredentials();
|
account = new PeertubeAPI(this.contextReference.get()).verifyCredentials();
|
||||||
account.setSocial("PEERTUBE");
|
account.setSocial("PEERTUBE");
|
||||||
|
@ -78,7 +78,7 @@ public class UpdateAccountInfoByIDAsyncTask extends AsyncTask<Void, Void, Void>
|
||||||
if( accountDb != null){
|
if( accountDb != null){
|
||||||
account.setInstance(accountDb.getInstance());
|
account.setInstance(accountDb.getInstance());
|
||||||
account.setToken(accountDb.getToken());
|
account.setToken(accountDb.getToken());
|
||||||
new AccountDAO(this.contextReference.get(), db).updateAccount(account);
|
new AccountDAO(this.contextReference.get(), db).updateAccountCredential(account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
|
if( social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
|
||||||
|
|
|
@ -34,6 +34,7 @@ import fr.gouv.etalab.mastodon.interfaces.OnUpdateCredentialInterface;
|
||||||
public class UpdateCredentialAsyncTask extends AsyncTask<Void, Void, Void> {
|
public class UpdateCredentialAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
private String display_name, note, avatarName, headerName;
|
private String display_name, note, avatarName, headerName;
|
||||||
|
private boolean senstive;
|
||||||
private ByteArrayInputStream avatar, header;
|
private ByteArrayInputStream avatar, header;
|
||||||
private API.accountPrivacy privacy;
|
private API.accountPrivacy privacy;
|
||||||
private APIResponse apiResponse;
|
private APIResponse apiResponse;
|
||||||
|
@ -41,7 +42,7 @@ public class UpdateCredentialAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
private WeakReference<Context> contextReference;
|
private WeakReference<Context> contextReference;
|
||||||
private HashMap<String, String> customFields;
|
private HashMap<String, String> customFields;
|
||||||
|
|
||||||
public UpdateCredentialAsyncTask(Context context, HashMap<String, String> customFields, String display_name, String note, ByteArrayInputStream avatar, String avatarName, ByteArrayInputStream header, String headerName, API.accountPrivacy privacy, OnUpdateCredentialInterface onUpdateCredentialInterface){
|
public UpdateCredentialAsyncTask(Context context, HashMap<String, String> customFields, String display_name, String note, ByteArrayInputStream avatar, String avatarName, ByteArrayInputStream header, String headerName, API.accountPrivacy privacy, boolean senstive, OnUpdateCredentialInterface onUpdateCredentialInterface){
|
||||||
this.contextReference = new WeakReference<>(context);
|
this.contextReference = new WeakReference<>(context);
|
||||||
this.display_name = display_name;
|
this.display_name = display_name;
|
||||||
this.note = note;
|
this.note = note;
|
||||||
|
@ -52,11 +53,12 @@ public class UpdateCredentialAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
this.avatarName = avatarName;
|
this.avatarName = avatarName;
|
||||||
this.headerName = headerName;
|
this.headerName = headerName;
|
||||||
this.customFields = customFields;
|
this.customFields = customFields;
|
||||||
|
this.senstive = senstive;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
apiResponse = new API(this.contextReference.get()).updateCredential(display_name, note, avatar, avatarName, header, headerName, privacy, customFields);
|
apiResponse = new API(this.contextReference.get()).updateCredential(display_name, note, avatar, avatarName, header, headerName, privacy, customFields, senstive);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -314,7 +314,7 @@ public class API {
|
||||||
* Update credential of the authenticated user *synchronously*
|
* Update credential of the authenticated user *synchronously*
|
||||||
* @return APIResponse
|
* @return APIResponse
|
||||||
*/
|
*/
|
||||||
public APIResponse updateCredential(String display_name, String note, ByteArrayInputStream avatar, String avatarName, ByteArrayInputStream header, String headerName, accountPrivacy privacy, HashMap<String, String> customFields) {
|
public APIResponse updateCredential(String display_name, String note, ByteArrayInputStream avatar, String avatarName, ByteArrayInputStream header, String headerName, accountPrivacy privacy, HashMap<String, String> customFields, boolean sensitive) {
|
||||||
|
|
||||||
HashMap<String, String> requestParams = new HashMap<>();
|
HashMap<String, String> requestParams = new HashMap<>();
|
||||||
if( display_name != null)
|
if( display_name != null)
|
||||||
|
@ -342,6 +342,9 @@ public class API {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(sensitive){
|
||||||
|
requestParams.put("source[sensitive]", String.valueOf(sensitive));
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
new HttpsConnection(context).patch(getAbsoluteUrl("/accounts/update_credentials"), 60, requestParams, avatar, avatarName, header, headerName, prefKeyOauthTokenT);
|
new HttpsConnection(context).patch(getAbsoluteUrl("/accounts/update_credentials"), 60, requestParams, avatar, avatarName, header, headerName, prefKeyOauthTokenT);
|
||||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||||
|
@ -393,7 +396,7 @@ public class API {
|
||||||
}
|
}
|
||||||
}if( values.containsKey("refresh_token") && values.get("refresh_token") != null)
|
}if( values.containsKey("refresh_token") && values.get("refresh_token") != null)
|
||||||
targetedAccount.setRefresh_token(values.get("refresh_token"));
|
targetedAccount.setRefresh_token(values.get("refresh_token"));
|
||||||
new AccountDAO(context, db).updateAccount(targetedAccount);
|
new AccountDAO(context, db).updateAccountCredential(targetedAccount);
|
||||||
String response;
|
String response;
|
||||||
try {
|
try {
|
||||||
response = new HttpsConnection(context).get(getAbsoluteUrl("/accounts/verify_credentials"), 60, null, targetedAccount.getToken());
|
response = new HttpsConnection(context).get(getAbsoluteUrl("/accounts/verify_credentials"), 60, null, targetedAccount.getToken());
|
||||||
|
@ -4454,6 +4457,8 @@ public class API {
|
||||||
account.setFieldsVerified(fieldsMapVerified);
|
account.setFieldsVerified(fieldsMapVerified);
|
||||||
}catch (Exception ignored){}
|
}catch (Exception ignored){}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Retrieves emjis
|
//Retrieves emjis
|
||||||
List<Emojis> emojiList = new ArrayList<>();
|
List<Emojis> emojiList = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
|
@ -4469,6 +4474,17 @@ public class API {
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
account.setEmojis(new ArrayList<>());
|
account.setEmojis(new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
if( resobj.has("source")){
|
||||||
|
JSONObject source = resobj.getJSONObject("source");
|
||||||
|
try{
|
||||||
|
account.setPrivacy(source.getString("privacy"));
|
||||||
|
account.setSensitive(source.getBoolean("sensitive"));
|
||||||
|
}catch (Exception e){
|
||||||
|
account.setPrivacy("public");
|
||||||
|
account.setSensitive(false);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (JSONException ignored) {} catch (ParseException e) {
|
} catch (JSONException ignored) {} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,8 @@ public class Account implements Parcelable {
|
||||||
private String refresh_token;
|
private String refresh_token;
|
||||||
private boolean isModerator = false;
|
private boolean isModerator = false;
|
||||||
private boolean isAdmin = false;
|
private boolean isAdmin = false;
|
||||||
|
private String privacy = "public";
|
||||||
|
private boolean sensitive = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,6 +174,8 @@ public class Account implements Parcelable {
|
||||||
dest.writeString(this.refresh_token);
|
dest.writeString(this.refresh_token);
|
||||||
dest.writeByte(this.isModerator ? (byte) 1 : (byte) 0);
|
dest.writeByte(this.isModerator ? (byte) 1 : (byte) 0);
|
||||||
dest.writeByte(this.isAdmin ? (byte) 1 : (byte) 0);
|
dest.writeByte(this.isAdmin ? (byte) 1 : (byte) 0);
|
||||||
|
dest.writeString(this.privacy);
|
||||||
|
dest.writeByte(this.sensitive ? (byte) 1 : (byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Account() {
|
public Account() {
|
||||||
|
@ -225,6 +229,8 @@ public class Account implements Parcelable {
|
||||||
this.refresh_token = in.readString();
|
this.refresh_token = in.readString();
|
||||||
this.isModerator = in.readByte() != 0;
|
this.isModerator = in.readByte() != 0;
|
||||||
this.isAdmin = in.readByte() != 0;
|
this.isAdmin = in.readByte() != 0;
|
||||||
|
this.privacy = in.readString();
|
||||||
|
this.sensitive =in.readByte() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<Account> CREATOR = new Creator<Account>() {
|
public static final Creator<Account> CREATOR = new Creator<Account>() {
|
||||||
|
@ -384,6 +390,22 @@ public class Account implements Parcelable {
|
||||||
this.updated_at = updated_at;
|
this.updated_at = updated_at;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPrivacy() {
|
||||||
|
return privacy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrivacy(String privacy) {
|
||||||
|
this.privacy = privacy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSensitive() {
|
||||||
|
return sensitive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensitive(boolean sensitive) {
|
||||||
|
this.sensitive = sensitive;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public enum followAction{
|
public enum followAction{
|
||||||
FOLLOW,
|
FOLLOW,
|
||||||
|
|
|
@ -82,6 +82,8 @@ public class AccountDAO {
|
||||||
if( account.getToken() != null)
|
if( account.getToken() != null)
|
||||||
values.put(Sqlite.COL_OAUTHTOKEN, account.getToken());
|
values.put(Sqlite.COL_OAUTHTOKEN, account.getToken());
|
||||||
|
|
||||||
|
values.put(Sqlite.COL_SENSITIVE, account.isSensitive());
|
||||||
|
values.put(Sqlite.COL_PRIVACY, account.getPrivacy());
|
||||||
//Inserts account
|
//Inserts account
|
||||||
try{
|
try{
|
||||||
db.insert(Sqlite.TABLE_USER_ACCOUNT, null, values);
|
db.insert(Sqlite.TABLE_USER_ACCOUNT, null, values);
|
||||||
|
@ -128,7 +130,49 @@ public class AccountDAO {
|
||||||
}
|
}
|
||||||
if( account.getToken() != null)
|
if( account.getToken() != null)
|
||||||
values.put(Sqlite.COL_OAUTHTOKEN, account.getToken());
|
values.put(Sqlite.COL_OAUTHTOKEN, account.getToken());
|
||||||
|
return db.update(Sqlite.TABLE_USER_ACCOUNT,
|
||||||
|
values, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_USERNAME + " =?",
|
||||||
|
new String[]{account.getId(), account.getUsername()});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an Account in database
|
||||||
|
* @param account Account
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public int updateAccountCredential(Account account)
|
||||||
|
{
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
if( account.getNote() == null)
|
||||||
|
account.setNote("");
|
||||||
|
if( account.getCreated_at() == null)
|
||||||
|
account.setCreated_at(new Date());
|
||||||
|
values.put(Sqlite.COL_ACCT, account.getAcct());
|
||||||
|
values.put(Sqlite.COL_DISPLAYED_NAME, account.getDisplay_name());
|
||||||
|
values.put(Sqlite.COL_LOCKED,account.isLocked());
|
||||||
|
values.put(Sqlite.COL_FOLLOWERS_COUNT,account.getFollowers_count());
|
||||||
|
values.put(Sqlite.COL_FOLLOWING_COUNT,account.getFollowing_count());
|
||||||
|
values.put(Sqlite.COL_STATUSES_COUNT,account.getStatuses_count());
|
||||||
|
values.put(Sqlite.COL_NOTE,account.getNote());
|
||||||
|
values.put(Sqlite.COL_URL,account.getUrl());
|
||||||
|
values.put(Sqlite.COL_AVATAR,account.getAvatar());
|
||||||
|
values.put(Sqlite.COL_AVATAR_STATIC,account.getAvatar_static());
|
||||||
|
values.put(Sqlite.COL_HEADER,account.getHeader());
|
||||||
|
values.put(Sqlite.COL_HEADER_STATIC,account.getHeader_static());
|
||||||
|
values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(account.getCreated_at()));
|
||||||
|
values.put(Sqlite.COL_INSTANCE, account.getInstance());
|
||||||
|
values.put(Sqlite.COL_EMOJIS, Helper.emojisToStringStorage(account.getEmojis()));
|
||||||
|
values.put(Sqlite.COL_SOCIAL, account.getSocial());
|
||||||
|
if( account.getClient_id() != null && account.getClient_secret() != null && account.getRefresh_token() != null) {
|
||||||
|
values.put(Sqlite.COL_CLIENT_ID, account.getClient_id());
|
||||||
|
values.put(Sqlite.COL_CLIENT_SECRET, account.getClient_secret());
|
||||||
|
values.put(Sqlite.COL_REFRESH_TOKEN, account.getRefresh_token());
|
||||||
|
}
|
||||||
|
if( account.getToken() != null)
|
||||||
|
values.put(Sqlite.COL_OAUTHTOKEN, account.getToken());
|
||||||
|
values.put(Sqlite.COL_SENSITIVE, account.isSensitive());
|
||||||
|
values.put(Sqlite.COL_PRIVACY, account.getPrivacy());
|
||||||
return db.update(Sqlite.TABLE_USER_ACCOUNT,
|
return db.update(Sqlite.TABLE_USER_ACCOUNT,
|
||||||
values, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_USERNAME + " =?",
|
values, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_USERNAME + " =?",
|
||||||
new String[]{account.getId(), account.getUsername()});
|
new String[]{account.getId(), account.getUsername()});
|
||||||
|
@ -325,6 +369,8 @@ public class AccountDAO {
|
||||||
account.setClient_id(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_ID)));
|
account.setClient_id(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_ID)));
|
||||||
account.setClient_secret(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_SECRET)));
|
account.setClient_secret(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_SECRET)));
|
||||||
account.setRefresh_token(c.getString(c.getColumnIndex(Sqlite.COL_REFRESH_TOKEN)));
|
account.setRefresh_token(c.getString(c.getColumnIndex(Sqlite.COL_REFRESH_TOKEN)));
|
||||||
|
account.setSensitive(c.getInt(c.getColumnIndex(Sqlite.COL_SENSITIVE)) == 1);
|
||||||
|
account.setPrivacy((c.getString(c.getColumnIndex(Sqlite.COL_PRIVACY))));
|
||||||
//Close the cursor
|
//Close the cursor
|
||||||
c.close();
|
c.close();
|
||||||
|
|
||||||
|
@ -368,6 +414,8 @@ public class AccountDAO {
|
||||||
account.setClient_id(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_ID)));
|
account.setClient_id(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_ID)));
|
||||||
account.setClient_secret(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_SECRET)));
|
account.setClient_secret(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_SECRET)));
|
||||||
account.setRefresh_token(c.getString(c.getColumnIndex(Sqlite.COL_REFRESH_TOKEN)));
|
account.setRefresh_token(c.getString(c.getColumnIndex(Sqlite.COL_REFRESH_TOKEN)));
|
||||||
|
account.setSensitive(c.getInt(c.getColumnIndex(Sqlite.COL_SENSITIVE)) == 1);
|
||||||
|
account.setPrivacy((c.getString(c.getColumnIndex(Sqlite.COL_PRIVACY))));
|
||||||
accounts.add(account);
|
accounts.add(account);
|
||||||
}
|
}
|
||||||
//Close the cursor
|
//Close the cursor
|
||||||
|
|
|
@ -46,7 +46,7 @@ import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
|
|
||||||
public class Sqlite extends SQLiteOpenHelper {
|
public class Sqlite extends SQLiteOpenHelper {
|
||||||
|
|
||||||
public static final int DB_VERSION = 28;
|
public static final int DB_VERSION = 29;
|
||||||
public static final String DB_NAME = "mastodon_etalab_db";
|
public static final String DB_NAME = "mastodon_etalab_db";
|
||||||
public static SQLiteDatabase db;
|
public static SQLiteDatabase db;
|
||||||
private static Sqlite sInstance;
|
private static Sqlite sInstance;
|
||||||
|
@ -115,6 +115,7 @@ public class Sqlite extends SQLiteOpenHelper {
|
||||||
static final String COL_IS_MODERATOR = "IS_MODERATOR";
|
static final String COL_IS_MODERATOR = "IS_MODERATOR";
|
||||||
static final String COL_IS_ADMIN = "IS_ADMIN";
|
static final String COL_IS_ADMIN = "IS_ADMIN";
|
||||||
static final String COL_UPDATED_AT = "UPDATED_AT";
|
static final String COL_UPDATED_AT = "UPDATED_AT";
|
||||||
|
static final String COL_PRIVACY = "PRIVACY";
|
||||||
|
|
||||||
private static final String CREATE_TABLE_USER_ACCOUNT = "CREATE TABLE " + TABLE_USER_ACCOUNT + " ("
|
private static final String CREATE_TABLE_USER_ACCOUNT = "CREATE TABLE " + TABLE_USER_ACCOUNT + " ("
|
||||||
+ COL_USER_ID + " TEXT PRIMARY KEY, " + COL_USERNAME + " TEXT NOT NULL, " + COL_ACCT + " TEXT NOT NULL, "
|
+ COL_USER_ID + " TEXT PRIMARY KEY, " + COL_USERNAME + " TEXT NOT NULL, " + COL_ACCT + " TEXT NOT NULL, "
|
||||||
|
@ -389,6 +390,9 @@ public class Sqlite extends SQLiteOpenHelper {
|
||||||
db.execSQL(CREATE_TABLE_TRACKING_BLOCK);
|
db.execSQL(CREATE_TABLE_TRACKING_BLOCK);
|
||||||
case 27:
|
case 27:
|
||||||
db.execSQL(CREATE_TABLE_TIMELINES);
|
db.execSQL(CREATE_TABLE_TIMELINES);
|
||||||
|
case 28:
|
||||||
|
db.execSQL("ALTER TABLE " + TABLE_USER_ACCOUNT + " ADD COLUMN " + COL_PRIVACY + " TEXT");
|
||||||
|
db.execSQL("ALTER TABLE " + TABLE_USER_ACCOUNT + " ADD COLUMN " + COL_SENSITIVE + " INTEGER DEFAULT 0");
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,6 +207,13 @@
|
||||||
android:text="@string/set_lock_account"
|
android:text="@string/set_lock_account"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<!-- Sensitive content -->
|
||||||
|
<CheckBox
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:id="@+id/set_sensitive_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:text="@string/set_sensitive_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
|
|
|
@ -940,6 +940,7 @@
|
||||||
<string name="warning_main_timeline">Main timelines can only be hidden!</string>
|
<string name="warning_main_timeline">Main timelines can only be hidden!</string>
|
||||||
<string name="action_bbcode">BBCode</string>
|
<string name="action_bbcode">BBCode</string>
|
||||||
<string name="add_timeline">Add a timeline</string>
|
<string name="add_timeline">Add a timeline</string>
|
||||||
|
<string name="set_sensitive_content">Always mark media as sensitive</string>
|
||||||
|
|
||||||
<plurals name="number_of_vote">
|
<plurals name="number_of_vote">
|
||||||
<item quantity="one">%d vote</item>
|
<item quantity="one">%d vote</item>
|
||||||
|
|
Loading…
Reference in New Issue