Fixed AppIntro, renamed some strings.

This commit is contained in:
Karim Abou Zeid 2015-12-30 16:13:21 +01:00
commit 82642ce94a
24 changed files with 104 additions and 43 deletions

View file

@ -35,4 +35,9 @@ public class IntroActivity extends AppIntro {
}
return true;
}
@Override
public void onBackPressed() {
previous();
}
}

View file

@ -74,6 +74,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
implements KabViewsDisableAble, CabHolder, DrawerLayout.DrawerListener {
public static final String TAG = MainActivity.class.getSimpleName();
public static final int APP_INTRO_REQUEST = 100;
@Bind(R.id.toolbar)
Toolbar toolbar;
@ -118,14 +119,26 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
checkChangelog();
PreferenceUtil.getInstance(this).incrementAppOpenCount();
if (PreferenceUtil.getInstance(MainActivity.this).getAppOpenCount() == 1) {
if (PreferenceUtil.getInstance(this).getAppOpenCount() == 1) {
// let the app intro handle getting the permissions first
introActivityHandlingPermissions = true;
new Thread(new Runnable() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(MainActivity.this, IntroActivity.class));
startActivityForResult(new Intent(MainActivity.this, IntroActivity.class), APP_INTRO_REQUEST);
}
}).start();
}, 200);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == APP_INTRO_REQUEST) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// app intro is done, recreate to refresh permissions
onPermissionsChanged();
}
}
}
@ -343,7 +356,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title);
}
Fragment currentFragment = getCurrentFragment();
if (currentFragment instanceof AbsMainActivityRecyclerViewCustomGridSizeFragment) {
if (currentFragment instanceof AbsMainActivityRecyclerViewCustomGridSizeFragment && currentFragment.isAdded()) {
AbsMainActivityRecyclerViewCustomGridSizeFragment absMainActivityRecyclerViewCustomGridSizeFragment = (AbsMainActivityRecyclerViewCustomGridSizeFragment) currentFragment;
MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);

View file

@ -25,6 +25,9 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
private boolean createdWithPermissionsGranted;
private String[] permissions;
private String permissionDeniedMessage;
private Snackbar goToPermissionsSnackbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -33,6 +36,16 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
permissions = getPermissionsToRequest();
createdWithPermissionsGranted = hasPermissions();
setPermissionDeniedMessage(null);
}
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
if (!hasPermissions()) {
requestPermissions();
}
}
@Override
@ -40,19 +53,27 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
super.onResume();
enableViews();
if (!hasPermissions()) {
requestPermissions();
} else if (!createdWithPermissionsGranted) {
// the handler is necessary to avoid "java.lang.RuntimeException: Performing pause of activity that is not resumed"
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
recreate();
}
}, 200);
if (hasPermissions() != createdWithPermissionsGranted) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// the handler is necessary to avoid "java.lang.RuntimeException: Performing pause of activity that is not resumed"
onPermissionsChanged();
}
}
}
protected void onPermissionsChanged() {
postRecreate();
}
protected void postRecreate() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
recreate();
}
}, 200);
}
@Override
public boolean dispatchKeyEvent(@NonNull KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_MENU && event.getAction() == KeyEvent.ACTION_UP) {
@ -96,6 +117,17 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
return null;
}
protected void setPermissionDeniedMessage(String message) {
if (message == null) {
permissionDeniedMessage = getString(R.string.permissions_denied);
} else {
permissionDeniedMessage = message;
}
if (goToPermissionsSnackbar != null) {
goToPermissionsSnackbar.setText(permissionDeniedMessage);
}
}
protected void requestPermissions() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && permissions != null) {
requestPermissions(permissions, PERMISSION_REQUEST);
@ -118,16 +150,21 @@ public abstract class AbsBaseActivity extends AbsThemeActivity implements KabVie
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == PERMISSION_REQUEST) {
for (int grantResult : grantResults) {
if (grantResult == PackageManager.PERMISSION_GRANTED) {
recreate();
if (grantResult != PackageManager.PERMISSION_GRANTED) {
if (goToPermissionsSnackbar == null) {
goToPermissionsSnackbar = Snackbar.make(getWindow().getDecorView(), permissionDeniedMessage, Snackbar.LENGTH_INDEFINITE)
.setAction(getString(R.string.action_settings), goToPermissionSettingsOnClick)
.setActionTextColor(ThemeSingleton.get().positiveColor);
goToPermissionsSnackbar.show();
}
return;
}
}
//TODO snack nachricht veralgemeinern
Snackbar.make(getWindow().getDecorView(), R.string.permission_to_access_external_storage_denied, Snackbar.LENGTH_INDEFINITE)
.setAction(getString(R.string.action_settings), goToPermissionSettingsOnClick)
.setActionTextColor(ThemeSingleton.get().positiveColor)
.show();
if (goToPermissionsSnackbar != null) {
goToPermissionsSnackbar.dismiss();
goToPermissionsSnackbar = null;
}
onPermissionsChanged();
}
}

View file

@ -12,6 +12,7 @@ import android.os.IBinder;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.interfaces.MusicServiceEventListener;
import com.kabouzeid.gramophone.service.MusicService;
@ -36,6 +37,8 @@ public abstract class AbsMusicServiceActivity extends AbsBaseActivity implements
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
serviceToken = MusicPlayerRemote.bindToService(this, this);
setPermissionDeniedMessage(getString(R.string.permission_external_storage_denied));
}
@Override

View file

@ -171,8 +171,10 @@ public class PlaybackControlsFragment extends Fragment implements MusicServiceEv
playPauseFab.post(new Runnable() {
@Override
public void run() {
playPauseFab.setPivotX(playPauseFab.getWidth() / 2);
playPauseFab.setPivotY(playPauseFab.getHeight() / 2);
if (playPauseFab != null) {
playPauseFab.setPivotX(playPauseFab.getWidth() / 2);
playPauseFab.setPivotY(playPauseFab.getHeight() / 2);
}
}
});
}

View file

@ -172,7 +172,7 @@
<string name="special_thanks_to">Besonderes Dankeschön an</string>
<string name="changelog">Änderungen</string>
<string name="licenses">Lizenzen</string>
<string name="permission_to_access_external_storage_denied">Die Rechte um auf den externen Speicher zuzugreifen wurden verweigert.</string>
<string name="permission_external_storage_denied">Die Rechte um auf den externen Speicher zuzugreifen wurden verweigert.</string>
<string name="back">zurück</string>
<string name="support_development">Unterstütze die Entwicklung</string>
<string name="thank_you">Vielen Dank!</string>

View file

@ -172,7 +172,7 @@
<string name="special_thanks_to">Agradecimientos especiales a</string>
<string name="changelog">Lista de cambios</string>
<string name="licenses">Licencias</string>
<string name="permission_to_access_external_storage_denied">Permiso para acceder al almacenamiento externo denegado.</string>
<string name="permission_external_storage_denied">Permiso para acceder al almacenamiento externo denegado.</string>
<string name="back">regresar</string>
<string name="support_development">Apoyar desarrollo</string>
<string name="thank_you">¡Gracias!</string>

View file

@ -172,7 +172,7 @@
<string name="special_thanks_to">Agradecimientos especiales a</string>
<string name="changelog">Lista de cambios</string>
<string name="licenses">Licencias</string>
<string name="permission_to_access_external_storage_denied">Permiso para acceder al almacenamiento externo denegado.</string>
<string name="permission_external_storage_denied">Permiso para acceder al almacenamiento externo denegado.</string>
<string name="back">regresar</string>
<string name="support_development">Apoyar el desarrollo</string>
<string name="thank_you">¡Gracias!</string>

View file

@ -172,7 +172,7 @@
<string name="special_thanks_to">Un grand merci à</string>
<string name="changelog">Changelog</string>
<string name="licenses">Licences</string>
<string name="permission_to_access_external_storage_denied">Accès au stockage externe refusé.</string>
<string name="permission_external_storage_denied">Accès au stockage externe refusé.</string>
<string name="back">Retour</string>
<string name="support_development">Faire un don</string>
<string name="thank_you">Merci !</string>

View file

