diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-03-31 11:06:09 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-03-31 11:06:09 +0200 |
commit | 721bbf47774f452ec8a87a56f1042b555022efba (patch) | |
tree | f91980cce03bd61bd51c209d5119a82e163de64a /src | |
parent | bde39e88511ca1ffd542ab587ab507382b8c77ae (diff) |
add activity to define some important privacy settings on first start
Diffstat (limited to '')
21 files changed, 565 insertions, 59 deletions
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index d458673da..71b2e5909 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -306,6 +306,10 @@ android:label="@string/enter_your_name" android:launchMode="singleTask" /> <activity + android:name=".ui.SetSettingsActivity" + android:label="@string/title_activity_settings" + android:launchMode="singleTask" /> + <activity android:name=".ui.MucUsersActivity" android:label="@string/group_chat_members" /> diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index b06ebc85d..caea57fc8 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -164,6 +164,12 @@ import de.pixart.messenger.xmpp.stanzas.PresencePacket; import me.leolin.shortcutbadger.ShortcutBadger; import rocks.xmpp.addr.Jid; +import static de.pixart.messenger.ui.SettingsActivity.CHAT_STATES; +import static de.pixart.messenger.ui.SettingsActivity.CONFIRM_MESSAGES; +import static de.pixart.messenger.ui.SettingsActivity.ENABLE_MULTI_ACCOUNTS; +import static de.pixart.messenger.ui.SettingsActivity.INDICATE_RECEIVED; +import static de.pixart.messenger.ui.SettingsActivity.ENABLE_MULTI_ACCOUNTS; + public class XmppConnectionService extends Service { public static final String ACTION_REPLY_TO_CONVERSATION = "reply_to_conversations"; @@ -3912,7 +3918,7 @@ public class XmppConnectionService extends Service { } public boolean confirmMessages() { - return getBooleanPreference("confirm_messages", R.bool.confirm_messages); + return getBooleanPreference(CONFIRM_MESSAGES, R.bool.confirm_messages); } public boolean allowMessageCorrection() { @@ -3920,7 +3926,7 @@ public class XmppConnectionService extends Service { } public boolean sendChatStates() { - return getBooleanPreference("chat_states", R.bool.chat_states); + return getBooleanPreference(CHAT_STATES, R.bool.chat_states); } private boolean synchronizeWithBookmarks() { @@ -3928,7 +3934,7 @@ public class XmppConnectionService extends Service { } public boolean indicateReceived() { - return getBooleanPreference("indicate_received", R.bool.indicate_received); + return getBooleanPreference(INDICATE_RECEIVED, R.bool.indicate_received); } public boolean useTorToConnect() { @@ -3948,7 +3954,7 @@ public class XmppConnectionService extends Service { } public boolean multipleAccounts() { - return getBooleanPreference("enable_multi_accounts", R.bool.enable_multi_accounts); + return getBooleanPreference(ENABLE_MULTI_ACCOUNTS, R.bool.enable_multi_accounts); } public int unreadCount() { diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java index e84e657b7..009ea217e 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java @@ -95,6 +95,7 @@ import de.pixart.messenger.xmpp.chatstate.ChatState; import rocks.xmpp.addr.Jid; import static de.pixart.messenger.ui.ConversationFragment.REQUEST_DECRYPT_PGP; +import static de.pixart.messenger.ui.SettingsActivity.USE_INTERNAL_UPDATER; public class ConversationsActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead, XmppConnectionService.OnAccountUpdate, XmppConnectionService.OnConversationUpdate, XmppConnectionService.OnRosterUpdate, OnUpdateBlocklist, XmppConnectionService.OnShowErrorToast, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoomDestroy { @@ -195,10 +196,12 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio System.exit(0); } - if (xmppConnectionService.getAccounts().size() != 0) { - if (xmppConnectionService.hasInternetConnection()) { - if (xmppConnectionService.isWIFI() || (xmppConnectionService.isMobile() && !xmppConnectionService.isMobileRoaming())) { - AppUpdate(xmppConnectionService.installedFrom()); + if (useInternalUpdater()) { + if (xmppConnectionService.getAccounts().size() != 0) { + if (xmppConnectionService.hasInternetConnection()) { + if (xmppConnectionService.isWIFI() || (xmppConnectionService.isMobile() && !xmppConnectionService.isMobileRoaming())) { + AppUpdate(xmppConnectionService.installedFrom()); + } } } } diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index f62d68bef..9f06bcf2a 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -299,7 +299,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat overridePendingTransition(R.animator.fade_in, R.animator.fade_out); finish(); } else if (mInitMode && mAccount != null && mAccount.getStatus() == Account.State.ONLINE) { - runOnUiThread(this::performPostVerificationRedirect); + runOnUiThread(this::next); } if (mAccount != null) { updateAccountInformation(false); @@ -307,7 +307,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat updateSaveButton(); } - private void performPostVerificationRedirect() { + private void next() { if (redirectInProgress.compareAndSet(false, true)) { Intent intent = new Intent(this, EnterNameActivity.class); startActivity(intent); diff --git a/src/main/java/de/pixart/messenger/ui/EnterNameActivity.java b/src/main/java/de/pixart/messenger/ui/EnterNameActivity.java index 1f59901a6..ccfd88dad 100644 --- a/src/main/java/de/pixart/messenger/ui/EnterNameActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EnterNameActivity.java @@ -13,13 +13,12 @@ import de.pixart.messenger.databinding.ActivityEnterNameBinding; import de.pixart.messenger.entities.Account; import de.pixart.messenger.services.XmppConnectionService; import de.pixart.messenger.utils.AccountUtils; +import de.pixart.messenger.utils.FirstStartManager; public class EnterNameActivity extends XmppActivity implements XmppConnectionService.OnAccountUpdate { private ActivityEnterNameBinding binding; - private Account account; - private AtomicBoolean setNick = new AtomicBoolean(false); @Override @@ -28,19 +27,38 @@ public class EnterNameActivity extends XmppActivity implements XmppConnectionSer this.binding = DataBindingUtil.setContentView(this, R.layout.activity_enter_name); setSupportActionBar((Toolbar) this.binding.toolbar); this.binding.next.setOnClickListener(this::next); + updateNextButton(); this.setNick.set(savedInstanceState != null && savedInstanceState.getBoolean("set_nick", false)); } + private void updateNextButton() { + if (account != null && (account.getStatus() == Account.State.CONNECTING || account.getStatus() == Account.State.REGISTRATION_SUCCESSFUL)) { + this.binding.next.setEnabled(false); + this.binding.next.setText(R.string.account_status_connecting); + } else if (account != null && (account.getStatus() == Account.State.ONLINE)) { + this.binding.next.setEnabled(true); + this.binding.next.setText(R.string.next); + } + } + private void next(View view) { + FirstStartManager firstStartManager = new FirstStartManager(this); if (account != null) { String name = this.binding.name.getText().toString().trim(); account.setDisplayName(name); xmppConnectionService.publishDisplayName(account); - Intent intent = new Intent(this, PublishProfilePictureActivity.class); - intent.putExtra(PublishProfilePictureActivity.EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString()); - intent.putExtra("setup", true); - startActivity(intent); - overridePendingTransition(R.animator.fade_in, R.animator.fade_out); + if (firstStartManager.isFirstTimeLaunch()) { + Intent intent = new Intent(this, SetSettingsActivity.class); + intent.putExtra("setup", true); + startActivity(intent); + overridePendingTransition(R.animator.fade_in, R.animator.fade_out); + } else { + Intent intent = new Intent(this, PublishProfilePictureActivity.class); + intent.putExtra(PublishProfilePictureActivity.EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString()); + intent.putExtra("setup", true); + startActivity(intent); + overridePendingTransition(R.animator.fade_in, R.animator.fade_out); + } } finish(); } @@ -54,12 +72,14 @@ public class EnterNameActivity extends XmppActivity implements XmppConnectionSer @Override protected void refreshUiReal() { checkSuggestPreviousNick(); + updateNextButton(); } @Override void onBackendConnected() { this.account = AccountUtils.getFirst(xmppConnectionService); checkSuggestPreviousNick(); + updateNextButton(); } private void checkSuggestPreviousNick() { diff --git a/src/main/java/de/pixart/messenger/ui/SetSettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SetSettingsActivity.java new file mode 100644 index 000000000..74786b6a9 --- /dev/null +++ b/src/main/java/de/pixart/messenger/ui/SetSettingsActivity.java @@ -0,0 +1,171 @@ +package de.pixart.messenger.ui; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.databinding.DataBindingUtil; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.support.v7.app.AlertDialog; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.View; + +import de.pixart.messenger.Config; +import de.pixart.messenger.R; +import de.pixart.messenger.databinding.ActivitySetSettingsBinding; +import de.pixart.messenger.entities.Account; +import de.pixart.messenger.services.XmppConnectionService; +import de.pixart.messenger.utils.AccountUtils; +import de.pixart.messenger.utils.FirstStartManager; + +import static de.pixart.messenger.ui.SettingsActivity.BROADCAST_LAST_ACTIVITY; +import static de.pixart.messenger.ui.SettingsActivity.CHAT_STATES; +import static de.pixart.messenger.ui.SettingsActivity.CONFIRM_MESSAGES; +import static de.pixart.messenger.ui.SettingsActivity.FORBID_SCREENSHOTS; +import static de.pixart.messenger.ui.SettingsActivity.SHOW_LINKS_INSIDE; +import static de.pixart.messenger.ui.SettingsActivity.SHOW_MAPS_INSIDE; + +public class SetSettingsActivity extends XmppActivity implements XmppConnectionService.OnAccountUpdate { + ActivitySetSettingsBinding binding; + Account account; + static final int FORDBIDSCREENSHOTS = 1; + static final int SHOWWEBLINKS = 2; + static final int SHOWMAPPREVIEW = 3; + static final int CHATSTATES = 4; + static final int CONFIRMMESSAGES = 5; + static final int LASTSEEN = 6; + + @Override + protected void refreshUiReal() { + createInfoMenu(); + } + + @Override + void onBackendConnected() { + this.account = AccountUtils.getFirst(xmppConnectionService); + refreshUi(); + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + this.binding = DataBindingUtil.setContentView(this, R.layout.activity_set_settings); + setSupportActionBar((Toolbar) this.binding.toolbar); + this.binding.next.setOnClickListener(this::next); + createInfoMenu(); + getDefaults(); + } + + private void createInfoMenu() { + this.binding.actionInfoForbidScreenshots.setOnClickListener(string -> showInfo(FORDBIDSCREENSHOTS)); + this.binding.actionInfoShowWeblinks.setOnClickListener(string -> showInfo(SHOWWEBLINKS)); + this.binding.actionInfoShowMapPreviews.setOnClickListener(string -> showInfo(SHOWMAPPREVIEW)); + this.binding.actionInfoChatStates.setOnClickListener(string -> showInfo(CHATSTATES)); + this.binding.actionInfoConfirmMessages.setOnClickListener(string -> showInfo(CONFIRMMESSAGES)); + this.binding.actionInfoLastSeen.setOnClickListener(string -> showInfo(LASTSEEN)); + } + + private void getDefaults() { + this.binding.forbidScreenshots.setChecked(getResources().getBoolean(R.bool.screen_security)); + this.binding.showLinks.setChecked(getResources().getBoolean(R.bool.show_links_inside)); + this.binding.showMappreview.setChecked(getResources().getBoolean(R.bool.show_maps_inside)); + this.binding.chatStates.setChecked(getResources().getBoolean(R.bool.chat_states)); + this.binding.confirmMessages.setChecked(getResources().getBoolean(R.bool.confirm_messages)); + this.binding.lastSeen.setChecked(getResources().getBoolean(R.bool.last_activity)); + } + + private void next(View view) { + setSettings(); + FirstStartManager firstStartManager = new FirstStartManager(this); + firstStartManager.setFirstTimeLaunch(false); + if (account != null) { + Intent intent = new Intent(this, PublishProfilePictureActivity.class); + intent.putExtra(PublishProfilePictureActivity.EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString()); + intent.putExtra("setup", true); + startActivity(intent); + overridePendingTransition(R.animator.fade_in, R.animator.fade_out); + } + finish(); + } + + private void showInfo(int setting) { + Log.d(Config.LOGTAG, "STRING " + setting); + String title; + String message; + switch (setting) { + case FORDBIDSCREENSHOTS: + title = getString(R.string.pref_screen_security); + message = getString(R.string.pref_screen_security_summary); + break; + case SHOWWEBLINKS: + title = getString(R.string.pref_show_links_inside); + message = getString(R.string.pref_show_links_inside_summary); + break; + case SHOWMAPPREVIEW: + title = getString(R.string.pref_show_mappreview_inside); + message = getString(R.string.pref_show_mappreview_inside_summary); + break; + case CHATSTATES: + title = getString(R.string.pref_chat_states); + message = getString(R.string.pref_chat_states_summary); + break; + case CONFIRMMESSAGES: + title = getString(R.string.pref_confirm_messages); + message = getString(R.string.pref_confirm_messages_summary); + break; + case LASTSEEN: + title = getString(R.string.pref_broadcast_last_activity); + message = getString(R.string.pref_broadcast_last_activity_summary); + break; + default: + title = getString(R.string.error); + message = getString(R.string.error); + } + Log.d(Config.LOGTAG, "STRING value " + title); + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(title); + builder.setMessage(message); + builder.setNeutralButton(getString(R.string.ok), null); + builder.create().show(); + } + + + private void setSettings() { + final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); + if (this.binding.forbidScreenshots.isChecked()) { + preferences.edit().putBoolean(FORBID_SCREENSHOTS, true).apply(); + } else { + preferences.edit().putBoolean(FORBID_SCREENSHOTS, false).apply(); + } + if (this.binding.showLinks.isChecked()) { + preferences.edit().putBoolean(SHOW_LINKS_INSIDE, true).apply(); + } else { + preferences.edit().putBoolean(SHOW_LINKS_INSIDE, false).apply(); + } + if (this.binding.showMappreview.isChecked()) { + preferences.edit().putBoolean(SHOW_MAPS_INSIDE, true).apply(); + } else { + preferences.edit().putBoolean(SHOW_MAPS_INSIDE, false).apply(); + } + if (this.binding.chatStates.isChecked()) { + preferences.edit().putBoolean(CHAT_STATES, true).apply(); + } else { + preferences.edit().putBoolean(CHAT_STATES, false).apply(); + } + if (this.binding.confirmMessages.isChecked()) { + preferences.edit().putBoolean(CONFIRM_MESSAGES, true).apply(); + } else { + preferences.edit().putBoolean(CONFIRM_MESSAGES, false).apply(); + } + if (this.binding.lastSeen.isChecked()) { + preferences.edit().putBoolean(BROADCAST_LAST_ACTIVITY, true).apply(); + } else { + preferences.edit().putBoolean(BROADCAST_LAST_ACTIVITY, false).apply(); + } + } + + @Override + public void onAccountUpdate() { + refreshUi(); + } +} diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java index 7d6f32dd8..9e321e079 100644 --- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java @@ -56,12 +56,18 @@ public class SettingsActivity extends XmppActivity implements public static final String OMEMO_SETTING = "omemo"; public static final String SHOW_FOREGROUND_SERVICE = "show_foreground_service"; public static final String USE_BUNDLED_EMOJIS = "use_bundled_emoji"; - public static final String USE_MULTI_ACCOUNTS = "use_multi_accounts"; + public static final String ENABLE_MULTI_ACCOUNTS = "enable_multi_accounts"; public static final String QUICK_SHARE_ATTACHMENT_CHOICE = "quick_share_attachment_choice"; public static final String NUMBER_OF_ACCOUNTS = "number_of_accounts"; public static final String PLAY_GIF_INSIDE = "play_gif_inside"; + public static final String USE_INTERNAL_UPDATER = "use_internal_updater"; public static final String SHOW_LINKS_INSIDE = "show_links_inside"; + public static final String SHOW_MAPS_INSIDE = "show_maps_inside"; public static final String PREFER_XMPP_AVATAR = "prefer_xmpp_avatar"; + public static final String CHAT_STATES = "chat_states"; + public static final String FORBID_SCREENSHOTS = "screen_security"; + public static final String CONFIRM_MESSAGES = "confirm_messages"; + public static final String INDICATE_RECEIVED = "indicate_received"; public static final int REQUEST_CREATE_BACKUP = 0xbf8701; Preference multiAccountPreference; @@ -438,7 +444,7 @@ public class SettingsActivity extends XmppActivity implements @Override public void onSharedPreferenceChanged(SharedPreferences preferences, String name) { final List<String> resendPresence = Arrays.asList( - "confirm_messages", + CONFIRM_MESSAGES, DND_ON_SILENT_MODE, AWAY_WHEN_SCREEN_IS_OFF, "allow_message_correction", diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index afc319048..936c62390 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -97,6 +97,7 @@ import pl.droidsonroids.gif.GifDrawable; import rocks.xmpp.addr.Jid; import static de.pixart.messenger.ui.SettingsActivity.USE_BUNDLED_EMOJIS; +import static de.pixart.messenger.ui.SettingsActivity.USE_INTERNAL_UPDATER; public abstract class XmppActivity extends ActionBarActivity { @@ -455,6 +456,10 @@ public abstract class XmppActivity extends ActionBarActivity { return getBooleanPreference("display_enter_key", R.bool.display_enter_key); } + public boolean useInternalUpdater() { + return getBooleanPreference(USE_INTERNAL_UPDATER, R.bool.use_internal_updater); + } + public SharedPreferences getPreferences() { return PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); } diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index df063bcdb..be483a5f6 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -84,6 +84,7 @@ import pl.droidsonroids.gif.GifImageView; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import static de.pixart.messenger.ui.SettingsActivity.PLAY_GIF_INSIDE; import static de.pixart.messenger.ui.SettingsActivity.SHOW_LINKS_INSIDE; +import static de.pixart.messenger.ui.SettingsActivity.SHOW_MAPS_INSIDE; public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextView.CopyHandler { @@ -107,6 +108,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie private boolean mIndicateReceived = false; private boolean mPlayGifInside = false; private boolean mShowLinksInside = false; + private boolean mShowMapsInside = false; private OnQuoteListener onQuoteListener; public MessageAdapter(XmppActivity activity, List<Message> messages) { @@ -740,39 +742,43 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie viewHolder.audioPlayer.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.GONE); String url = GeoHelper.MapPreviewUri(message); - viewHolder.image.setVisibility(View.VISIBLE); viewHolder.gifImage.setVisibility(View.GONE); viewHolder.richlinkview.setVisibility(View.GONE); - double target = metrics.density * 200; - int scaledW; - int scaledH; - if (Math.max(500, 500) * metrics.density <= target) { - scaledW = (int) (500 * metrics.density); - scaledH = (int) (500 * metrics.density); - } else if (Math.max(500, 500) <= target) { - scaledW = 500; - scaledH = 500; + if (mShowMapsInside) { + viewHolder.image.setVisibility(View.VISIBLE); + double target = metrics.density * 200; + int scaledW; + int scaledH; + if (Math.max(500, 500) * metrics.density <= target) { + scaledW = (int) (500 * metrics.density); + scaledH = (int) (500 * metrics.density); + } else if (Math.max(500, 500) <= target) { + scaledW = 500; + scaledH = 500; + } else { + scaledW = (int) target; + scaledH = (int) (500 / ((double) 500 / target)); + } + LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(scaledW, scaledH); + layoutParams.setMargins(0, (int) (metrics.density * 4), 0, (int) (metrics.density * 4)); + viewHolder.image.setLayoutParams(layoutParams); + viewHolder.image.setOnClickListener(v -> showLocation(message)); + Picasso + .get() + .load(Uri.parse(url)) + .placeholder(R.drawable.ic_map_marker_grey600_48dp) + .error(R.drawable.ic_map_marker_grey600_48dp) + .into(viewHolder.image); + viewHolder.image.setMaxWidth(500); + viewHolder.image.setAdjustViewBounds(true); + viewHolder.download_button.setVisibility(View.GONE); } else { - scaledW = (int) target; - scaledH = (int) (500 / ((double) 500 / target)); + viewHolder.image.setVisibility(View.GONE); + viewHolder.download_button.setVisibility(View.VISIBLE); + viewHolder.download_button.setText(R.string.show_location); + viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_map_marker_grey600_48dp, 0, 0, 0); + viewHolder.download_button.setOnClickListener(v -> showLocation(message)); } - LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(scaledW, scaledH); - layoutParams.setMargins(0, (int) (metrics.density * 4), 0, (int) (metrics.density * 4)); - viewHolder.image.setLayoutParams(layoutParams); - viewHolder.image.setOnClickListener(v -> showLocation(message)); - Picasso - .get() - .load(Uri.parse(url)) - .placeholder(R.drawable.ic_map_marker_grey600_48dp) - .error(R.drawable.ic_map_marker_grey600_48dp) - .into(viewHolder.image); - viewHolder.image.setMaxWidth(500); - viewHolder.image.setAdjustViewBounds(true); - viewHolder.download_button.setVisibility(View.GONE); - viewHolder.download_button.setText(R.string.show_location); - viewHolder.download_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_map_marker_grey600_48dp, 0, 0, 0); - viewHolder.download_button.setOnClickListener(v -> showLocation(message)); - } private void displayAudioMessage(ViewHolder viewHolder, Message message, boolean darkBackground) { @@ -1183,6 +1189,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie this.mIndicateReceived = p.getBoolean("indicate_received", activity.getResources().getBoolean(R.bool.indicate_received)); this.mPlayGifInside = p.getBoolean(PLAY_GIF_INSIDE, activity.getResources().getBoolean(R.bool.play_gif_inside)); this.mShowLinksInside = p.getBoolean(SHOW_LINKS_INSIDE, activity.getResources().getBoolean(R.bool.show_links_inside)); + this.mShowMapsInside = p.getBoolean(SHOW_MAPS_INSIDE, activity.getResources().getBoolean(R.bool.show_maps_inside)); } public void setHighlightedTerm(List<String> terms) { diff --git a/src/main/java/de/pixart/messenger/utils/FirstStartManager.java b/src/main/java/de/pixart/messenger/utils/FirstStartManager.java new file mode 100644 index 000000000..755b4a265 --- /dev/null +++ b/src/main/java/de/pixart/messenger/utils/FirstStartManager.java @@ -0,0 +1,30 @@ +package de.pixart.messenger.utils; + +import android.content.Context; +import android.content.SharedPreferences; + +import static android.content.Context.MODE_PRIVATE; + +public class FirstStartManager { + Context context; + private SharedPreferences pref; + private SharedPreferences.Editor editor; + private static final String PREF_NAME = "de.pixart.messenger"; + private static final String IS_FIRST_TIME_LAUNCH = "IsFirstTimeLaunch"; + + public FirstStartManager(Context context) { + this.context = context; + pref = this.context.getSharedPreferences(PREF_NAME, MODE_PRIVATE); + editor = pref.edit(); + } + + public void setFirstTimeLaunch(boolean isFirstTime) { + editor = pref.edit(); + editor.putBoolean(IS_FIRST_TIME_LAUNCH, isFirstTime); + editor.commit(); + } + + public boolean isFirstTimeLaunch() { + return pref.getBoolean(IS_FIRST_TIME_LAUNCH, true); + } +} diff --git a/src/main/res/drawable-hdpi/ic_help_circle_outline_black_24dp.png b/src/main/res/drawable-hdpi/ic_help_circle_outline_black_24dp.png Binary files differnew file mode 100644 index 000000000..66c326231 --- /dev/null +++ b/src/main/res/drawable-hdpi/ic_help_circle_outline_black_24dp.png diff --git a/src/main/res/drawable-mdpi/ic_help_circle_outline_black_24dp.png b/src/main/res/drawable-mdpi/ic_help_circle_outline_black_24dp.png Binary files differnew file mode 100644 index 000000000..e7f0d63b5 --- /dev/null +++ b/src/main/res/drawable-mdpi/ic_help_circle_outline_black_24dp.png diff --git a/src/main/res/drawable-xhdpi/ic_help_circle_outline_black_24dp.png b/src/main/res/drawable-xhdpi/ic_help_circle_outline_black_24dp.png Binary files differnew file mode 100644 index 000000000..82f8a1ab0 --- /dev/null +++ b/src/main/res/drawable-xhdpi/ic_help_circle_outline_black_24dp.png diff --git a/src/main/res/drawable-xxhdpi/ic_help_circle_outline_black_24dp.png b/src/main/res/drawable-xxhdpi/ic_help_circle_outline_black_24dp.png Binary files differnew file mode 100644 index 000000000..3eb7065fe --- /dev/null +++ b/src/main/res/drawable-xxhdpi/ic_help_circle_outline_black_24dp.png diff --git a/src/main/res/drawable-xxxhdpi/ic_help_circle_outline_black_24dp.png b/src/main/res/drawable-xxxhdpi/ic_help_circle_outline_black_24dp.png Binary files differnew file mode 100644 index 000000000..5838e0bbd --- /dev/null +++ b/src/main/res/drawable-xxxhdpi/ic_help_circle_outline_black_24dp.png diff --git a/src/main/res/layout/activity_enter_name.xml b/src/main/res/layout/activity_enter_name.xml index cb446479d..e98d55233 100644 --- a/src/main/res/layout/activity_enter_name.xml +++ b/src/main/res/layout/activity_enter_name.xml @@ -54,6 +54,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" + android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:text="@string/next" android:textColor="?colorAccent" /> diff --git a/src/main/res/layout/activity_set_settings.xml b/src/main/res/layout/activity_set_settings.xml new file mode 100644 index 000000000..5560b6106 --- /dev/null +++ b/src/main/res/layout/activity_set_settings.xml @@ -0,0 +1,239 @@ +<?xml version="1.0" encoding="utf-8"?> +<layout xmlns:tools="http://schemas.android.com/tools" + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:card_view="http://schemas.android.com/apk/res-auto"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <include + android:id="@+id/toolbar" + layout="@layout/toolbar" /> + + <ScrollView + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fillViewport="true"> + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:padding="@dimen/card_padding_regular"> + + <TextView + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingBottom="@dimen/card_padding_regular" + android:text="@string/set_settings_intro" + android:textAppearance="@style/TextAppearance.Conversations.Subhead" /> + + <TableLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:shrinkColumns="0" + android:stretchColumns="0"> + + <TableRow + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingBottom="@dimen/card_padding_regular"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:ellipsize="end" + android:gravity="center_vertical" + android:text="@string/pref_screen_security" + android:textAppearance="@style/TextAppearance.Conversations.Body1" /> + + <ImageButton + android:id="@+id/action_info_forbid_screenshots" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:alpha="?attr/icon_alpha" + android:background="?attr/selectableItemBackgroundBorderless" + android:gravity="center_vertical" + android:padding="@dimen/image_button_padding" + android:src="@drawable/ic_help_circle_outline_black_24dp" /> + + <android.support.v7.widget.AppCompatCheckBox + android:id="@+id/forbid_screenshots" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:gravity="center_vertical" + android:padding="@dimen/image_button_padding" /> + </TableRow> + + <TableRow + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:paddingBottom="@dimen/card_padding_regular"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:ellipsize="end" + android:gravity="center_vertical" + android:text="@string/pref_show_links_inside" + android:textAppearance="@style/TextAppearance.Conversations.Body1" /> + + <ImageButton + android:id="@+id/action_info_show_weblinks" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:alpha="?attr/icon_alpha" + android:background="?attr/selectableItemBackgroundBorderless" + android:gravity="center_vertical" + android:padding="@dimen/image_button_padding" + android:src="@drawable/ic_help_circle_outline_black_24dp" /> + + <android.support.v7.widget.AppCompatCheckBox + android:id="@+id/show_links" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:gravity="center_vertical" /> + </TableRow> + + <TableRow + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:paddingBottom="@dimen/card_padding_regular"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:ellipsize="end" + android:gravity="center_vertical" + android:text="@string/pref_show_mappreview_inside" + android:textAppearance="@style/TextAppearance.Conversations.Body1" /> + + <ImageButton + android:id="@+id/action_info_show_map_previews" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:alpha="?attr/icon_alpha" + android:background="?attr/selectableItemBackgroundBorderless" + android:gravity="center_vertical" + android:padding="@dimen/image_button_padding" + android:src="@drawable/ic_help_circle_outline_black_24dp" /> + + <android.support.v7.widget.AppCompatCheckBox + android:id="@+id/show_mappreview" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:gravity="center_vertical" /> + </TableRow> + + <TableRow + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:paddingBottom="@dimen/card_padding_regular"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:ellipsize="end" + android:gravity="center_vertical" + android:text="@string/pref_chat_states" + android:textAppearance="@style/TextAppearance.Conversations.Body1" /> + + <ImageButton + android:id="@+id/action_info_chat_states" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:alpha="?attr/icon_alpha" + android:background="?attr/selectableItemBackgroundBorderless" + android:gravity="center_vertical" + android:padding="@dimen/image_button_padding" + android:src="@drawable/ic_help_circle_outline_black_24dp" /> + + <android.support.v7.widget.AppCompatCheckBox + android:id="@+id/chat_states" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:gravity="center_vertical" /> + </TableRow> + + <TableRow + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:paddingBottom="@dimen/card_padding_regular"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:ellipsize="end" + android:gravity="center_vertical" + android:text="@string/pref_confirm_messages" + android:textAppearance="@style/TextAppearance.Conversations.Body1" /> + + <ImageButton + android:id="@+id/action_info_confirm_messages" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:alpha="?attr/icon_alpha" + android:background="?attr/selectableItemBackgroundBorderless" + android:gravity="center_vertical" + android:padding="@dimen/image_button_padding" + android:src="@drawable/ic_help_circle_outline_black_24dp" /> + + <android.support.v7.widget.AppCompatCheckBox + android:id="@+id/confirm_messages" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:gravity="center_vertical" /> + </TableRow> + + <TableRow + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:paddingBottom="@dimen/card_padding_regular"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:ellipsize="end" + android:gravity="center_vertical" + android:text="@string/pref_broadcast_last_activity" + android:textAppearance="@style/TextAppearance.Conversations.Body1" /> + + <ImageButton + android:id="@+id/action_info_last_seen" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:alpha="?attr/icon_alpha" + android:background="?attr/selectableItemBackgroundBorderless" + android:gravity="center_vertical" + android:padding="@dimen/image_button_padding" + android:src="@drawable/ic_help_circle_outline_black_24dp" /> + + <android.support.v7.widget.AppCompatCheckBox + android:id="@+id/last_seen" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:gravity="center_vertical" /> + </TableRow> + </TableLayout> + </LinearLayout> + + <Button + android:id="@+id/next" + style="@style/Widget.Conversations.Button.Borderless" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentEnd="true" + android:layout_alignParentRight="true" + android:layout_alignParentBottom="true" + android:text="@string/next" + android:textColor="?colorAccent" /> + </RelativeLayout> + </ScrollView> + </LinearLayout> +</layout>
\ No newline at end of file diff --git a/src/main/res/values/bools.xml b/src/main/res/values/bools.xml deleted file mode 100644 index f5d0a43b6..000000000 --- a/src/main/res/values/bools.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <bool name="prefer_xmpp_avatar">true</bool> - <bool name="show_links_inside">true</bool> -</resources>
\ No newline at end of file diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml index e8e0c9206..dc4f7ead3 100644 --- a/src/main/res/values/defaults.xml +++ b/src/main/res/values/defaults.xml @@ -113,6 +113,10 @@ <bool name="quick_share_attachment_choice">true</bool> <bool name="screen_security">false</bool> <bool name="play_gif_inside">false</bool> + <bool name="prefer_xmpp_avatar">true</bool> + <bool name="show_links_inside">true</bool> + <bool name="show_maps_inside">true</bool> + <bool name="use_internal_updater">true</bool> <string-array name="domains"> <item>pix-art.de</item> diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index d4dd1c5cf..00f199a0f 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -110,7 +110,7 @@ <string name="pref_sound">Ringtone</string> <string name="pref_sound_summary">Play sound when a new message arrives</string> <string name="pref_send_crash">Send crash reports</string> - <string name="pref_send_crash_summary">By sending in stack traces you are helping the ongoing development of Pix-Art Messenger</string> + <string name="pref_send_crash_summary">By sending stack traces you are helping the ongoing development of Pix-Art Messenger</string> <string name="pref_confirm_messages">Confirm Messages</string> <string name="pref_confirm_messages_summary">Let your contacts know when you have received and read their messages</string> <string name="pref_ui_options">UI</string> @@ -890,4 +890,9 @@ <string name="mgmt_account_password_forgotten">Password forgotten</string> <string name="password_forgotten_title">Password forgotten</string> <string name="password_forgotten_text">You have forgotten your account password? We will now try to open the support website of your provider.</string> + <string name="set_settings_intro">Here you can set some important privacy settings to your needs. All the settings can also be modified later.</string> + <string name="pref_show_mappreview_inside_summary">Show map previews directly inside the chat view</string> + <string name="pref_show_mappreview_inside">Show previews of locations in chat</string> + <string name="pref_use_internal_updater_summary">Let the messenger look for new app updates once a day</string> + <string name="pref_use_internal_updater">look for updates</string> </resources> diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 15fe0fc34..069adc3e8 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -77,11 +77,6 @@ android:summary="@string/pref_play_gif_inside_summary" android:title="@string/pref_play_gif_inside" /> <CheckBoxPreference - android:defaultValue="@bool/show_links_inside" - android:key="show_links_inside" - android:summary="@string/pref_show_links_inside_summary" - android:title="@string/pref_show_links_inside" /> - <CheckBoxPreference android:defaultValue="@bool/prefer_xmpp_avatar" android:key="prefer_xmpp_avatar" android:summary="@string/pref_prefer_xmpp_avatar_summary" @@ -301,6 +296,21 @@ android:summary="@string/pref_broadcast_last_activity_summary" android:title="@string/pref_broadcast_last_activity" /> <CheckBoxPreference + android:defaultValue="@bool/use_internal_updater" + android:key="use_internal_updater" + android:summary="@string/pref_use_internal_updater_summary" + android:title="@string/pref_use_internal_updater" /> + <CheckBoxPreference + android:defaultValue="@bool/show_links_inside" + android:key="show_links_inside" + android:summary="@string/pref_show_links_inside_summary" + android:title="@string/pref_show_links_inside" /> + <CheckBoxPreference + android:defaultValue="@bool/show_maps_inside" + android:key="show_maps_inside" + android:summary="@string/pref_show_mappreview_inside_summary" + android:title="@string/pref_show_mappreview_inside" /> + <CheckBoxPreference android:defaultValue="@bool/warn_unencrypted_chat" android:key="warn_unencrypted_chat" android:summary="@string/pref_warn_unencrypted_chat_summary" |