add themed remoteview

This commit is contained in:
Alexey Kuznetsov 2016-04-03 10:01:23 +03:00
commit d0edb73265
6 changed files with 27 additions and 17 deletions

View file

@ -1,6 +1,7 @@
package com.github.axet.audiorecorder.activities;
import android.Manifest;
import android.app.ActionBar;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
@ -8,6 +9,8 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;

View file

@ -138,25 +138,15 @@ public class RecordingService extends Service {
new Intent(this, RecordingService.class).setAction(PAUSE_BUTTON),
PendingIntent.FLAG_UPDATE_CURRENT);
RemoteViews view = new RemoteViews(getPackageName(), R.layout.notifictaion_recording);
RemoteViews view = new RemoteViews(getPackageName(), MainApplication.getTheme(getBaseContext(),
R.layout.notifictaion_recording_light,
R.layout.notifictaion_recording_dark));
view.setOnClickPendingIntent(R.id.status_bar_latest_event_content, main);
view.setTextViewText(R.id.notification_text, ".../" + targetFile);
view.setOnClickPendingIntent(R.id.notification_pause, pe);
view.setImageViewResource(R.id.notification_pause, !recording ? R.drawable.play : R.drawable.pause);
getBaseContext().setTheme(((MainApplication) getApplication()).getUserTheme());
view.apply(new ContextWrapper(getBaseContext()) {
public Context createPackageContext(String packageName, int flags) throws PackageManager.NameNotFoundException {
return new ContextWrapper(getBaseContext().createPackageContext(packageName, flags)) {
@Override
public Resources.Theme getTheme() {
return getBaseContext().getTheme();
}
};
}
}, null);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setOngoing(true)
.setContentTitle("Recording")

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/AppThemeDark">
<include layout="@layout/notifictaion_recording" />
</FrameLayout>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/AppThemeLight">
<include layout="@layout/notifictaion_recording" />
</FrameLayout>

View file

@ -70,8 +70,8 @@
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="vertical"
android:background="?attr/secondBackground"
android:orientation="vertical"
android:padding="5dp">
<LinearLayout
@ -81,11 +81,11 @@
android:orientation="horizontal">
<TextView
android:textColor="?android:textColorSecondary"
android:id="@+id/recording_player_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="01:01" />
android:text="01:01"
android:textColor="?android:textColorSecondary" />
<SeekBar
android:id="@+id/recording_player_seek"

View file

@ -2,4 +2,5 @@
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="secondBackground">#33333333</color>
</resources>