Merge pull request #1100 from substars/dev-scroll-label-fixes

confirm dialog scroll + title fixes
This commit is contained in:
Milos Kozak 2021-12-30 18:57:24 +01:00 committed by GitHub
commit 6495690b78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 14 deletions

View file

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

View file

@ -7,11 +7,17 @@ import android.os.SystemClock;
import android.os.Vibrator; import android.os.Vibrator;
import android.support.wearable.view.GridPagerAdapter; import android.support.wearable.view.GridPagerAdapter;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.core.view.InputDeviceCompat;
import androidx.core.view.MotionEventCompat;
import androidx.core.view.ViewConfigurationCompat;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.ListenerService; import info.nightscout.androidaps.data.ListenerService;
@ -71,8 +77,28 @@ public class AcceptActivity extends ViewSelectorActivity {
if (col == 0) { if (col == 0) {
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_confirm_text, container, false); final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_confirm_text, container, false);
final TextView textView = view.findViewById(R.id.message); final TextView textView = view.findViewById(R.id.message);
final View scrollView = view.findViewById(R.id.message_scroll);
textView.setText(message); textView.setText(message);
container.addView(view); container.addView(view);
scrollView.setOnGenericMotionListener(new View.OnGenericMotionListener() {
@Override
public boolean onGenericMotion(View v, MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_SCROLL &&
ev.isFromSource(InputDeviceCompat.SOURCE_ROTARY_ENCODER)
) {
float delta = -ev.getAxisValue(MotionEventCompat.AXIS_SCROLL) *
ViewConfigurationCompat.getScaledVerticalScrollFactor(
ViewConfiguration.get(container.getContext()),
container.getContext());
v.scrollBy(0, Math.round(delta));
return true;
}
return false;
}
});
scrollView.requestFocus();
return view; return view;
} else { } else {
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false); final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);

View file

@ -29,7 +29,7 @@ public class ViewSelectorActivity extends Activity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.grid_layout); setContentView(R.layout.grid_layout);
setTitleBasedOnScreenShape(String.valueOf(getTitle())); setTitleBasedOnScreenShape();
pager = findViewById(R.id.pager); pager = findViewById(R.id.pager);
DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator); DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator);
@ -59,7 +59,12 @@ public class ViewSelectorActivity extends Activity {
pager.setAdapter(adapter); 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); CurvedTextView titleViewCurved = findViewById(R.id.title_curved);
TextView titleView = findViewById(R.id.title); TextView titleView = findViewById(R.id.title);
if (this.getResources().getConfiguration().isScreenRound()) { if (this.getResources().getConfiguration().isScreenRound()) {
@ -91,18 +96,8 @@ public class ViewSelectorActivity extends Activity {
} }
void setLabelToPlusMinusView(View view, String labelText) { 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); final TextView textView = view.findViewById(R.id.label);
textView.setText(labelText); textView.setText(labelText);
} else {
final TextView textView = view.findViewById(R.id.label);
textView.setText(labelText);
}
} }
} }

View file

@ -11,6 +11,9 @@
app:boxedEdges="all"> app:boxedEdges="all">
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:id="@+id/message_scroll"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<TextView <TextView