Added tutorial. WIP
This commit is contained in:
parent
0ca3ec2ad8
commit
8afcce22b1
13 changed files with 104 additions and 24 deletions
|
|
@ -132,5 +132,6 @@ dependencies {
|
||||||
compile 'org.solovyev.android.views:linear-layout-manager:0.5@aar'
|
compile 'org.solovyev.android.views:linear-layout-manager:0.5@aar'
|
||||||
//noinspection GradleDynamicVersion
|
//noinspection GradleDynamicVersion
|
||||||
compile 'com.anjlab.android.iab.v3:library:1.0.+'
|
compile 'com.anjlab.android.iab.v3:library:1.0.+'
|
||||||
compile('de.psdev.licensesdialog:licensesdialog:1.8.0')
|
compile 'de.psdev.licensesdialog:licensesdialog:1.8.0'
|
||||||
|
compile 'com.github.kabouzeid:AppIntro:3.3.0k'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,10 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activities.AboutActivity"
|
android:name=".ui.activities.AboutActivity"
|
||||||
android:label="@string/action_about" />
|
android:label="@string/action_about" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".ui.activities.IntroActivity"
|
||||||
|
android:label="@string/intro_activity" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.kabouzeid.gramophone.ui.activities;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
|
||||||
|
import com.github.paolorotolo.appintro.AppIntro;
|
||||||
|
import com.github.paolorotolo.appintro.AppIntroFragment;
|
||||||
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.util.ColorUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
|
*/
|
||||||
|
public class IntroActivity extends AppIntro {
|
||||||
|
@Override
|
||||||
|
public void init(Bundle savedInstanceState) {
|
||||||
|
int color = ContextCompat.getColor(this, R.color.blue_grey_700);
|
||||||
|
setStatusBarColor(ColorUtil.shiftColorDown(color));
|
||||||
|
|
||||||
|
addSlide(AppIntroFragment.newInstance(getString(R.string.app_name), "Welcome to Phonograph, a beautiful and lightweight music player for Android. ", R.drawable.icon_web, color));
|
||||||
|
if (!hasExternalStoragePermission()) {
|
||||||
|
addSlide(AppIntroFragment.newInstance("Storage", "The storage permission is required for Phonograph to read your music library.", R.drawable.ic_folder_web, color));
|
||||||
|
askForPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
|
||||||
|
}
|
||||||
|
addSlide(AppIntroFragment.newInstance(getString(R.string.label_current_playing_queue), "You can swipe the card in the now playing screen up to reveal to full playing queue.", R.drawable.intro_swipe_up, color));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasExternalStoragePermission() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
return checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -114,6 +114,17 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
setStatusBarThemeColor();
|
setStatusBarThemeColor();
|
||||||
|
|
||||||
checkChangelog();
|
checkChangelog();
|
||||||
|
|
||||||
|
PreferenceUtil.getInstance(this).incrementAppOpenCount();
|
||||||
|
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (PreferenceUtil.getInstance(MainActivity.this).getAppOpenCount() == 1) {
|
||||||
|
startActivity(new Intent(MainActivity.this, IntroActivity.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,11 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.design.widget.Snackbar;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.widget.Toast;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.internal.ThemeSingleton;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
||||||
|
|
||||||
|
|
@ -28,7 +30,7 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||||
checkExternalStoragePermissions();
|
hasExternalStoragePermission = hasExternalStoragePermission();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -36,14 +38,18 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
||||||
super.onResume();
|
super.onResume();
|
||||||
enableViews();
|
enableViews();
|
||||||
|
|
||||||
|
if (!hasExternalStoragePermission()) {
|
||||||
|
requestPermissions();
|
||||||
|
} else if (didPermissionsChanged()) {
|
||||||
// the handler is necessary to avoid "java.lang.RuntimeException: Performing pause of activity that is not resumed"
|
// the handler is necessary to avoid "java.lang.RuntimeException: Performing pause of activity that is not resumed"
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
recreateIfPermissionsChanged();
|
recreate();
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchKeyEvent(@NonNull KeyEvent event) {
|
public boolean dispatchKeyEvent(@NonNull KeyEvent event) {
|
||||||
|
|
@ -83,24 +89,15 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
||||||
return areViewsEnabled;
|
return areViewsEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void recreateIfPermissionsChanged() {
|
|
||||||
if (didPermissionsChanged()) {
|
|
||||||
recreate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean didPermissionsChanged() {
|
private boolean didPermissionsChanged() {
|
||||||
return hasExternalStoragePermission != hasExternalStoragePermission();
|
return hasExternalStoragePermission != hasExternalStoragePermission();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkExternalStoragePermissions() {
|
private void requestPermissions() {
|
||||||
hasExternalStoragePermission = hasExternalStoragePermission();
|
|
||||||
if (!hasExternalStoragePermission) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_EXTERNAL_STORAGE_PERMISSION);
|
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_EXTERNAL_STORAGE_PERMISSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private boolean hasExternalStoragePermission() {
|
private boolean hasExternalStoragePermission() {
|
||||||
|
|
@ -117,7 +114,17 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Toast.makeText(this, getResources().getString(R.string.permission_to_access_external_storage_denied), Toast.LENGTH_SHORT).show();
|
Snackbar.make(getWindow().getDecorView(), R.string.permission_to_access_external_storage_denied, Snackbar.LENGTH_INDEFINITE)
|
||||||
|
.setAction(getString(R.string.action_settings), onGoToPermissionSettingsClickListener)
|
||||||
|
.setActionTextColor(ThemeSingleton.get().positiveColor)
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private View.OnClickListener onGoToPermissionSettingsClickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ public final class PreferenceUtil {
|
||||||
|
|
||||||
public static final String LAST_CHANGELOG_VERSION = "last_changelog_version";
|
public static final String LAST_CHANGELOG_VERSION = "last_changelog_version";
|
||||||
|
|
||||||
|
public static final String APP_OPEN_COUNT = "app_open_count";
|
||||||
|
|
||||||
private static PreferenceUtil sInstance;
|
private static PreferenceUtil sInstance;
|
||||||
|
|
||||||
private final SharedPreferences mPreferences;
|
private final SharedPreferences mPreferences;
|
||||||
|
|
@ -361,4 +363,12 @@ public final class PreferenceUtil {
|
||||||
public final int getLastChangelogVersion() {
|
public final int getLastChangelogVersion() {
|
||||||
return mPreferences.getInt(LAST_CHANGELOG_VERSION, -1);
|
return mPreferences.getInt(LAST_CHANGELOG_VERSION, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void incrementAppOpenCount() {
|
||||||
|
mPreferences.edit().putInt(APP_OPEN_COUNT, getAppOpenCount() + 1).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getAppOpenCount() {
|
||||||
|
return mPreferences.getInt(APP_OPEN_COUNT, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
app/src/main/res/drawable-xxxhdpi/ic_folder_web.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/ic_folder_web.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.8 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/icon_web.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/icon_web.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 163 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/intro_swipe_up.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/intro_swipe_up.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
|
|
@ -88,6 +88,12 @@
|
||||||
<copyright>Copyright 2014 AnjLab</copyright>
|
<copyright>Copyright 2014 AnjLab</copyright>
|
||||||
<license>Apache Software License 2.0</license>
|
<license>Apache Software License 2.0</license>
|
||||||
</notice>
|
</notice>
|
||||||
|
<notice>
|
||||||
|
<name>AppIntro</name>
|
||||||
|
<url>https://github.com/PaoloRotolo/AppIntro</url>
|
||||||
|
<copyright>Copyright {2015} {Paolo Rotolo}</copyright>
|
||||||
|
<license>Apache Software License 2.0</license>
|
||||||
|
</notice>
|
||||||
<notice>
|
<notice>
|
||||||
<name>Material Dialogs</name>
|
<name>Material Dialogs</name>
|
||||||
<url>https://github.com/afollestad/material-dialogs</url>
|
<url>https://github.com/afollestad/material-dialogs</url>
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@
|
||||||
<color name="grey_800">#424242</color>
|
<color name="grey_800">#424242</color>
|
||||||
<color name="grey_300">#E0E0E0</color>
|
<color name="grey_300">#E0E0E0</color>
|
||||||
|
|
||||||
|
<color name="blue_grey_700">#455A64</color>
|
||||||
|
|
||||||
<color name="white">#FFFFFF</color>
|
<color name="white">#FFFFFF</color>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
<string name="action_share">Share</string>
|
<string name="action_share">Share</string>
|
||||||
<string name="action_settings">"Settings"</string>
|
<string name="action_settings">"Settings"</string>
|
||||||
<string name="action_about">About</string>
|
<string name="action_about">About</string>
|
||||||
|
<string name="action_show_intro">Show intro</string>
|
||||||
<string name="action_clear_playlist">Clear playlist</string>
|
<string name="action_clear_playlist">Clear playlist</string>
|
||||||
<string name="action_playing_queue">Playing queue</string>
|
<string name="action_playing_queue">Playing queue</string>
|
||||||
<string name="action_add_to_favorites">Add to favorites</string>
|
<string name="action_add_to_favorites">Add to favorites</string>
|
||||||
|
|
@ -212,4 +213,5 @@
|
||||||
<string name="loading_products">Loading products…</string>
|
<string name="loading_products">Loading products…</string>
|
||||||
<string name="up_next">Up next</string>
|
<string name="up_next">Up next</string>
|
||||||
<string name="pref_title_now_playing_layout">Now playing layout</string>
|
<string name="pref_title_now_playing_layout">Now playing layout</string>
|
||||||
|
<string name="intro_activity">Intro</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue