Skip to content

Commit 77d037d

Browse files
committed
Add confirm step on gdrive setup
1 parent c7dd73a commit 77d037d

File tree

3 files changed

+127
-10
lines changed

3 files changed

+127
-10
lines changed

OpenScienceJournal/whistlepunk_library/src/main/java/com/google/android/apps/forscience/whistlepunk/gdrivesync/GDriveSyncSetupActivity.java

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ public class GDriveSyncSetupActivity extends AppCompatActivity {
9191

9292
private View mSelectFolderView;
9393

94-
private TextView mStep3Description;
94+
private TextView mStepDescription;
9595

96-
private TextView mStep3Folder;
96+
private TextView mStepFolder;
9797

9898
private DisposableObserver<AppAccount> mAppAccountObserver;
9999

@@ -419,20 +419,40 @@ private void onFolderSelected() {
419419

420420
private View onCreateStep3(@NonNull ViewGroup container) {
421421
final View view = getLayoutInflater().inflate(R.layout.activity_drive_setup__step_3, container, false);
422-
mStep3Description = view.findViewById(R.id.drive_description);
423-
mStep3Folder = view.findViewById(R.id.drive_folder);
424-
view.findViewById(R.id.drive_btn_sync).setOnClickListener(v -> onCompleted());
422+
mStepDescription = view.findViewById(R.id.drive_description);
423+
mStepFolder = view.findViewById(R.id.drive_folder);
424+
view.findViewById(R.id.drive_btn_confirm).setOnClickListener(v -> onFolderSelectionConfirmed());
425425
return view;
426426
}
427427

428428
private void goToStep3() {
429429
GDriveFile f = mPath.get(mPath.size() - 1);
430430
mFolderId = f.id;
431-
mStep3Description.setText(getString(R.string.drive_setup_step_3_description, f.name));
432-
mStep3Folder.setText(f.name);
431+
mStepDescription.setText(getString(R.string.drive_setup_step_3_description, f.name));
432+
mStepFolder.setText(f.name);
433433
mViewPager.setCurrentItem(2, true);
434434
}
435435

436+
private void onFolderSelectionConfirmed() {
437+
goToStep4();
438+
}
439+
440+
private View onCreateStep4(@NonNull ViewGroup container) {
441+
final View view = getLayoutInflater().inflate(R.layout.activity_drive_setup__step_4, container, false);
442+
mStepDescription = view.findViewById(R.id.drive_description);
443+
mStepFolder = view.findViewById(R.id.drive_folder);
444+
view.findViewById(R.id.drive_btn_sync).setOnClickListener(v -> onCompleted());
445+
return view;
446+
}
447+
448+
private void goToStep4() {
449+
GDriveFile f = mPath.get(mPath.size() - 1);
450+
mFolderId = f.id;
451+
mStepDescription.setText(getString(R.string.arduino_auth_settings_drive_start_text));
452+
mStepFolder.setText(f.name);
453+
mViewPager.setCurrentItem(3, true);
454+
}
455+
436456
private void onCompleted() {
437457
if (mAppAccount == null || mAppAccount.isMinor()) {
438458
return;
@@ -481,7 +501,7 @@ private class MyPagerAdapter extends PagerAdapter {
481501

482502
@Override
483503
public int getCount() {
484-
return 3;
504+
return 4;
485505
}
486506

487507
@NonNull
@@ -498,6 +518,9 @@ public Object instantiateItem(@NonNull ViewGroup container, int position) {
498518
case 2:
499519
view = onCreateStep3(container);
500520
break;
521+
case 3:
522+
view = onCreateStep4(container);
523+
break;
501524
default:
502525
throw new RuntimeException("Unknown drive setup page index " + position);
503526
}

OpenScienceJournal/whistlepunk_library/src/main/res/layout/activity_drive_setup__step_3.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@
8080
app:layout_constraintTop_toBottomOf="@id/drive_description" />
8181

8282
<TextView
83-
android:id="@+id/drive_btn_sync"
83+
android:id="@+id/drive_btn_confirm"
8484
style="@style/ArduinoAuth_Button"
8585
android:layout_width="wrap_content"
8686
android:layout_height="wrap_content"
8787
android:layout_marginTop="50dp"
8888
android:paddingStart="30dp"
8989
android:paddingEnd="30dp"
90-
android:text="@string/drive_setup_step_3_action"
90+
android:text="@string/arduino_auth_settings_drive_confirm_button"
9191
app:layout_constraintEnd_toEndOf="parent"
9292
app:layout_constraintStart_toStartOf="parent"
9393
app:layout_constraintTop_toBottomOf="@id/drive_folder" />
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:app="http://schemas.android.com/apk/res-auto"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:background="@color/arduino_clouds"
7+
tools:context="com.google.android.apps.forscience.whistlepunk.gdrivesync.GDriveSyncSetupActivity">
8+
9+
<androidx.constraintlayout.widget.ConstraintLayout
10+
android:id="@+id/drive_header"
11+
android:layout_width="0dp"
12+
android:layout_height="wrap_content"
13+
android:clipChildren="false"
14+
android:paddingTop="20dp"
15+
app:layout_constraintEnd_toEndOf="parent"
16+
app:layout_constraintStart_toStartOf="parent"
17+
app:layout_constraintTop_toTopOf="parent">
18+
19+
<View
20+
android:id="@+id/placeholder_start"
21+
android:layout_width="48dp"
22+
android:layout_height="48dp"
23+
android:layout_marginStart="10dp"
24+
android:visibility="invisible"
25+
app:layout_constraintBottom_toBottomOf="parent"
26+
app:layout_constraintStart_toStartOf="parent"
27+
app:layout_constraintTop_toTopOf="parent" />
28+
29+
<View
30+
android:id="@+id/placeholder_end"
31+
android:layout_width="48dp"
32+
android:layout_height="48dp"
33+
android:layout_marginEnd="10dp"
34+
app:layout_constraintBottom_toBottomOf="parent"
35+
app:layout_constraintEnd_toEndOf="parent"
36+
app:layout_constraintTop_toTopOf="parent" />
37+
38+
<TextView
39+
style="@style/ArduinoAuth_Text.Header"
40+
android:layout_width="wrap_content"
41+
android:layout_height="wrap_content"
42+
android:contentDescription="@null"
43+
android:text="@string/drive_setup_step_3_title"
44+
app:layout_constraintBottom_toBottomOf="parent"
45+
app:layout_constraintEnd_toStartOf="@id/placeholder_end"
46+
app:layout_constraintStart_toEndOf="@id/placeholder_start"
47+
app:layout_constraintTop_toTopOf="parent" />
48+
</androidx.constraintlayout.widget.ConstraintLayout>
49+
50+
<TextView
51+
android:id="@+id/drive_description"
52+
style="@style/ArduinoAuth_Text"
53+
android:layout_width="wrap_content"
54+
android:layout_height="wrap_content"
55+
android:layout_marginTop="48dp"
56+
android:gravity="center"
57+
android:maxWidth="360dp"
58+
android:paddingStart="20dp"
59+
android:paddingEnd="20dp"
60+
android:text="@string/drive_setup_step_3_description"
61+
app:layout_constraintEnd_toEndOf="parent"
62+
app:layout_constraintStart_toStartOf="parent"
63+
app:layout_constraintTop_toBottomOf="@id/drive_header" />
64+
65+
<TextView
66+
android:id="@+id/drive_folder"
67+
style="@style/ArduinoAuth_Text"
68+
android:layout_width="wrap_content"
69+
android:layout_height="wrap_content"
70+
android:layout_marginTop="20dp"
71+
android:background="@drawable/drive_step3_folder_bg"
72+
android:drawablePadding="10dp"
73+
android:gravity="center"
74+
android:maxWidth="300dp"
75+
android:padding="10dp"
76+
android:textColor="@color/arduino_gris"
77+
app:drawableStartCompat="@drawable/ic_drive_folder"
78+
app:layout_constraintEnd_toEndOf="parent"
79+
app:layout_constraintStart_toStartOf="parent"
80+
app:layout_constraintTop_toBottomOf="@id/drive_description" />
81+
82+
<TextView
83+
android:id="@+id/drive_btn_sync"
84+
style="@style/ArduinoAuth_Button"
85+
android:layout_width="wrap_content"
86+
android:layout_height="wrap_content"
87+
android:layout_marginTop="50dp"
88+
android:paddingStart="30dp"
89+
android:paddingEnd="30dp"
90+
android:text="@string/arduino_auth_settings_drive_start_button"
91+
app:layout_constraintEnd_toEndOf="parent"
92+
app:layout_constraintStart_toStartOf="parent"
93+
app:layout_constraintTop_toBottomOf="@id/drive_folder" />
94+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)