forked from cgruber/u2020
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8ddf4a
commit 3011014
Showing
6 changed files
with
136 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 53 additions & 2 deletions
55
src/internalRelease/java/com/jakewharton/u2020/ui/TelescopeAppContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Binary file added
BIN
+13.9 KB
src/internalRelease/res/drawable-xxhdpi/telescope_tutorial_thumbs_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.9 KB
src/internalRelease/res/drawable-xxhdpi/telescope_tutorial_two_finger.png
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
51
src/internalRelease/res/layout/telescope_tutorial_dialog.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 & 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
24
src/internalRelease/res/layout/telescope_tutorial_toast.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |