mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-02-07 15:48:39 +01:00
bug fix, settings layout fix, dependency update
This commit is contained in:
parent
5421071c27
commit
0aa15a1f71
@ -42,7 +42,7 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.3.0'
|
implementation 'androidx.recyclerview:recyclerview:1.3.1'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.cardview:cardview:1.0.0'
|
implementation 'androidx.cardview:cardview:1.0.0'
|
||||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||||
|
@ -30,6 +30,11 @@ public class PushNotification {
|
|||||||
public static final String NOTIFICATION_NAME = BuildConfig.APPLICATION_ID + " UnifiedPush";
|
public static final String NOTIFICATION_NAME = BuildConfig.APPLICATION_ID + " UnifiedPush";
|
||||||
public static final String NOTIFICATION_ID_STR = BuildConfig.APPLICATION_ID + ".notification";
|
public static final String NOTIFICATION_ID_STR = BuildConfig.APPLICATION_ID + ".notification";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* maximum notifications to show
|
||||||
|
*/
|
||||||
|
private static final int NOTIFICATION_LIMIT = 3;
|
||||||
|
|
||||||
private static final int NOTIFICATION_ID = 0x25281;
|
private static final int NOTIFICATION_ID = 0x25281;
|
||||||
|
|
||||||
private NotificationManagerCompat notificationManager;
|
private NotificationManagerCompat notificationManager;
|
||||||
@ -73,10 +78,7 @@ public class PushNotification {
|
|||||||
String title = settings.getLogin().getConfiguration().getName();
|
String title = settings.getLogin().getConfiguration().getName();
|
||||||
String content;
|
String content;
|
||||||
int icon;
|
int icon;
|
||||||
if (notifications.size() > 1) {
|
if (notifications.size() == 1) {
|
||||||
content = context.getString(R.string.notification_new);
|
|
||||||
icon = R.drawable.bell;
|
|
||||||
} else {
|
|
||||||
Notification notification = notifications.getFirst();
|
Notification notification = notifications.getFirst();
|
||||||
switch (notification.getType()) {
|
switch (notification.getType()) {
|
||||||
case Notification.TYPE_FAVORITE:
|
case Notification.TYPE_FAVORITE:
|
||||||
@ -124,6 +126,12 @@ public class PushNotification {
|
|||||||
content = context.getString(R.string.notification_new);
|
content = context.getString(R.string.notification_new);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (notifications.size() <= NOTIFICATION_LIMIT) {
|
||||||
|
content = context.getString(R.string.notification_new);
|
||||||
|
icon = R.drawable.bell;
|
||||||
|
} else {
|
||||||
|
// ignore new push notifications
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU || context.checkSelfPermission(POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU || context.checkSelfPermission(POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {
|
||||||
notificationBuilder.setContentTitle(title).setContentText(content).setSmallIcon(icon);
|
notificationBuilder.setContentTitle(title).setContentText(content).setSmallIcon(icon);
|
||||||
|
@ -93,6 +93,7 @@ public class MainActivity extends AppCompatActivity implements ActivityResultCal
|
|||||||
private Dialog loadingCircle;
|
private Dialog loadingCircle;
|
||||||
|
|
||||||
private DrawerLayout drawerLayout;
|
private DrawerLayout drawerLayout;
|
||||||
|
private NavigationView navigationView;
|
||||||
private TabSelector tabSelector;
|
private TabSelector tabSelector;
|
||||||
private ViewPager2 viewPager;
|
private ViewPager2 viewPager;
|
||||||
private ImageView profileImage;
|
private ImageView profileImage;
|
||||||
@ -116,7 +117,7 @@ public class MainActivity extends AppCompatActivity implements ActivityResultCal
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.page_main);
|
setContentView(R.layout.page_main);
|
||||||
Toolbar toolbar = findViewById(R.id.home_toolbar);
|
Toolbar toolbar = findViewById(R.id.home_toolbar);
|
||||||
NavigationView navigationView = findViewById(R.id.home_navigator);
|
navigationView = findViewById(R.id.home_navigator);
|
||||||
header = (ViewGroup) navigationView.getHeaderView(0);
|
header = (ViewGroup) navigationView.getHeaderView(0);
|
||||||
floatingButton = findViewById(R.id.home_post);
|
floatingButton = findViewById(R.id.home_post);
|
||||||
drawerLayout = findViewById(R.id.main_layout);
|
drawerLayout = findViewById(R.id.main_layout);
|
||||||
@ -138,34 +139,29 @@ public class MainActivity extends AppCompatActivity implements ActivityResultCal
|
|||||||
if (navigationView.getLayoutParams() != null) {
|
if (navigationView.getLayoutParams() != null) {
|
||||||
navigationView.getLayoutParams().width = Math.round(getResources().getDisplayMetrics().widthPixels / 2.0f);
|
navigationView.getLayoutParams().width = Math.round(getResources().getDisplayMetrics().widthPixels / 2.0f);
|
||||||
}
|
}
|
||||||
if (!settings.floatingButtonEnabled()) {
|
|
||||||
floatingButton.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
if (!settings.getLogin().getConfiguration().isFilterSupported()) {
|
|
||||||
navigationView.getMenu().findItem(R.id.menu_navigator_filter).setVisible(false);
|
|
||||||
}
|
|
||||||
toolbar.setTitle("");
|
toolbar.setTitle("");
|
||||||
toolbar.setNavigationIcon(R.drawable.menu);
|
toolbar.setNavigationIcon(R.drawable.menu);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
AppStyles.setTheme(header);
|
updateUI();
|
||||||
setStyle();
|
|
||||||
|
|
||||||
navigationView.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
AppStyles.setTheme(navigationView);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
Serializable data = savedInstanceState.getSerializable(KEY_USER_SAVE);
|
Serializable data = savedInstanceState.getSerializable(KEY_USER_SAVE);
|
||||||
if (data instanceof User) {
|
if (data instanceof User) {
|
||||||
setCurrentUser((User) data);
|
setCurrentUser((User) data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// load user information
|
||||||
if (settings.isLoggedIn() && currentUser == null) {
|
if (settings.isLoggedIn() && currentUser == null) {
|
||||||
UserParam param = new UserParam(UserParam.DATABASE, settings.getLogin().getId());
|
UserParam param = new UserParam(UserParam.DATABASE, settings.getLogin().getId());
|
||||||
userLoader.execute(param, this);
|
userLoader.execute(param, this);
|
||||||
}
|
}
|
||||||
|
// set navigation view style
|
||||||
|
navigationView.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
AppStyles.setTheme(navigationView);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
toolbar.setNavigationOnClickListener(new OnClickListener() {
|
toolbar.setNavigationOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -298,15 +294,10 @@ public class MainActivity extends AppCompatActivity implements ActivityResultCal
|
|||||||
// update layout & theme
|
// update layout & theme
|
||||||
case SettingsActivity.RETURN_SETTINGS_CHANGED:
|
case SettingsActivity.RETURN_SETTINGS_CHANGED:
|
||||||
case AccountActivity.RETURN_SETTINGS_CHANGED:
|
case AccountActivity.RETURN_SETTINGS_CHANGED:
|
||||||
if (settings.floatingButtonEnabled()) {
|
|
||||||
floatingButton.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
floatingButton.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
adapter.notifySettingsChanged();
|
adapter.notifySettingsChanged();
|
||||||
}
|
}
|
||||||
setStyle();
|
updateUI();
|
||||||
setCurrentUser(currentUser);
|
setCurrentUser(currentUser);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -455,11 +446,17 @@ public class MainActivity extends AppCompatActivity implements ActivityResultCal
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void setStyle() {
|
private void updateUI() {
|
||||||
AppStyles.setTheme(drawerLayout);
|
AppStyles.setTheme(drawerLayout);
|
||||||
AppStyles.setTheme(header);
|
AppStyles.setTheme(header);
|
||||||
tabSelector.addTabIcons(settings.getLogin().getConfiguration().getHomeTabIcons());
|
tabSelector.addTabIcons(settings.getLogin().getConfiguration().getHomeTabIcons());
|
||||||
tabSelector.updateTheme();
|
tabSelector.updateTheme();
|
||||||
|
if (!settings.floatingButtonEnabled()) {
|
||||||
|
floatingButton.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
if (!settings.getLogin().getConfiguration().isFilterSupported()) {
|
||||||
|
navigationView.getMenu().findItem(R.id.menu_navigator_filter).setVisible(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -470,6 +467,7 @@ public class MainActivity extends AppCompatActivity implements ActivityResultCal
|
|||||||
private void setCurrentUser(@Nullable User user) {
|
private void setCurrentUser(@Nullable User user) {
|
||||||
currentUser = user;
|
currentUser = user;
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
|
header.setVisibility(View.VISIBLE);
|
||||||
followingCount.setText(StringUtils.NUMBER_FORMAT.format(user.getFollowing()));
|
followingCount.setText(StringUtils.NUMBER_FORMAT.format(user.getFollowing()));
|
||||||
followerCount.setText(StringUtils.NUMBER_FORMAT.format(user.getFollower()));
|
followerCount.setText(StringUtils.NUMBER_FORMAT.format(user.getFollower()));
|
||||||
screenname.setText(user.getScreenname());
|
screenname.setText(user.getScreenname());
|
||||||
@ -488,11 +486,7 @@ public class MainActivity extends AppCompatActivity implements ActivityResultCal
|
|||||||
profileImage.setImageDrawable(placeholder);
|
profileImage.setImageDrawable(placeholder);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
profileImage.setImageResource(0);
|
header.setVisibility(View.INVISIBLE);
|
||||||
followingCount.setText("");
|
|
||||||
followerCount.setText("");
|
|
||||||
screenname.setText("");
|
|
||||||
username.setText("");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,6 +7,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/mainpage_toolbar_height"
|
android:layout_marginTop="@dimen/mainpage_toolbar_height"
|
||||||
android:padding="@dimen/navigation_header_layout_padding"
|
android:padding="@dimen/navigation_header_layout_padding"
|
||||||
|
android:visibility="invisible"
|
||||||
tools:ignore="UseCompatTextViewDrawableXml">
|
tools:ignore="UseCompatTextViewDrawableXml">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
@ -333,6 +333,7 @@
|
|||||||
android:id="@+id/spinner_font"
|
android:id="@+id/spinner_font"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/settings_column_margin"
|
||||||
app:layout_constraintStart_toStartOf="@+id/enable_status_hide_sensitive_descr"
|
app:layout_constraintStart_toStartOf="@+id/enable_status_hide_sensitive_descr"
|
||||||
app:layout_constraintTop_toBottomOf="@id/enable_status_hide_sensitive"
|
app:layout_constraintTop_toBottomOf="@id/enable_status_hide_sensitive"
|
||||||
app:layout_constraintEnd_toStartOf="@id/spinner_scale"
|
app:layout_constraintEnd_toStartOf="@id/spinner_scale"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user