@ -171,7 +171,7 @@
<string name="colored_footers">Obojena podnožja</string>
<string name="special_thanks_to">Posebna zahvala</string>
<string name="changelog">Promjene</string>
<string name="permission_to_access_external_storage_denied">Dopuštenje za pristup vanjskoj pohrani je odbijeno.</string>
<string name="permission_external_storage_denied">Dopuštenje za pristup vanjskoj pohrani je odbijeno.</string>
<string name="back">natrag</string>
<string name="support_development">Podržite razvoj</string>
<string name="thank_you">Hvala vam!</string>

View file

@ -168,7 +168,7 @@
<string name="colored_footers">Footer berwarna</string>
<string name="special_thanks_to">Terima kasih khusus kepada</string>
<string name="changelog">Log perubahan</string>
<string name="permission_to_access_external_storage_denied">"Izin akses memori eksternal ditolak. "</string>
<string name="permission_external_storage_denied">"Izin akses memori eksternal ditolak. "</string>
<string name="back">kembali</string>
<string name="support_development">Dukung pengembangan</string>
<string name="thank_you">Terima kasih!</string>

View file

@ -168,7 +168,7 @@
<string name="colored_footers">Footer berwarna</string>
<string name="special_thanks_to">Terima kasih khusus kepada</string>
<string name="changelog">Log perubahan</string>
<string name="permission_to_access_external_storage_denied">"Izin akses memori eksternal ditolak. "</string>
<string name="permission_external_storage_denied">"Izin akses memori eksternal ditolak. "</string>
<string name="back">kembali</string>
<string name="support_development">Dukung pengembangan</string>
<string name="thank_you">Terima kasih!</string>

View file

@ -171,7 +171,7 @@
<string name="colored_footers">Riquadri colorati</string>
<string name="special_thanks_to">Ringraziamenti speciali a</string>
<string name="changelog">Modifiche</string>
<string name="permission_to_access_external_storage_denied">Permesso per accedere alla memoria esterna negato.</string>
<string name="permission_external_storage_denied">Permesso per accedere alla memoria esterna negato.</string>
<string name="back">indietro</string>
<string name="support_development">Supporta lo sviluppo</string>
<string name="thank_you">Grazie!</string>

View file

@ -166,7 +166,7 @@
<string name="colored_footers">색칠된 앨범 카드</string>
<string name="special_thanks_to">"특별히 감사드립니다 : "</string>
<string name="changelog">변경점</string>
<string name="permission_to_access_external_storage_denied">외장 메모리 접근 권한이 거부되었습니다.</string>
<string name="permission_external_storage_denied">외장 메모리 접근 권한이 거부되었습니다.</string>
<string name="back">뒤로</string>
<string name="support_development">개발자 지원하기</string>
<string name="thank_you">감사합니다!</string>

View file

@ -168,7 +168,7 @@
<string name="colored_footers">Gekleurde voetkaders</string>
<string name="special_thanks_to">Speciale dank aan</string>
<string name="changelog">Changelog</string>
<string name="permission_to_access_external_storage_denied">Toegang tot externe opslag geweigerd.</string>
<string name="permission_external_storage_denied">Toegang tot externe opslag geweigerd.</string>
<string name="back">Terug</string>
<string name="support_development">Ondersteun ontwikkeling</string>
<string name="thank_you">Dankjewel!</string>

View file

@ -170,7 +170,7 @@
<string name="colored_footers">Kolorowe stopki</string>
<string name="special_thanks_to">Specjalne podziękowania dla</string>
<string name="changelog">Lista zmian</string>
<string name="permission_to_access_external_storage_denied">Pozwolenie na dostęp do pamięci zewnętrznej odrzucone</string>
<string name="permission_external_storage_denied">Pozwolenie na dostęp do pamięci zewnętrznej odrzucone</string>
<string name="back">Wróć</string>
<string name="support_development">Wspomóż rozwój</string>
<string name="thank_you">Dziękuję!</string>

View file

