aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java2
-rw-r--r--src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java3
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationsActivity.java14
-rw-r--r--src/main/java/de/pixart/messenger/ui/IntroActivity.java134
-rw-r--r--src/main/java/de/pixart/messenger/ui/SettingsActivity.java35
-rw-r--r--src/main/java/de/pixart/messenger/ui/StartUI.java5
-rw-r--r--src/main/java/de/pixart/messenger/ui/util/IntroHelper.java39
7 files changed, 223 insertions, 9 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
index 043edfe49..6fdd8c50a 100644
--- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
@@ -54,6 +54,7 @@ import me.drakeet.support.toast.ToastCompat;
import rocks.xmpp.addr.Jid;
import static de.pixart.messenger.entities.Bookmark.printableValue;
+import static de.pixart.messenger.ui.util.IntroHelper.showIntro;
import static de.pixart.messenger.utils.StringUtils.changed;
public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnConfigurationPushed, TextWatcher, OnMediaLoaded {
@@ -262,6 +263,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
intent.putExtra("uuid", mConversation.getUuid());
startActivity(intent);
});
+ showIntro(this, true);
}
@Override
diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
index 4bee618f5..f8421cac9 100644
--- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
@@ -67,6 +67,8 @@ import de.pixart.messenger.xmpp.OnUpdateBlocklist;
import de.pixart.messenger.xmpp.XmppConnection;
import rocks.xmpp.addr.Jid;
+import static de.pixart.messenger.ui.util.IntroHelper.showIntro;
+
public class ContactDetailsActivity extends OmemoActivity implements OnAccountUpdate, OnRosterUpdate, OnUpdateBlocklist, OnKeyStatusUpdated, OnMediaLoaded {
public static final String ACTION_VIEW_CONTACT = "view_contact";
@@ -278,6 +280,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
mMediaAdapter = new MediaAdapter(this, R.dimen.media_size);
this.binding.media.setAdapter(mMediaAdapter);
GridManager.setupLayoutManager(this, this.binding.media, R.dimen.media_size);
+ showIntro(this, false);
}
@Override
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java
index 75b3ce91a..26e44a0f2 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java
@@ -40,17 +40,12 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
-import androidx.databinding.DataBindingUtil;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.Settings;
-import androidx.annotation.IdRes;
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.ActionBar;
-import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@@ -59,6 +54,12 @@ import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;
+import androidx.annotation.IdRes;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.widget.Toolbar;
+import androidx.databinding.DataBindingUtil;
+
import net.java.otr4j.session.SessionStatus;
import org.openintents.openpgp.util.OpenPgpApi;
@@ -73,6 +74,7 @@ import de.pixart.messenger.crypto.OmemoSetting;
import de.pixart.messenger.databinding.ActivityConversationsBinding;
import de.pixart.messenger.entities.Account;
import de.pixart.messenger.entities.Conversation;
+import de.pixart.messenger.entities.Conversational;
import de.pixart.messenger.entities.MucOptions;
import de.pixart.messenger.entities.Presence;
import de.pixart.messenger.services.XmppConnectionService;
@@ -83,6 +85,7 @@ import de.pixart.messenger.ui.interfaces.OnConversationSelected;
import de.pixart.messenger.ui.interfaces.OnConversationsListItemUpdated;
import de.pixart.messenger.ui.util.ActivityResult;
import de.pixart.messenger.ui.util.ConversationMenuConfigurator;
+import de.pixart.messenger.ui.util.IntroHelper;
import de.pixart.messenger.ui.util.PendingItem;
import de.pixart.messenger.utils.EmojiWrapper;
import de.pixart.messenger.utils.ExceptionHelper;
@@ -531,6 +534,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
} else {
invalidateActionBarTitle();
}
+ IntroHelper.showIntro(this, conversation.getMode() == Conversational.MODE_MULTI);
}
public boolean onXmppUriClicked(Uri uri) {
diff --git a/src/main/java/de/pixart/messenger/ui/IntroActivity.java b/src/main/java/de/pixart/messenger/ui/IntroActivity.java
new file mode 100644
index 000000000..802072efe
--- /dev/null
+++ b/src/main/java/de/pixart/messenger/ui/IntroActivity.java
@@ -0,0 +1,134 @@
+package de.pixart.messenger.ui;
+
+import android.content.Intent;
+import android.os.Bundle;
+
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+
+import com.github.paolorotolo.appintro.AppIntro;
+import com.github.paolorotolo.appintro.AppIntroFragment;
+import com.github.paolorotolo.appintro.model.SliderPage;
+
+import de.pixart.messenger.R;
+
+import static de.pixart.messenger.ui.util.IntroHelper.SaveIntroShown;
+
+public class IntroActivity extends AppIntro {
+ public static final String ACTIVITY = "activity";
+ public static final String MULTICHAT = "multi_chat";
+ public static final String START_UI = "StartUI";
+ public static final String CONVERSATIONS_ACTIVITY = "ConversationsActivity";
+ public static final String CONTACT_DETAILS_ACTIVITY = "ContactDetailsActivity";
+ public static final String CONFERENCE_DETAILS_ACTIVITY = "ConferenceDetailsActivity";
+ String activity = null;
+ boolean mode_multi = false;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final int backgroundColor = getResources().getColor(R.color.primary_dark);
+ final int barColor = getResources().getColor(R.color.primary);
+ final int separatorColor = getResources().getColor(R.color.accent);
+
+ setBarColor(barColor);
+ setSeparatorColor(separatorColor);
+ setProgressButtonEnabled(true);
+ showSkipButton(false);
+ setBackButtonVisibilityWithDone(true);
+ setGoBackLock(true);
+ setFadeAnimation();
+
+ final Intent intent = getIntent();
+ if (intent != null) {
+ activity = intent.getStringExtra(ACTIVITY);
+ mode_multi = intent.getBooleanExtra(MULTICHAT, false);
+ }
+ if (activity == null) {
+ finish();
+ }
+ switch (activity) {
+ case START_UI:
+ SliderPage welcome = new SliderPage();
+ welcome.setTitle(getString(R.string.welcome_header));
+ welcome.setDescription(getString(R.string.intro_desc_main));
+ welcome.setImageDrawable(R.drawable.main_logo);
+ welcome.setBgColor(backgroundColor);
+ addSlide(AppIntroFragment.newInstance(welcome));
+
+ SliderPage permissions = new SliderPage();
+ permissions.setTitle(getString(R.string.intro_permissions));
+ permissions.setDescription(getString(R.string.intro_desc_permissions));
+ permissions.setImageDrawable(R.drawable.intro_memory_icon);
+ permissions.setBgColor(backgroundColor);
+ addSlide(AppIntroFragment.newInstance(permissions));
+
+ SliderPage account = new SliderPage();
+ account.setTitle(getString(R.string.intro_account));
+ account.setDescription(getString(R.string.intro_desc_account));
+ account.setImageDrawable(R.drawable.intro_account_icon);
+ account.setBgColor(backgroundColor);
+ addSlide(AppIntroFragment.newInstance(account));
+
+ SliderPage startChatting = new SliderPage();
+ startChatting.setTitle(getString(R.string.intro_start_chatting));
+ startChatting.setDescription(getString(R.string.intro_desc_start_chatting));
+ startChatting.setImageDrawable(R.drawable.intro_start_chat_icon);
+ startChatting.setBgColor(backgroundColor);
+ addSlide(AppIntroFragment.newInstance(startChatting));
+ break;
+ case CONVERSATIONS_ACTIVITY:
+ SliderPage openChat = new SliderPage();
+ openChat.setTitle(getString(R.string.intro_start_chatting));
+ openChat.setDescription(getString(R.string.intro_desc_open_chat));
+ openChat.setImageDrawable(R.drawable.intro_start_chat_icon);
+ openChat.setBgColor(backgroundColor);
+ addSlide(AppIntroFragment.newInstance(openChat));
+
+ SliderPage chatDetails = new SliderPage();
+ chatDetails.setTitle(getString(R.string.intro_chat_details));
+ chatDetails.setDescription(getString(R.string.intro_desc_chat_details));
+ chatDetails.setImageDrawable(R.drawable.intro_account_details_icon);
+ chatDetails.setBgColor(backgroundColor);
+ addSlide(AppIntroFragment.newInstance(chatDetails));
+
+ if (mode_multi) {
+ SliderPage highlightUser = new SliderPage();
+ highlightUser.setTitle(getString(R.string.intro_highlight_user));
+ highlightUser.setDescription(getString(R.string.intro_desc_highlight_user));
+ highlightUser.setImageDrawable(R.drawable.intro_account_details_icon);
+ highlightUser.setBgColor(backgroundColor);
+ addSlide(AppIntroFragment.newInstance(highlightUser));
+ }
+ break;
+ case CONTACT_DETAILS_ACTIVITY:
+ case CONFERENCE_DETAILS_ACTIVITY:
+ SliderPage openChatDetails = new SliderPage();
+ openChatDetails.setTitle(getString(R.string.intro_chat_details));
+ openChatDetails.setDescription(getString(R.string.intro_desc_open_chat_details));
+ openChatDetails.setImageDrawable(R.drawable.intro_account_details_icon);
+ openChatDetails.setBgColor(backgroundColor);
+ addSlide(AppIntroFragment.newInstance(openChatDetails));
+ }
+ }
+
+ @Override
+ public void onSkipPressed(Fragment currentFragment) {
+ super.onSkipPressed(currentFragment);
+ finish();
+ }
+
+ @Override
+ public void onDonePressed(Fragment currentFragment) {
+ super.onDonePressed(currentFragment);
+ SaveIntroShown(getBaseContext(), activity, mode_multi);
+ finish();
+ }
+
+ @Override
+ public void onSlideChanged(@Nullable Fragment oldFragment, @Nullable Fragment newFragment) {
+ super.onSlideChanged(oldFragment, newFragment);
+ // Do something when the slide changes.
+ }
+}
diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
index 26b1bfdd9..ba7508556 100644
--- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
@@ -15,18 +15,20 @@ import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
-import androidx.annotation.NonNull;
-import androidx.core.content.ContextCompat;
-import androidx.appcompat.app.AlertDialog;
import android.util.Log;
import android.widget.Toast;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
+import androidx.core.content.ContextCompat;
+
import java.io.File;
import java.security.KeyStoreException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import de.pixart.messenger.Config;
import de.pixart.messenger.R;
@@ -37,6 +39,7 @@ import de.pixart.messenger.services.ExportBackupService;
import de.pixart.messenger.services.MemorizingTrustManager;
import de.pixart.messenger.ui.util.StyledAttributes;
import de.pixart.messenger.utils.TimeframeUtils;
+import me.drakeet.support.toast.ToastCompat;
import rocks.xmpp.addr.Jid;
public class SettingsActivity extends XmppActivity implements
@@ -266,6 +269,15 @@ public class SettingsActivity extends XmppActivity implements
});
}
+ final Preference showIntroAgainPreference = mSettingsFragment.findPreference("show_intro");
+ if (showIntroAgainPreference != null) {
+ showIntroAgainPreference.setSummary(getString(R.string.pref_show_intro_summary));
+ showIntroAgainPreference.setOnPreferenceClickListener(preference -> {
+ showIntroAgain();
+ return true;
+ });
+ }
+
if (Config.ONLY_INTERNAL_STORAGE) {
final Preference cleanCachePreference = mSettingsFragment.findPreference("clean_cache");
if (cleanCachePreference != null) {
@@ -519,4 +531,21 @@ public class SettingsActivity extends XmppActivity implements
Log.d(Config.LOGTAG, "Get number of accounts from file: " + NumberOfAccounts);
return NumberOfAccounts;
}
+
+ private void showIntroAgain() {
+ SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(this.getBaseContext());
+ Map<String, ?> allEntries = getPrefs.getAll();
+ for (Map.Entry<String, ?> entry : allEntries.entrySet()) {
+ if (entry.getKey().contains("intro_shown_on_activity")) {
+ SharedPreferences.Editor e = getPrefs.edit();
+ e.putBoolean(entry.getKey(), true);
+ if (e.commit()) {
+ ToastCompat.makeText(this, R.string.show_intro_again, ToastCompat.LENGTH_SHORT).show();
+ } else {
+ ToastCompat.makeText(this, R.string.show_intro_again_failed, ToastCompat.LENGTH_SHORT).show();
+ }
+
+ }
+ }
+ }
}
diff --git a/src/main/java/de/pixart/messenger/ui/StartUI.java b/src/main/java/de/pixart/messenger/ui/StartUI.java
index 7abfc0912..c3c2596d2 100644
--- a/src/main/java/de/pixart/messenger/ui/StartUI.java
+++ b/src/main/java/de/pixart/messenger/ui/StartUI.java
@@ -9,14 +9,16 @@ import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
+import android.util.Log;
+
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
-import android.util.Log;
import java.util.List;
import de.pixart.messenger.Config;
import de.pixart.messenger.R;
+import de.pixart.messenger.ui.util.IntroHelper;
import pub.devrel.easypermissions.AfterPermissionGranted;
import pub.devrel.easypermissions.EasyPermissions;
@@ -33,6 +35,7 @@ public class StartUI extends AppCompatActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start_ui);
+ IntroHelper.showIntro(this, false);
requestNeededPermissions();
}
diff --git a/src/main/java/de/pixart/messenger/ui/util/IntroHelper.java b/src/main/java/de/pixart/messenger/ui/util/IntroHelper.java
new file mode 100644
index 000000000..817551c4f
--- /dev/null
+++ b/src/main/java/de/pixart/messenger/ui/util/IntroHelper.java
@@ -0,0 +1,39 @@
+package de.pixart.messenger.ui.util;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+
+import de.pixart.messenger.ui.IntroActivity;
+
+import static de.pixart.messenger.ui.IntroActivity.ACTIVITY;
+import static de.pixart.messenger.ui.IntroActivity.MULTICHAT;
+
+public class IntroHelper {
+ public static void showIntro(Activity activity, boolean mode_multi) {
+ Thread t = new Thread(() -> {
+ SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(activity.getBaseContext());
+ String activityname = activity.getClass().getSimpleName();
+ String INTRO = "intro_shown_on_activity_" + activityname + "_MultiMode_" + mode_multi;
+ boolean SHOW_INTRO = getPrefs.getBoolean(INTRO, true);
+
+ if (SHOW_INTRO) {
+ final Intent i = new Intent(activity, IntroActivity.class);
+ i.putExtra(ACTIVITY, activityname);
+ i.putExtra(MULTICHAT, mode_multi);
+ activity.runOnUiThread(() -> activity.startActivity(i));
+ }
+ });
+ t.start();
+ }
+
+ public static void SaveIntroShown(Context context, String activity, boolean mode_multi) {
+ SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ String INTRO = "intro_shown_on_activity_" + activity + "_MultiMode_" + mode_multi;
+ SharedPreferences.Editor e = getPrefs.edit();
+ e.putBoolean(INTRO, false);
+ e.apply();
+ }
+}