use dynamic titles for activities when they are supplied

This commit is contained in:
Benjamin Ortega 2021-12-23 20:30:21 -06:00
parent e14cdd7c2a
commit 7b1e500659
2 changed files with 10 additions and 14 deletions

View file

@ -522,7 +522,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
intent.putExtras(params);
startActivity(intent);
} else {
showConfirmationDialog(message, actionstring);
showConfirmationDialog(title, message, actionstring);
}
} else if (path.equals(NEW_STATUS_PATH)) {
@ -680,10 +680,11 @@ public class ListenerService extends WearableListenerService implements GoogleAp
notificationManager.createNotificationChannel(channel);
}
private void showConfirmationDialog(String message, String actionstring) {
private void showConfirmationDialog(String title, String message, String actionstring) {
Intent intent = new Intent(this, AcceptActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle params = new Bundle();
params.putString("title", title);
params.putString("message", message);
params.putString("actionstring", actionstring);
intent.putExtras(params);

View file

@ -29,7 +29,7 @@ public class ViewSelectorActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.grid_layout);
setTitleBasedOnScreenShape(String.valueOf(getTitle()));
setTitleBasedOnScreenShape();
pager = findViewById(R.id.pager);
DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator);
@ -59,7 +59,12 @@ public class ViewSelectorActivity extends Activity {
pager.setAdapter(adapter);
}
private void setTitleBasedOnScreenShape(String title) {
private void setTitleBasedOnScreenShape() {
// intents can inject dynamic titles, otherwise we'll use the default
String title = String.valueOf(getTitle());
if (getIntent().getExtras() != null)
title = getIntent().getExtras().getString("title", title);
CurvedTextView titleViewCurved = findViewById(R.id.title_curved);
TextView titleView = findViewById(R.id.title);
if (this.getResources().getConfiguration().isScreenRound()) {
@ -91,18 +96,8 @@ public class ViewSelectorActivity extends Activity {
}
void setLabelToPlusMinusView(View view, String labelText) {
SharedPreferences sharedPrefs = PreferenceManager
.getDefaultSharedPreferences(this);
int design = Integer.parseInt(sharedPrefs.getString("input_design", "1"));
if (design == 4) {
//@LadyViktoria: Here the label can be set differently, if you like.
final TextView textView = view.findViewById(R.id.label);
textView.setText(labelText);
} else {
final TextView textView = view.findViewById(R.id.label);
textView.setText(labelText);
}
}
}