summaryrefslogtreecommitdiffstats
path: root/app/src/main/java
diff options
context:
space:
mode:
authorstom79 <tschneider.ac@gmail.com>2019-01-10 17:56:19 +0100
committerstom79 <tschneider.ac@gmail.com>2019-01-10 17:56:19 +0100
commit005fe00dd2eba4eaa8963b715e22bda4b2d268c7 (patch)
treeb6dff291be528181ff86a97fb26bdf90a79068ef /app/src/main/java
parent0d310ff856fec32cf4aeb7d4620ceedf332afc23 (diff)
Fix resolution issue
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java110
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeActivity.java5
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java6
3 files changed, 63 insertions, 58 deletions
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java
index c5924f1ed..30d5f6eaf 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java
@@ -57,6 +57,7 @@ import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
+import android.util.Log;
import android.util.Patterns;
import android.util.SparseArray;
import android.view.Gravity;
@@ -1633,16 +1634,19 @@ public abstract class BaseMainActivity extends BaseActivity
if( intent == null )
return;
-
+ Log.v(Helper.TAG,"intent: " + intent);
String action = intent.getAction();
String type = intent.getType();
Bundle extras = intent.getExtras();
String userIdIntent;
+ Log.v(Helper.TAG,"action: " + action);
+ Log.v(Helper.TAG,"type: " + type);
+ Log.v(Helper.TAG,"extras: " + extras);
if( extras != null && extras.containsKey(INTENT_ACTION) ){
final NavigationView navigationView = findViewById(R.id.nav_view);
userIdIntent = extras.getString(PREF_KEY_ID); //Id of the account in the intent
if (extras.getInt(INTENT_ACTION) == NOTIFICATION_INTENT){
- changeUser(BaseMainActivity.this, userIdIntent, false); //Connects the account which is related to the notification
+ changeUser(BaseMainActivity.this, userIdIntent, true); //Connects the account which is related to the notification
unCheckAllMenuItems(navigationView);
if( tabLayout.getTabAt(1) != null)
//noinspection ConstantConditions
@@ -1673,7 +1677,7 @@ public abstract class BaseMainActivity extends BaseActivity
tabLayout.setVisibility(View.GONE);
toolbarTitle.setText(instance);
}else if( extras.getInt(INTENT_ACTION) == HOME_TIMELINE_INTENT){
- changeUser(BaseMainActivity.this, userIdIntent, true); //Connects the account which is related to the notification
+ changeUser(BaseMainActivity.this, userIdIntent, false); //Connects the account which is related to the notification
}else if( extras.getInt(INTENT_ACTION) == BACK_TO_SETTINGS){
unCheckAllMenuItems(navigationView);
navigationView.setCheckedItem(R.id.nav_settings);
@@ -1845,8 +1849,6 @@ public abstract class BaseMainActivity extends BaseActivity
updateNotifCounter();
updateHomeCounter();
- SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
- Account account = new AccountDAO(getApplicationContext(), db).getAccountByID(userId);
//Proceeds to update of the authenticated account
if(Helper.isLoggedIn(getApplicationContext())) {
@@ -1864,58 +1866,60 @@ public abstract class BaseMainActivity extends BaseActivity
@Override
public void onStart(){
super.onStart();
- if( receive_federated_data != null)
- LocalBroadcastManager.getInstance(this).unregisterReceiver(receive_federated_data);
- receive_federated_data = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- Bundle b = intent.getExtras();
- assert b != null;
- userIdService = b.getString("userIdService", null);
- if( userIdService != null && userIdService.equals(userId)) {
- Status status = b.getParcelable("data");
- if (federatedFragment != null) {
- federatedFragment.refresh(status);
+ if( social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
+ if (receive_federated_data != null)
+ LocalBroadcastManager.getInstance(this).unregisterReceiver(receive_federated_data);
+ receive_federated_data = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Bundle b = intent.getExtras();
+ assert b != null;
+ userIdService = b.getString("userIdService", null);
+ if (userIdService != null && userIdService.equals(userId)) {
+ Status status = b.getParcelable("data");
+ if (federatedFragment != null) {
+ federatedFragment.refresh(status);
+ }
+ }
}
- }
- }
- };
- if( receive_home_data != null)
- LocalBroadcastManager.getInstance(this).unregisterReceiver(receive_home_data);
- receive_home_data = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- Bundle b = intent.getExtras();
- assert b != null;
- userIdService = b.getString("userIdService", null);
- if( userIdService != null && userIdService.equals(userId)) {
- Status status = b.getParcelable("data");
- if (homeFragment != null) {
- homeFragment.refresh(status);
+ };
+ if (receive_home_data != null)
+ LocalBroadcastManager.getInstance(this).unregisterReceiver(receive_home_data);
+ receive_home_data = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Bundle b = intent.getExtras();
+ assert b != null;
+ userIdService = b.getString("userIdService", null);
+ if (userIdService != null && userIdService.equals(userId)) {
+ Status status = b.getParcelable("data");
+ if (homeFragment != null) {
+ homeFragment.refresh(status);
+ }
+ }
}
- }
- }
- };
- if( receive_local_data != null)
- LocalBroadcastManager.getInstance(this).unregisterReceiver(receive_local_data);
- receive_local_data = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- Bundle b = intent.getExtras();
- assert b != null;
- userIdService = b.getString("userIdService", null);
- if( userIdService != null && userIdService.equals(userId)) {
- Status status = b.getParcelable("data");
- if (localFragment != null) {
- localFragment.refresh(status);
+ };
+ if (receive_local_data != null)
+ LocalBroadcastManager.getInstance(this).unregisterReceiver(receive_local_data);
+ receive_local_data = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Bundle b = intent.getExtras();
+ assert b != null;
+ userIdService = b.getString("userIdService", null);
+ if (userIdService != null && userIdService.equals(userId)) {
+ Status status = b.getParcelable("data");
+ if (localFragment != null) {
+ localFragment.refresh(status);
+ }
+ }
}
- }
- }
- };
+ };
- LocalBroadcastManager.getInstance(this).registerReceiver(receive_home_data, new IntentFilter(Helper.RECEIVE_HOME_DATA));
- LocalBroadcastManager.getInstance(this).registerReceiver(receive_federated_data, new IntentFilter(Helper.RECEIVE_FEDERATED_DATA));
- LocalBroadcastManager.getInstance(this).registerReceiver(receive_local_data, new IntentFilter(Helper.RECEIVE_LOCAL_DATA));
+ LocalBroadcastManager.getInstance(this).registerReceiver(receive_home_data, new IntentFilter(Helper.RECEIVE_HOME_DATA));
+ LocalBroadcastManager.getInstance(this).registerReceiver(receive_federated_data, new IntentFilter(Helper.RECEIVE_FEDERATED_DATA));
+ LocalBroadcastManager.getInstance(this).registerReceiver(receive_local_data, new IntentFilter(Helper.RECEIVE_LOCAL_DATA));
+ }
}
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeActivity.java
index d0afdaa7a..6db9b8aa9 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeActivity.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/PeertubeActivity.java
@@ -139,7 +139,6 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
private AppCompatImageView fullScreenIcon;
private TextView resolution;
private DefaultTrackSelector trackSelector;
- private WebView webview_video;
private int mode;
@@ -174,7 +173,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
peertube_description = findViewById(R.id.peertube_description);
peertube_title = findViewById(R.id.peertube_title);
peertube_information_container = findViewById(R.id.peertube_information_container);
- webview_video = findViewById(R.id.webview_video);
+ WebView webview_video = findViewById(R.id.webview_video);
playerView = findViewById(R.id.media_video);
Bundle b = getIntent().getExtras();
@@ -215,7 +214,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
FrameLayout webview_container = findViewById(R.id.main_media_frame);
final ViewGroup videoLayout = findViewById(R.id.videoLayout);
- MastalabWebChromeClient mastalabWebChromeClient = new MastalabWebChromeClient(PeertubeActivity.this, webview_video, webview_container, videoLayout);
+ MastalabWebChromeClient mastalabWebChromeClient = new MastalabWebChromeClient(PeertubeActivity.this, webview_video, webview_container, videoLayout);
mastalabWebChromeClient.setOnToggledFullscreen(new MastalabWebChromeClient.ToggledFullscreenCallback() {
@Override
public void toggledFullscreen(boolean fullscreen) {
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
index e304df387..ee1f19c8c 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
@@ -1192,7 +1192,7 @@ public class Helper {
menuAccountsOpened = false;
String userId = account.getId();
Toasty.info(activity, activity.getString(R.string.toast_account_changed, "@" + account.getAcct() + "@" + account.getInstance()), Toast.LENGTH_LONG).show();
- changeUser(activity, userId, true);
+ changeUser(activity, userId, false);
arrow.setImageResource(R.drawable.ic_arrow_drop_down);
return true;
}
@@ -1279,7 +1279,7 @@ public class Helper {
* @param activity Activity
* @param userID String - the new user id
*/
- public static void changeUser(Activity activity, String userID, boolean checkItem) {
+ public static void changeUser(Activity activity, String userID, boolean notificationIntent) {
final NavigationView navigationView = activity.findViewById(R.id.nav_view);
@@ -1315,6 +1315,8 @@ public class Helper {
editor.commit();
Intent changeAccount = new Intent(activity, MainActivity.class);
changeAccount.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ if( notificationIntent)
+ changeAccount.putExtra(INTENT_ACTION, NOTIFICATION_INTENT);
activity.finish();
activity.startActivity(changeAccount);