aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/pixart/messenger/ui/AboutActivity.java4
-rw-r--r--src/main/java/de/pixart/messenger/ui/AbstractSearchableListItemActivity.java3
-rw-r--r--src/main/java/de/pixart/messenger/ui/ChangePasswordActivity.java2
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java7
-rw-r--r--src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java7
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationsActivity.java3
-rw-r--r--src/main/java/de/pixart/messenger/ui/EditAccountActivity.java3
-rw-r--r--src/main/java/de/pixart/messenger/ui/LocationActivity.java6
-rw-r--r--src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java2
-rw-r--r--src/main/java/de/pixart/messenger/ui/ManageAccountActivity.java2
-rw-r--r--src/main/java/de/pixart/messenger/ui/MemorizingActivity.java2
-rw-r--r--src/main/java/de/pixart/messenger/ui/PublishProfilePictureActivity.java2
-rw-r--r--src/main/java/de/pixart/messenger/ui/SettingsActivity.java14
-rw-r--r--src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java101
-rw-r--r--src/main/java/de/pixart/messenger/ui/ShareViaAccountActivity.java3
-rw-r--r--src/main/java/de/pixart/messenger/ui/ShareWithActivity.java5
-rw-r--r--src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java122
-rw-r--r--src/main/java/de/pixart/messenger/ui/StartConversationActivity.java60
-rw-r--r--src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java8
-rw-r--r--src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java2
-rw-r--r--src/main/java/de/pixart/messenger/ui/WelcomeActivity.java1
-rw-r--r--src/main/java/de/pixart/messenger/ui/XmppActivity.java11
22 files changed, 204 insertions, 166 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/AboutActivity.java b/src/main/java/de/pixart/messenger/ui/AboutActivity.java
index e00707d96..ac8b72ec0 100644
--- a/src/main/java/de/pixart/messenger/ui/AboutActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/AboutActivity.java
@@ -5,11 +5,15 @@ import android.support.v7.app.AppCompatActivity;
import de.pixart.messenger.R;
+import static de.pixart.messenger.ui.XmppActivity.configureActionBar;
+
public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
+ setSupportActionBar(findViewById(R.id.toolbar));
+ configureActionBar(getSupportActionBar());
}
}
diff --git a/src/main/java/de/pixart/messenger/ui/AbstractSearchableListItemActivity.java b/src/main/java/de/pixart/messenger/ui/AbstractSearchableListItemActivity.java
index 059df9bb8..91dc52ecf 100644
--- a/src/main/java/de/pixart/messenger/ui/AbstractSearchableListItemActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/AbstractSearchableListItemActivity.java
@@ -3,6 +3,7 @@ package de.pixart.messenger.ui;
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
+import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
@@ -95,6 +96,8 @@ public abstract class AbstractSearchableListItemActivity extends XmppActivity {
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_choose_contact);
+ setSupportActionBar((Toolbar) binding.toolbar);
+ configureActionBar(getSupportActionBar());
this.binding.chooseContactList.setFastScrollEnabled(true);
mListItemsAdapter = new ListItemAdapter(this, listItems);
this.binding.chooseContactList.setAdapter(mListItemsAdapter);
diff --git a/src/main/java/de/pixart/messenger/ui/ChangePasswordActivity.java b/src/main/java/de/pixart/messenger/ui/ChangePasswordActivity.java
index cbf9aaec5..ca4c01183 100644
--- a/src/main/java/de/pixart/messenger/ui/ChangePasswordActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ChangePasswordActivity.java
@@ -60,6 +60,8 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_change_password);
+ setSupportActionBar(findViewById(R.id.toolbar));
+ configureActionBar(getSupportActionBar());
Button mCancelButton = findViewById(R.id.left_button);
mCancelButton.setOnClickListener(view -> finish());
this.mChangePasswordButton = findViewById(R.id.right_button);
diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
index 119f06fc1..5dab8b9e7 100644
--- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
@@ -14,6 +14,7 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
@@ -278,10 +279,8 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
this.binding.destroy.setOnClickListener(destroyListener);
this.binding.destroy.getBackground().setColorFilter(getWarningButtonColor(), PorterDuff.Mode.MULTIPLY);
this.binding.mucMoreDetails.setVisibility(View.GONE);
- if (getSupportActionBar() != null) {
- getSupportActionBar().setHomeButtonEnabled(true);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- }
+ setSupportActionBar((Toolbar) binding.toolbar);
+ configureActionBar(getSupportActionBar());
this.binding.editNickButton.setOnClickListener(v -> quickEdit(mConversation.getMucOptions().getActualNick(),
0,
value -> {
diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
index 841961a14..42d7ab8da 100644
--- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
@@ -15,6 +15,7 @@ import android.provider.ContactsContract.Intents;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@@ -254,10 +255,8 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
this.messageFingerprint = getIntent().getStringExtra("fingerprint");
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_contact_details);
- if (getSupportActionBar() != null) {
- getSupportActionBar().setHomeButtonEnabled(true);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- }
+ setSupportActionBar((Toolbar) binding.toolbar);
+ configureActionBar(getSupportActionBar());
binding.showInactiveDevices.setOnClickListener(v -> {
showInactiveOmemo = !showInactiveOmemo;
populateView();
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java
index 69deb91e3..cb2bfa807 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java
@@ -50,6 +50,7 @@ import android.provider.Settings;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar;
+import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@@ -425,6 +426,8 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
super.onCreate(savedInstanceState);
new EmojiService(this).init(useBundledEmoji());
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_conversations);
+ setSupportActionBar((Toolbar) binding.toolbar);
+ configureActionBar(getSupportActionBar());
this.getFragmentManager().addOnBackStackChangedListener(this::invalidateActionBarTitle);
this.getFragmentManager().addOnBackStackChangedListener(this::showDialogsIfMainIsOverview);
this.initializeFragments();
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
index 8985c19cf..74e2910c6 100644
--- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
@@ -20,6 +20,7 @@ import android.support.design.widget.TextInputLayout;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
@@ -544,6 +545,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
this.mSavedInstanceInit = savedInstanceState.getBoolean("initMode", false);
}
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_edit_account);
+ setSupportActionBar((Toolbar) binding.toolbar);
+ configureActionBar(getSupportActionBar());
this.binding.accountJid.addTextChangedListener(this.mTextWatcher);
this.binding.accountJid.setOnFocusChangeListener(this.mEditTextFocusListener);
this.mAccountJidLayout = (TextInputLayout) findViewById(R.id.account_jid_layout);
diff --git a/src/main/java/de/pixart/messenger/ui/LocationActivity.java b/src/main/java/de/pixart/messenger/ui/LocationActivity.java
index ccf28bdf2..1e5f2a643 100644
--- a/src/main/java/de/pixart/messenger/ui/LocationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/LocationActivity.java
@@ -9,7 +9,7 @@ import android.support.v7.app.AppCompatActivity;
import de.pixart.messenger.Config;
-public abstract class LocationActivity extends AppCompatActivity implements LocationListener {
+public abstract class LocationActivity extends XmppActivity implements LocationListener {
private LocationManager locationManager;
@Override
@@ -51,13 +51,13 @@ public abstract class LocationActivity extends AppCompatActivity implements Loca
}
@Override
- protected void onPause() {
+ public void onPause() {
super.onPause();
pauseLocationUpdates();
}
@Override
- protected void onResume() {
+ public void onResume() {
super.onResume();
this.setmLastLocation(null);
diff --git a/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java b/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java
index 8c758be6d..90531b0fd 100644
--- a/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java
@@ -53,6 +53,8 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher {
}
super.onCreate(savedInstanceState);
setContentView(R.layout.magic_create);
+ setSupportActionBar(findViewById(R.id.toolbar));
+ configureActionBar(getSupportActionBar());
mFullJidDisplay = findViewById(R.id.full_jid);
mUsername = findViewById(R.id.username);
mRandom = new SecureRandom();
diff --git a/src/main/java/de/pixart/messenger/ui/ManageAccountActivity.java b/src/main/java/de/pixart/messenger/ui/ManageAccountActivity.java
index 9513c2fca..a5ca8a7b6 100644
--- a/src/main/java/de/pixart/messenger/ui/ManageAccountActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ManageAccountActivity.java
@@ -75,6 +75,8 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
setContentView(R.layout.activity_manage_accounts);
+ setSupportActionBar(findViewById(R.id.toolbar));
+ configureActionBar(getSupportActionBar());
if (savedInstanceState != null) {
String jid = savedInstanceState.getString(STATE_SELECTED_ACCOUNT);
if (jid != null) {
diff --git a/src/main/java/de/pixart/messenger/ui/MemorizingActivity.java b/src/main/java/de/pixart/messenger/ui/MemorizingActivity.java
index 8172e6f9c..2d9a2b499 100644
--- a/src/main/java/de/pixart/messenger/ui/MemorizingActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/MemorizingActivity.java
@@ -53,6 +53,8 @@ public class MemorizingActivity extends AppCompatActivity implements OnClickList
LOGGER.log(Level.FINE, "onCreate");
//setTheme(findTheme());
super.onCreate(savedInstanceState);
+ getLayoutInflater().inflate(R.layout.toolbar, findViewById(android.R.id.content));
+ setSupportActionBar(findViewById(R.id.toolbar));
}
@Override
diff --git a/src/main/java/de/pixart/messenger/ui/PublishProfilePictureActivity.java b/src/main/java/de/pixart/messenger/ui/PublishProfilePictureActivity.java
index 1dd23a3de..f59e9b30c 100644
--- a/src/main/java/de/pixart/messenger/ui/PublishProfilePictureActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/PublishProfilePictureActivity.java
@@ -95,6 +95,8 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_publish_profile_picture);
+ setSupportActionBar(findViewById(R.id.toolbar));
+ configureActionBar(getSupportActionBar());
this.avatar = findViewById(R.id.account_image);
this.cancelButton = findViewById(R.id.cancel_button);
this.publishButton = findViewById(R.id.publish_button);
diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
index eaefb1fa2..aa7407c32 100644
--- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java
@@ -58,29 +58,28 @@ public class SettingsActivity extends XmppActivity implements
public static final String USE_MULTI_ACCOUNTS = "use_multi_accounts";
public static final int REQUEST_WRITE_LOGS = 0xbf8701;
- private SettingsFragment mSettingsFragment;
-
Preference multiAccountPreference;
Preference BundledEmojiPreference;
-
boolean isMultiAccountChecked = false;
boolean isBundledEmojiChecked;
+ private SettingsFragment mSettingsFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_settings);
FragmentManager fm = getFragmentManager();
- mSettingsFragment = (SettingsFragment) fm.findFragmentById(android.R.id.content);
+ mSettingsFragment = (SettingsFragment) fm.findFragmentById(R.id.settings_content);
if (mSettingsFragment == null || !mSettingsFragment.getClass().equals(SettingsFragment.class)) {
mSettingsFragment = new SettingsFragment();
- fm.beginTransaction().replace(android.R.id.content, mSettingsFragment).commit();
+ fm.beginTransaction().replace(R.id.settings_content, mSettingsFragment).commit();
}
mSettingsFragment.setActivityIntent(getIntent());
-
this.mTheme = findTheme();
setTheme(this.mTheme);
-
getWindow().getDecorView().setBackgroundColor(Color.get(this, R.attr.color_background_primary));
+ setSupportActionBar(findViewById(R.id.toolbar));
+ configureActionBar(getSupportActionBar());
}
@Override
@@ -434,7 +433,6 @@ public class SettingsActivity extends XmppActivity implements
}
-
@Override
public void onStop() {
super.onStop();
diff --git a/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java
index 510135c5a..9ad877db1 100644
--- a/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java
@@ -37,14 +37,47 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
private String mLocationName;
private RelativeLayout mSnackbar;
+ private static String getAddress(Context context, Location location) {
+ double longitude = location.getLongitude();
+ double latitude = location.getLatitude();
+ String address = "";
+ if (latitude != 0 && longitude != 0) {
+ Geocoder geoCoder = new Geocoder(context, Locale.getDefault());
+ try {
+ List<Address> addresses = geoCoder.getFromLocation(latitude, longitude, 1);
+ if (addresses != null && addresses.size() > 0) {
+ Address Address = addresses.get(0);
+ StringBuilder strAddress = new StringBuilder("");
+
+ if (Address.getAddressLine(0).length() > 0) {
+ strAddress.append(Address.getAddressLine(0));
+ }
+ address = strAddress.toString().replace(", ", "<br>");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return address;
+ }
+
+ @Override
+ protected void refreshUiReal() {
+
+ }
+
+ @Override
+ void onBackendConnected() {
+
+ }
+
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_share_locaction);
- if (getSupportActionBar() != null) {
- getSupportActionBar().setHomeButtonEnabled(true);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- }
+ setTitle(getString(R.string.share_location));
+ setSupportActionBar(findViewById(R.id.toolbar));
+ configureActionBar(getSupportActionBar());
locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
mLocationName = getString(R.string.me);
@@ -87,12 +120,12 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
}
@Override
- protected void onPause() {
+ public void onPause() {
super.onPause();
}
@Override
- protected void onResume() {
+ public void onResume() {
super.onResume();
if (isLocationEnabled()) {
this.mSnackbar.setVisibility(View.GONE);
@@ -145,7 +178,7 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
}
private boolean isLocationEnabled() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return isLocationEnabledKitkat();
} else {
return isLocationEnabledLegacy();
@@ -164,28 +197,22 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
}
}
- private static String getAddress(Context context, Location location) {
- double longitude = location.getLongitude();
- double latitude = location.getLatitude();
- String address = "";
- if (latitude != 0 && longitude != 0) {
- Geocoder geoCoder = new Geocoder(context, Locale.getDefault());
- try {
- List<Address> addresses = geoCoder.getFromLocation(latitude, longitude, 1);
- if (addresses != null && addresses.size() > 0) {
- Address Address = addresses.get(0);
- StringBuilder strAddress = new StringBuilder("");
-
- if (Address.getAddressLine(0).length() > 0) {
- strAddress.append(Address.getAddressLine(0));
- }
- address = strAddress.toString().replace(", ", "<br>");
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
+ private void showLocation(@Nullable Location location, @Nullable String address) {
+ if (location == null && TextUtils.isEmpty(address)) { // no location and no address available
+ final WebView webView = findViewById(R.id.webView);
+ webView.getSettings().setJavaScriptEnabled(true);
+ webView.loadUrl("file:///android_asset/map.html");
+ } else if (location != null && TextUtils.isEmpty(address)) { // location but no address available
+ String LocationName = "<b>" + mLocationName + "</b>";
+ final WebView webView = findViewById(R.id.webView);
+ webView.getSettings().setJavaScriptEnabled(true);
+ webView.loadUrl("file:///android_asset/map.html?lat=" + mLastLocation.getLatitude() + "&lon=" + mLastLocation.getLongitude() + "&name=" + LocationName);
+ } else if (location != null && !TextUtils.isEmpty(address)) { // location and address available
+ String LocationName = "<b>" + mLocationName + "</b><br>" + address;
+ final WebView webView = findViewById(R.id.webView);
+ webView.getSettings().setJavaScriptEnabled(true);
+ webView.loadUrl("file:///android_asset/map.html?lat=" + mLastLocation.getLatitude() + "&lon=" + mLastLocation.getLongitude() + "&name=" + LocationName);
}
- return address;
}
private class getAddressAsync extends AsyncTask<Void, Void, Void> {
@@ -215,22 +242,4 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
showLocation(mLastLocation, address);
}
}
-
- private void showLocation (@Nullable Location location, @Nullable String address) {
- if (location == null && TextUtils.isEmpty(address)) { // no location and no address available
- final WebView webView = findViewById(R.id.webView);
- webView.getSettings().setJavaScriptEnabled(true);
- webView.loadUrl("file:///android_asset/map.html");
- } else if (location != null && TextUtils.isEmpty(address)) { // location but no address available
- String LocationName = "<b>" + mLocationName + "</b>";
- final WebView webView = findViewById(R.id.webView);
- webView.getSettings().setJavaScriptEnabled(true);
- webView.loadUrl("file:///android_asset/map.html?lat=" + mLastLocation.getLatitude() + "&lon=" + mLastLocation.getLongitude() + "&name=" + LocationName);
- } else if (location != null && !TextUtils.isEmpty(address)) { // location and address available
- String LocationName = "<b>" + mLocationName + "</b><br>" + address;
- final WebView webView = findViewById(R.id.webView);
- webView.getSettings().setJavaScriptEnabled(true);
- webView.loadUrl("file:///android_asset/map.html?lat=" + mLastLocation.getLatitude() + "&lon=" + mLastLocation.getLongitude() + "&name=" + LocationName);
- }
- }
}
diff --git a/src/main/java/de/pixart/messenger/ui/ShareViaAccountActivity.java b/src/main/java/de/pixart/messenger/ui/ShareViaAccountActivity.java
index 74892ed93..7aa0d3f64 100644
--- a/src/main/java/de/pixart/messenger/ui/ShareViaAccountActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ShareViaAccountActivity.java
@@ -43,7 +43,8 @@ public class ShareViaAccountActivity extends XmppActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manage_accounts);
-
+ setSupportActionBar(findViewById(R.id.toolbar));
+ configureActionBar(getSupportActionBar());
accountListView = findViewById(R.id.account_list);
this.mAccountAdapter = new AccountAdapter(this, accountList);
accountListView.setAdapter(this.mAccountAdapter);
diff --git a/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java b/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java
index 864653052..55b392e97 100644
--- a/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java
@@ -162,12 +162,15 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
super.onCreate(savedInstanceState);
boolean useBundledEmoji = getPreferences().getBoolean(USE_BUNDLED_EMOJIS, getResources().getBoolean(R.bool.use_bundled_emoji));
new EmojiService(this).init(useBundledEmoji);
+
+ setContentView(R.layout.activity_share_with);
+
+ setSupportActionBar(findViewById(R.id.toolbar));
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setHomeButtonEnabled(false);
}
- setContentView(R.layout.activity_share_with);
setTitle(getString(R.string.title_activity_sharewith));
mListView = findViewById(R.id.choose_conversation_list);
diff --git a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java
index 2661589d8..7c9318fa5 100644
--- a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java
@@ -11,7 +11,6 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
-import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuInflater;
@@ -30,20 +29,43 @@ import de.pixart.messenger.services.EmojiService;
import static de.pixart.messenger.ui.SettingsActivity.USE_BUNDLED_EMOJIS;
-public class ShowLocationActivity extends AppCompatActivity {
+public class ShowLocationActivity extends XmppActivity {
private Location location;
private String mLocationName;
+ private static String getAddress(Context context, Location location) {
+ double longitude = location.getLongitude();
+ double latitude = location.getLatitude();
+ String address = "";
+ if (latitude != 0 && longitude != 0) {
+ Geocoder geoCoder = new Geocoder(context, Locale.getDefault());
+ try {
+ List<Address> addresses = geoCoder.getFromLocation(latitude, longitude, 1);
+ if (addresses != null && addresses.size() > 0) {
+ Address Address = addresses.get(0);
+ StringBuilder strAddress = new StringBuilder("");
+
+ if (Address.getAddressLine(0).length() > 0) {
+ strAddress.append(Address.getAddressLine(0));
+ }
+ address = strAddress.toString().replace(", ", "<br>");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return address;
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean useBundledEmoji = getPreferences().getBoolean(USE_BUNDLED_EMOJIS, getResources().getBoolean(R.bool.use_bundled_emoji));
new EmojiService(this).init(useBundledEmoji);
- if (getSupportActionBar() != null) {
- getSupportActionBar().setHomeButtonEnabled(true);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- }
setContentView(R.layout.activity_show_locaction);
+ setTitle(getString(R.string.show_location));
+ setSupportActionBar(findViewById(R.id.toolbar));
+ configureActionBar(getSupportActionBar());
Intent intent = getIntent();
@@ -66,61 +88,21 @@ public class ShowLocationActivity extends AppCompatActivity {
new getAddressAsync(this).execute();
}
}
- private class getAddressAsync extends AsyncTask<Void, Void, Void> {
- String address = null;
- private WeakReference<ShowLocationActivity> activityReference;
-
- getAddressAsync(ShowLocationActivity context) {
- activityReference = new WeakReference<>(context);
- }
-
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- showLocation(location, null);
- }
-
- @Override
- protected Void doInBackground(Void... params) {
- address = getAddress(ShowLocationActivity.this, location);
- return null;
- }
+ ;
- @Override
- protected void onPostExecute(Void result) {
- super.onPostExecute(result);
- showLocation(location, address);
- }
- };
+ protected SharedPreferences getPreferences() {
+ return PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ }
- private static String getAddress(Context context, Location location) {
- double longitude = location.getLongitude();
- double latitude = location.getLatitude();
- String address = "";
- if (latitude != 0 && longitude != 0) {
- Geocoder geoCoder = new Geocoder(context, Locale.getDefault());
- try {
- List<Address> addresses = geoCoder.getFromLocation(latitude, longitude, 1);
- if (addresses != null && addresses.size() > 0) {
- Address Address = addresses.get(0);
- StringBuilder strAddress = new StringBuilder("");
+ @Override
+ protected void refreshUiReal() {
- if (Address.getAddressLine(0).length() > 0) {
- strAddress.append(Address.getAddressLine(0));
- }
- address = strAddress.toString().replace(", ", "<br>");
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return address;
}
+ @Override
+ void onBackendConnected() {
- protected SharedPreferences getPreferences() {
- return PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
}
@Override
@@ -155,7 +137,7 @@ public class ShowLocationActivity extends AppCompatActivity {
super.onSaveInstanceState(outState);
}
- private void showLocation (@Nullable Location location, @Nullable String address) {
+ private void showLocation(@Nullable Location location, @Nullable String address) {
if (location == null && TextUtils.isEmpty(address)) { // no location and no address available
final WebView webView = findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
@@ -164,7 +146,7 @@ public class ShowLocationActivity extends AppCompatActivity {
String LocationName = "<b>" + mLocationName + "</b>";
final WebView webView = findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
- webView.loadUrl("file:///android_asset/map.html?lat=" + location.getLatitude() + "&lon=" + location.getLongitude()+ "&name=" + LocationName);
+ webView.loadUrl("file:///android_asset/map.html?lat=" + location.getLatitude() + "&lon=" + location.getLongitude() + "&name=" + LocationName);
} else if (location != null && !TextUtils.isEmpty(address)) { // location and address available
String LocationName = "<b>" + mLocationName + "</b><br>" + address;
final WebView webView = findViewById(R.id.webView);
@@ -172,4 +154,32 @@ public class ShowLocationActivity extends AppCompatActivity {
webView.loadUrl("file:///android_asset/map.html?lat=" + location.getLatitude() + "&lon=" + location.getLongitude() + "&name=" + LocationName);
}
}
+
+ private class getAddressAsync extends AsyncTask<Void, Void, Void> {
+ String address = null;
+
+ private WeakReference<ShowLocationActivity> activityReference;
+
+ getAddressAsync(ShowLocationActivity context) {
+ activityReference = new WeakReference<>(context);
+ }
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ showLocation(location, null);
+ }
+
+ @Override
+ protected Void doInBackground(Void... params) {
+ address = getAddress(ShowLocationActivity.this, location);
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void result) {
+ super.onPostExecute(result);
+ showLocation(location, address);
+ }
+ }
} \ No newline at end of file
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
index f5abf2239..526d9275f 100644
--- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
@@ -16,6 +16,8 @@ import android.os.Build;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
@@ -24,6 +26,7 @@ import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.SpannableString;
import android.text.Spanned;
@@ -132,7 +135,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
private TextView.OnEditorActionListener mSearchDone = new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
- int pos = getSupportActionBar().getSelectedNavigationIndex();
+ int pos = binding.startConversationViewPager.getCurrentItem();
if (pos == 0) {
if (contacts.size() == 1) {
openConversationForContact((Contact) contacts.get(0));
@@ -184,31 +187,10 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
};
private ActivityStartConversationBinding binding;
- private ActionBar.TabListener mTabListener = new ActionBar.TabListener() {
- @Override
- public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
- return;
- }
-
- @Override
- public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
- binding.startConversationViewPager.setCurrentItem(tab.getPosition());
- onTabChanged();
- }
-
- @Override
- public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
- return;
- }
- };
private ViewPager.SimpleOnPageChangeListener mOnPageChangeListener = new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
- ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setSelectedNavigationItem(position);
- }
onTabChanged();
}
};
@@ -256,8 +238,11 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
super.onCreate(savedInstanceState);
new EmojiService(this).init(useBundledEmoji());
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_start_conversation);
+ Toolbar toolbar = (Toolbar) binding.toolbar;
+ setSupportActionBar(toolbar);
+ configureActionBar(getSupportActionBar());
this.binding.fab.setOnClickListener((v) -> {
- if (getSupportActionBar().getSelectedNavigationIndex() == 0) {
+ if (binding.startConversationViewPager.getCurrentItem() == 0) {
String searchString = mSearchEditText != null ? mSearchEditText.getText().toString() : null;
if (searchString != null && !searchString.trim().isEmpty()) {
try {
@@ -275,15 +260,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
showCreateConferenceDialog();
}
});
- ActionBar actionBar = getSupportActionBar();
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
-
- ActionBar.Tab mContactsTab = actionBar.newTab().setText(R.string.contacts).setTabListener(mTabListener);
- ActionBar.Tab mConferencesTab = actionBar.newTab().setText(R.string.conferences).setTabListener(mTabListener);
- actionBar.addTab(mContactsTab);
- actionBar.addTab(mConferencesTab);
-
- binding.startConversationViewPager.setOnPageChangeListener(mOnPageChangeListener);
+ TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
+ tabLayout.setupWithViewPager(binding.startConversationViewPager);
+ binding.startConversationViewPager.addOnPageChangeListener(mOnPageChangeListener);
mListPagerAdapter = new ListPagerAdapter(getSupportFragmentManager());
binding.startConversationViewPager.setAdapter(mListPagerAdapter);
@@ -537,7 +516,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
MenuItem joinGroupChat = menu.findItem(R.id.action_join_conference);
MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code);
ActionBar bar = getSupportActionBar();
- joinGroupChat.setVisible(bar != null && bar.getSelectedNavigationIndex() == 1);
+ joinGroupChat.setVisible(bar != null && binding.startConversationViewPager.getCurrentItem() == 1);
qrCodeScanMenuItem.setVisible(isCameraFeatureAvailable());
menuHideOffline.setChecked(this.mHideOfflineContacts);
mMenuSearchView = menu.findItem(R.id.action_search);
@@ -871,7 +850,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
private void onTabChanged() {
@DrawableRes final int fabDrawable;
- if (getSupportActionBar().getSelectedNavigationIndex() == 0) {
+ if (binding.startConversationViewPager.getCurrentItem() == 0) {
fabDrawable = R.drawable.ic_person_add_white_24dp;
} else {
fabDrawable = R.drawable.ic_group_add_white_24dp;
@@ -1093,6 +1072,19 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
return ((Fragment) fragment).getView() == view;
}
+ @Nullable
+ @Override
+ public CharSequence getPageTitle(int position) {
+ switch (position) {
+ case 0:
+ return getResources().getString(R.string.contacts);
+ case 1:
+ return getResources().getString(R.string.conferences);
+ default:
+ return super.getPageTitle(position);
+ }
+ }
+
public Fragment getItem(int position) {
assert (0 <= position && position < fragments.length);
if (fragments[position] == null) {
diff --git a/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java b/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java
index 0a2dade8d..c1938aef9 100644
--- a/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/TrustKeysActivity.java
@@ -5,6 +5,7 @@ import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
+import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
@@ -79,11 +80,8 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
binding.cancelButton.setOnClickListener(mCancelButtonListener);
binding.saveButton.setOnClickListener(mSaveButtonListener);
-
- if (getSupportActionBar() != null) {
- getSupportActionBar().setHomeButtonEnabled(true);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- }
+ setSupportActionBar((Toolbar) binding.toolbar);
+ configureActionBar(getSupportActionBar());
if (savedInstanceState != null) {
mUseCameraHintShown.set(savedInstanceState.getBoolean("camera_hint_shown", false));
diff --git a/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java b/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java
index b2d7e1064..a77303d85 100644
--- a/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java
@@ -54,6 +54,8 @@ public class UriHandlerActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.handled = savedInstanceState != null && savedInstanceState.getBoolean("handled", false);
+ getLayoutInflater().inflate(R.layout.toolbar, findViewById(android.R.id.content));
+ setSupportActionBar(findViewById(R.id.toolbar));
}
@Override
diff --git a/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java b/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java
index 07c6e1ff7..84a14c7c0 100644
--- a/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java
@@ -79,6 +79,7 @@ public class WelcomeActivity extends XmppActivity {
}
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);
+ setSupportActionBar(findViewById(R.id.toolbar));
final ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setDisplayShowHomeEnabled(false);
diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
index 48ddf8fdf..112c01cee 100644
--- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
@@ -421,10 +421,6 @@ public abstract class XmppActivity extends AppCompatActivity {
setTheme(this.mTheme);
this.mUsingEnterKey = usingEnterKey();
mUseSubject = getPreferences().getBoolean("use_subject", getResources().getBoolean(R.bool.use_subject));
- final ActionBar ab = getSupportActionBar();
- if (ab != null) {
- ab.setDisplayHomeAsUpEnabled(true);
- }
}
protected boolean isCameraFeatureAvailable() {
@@ -609,6 +605,13 @@ public abstract class XmppActivity extends AppCompatActivity {
}
}
+ public static void configureActionBar(ActionBar actionBar) {
+ if (actionBar != null) {
+ actionBar.setHomeButtonEnabled(true);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ }
+ }
+
protected boolean noAccountUsesPgp() {
if (!hasPgp()) {
return true;