mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-01-07 00:20:08 +02:00
Fix issue #34 - Avatar and header inversed when editing profile
This commit is contained in:
parent
7d923ed93b
commit
ea984f0553
5 changed files with 22 additions and 21 deletions
|
@ -165,9 +165,9 @@ public class EditProfileActivity extends BaseActivity {
|
||||||
});
|
});
|
||||||
//Actions with the activity
|
//Actions with the activity
|
||||||
accountsVM = new ViewModelProvider(EditProfileActivity.this).get(AccountsVM.class);
|
accountsVM = new ViewModelProvider(EditProfileActivity.this).get(AccountsVM.class);
|
||||||
binding.headerSelect.setOnClickListener(view -> startActivityForResult(prepareIntent(), EditProfileActivity.PICK_MEDIA_AVATAR));
|
binding.headerSelect.setOnClickListener(view -> startActivityForResult(prepareIntent(), EditProfileActivity.PICK_MEDIA_HEADER));
|
||||||
|
|
||||||
binding.avatarSelect.setOnClickListener(view -> startActivityForResult(prepareIntent(), EditProfileActivity.PICK_MEDIA_HEADER));
|
binding.avatarSelect.setOnClickListener(view -> startActivityForResult(prepareIntent(), EditProfileActivity.PICK_MEDIA_AVATAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -185,6 +185,7 @@ public class EditProfileActivity extends BaseActivity {
|
||||||
sendBroadCast(account);
|
sendBroadCast(account);
|
||||||
binding.avatarProgress.setVisibility(View.GONE);
|
binding.avatarProgress.setVisibility(View.GONE);
|
||||||
BaseMainActivity.accountWeakReference.get().mastodon_account = account;
|
BaseMainActivity.accountWeakReference.get().mastodon_account = account;
|
||||||
|
Helper.recreateMainActivity(EditProfileActivity.this);
|
||||||
});
|
});
|
||||||
} else if (requestCode == PICK_MEDIA_HEADER && resultCode == RESULT_OK) {
|
} else if (requestCode == PICK_MEDIA_HEADER && resultCode == RESULT_OK) {
|
||||||
Glide.with(EditProfileActivity.this)
|
Glide.with(EditProfileActivity.this)
|
||||||
|
@ -198,6 +199,7 @@ public class EditProfileActivity extends BaseActivity {
|
||||||
sendBroadCast(account);
|
sendBroadCast(account);
|
||||||
binding.headerProgress.setVisibility(View.GONE);
|
binding.headerProgress.setVisibility(View.GONE);
|
||||||
BaseMainActivity.accountWeakReference.get().mastodon_account = account;
|
BaseMainActivity.accountWeakReference.get().mastodon_account = account;
|
||||||
|
Helper.recreateMainActivity(EditProfileActivity.this);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,7 @@ import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.lifecycle.ViewModelStoreOwner;
|
import androidx.lifecycle.ViewModelStoreOwner;
|
||||||
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
|
@ -1473,6 +1474,20 @@ public class Helper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send broadcast to recreate Mainactivity
|
||||||
|
*
|
||||||
|
* @param activity - Activity
|
||||||
|
*/
|
||||||
|
public static void recreateMainActivity(Activity activity) {
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
b.putBoolean(Helper.RECEIVE_RECREATE_ACTIVITY, true);
|
||||||
|
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
|
||||||
|
intentBD.putExtras(b);
|
||||||
|
LocalBroadcastManager.getInstance(activity).sendBroadcast(intentBD);
|
||||||
|
}
|
||||||
|
|
||||||
public static void showKeyboard(Context context, View view) {
|
public static void showKeyboard(Context context, View view) {
|
||||||
view.requestFocus();
|
view.requestFocus();
|
||||||
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
|
@ -18,12 +18,10 @@ import static android.content.Context.WINDOW_SERVICE;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -35,7 +33,6 @@ import androidx.annotation.AttrRes;
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.graphics.ColorUtils;
|
import androidx.core.graphics.ColorUtils;
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import com.google.android.material.button.MaterialButton;
|
import com.google.android.material.button.MaterialButton;
|
||||||
|
@ -365,18 +362,6 @@ public class ThemeHelper {
|
||||||
return new ColorStateList(states, colors);
|
return new ColorStateList(states, colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Send broadcast to recreate Mainactivity
|
|
||||||
*
|
|
||||||
* @param activity - Activity
|
|
||||||
*/
|
|
||||||
public static void recreateMainActivity(Activity activity) {
|
|
||||||
Bundle b = new Bundle();
|
|
||||||
b.putBoolean(Helper.RECEIVE_RECREATE_ACTIVITY, true);
|
|
||||||
Intent intentBD = new Intent(Helper.BROADCAST_DATA);
|
|
||||||
intentBD.putExtras(b);
|
|
||||||
LocalBroadcastManager.getInstance(activity).sendBroadcast(intentBD);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface SlideAnimation {
|
public interface SlideAnimation {
|
||||||
void onAnimationEnded();
|
void onAnimationEnded();
|
||||||
|
|
|
@ -22,7 +22,6 @@ import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
|
||||||
import app.fedilab.android.R;
|
import app.fedilab.android.R;
|
||||||
import app.fedilab.android.helper.Helper;
|
import app.fedilab.android.helper.Helper;
|
||||||
import app.fedilab.android.helper.ThemeHelper;
|
|
||||||
|
|
||||||
public class FragmentLanguageSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public class FragmentLanguageSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
|
@ -43,7 +42,7 @@ public class FragmentLanguageSettings extends PreferenceFragmentCompat implement
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
if (key.compareToIgnoreCase(getString(R.string.SET_DEFAULT_LOCALE_NEW)) == 0) {
|
if (key.compareToIgnoreCase(getString(R.string.SET_DEFAULT_LOCALE_NEW)) == 0) {
|
||||||
requireActivity().recreate();
|
requireActivity().recreate();
|
||||||
ThemeHelper.recreateMainActivity(requireActivity());
|
Helper.recreateMainActivity(requireActivity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class FragmentThemingSettings extends PreferenceFragmentCompat implements
|
||||||
if (key.equals("use_custom_theme")) {
|
if (key.equals("use_custom_theme")) {
|
||||||
createPref();
|
createPref();
|
||||||
}
|
}
|
||||||
ThemeHelper.recreateMainActivity(requireActivity());
|
Helper.recreateMainActivity(requireActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ public class FragmentThemingSettings extends PreferenceFragmentCompat implements
|
||||||
}
|
}
|
||||||
appEditor.commit();
|
appEditor.commit();
|
||||||
cyaneaEditor.apply().recreate(requireActivity());
|
cyaneaEditor.apply().recreate(requireActivity());
|
||||||
ThemeHelper.recreateMainActivity(requireActivity());
|
Helper.recreateMainActivity(requireActivity());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in a new issue