Skip to content

Commit

Permalink
First-run telescope tutorial.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton committed Apr 3, 2015
1 parent a8ddf4a commit 3011014
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 2 deletions.
8 changes: 8 additions & 0 deletions ATTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ http://thenounproject.com/term/smile/71417/
error.png
CC BY 3.0
Modified from http://thenounproject.com/term/smile/71417/

telescope_tutorial_thumbs_up.png
CC BY 3.0
https://thenounproject.com/term/thumbs-up/40917/

telescope_tutorial_two_finger.png
CC BY 3.0
https://thenounproject.com/term/tap-and-hold/13944/
Original file line number Diff line number Diff line change
@@ -1,33 +1,84 @@
package com.jakewharton.u2020.ui;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import butterknife.ButterKnife;
import butterknife.InjectView;
import com.jakewharton.u2020.R;
import com.jakewharton.u2020.data.LumberYard;
import com.jakewharton.u2020.data.prefs.BooleanPreference;
import com.jakewharton.u2020.ui.bugreport.BugReportLens;
import com.mattprecious.telescope.Lens;
import com.mattprecious.telescope.TelescopeLayout;
import java.io.File;
import javax.inject.Inject;
import javax.inject.Singleton;

@Singleton
public final class TelescopeAppContainer implements AppContainer {
private final LumberYard lumberYard;
private final BooleanPreference seenTelescopeDialog;

@Inject public TelescopeAppContainer(LumberYard lumberYard) {
@Inject public TelescopeAppContainer(LumberYard lumberYard, SharedPreferences preferences) {
this.lumberYard = lumberYard;
this.seenTelescopeDialog = new BooleanPreference(preferences, "internal-seen-telescope-dialog");
}

@InjectView(R.id.telescope_container) TelescopeLayout telescopeLayout;

@Override public ViewGroup bind(Activity activity) {
@Override public ViewGroup bind(final Activity activity) {
activity.setContentView(R.layout.internal_activity_frame);
ButterKnife.inject(this, activity);

TelescopeLayout.cleanUp(activity); // Clean up any old screenshots.
telescopeLayout.setLens(new BugReportLens(activity, lumberYard));

// If you have not seen the telescope dialog before, show it.
if (!seenTelescopeDialog.get()) {
telescopeLayout.postDelayed(new Runnable() {
@Override public void run() {
if (activity.isFinishing()) {
return;
}

seenTelescopeDialog.set(true);
showTelescopeDialog(activity);
}
}, 1000);
}

return telescopeLayout;
}

public void showTelescopeDialog(final Activity activity) {
LayoutInflater inflater = LayoutInflater.from(activity);
TelescopeLayout content =
(TelescopeLayout) inflater.inflate(R.layout.telescope_tutorial_dialog, null);
final AlertDialog dialog =
new AlertDialog.Builder(activity).setView(content).setCancelable(false).create();

content.setLens(new Lens() {
@Override public void onCapture(File file) {
dialog.dismiss();

Context toastContext = new ContextThemeWrapper(activity, android.R.style.Theme_DeviceDefault_Dialog);
LayoutInflater toastInflater = LayoutInflater.from(toastContext);
Toast toast = Toast.makeText(toastContext, "", Toast.LENGTH_SHORT);
View toastView = toastInflater.inflate(R.layout.telescope_tutorial_toast, null);
toast.setView(toastView);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
});

dialog.show();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions src/internalRelease/res/layout/telescope_tutorial_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>

<com.mattprecious.telescope.TelescopeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:progressColor="@color/bugreport_frame"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="56dp"
android:gravity="center"
android:text="Quick &amp; Easy Bug Reports!"
android:textSize="20sp"
android:textStyle="bold"
android:background="@color/accent"
android:textColor="@color/timespan_title_text"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="center"
android:text="Found a bug? Report it!\n\nPress and hold two fingers on the screen to launch the reporting dialog."
android:textColor="?android:attr/textColorPrimary"
android:textSize="15sp"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/telescope_tutorial_two_finger"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="center"
android:text="Try it out to continue."
android:textColor="?android:attr/textColorPrimary"
android:textSize="15sp"
android:textStyle="bold"
/>
</LinearLayout>
</com.mattprecious.telescope.TelescopeLayout>
24 changes: 24 additions & 0 deletions src/internalRelease/res/layout/telescope_tutorial_toast.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="?android:attr/windowBackground"
android:gravity="center_horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Perfect!"
android:textColor="?android:attr/textColorPrimary"
android:textSize="20sp"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/telescope_tutorial_thumbs_up"
/>
</LinearLayout>

0 comments on commit 3011014

Please sign in to comment.