Merge pull request #1100 from substars/dev-scroll-label-fixes
confirm dialog scroll + title fixes
This commit is contained in:
commit
6495690b78
|
@ -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);
|
||||
|
|
|
@ -7,11 +7,17 @@ import android.os.SystemClock;
|
|||
import android.os.Vibrator;
|
||||
import android.support.wearable.view.GridPagerAdapter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
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.data.ListenerService;
|
||||
|
||||
|
@ -71,8 +77,28 @@ public class AcceptActivity extends ViewSelectorActivity {
|
|||
if (col == 0) {
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_confirm_text, container, false);
|
||||
final TextView textView = view.findViewById(R.id.message);
|
||||
final View scrollView = view.findViewById(R.id.message_scroll);
|
||||
textView.setText(message);
|
||||
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;
|
||||
} else {
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
app:boxedEdges="all">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/message_scroll"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
|
|
Loading…
Reference in a new issue