@ -168,7 +168,7 @@
<string name="colored_footers">Rodapés coloridos</string>
<string name="special_thanks_to">Agradecimentos especiais para</string>
<string name="changelog">Novidades</string>
<string name="permission_to_access_external_storage_denied">Permissão para acessar armazenamento externo negado.</string>
<string name="permission_external_storage_denied">Permissão para acessar armazenamento externo negado.</string>
<string name="back">voltar</string>
<string name="support_development">Apoiar o desenvolvimento</string>
<string name="thank_you">Obrigado!</string>

View file

@ -168,7 +168,7 @@
<string name="colored_footers">Rodapés coloridos</string>
<string name="special_thanks_to">Agradecimentos especiais a</string>
<string name="changelog">Changelog</string>
<string name="permission_to_access_external_storage_denied">Permissão negada para aceder a armazenamento externo.</string>
<string name="permission_external_storage_denied">Permissão negada para aceder a armazenamento externo.</string>
<string name="back">voltar</string>
<string name="support_development">Apoiar o desenvolvimento</string>
<string name="thank_you">Obrigado!</string>

View file

@ -171,7 +171,7 @@
<string name="colored_footers">Окрашенные нижние колонтитулы</string>
<string name="special_thanks_to">Особая благодарность</string>
<string name="changelog">Список изменений</string>
<string name="permission_to_access_external_storage_denied">В разрешении на доступ к внешнему хранилищу отказано.</string>
<string name="permission_external_storage_denied">В разрешении на доступ к внешнему хранилищу отказано.</string>
<string name="back">назад</string>
<string name="support_development">Поддержать разработку</string>
<string name="thank_you">Спасибо!</string>

View file

@ -171,7 +171,7 @@
<string name="colored_footers">Renkli alt bilgiler</string>
<string name="special_thanks_to">Özel teşekkür</string>
<string name="changelog">Sürüm Notları</string>
<string name="permission_to_access_external_storage_denied">Harici depolamaya erişmek için izin verilmedi</string>
<string name="permission_external_storage_denied">Harici depolamaya erişmek için izin verilmedi</string>
<string name="back">geri</string>
<string name="support_development">Geliştirmeyi destekleyin</string>
<string name="thank_you">Teşekkürler</string>

View file

@ -168,7 +168,7 @@
<string name="colored_footers">Фарбовані колонтитули</string>
<string name="special_thanks_to">Особлива подяка</string>
<string name="changelog">Список змін</string>
<string name="permission_to_access_external_storage_denied">У дозволі на доступ до зовнішньої пам’яті відмовлено.</string>
<string name="permission_external_storage_denied">У дозволі на доступ до зовнішньої пам’яті відмовлено.</string>
<string name="back">назад</string>
<string name="support_development">Підтримати розробника</string>
<string name="thank_you">Щиро дякую!</string>

View file

@ -171,7 +171,7 @@
<string name="colored_footers">变色页脚</string>
<string name="special_thanks_to">特别感谢</string>
<string name="changelog">更新日志</string>
<string name="permission_to_access_external_storage_denied">访问外部存储的权限被拒绝。</string>
<string name="permission_external_storage_denied">访问外部存储的权限被拒绝。</string>
<string name="back">返回</string>
<string name="support_development">支持开发者</string>
<string name="thank_you">非常感谢!</string>

View file

@ -166,7 +166,7 @@
<string name="colored_footers">彩色的註腳</string>
<string name="special_thanks_to">特別感謝</string>
<string name="changelog">新功能</string>
<string name="permission_to_access_external_storage_denied">無法取得存取外部儲存空間的權限。</string>
<string name="permission_external_storage_denied">無法取得存取外部儲存空間的權限。</string>
<string name="back">返回</string>
<string name="support_development">支援開發</string>
<string name="thank_you">感謝您!</string>

View file

@ -182,7 +182,8 @@
<string name="special_thanks_to">Special thanks to</string>
<string name="changelog">Changelog</string>
<string name="licenses">Licenses</string>
<string name="permission_to_access_external_storage_denied">Permission to access external storage denied.</string>
<string name="permissions_denied">Permissions denied.</string>
<string name="permission_external_storage_denied">Permission to access external storage denied.</string>
<string name="back">back</string>
<string name="support_development">Support development</string>
<string name="thank_you">Thank you!</string>