switch to androidx
This commit is contained in:
parent
0b22a18088
commit
d6becd15c1
@ -35,23 +35,21 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
implementation 'com.android.support:support-v4:28.0.0'
|
//implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
implementation 'androidx.appcompat:appcompat:1.0.0'
|
||||||
implementation 'com.android.support:cardview-v7:28.0.0'
|
implementation 'androidx.cardview:cardview:1.0.0'
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
implementation 'com.android.support:recyclerview-v7:28.0.0'
|
implementation 'androidx.recyclerview:recyclerview:1.0.0'
|
||||||
implementation 'com.android.support:design:28.0.0'
|
implementation 'com.google.android.material:material:1.0.0'
|
||||||
|
|
||||||
implementation 'com.takisoft.fix:preference-v7:28.0.0.0'
|
|
||||||
implementation 'com.takisoft.fix:preference-v7-extras:28.0.0.0'
|
|
||||||
|
|
||||||
implementation 'com.google.firebase:firebase-core:16.0.4'
|
implementation 'com.google.firebase:firebase-core:16.0.4'
|
||||||
implementation 'com.google.firebase:firebase-messaging:17.3.3'
|
implementation 'com.google.firebase:firebase-messaging:17.3.4'
|
||||||
|
|
||||||
implementation "android.arch.lifecycle:extensions:1.1.1"
|
implementation "android.arch.lifecycle:extensions:1.1.1"
|
||||||
|
|
||||||
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
|
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
|
||||||
implementation 'com.github.kenglxn.QRGen:android:2.5.0'
|
implementation 'com.github.kenglxn.QRGen:android:2.5.0'
|
||||||
|
implementation "com.github.DeweyReed:UltimateMusicPicker:2.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'com.google.gms.google-services'
|
apply plugin: 'com.google.gms.google-services'
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.blackforestbytes.simplecloudnotifier">
|
package="com.blackforestbytes.simplecloudnotifier">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="false"
|
android:allowBackup="false"
|
||||||
android:name="SCNApp"
|
android:name="SCNApp"
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
package com.blackforestbytes.simplecloudnotifier;
|
package com.blackforestbytes.simplecloudnotifier;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.arch.lifecycle.Lifecycle;
|
|
||||||
import android.arch.lifecycle.LifecycleObserver;
|
|
||||||
import android.arch.lifecycle.OnLifecycleEvent;
|
|
||||||
import android.arch.lifecycle.ProcessLifecycleOwner;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.blackforestbytes.simplecloudnotifier.model.CMessageList;
|
|
||||||
import com.blackforestbytes.simplecloudnotifier.service.NotificationService;
|
|
||||||
import com.blackforestbytes.simplecloudnotifier.view.AccountFragment;
|
import com.blackforestbytes.simplecloudnotifier.view.AccountFragment;
|
||||||
import com.blackforestbytes.simplecloudnotifier.view.MainActivity;
|
import com.blackforestbytes.simplecloudnotifier.view.MainActivity;
|
||||||
import com.blackforestbytes.simplecloudnotifier.view.TabAdapter;
|
import com.blackforestbytes.simplecloudnotifier.view.TabAdapter;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
import androidx.lifecycle.Lifecycle;
|
||||||
|
import androidx.lifecycle.LifecycleObserver;
|
||||||
|
import androidx.lifecycle.OnLifecycleEvent;
|
||||||
|
import androidx.lifecycle.ProcessLifecycleOwner;
|
||||||
|
|
||||||
public class SCNApp extends Application implements LifecycleObserver
|
public class SCNApp extends Application implements LifecycleObserver
|
||||||
{
|
{
|
||||||
private static SCNApp instance;
|
private static SCNApp instance;
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.blackforestbytes.simplecloudnotifier.model;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
|
|
||||||
|
public class NotificationSettings
|
||||||
|
{
|
||||||
|
public boolean EnableSound = false;
|
||||||
|
public String SoundSource = "";
|
||||||
|
public boolean RepeatSound = false;
|
||||||
|
|
||||||
|
public boolean EnableLED = false;
|
||||||
|
public int LEDColor = Color.BLUE;
|
||||||
|
|
||||||
|
public boolean EnableVibration = false;
|
||||||
|
}
|
@ -22,6 +22,12 @@ public class SCNSettings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
|
||||||
|
public final static Integer[] CHOOSABLE_CACHE_SIZES = new Integer[]{20, 50, 100, 200, 500, 1000, 2000, 5000};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
|
||||||
public int quota_curr;
|
public int quota_curr;
|
||||||
public int quota_max;
|
public int quota_max;
|
||||||
public int user_id;
|
public int user_id;
|
||||||
@ -30,6 +36,17 @@ public class SCNSettings
|
|||||||
public String fcm_token_local;
|
public String fcm_token_local;
|
||||||
public String fcm_token_server;
|
public String fcm_token_server;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
|
||||||
|
public boolean Enabled = true;
|
||||||
|
public int LocalCacheSize = 500;
|
||||||
|
|
||||||
|
public final NotificationSettings PriorityLow = new NotificationSettings();
|
||||||
|
public final NotificationSettings PriorityNorm = new NotificationSettings();
|
||||||
|
public final NotificationSettings PriorityHigh = new NotificationSettings();
|
||||||
|
|
||||||
|
// ------------------------------------------------------------
|
||||||
|
|
||||||
public SCNSettings()
|
public SCNSettings()
|
||||||
{
|
{
|
||||||
SharedPreferences sharedPref = SCNApp.getContext().getSharedPreferences("Config", Context.MODE_PRIVATE);
|
SharedPreferences sharedPref = SCNApp.getContext().getSharedPreferences("Config", Context.MODE_PRIVATE);
|
||||||
@ -40,6 +57,30 @@ public class SCNSettings
|
|||||||
user_key = sharedPref.getString("user_key", "");
|
user_key = sharedPref.getString("user_key", "");
|
||||||
fcm_token_local = sharedPref.getString("fcm_token_local", "");
|
fcm_token_local = sharedPref.getString("fcm_token_local", "");
|
||||||
fcm_token_server = sharedPref.getString("fcm_token_server", "");
|
fcm_token_server = sharedPref.getString("fcm_token_server", "");
|
||||||
|
|
||||||
|
Enabled = sharedPref.getBoolean("app_enabled", Enabled);
|
||||||
|
LocalCacheSize = sharedPref.getInt("local_cache_size", LocalCacheSize);
|
||||||
|
|
||||||
|
PriorityLow.EnableLED = sharedPref.getBoolean("priority_low:enabled_led", PriorityLow.EnableLED);
|
||||||
|
PriorityLow.EnableSound = sharedPref.getBoolean("priority_low:enabled_sound", PriorityLow.EnableSound);
|
||||||
|
PriorityLow.EnableVibration = sharedPref.getBoolean("priority_low:enabled_vibration", PriorityLow.EnableVibration);
|
||||||
|
PriorityLow.RepeatSound = sharedPref.getBoolean("priority_low:repeat_sound", PriorityLow.RepeatSound);
|
||||||
|
PriorityLow.SoundSource = sharedPref.getString( "priority_low:sound_source", PriorityLow.SoundSource);
|
||||||
|
PriorityLow.LEDColor = sharedPref.getInt( "priority_low:led_color", PriorityLow.LEDColor);
|
||||||
|
|
||||||
|
PriorityNorm.EnableLED = sharedPref.getBoolean("priority_norm:enabled_led", PriorityNorm.EnableLED);
|
||||||
|
PriorityNorm.EnableSound = sharedPref.getBoolean("priority_norm:enabled_sound", PriorityNorm.EnableSound);
|
||||||
|
PriorityNorm.EnableVibration = sharedPref.getBoolean("priority_norm:enabled_vibration", PriorityNorm.EnableVibration);
|
||||||
|
PriorityNorm.RepeatSound = sharedPref.getBoolean("priority_norm:repeat_sound", PriorityNorm.RepeatSound);
|
||||||
|
PriorityNorm.SoundSource = sharedPref.getString( "priority_norm:sound_source", PriorityNorm.SoundSource);
|
||||||
|
PriorityNorm.LEDColor = sharedPref.getInt( "priority_norm:led_color", PriorityNorm.LEDColor);
|
||||||
|
|
||||||
|
PriorityHigh.EnableLED = sharedPref.getBoolean("priority_high:enabled_led", PriorityHigh.EnableLED);
|
||||||
|
PriorityHigh.EnableSound = sharedPref.getBoolean("priority_high:enabled_sound", PriorityHigh.EnableSound);
|
||||||
|
PriorityHigh.EnableVibration = sharedPref.getBoolean("priority_high:enabled_vibration", PriorityHigh.EnableVibration);
|
||||||
|
PriorityHigh.RepeatSound = sharedPref.getBoolean("priority_high:repeat_sound", PriorityHigh.RepeatSound);
|
||||||
|
PriorityHigh.SoundSource = sharedPref.getString( "priority_high:sound_source", PriorityHigh.SoundSource);
|
||||||
|
PriorityHigh.LEDColor = sharedPref.getInt( "priority_high:led_color", PriorityHigh.LEDColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save()
|
public void save()
|
||||||
@ -54,6 +95,30 @@ public class SCNSettings
|
|||||||
e.putString("fcm_token_local", fcm_token_local);
|
e.putString("fcm_token_local", fcm_token_local);
|
||||||
e.putString("fcm_token_server", fcm_token_server);
|
e.putString("fcm_token_server", fcm_token_server);
|
||||||
|
|
||||||
|
e.putBoolean("app_enabled", Enabled);
|
||||||
|
e.putInt( "local_cache_size", LocalCacheSize);
|
||||||
|
|
||||||
|
e.putBoolean("priority_low:enabled_led", PriorityLow.EnableLED);
|
||||||
|
e.putBoolean("priority_low:enabled_sound", PriorityLow.EnableSound);
|
||||||
|
e.putBoolean("priority_low:enabled_vibration", PriorityLow.EnableVibration);
|
||||||
|
e.putBoolean("priority_low:repeat_sound", PriorityLow.RepeatSound);
|
||||||
|
e.putString( "priority_low:sound_source", PriorityLow.SoundSource);
|
||||||
|
e.putInt( "priority_low:led_color", PriorityLow.LEDColor);
|
||||||
|
|
||||||
|
e.putBoolean("priority_norm:enabled_led", PriorityNorm.EnableLED);
|
||||||
|
e.putBoolean("priority_norm:enabled_sound", PriorityNorm.EnableSound);
|
||||||
|
e.putBoolean("priority_norm:enabled_vibration", PriorityNorm.EnableVibration);
|
||||||
|
e.putBoolean("priority_norm:repeat_sound", PriorityNorm.RepeatSound);
|
||||||
|
e.putString( "priority_norm:sound_source", PriorityNorm.SoundSource);
|
||||||
|
e.putInt( "priority_norm:led_color", PriorityNorm.LEDColor);
|
||||||
|
|
||||||
|
e.putBoolean("priority_high:enabled_led", PriorityHigh.EnableLED);
|
||||||
|
e.putBoolean("priority_high:enabled_sound", PriorityHigh.EnableSound);
|
||||||
|
e.putBoolean("priority_high:enabled_vibration", PriorityHigh.EnableVibration);
|
||||||
|
e.putBoolean("priority_high:repeat_sound", PriorityHigh.RepeatSound);
|
||||||
|
e.putString( "priority_high:sound_source", PriorityHigh.SoundSource);
|
||||||
|
e.putInt( "priority_high:led_color", PriorityHigh.LEDColor);
|
||||||
|
|
||||||
e.apply();
|
e.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +1,13 @@
|
|||||||
package com.blackforestbytes.simplecloudnotifier.service;
|
package com.blackforestbytes.simplecloudnotifier.service;
|
||||||
|
|
||||||
import android.app.NotificationManager;
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.support.v4.app.NotificationCompat;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.blackforestbytes.simplecloudnotifier.R;
|
|
||||||
import com.blackforestbytes.simplecloudnotifier.SCNApp;
|
import com.blackforestbytes.simplecloudnotifier.SCNApp;
|
||||||
import com.blackforestbytes.simplecloudnotifier.model.CMessage;
|
import com.blackforestbytes.simplecloudnotifier.model.CMessage;
|
||||||
import com.blackforestbytes.simplecloudnotifier.model.CMessageList;
|
import com.blackforestbytes.simplecloudnotifier.model.CMessageList;
|
||||||
import com.blackforestbytes.simplecloudnotifier.model.PriorityEnum;
|
import com.blackforestbytes.simplecloudnotifier.model.PriorityEnum;
|
||||||
import com.blackforestbytes.simplecloudnotifier.model.SCNSettings;
|
import com.blackforestbytes.simplecloudnotifier.model.SCNSettings;
|
||||||
import com.blackforestbytes.simplecloudnotifier.view.MainActivity;
|
|
||||||
import com.google.firebase.messaging.FirebaseMessagingService;
|
import com.google.firebase.messaging.FirebaseMessagingService;
|
||||||
import com.google.firebase.messaging.RemoteMessage;
|
import com.google.firebase.messaging.RemoteMessage;
|
||||||
|
|
||||||
|
@ -7,13 +7,14 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.support.v4.app.NotificationCompat;
|
|
||||||
|
|
||||||
import com.blackforestbytes.simplecloudnotifier.R;
|
import com.blackforestbytes.simplecloudnotifier.R;
|
||||||
import com.blackforestbytes.simplecloudnotifier.SCNApp;
|
import com.blackforestbytes.simplecloudnotifier.SCNApp;
|
||||||
import com.blackforestbytes.simplecloudnotifier.model.CMessage;
|
import com.blackforestbytes.simplecloudnotifier.model.CMessage;
|
||||||
import com.blackforestbytes.simplecloudnotifier.view.MainActivity;
|
import com.blackforestbytes.simplecloudnotifier.view.MainActivity;
|
||||||
|
|
||||||
|
import androidx.core.app.NotificationCompat;
|
||||||
|
|
||||||
public class NotificationService
|
public class NotificationService
|
||||||
{
|
{
|
||||||
private final static String CHANNEL_ID = "CHAN_BFB_SCN_MESSAGES";
|
private final static String CHANNEL_ID = "CHAN_BFB_SCN_MESSAGES";
|
||||||
|
@ -6,8 +6,6 @@ import android.content.ClipboardManager;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -22,6 +20,9 @@ import com.blackforestbytes.simplecloudnotifier.model.SCNSettings;
|
|||||||
import net.glxn.qrgen.android.QRCode;
|
import net.glxn.qrgen.android.QRCode;
|
||||||
import net.glxn.qrgen.core.image.ImageType;
|
import net.glxn.qrgen.core.image.ImageType;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import static android.content.Context.CLIPBOARD_SERVICE;
|
import static android.content.Context.CLIPBOARD_SERVICE;
|
||||||
|
|
||||||
public class AccountFragment extends Fragment
|
public class AccountFragment extends Fragment
|
||||||
|
@ -1,24 +1,18 @@
|
|||||||
package com.blackforestbytes.simplecloudnotifier.view;
|
package com.blackforestbytes.simplecloudnotifier.view;
|
||||||
|
|
||||||
import android.support.design.widget.TabLayout;
|
|
||||||
import android.support.v4.view.PagerAdapter;
|
|
||||||
import android.support.v4.view.ViewPager;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
|
|
||||||
import com.blackforestbytes.simplecloudnotifier.R;
|
import com.blackforestbytes.simplecloudnotifier.R;
|
||||||
import com.blackforestbytes.simplecloudnotifier.SCNApp;
|
import com.blackforestbytes.simplecloudnotifier.SCNApp;
|
||||||
import com.blackforestbytes.simplecloudnotifier.model.CMessageList;
|
import com.blackforestbytes.simplecloudnotifier.model.CMessageList;
|
||||||
import com.blackforestbytes.simplecloudnotifier.model.SCNSettings;
|
import com.blackforestbytes.simplecloudnotifier.model.SCNSettings;
|
||||||
import com.blackforestbytes.simplecloudnotifier.model.ServerCommunication;
|
|
||||||
import com.blackforestbytes.simplecloudnotifier.service.NotificationService;
|
import com.blackforestbytes.simplecloudnotifier.service.NotificationService;
|
||||||
import com.google.firebase.iid.FirebaseInstanceId;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.viewpager.widget.PagerAdapter;
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity
|
public class MainActivity extends AppCompatActivity
|
||||||
{
|
{
|
||||||
|
@ -1,19 +1,18 @@
|
|||||||
package com.blackforestbytes.simplecloudnotifier.view;
|
package com.blackforestbytes.simplecloudnotifier.view;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.blackforestbytes.simplecloudnotifier.R;
|
import com.blackforestbytes.simplecloudnotifier.R;
|
||||||
import com.blackforestbytes.simplecloudnotifier.SCNApp;
|
|
||||||
import com.blackforestbytes.simplecloudnotifier.model.CMessage;
|
import com.blackforestbytes.simplecloudnotifier.model.CMessage;
|
||||||
import com.blackforestbytes.simplecloudnotifier.model.CMessageList;
|
import com.blackforestbytes.simplecloudnotifier.model.CMessageList;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
public class MessageAdapter extends RecyclerView.Adapter
|
public class MessageAdapter extends RecyclerView.Adapter
|
||||||
{
|
{
|
||||||
private final View vNoElements;
|
private final View vNoElements;
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
package com.blackforestbytes.simplecloudnotifier.view;
|
package com.blackforestbytes.simplecloudnotifier.view;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.blackforestbytes.simplecloudnotifier.R;
|
import com.blackforestbytes.simplecloudnotifier.R;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
public class NotificationsFragment extends Fragment
|
public class NotificationsFragment extends Fragment
|
||||||
{
|
{
|
||||||
public NotificationsFragment()
|
public NotificationsFragment()
|
||||||
|
@ -1,19 +1,56 @@
|
|||||||
package com.blackforestbytes.simplecloudnotifier.view;
|
package com.blackforestbytes.simplecloudnotifier.view;
|
||||||
|
|
||||||
|
import android.media.AudioManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v7.preference.PreferenceFragmentCompat;
|
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
import android.widget.Switch;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.blackforestbytes.simplecloudnotifier.R;
|
import com.blackforestbytes.simplecloudnotifier.R;
|
||||||
|
import com.blackforestbytes.simplecloudnotifier.model.SCNSettings;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import xyz.aprildown.ultimatemusicpicker.UltimateMusicPicker;
|
||||||
|
|
||||||
public class SettingsFragment extends Fragment
|
public class SettingsFragment extends Fragment
|
||||||
{
|
{
|
||||||
|
private Switch prefAppEnabled;
|
||||||
|
private Spinner prefLocalCacheSize;
|
||||||
|
|
||||||
|
private Switch prefMsgLowEnableSound;
|
||||||
|
private TextView tvMsgLowRingtone_value;
|
||||||
|
private View prevMsgLowRingtone;
|
||||||
|
private Switch prefMsgLowRepeatSound;
|
||||||
|
private Switch prefMsgLowEnableLED;
|
||||||
|
private TextView tvMsgLowLedColor;
|
||||||
|
private ImageView prefMsgLowLedColor;
|
||||||
|
private Switch prefMsgLowEnableVibrations;
|
||||||
|
|
||||||
|
private Switch prefMsgNormEnableSound;
|
||||||
|
private TextView tvMsgNormRingtone_value;
|
||||||
|
private View prevMsgNormRingtone;
|
||||||
|
private Switch prefMsgNormRepeatSound;
|
||||||
|
private Switch prefMsgNormEnableLED;
|
||||||
|
private TextView tvMsgNormLedColor;
|
||||||
|
private ImageView prefMsgNormLedColor;
|
||||||
|
private Switch prefMsgNormEnableVibrations;
|
||||||
|
|
||||||
|
private Switch prefMsgHighEnableSound;
|
||||||
|
private TextView tvMsgHighRingtone_value;
|
||||||
|
private View prevMsgHighRingtone;
|
||||||
|
private Switch prefMsgHighRepeatSound;
|
||||||
|
private Switch prefMsgHighEnableLED;
|
||||||
|
private TextView tvMsgHighLedColor;
|
||||||
|
private ImageView prefMsgHighLedColor;
|
||||||
|
private Switch prefMsgHighEnableVibrations;
|
||||||
|
|
||||||
public SettingsFragment()
|
public SettingsFragment()
|
||||||
{
|
{
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@ -24,6 +61,87 @@ public class SettingsFragment extends Fragment
|
|||||||
{
|
{
|
||||||
View v = inflater.inflate(R.layout.fragment_settings, container, false);
|
View v = inflater.inflate(R.layout.fragment_settings, container, false);
|
||||||
|
|
||||||
|
{
|
||||||
|
prefAppEnabled = v.findViewById(R.id.prefAppEnabled);
|
||||||
|
prefLocalCacheSize = v.findViewById(R.id.prefLocalCacheSize);
|
||||||
|
|
||||||
|
prefMsgLowEnableSound = v.findViewById(R.id.prefMsgLowEnableSound);
|
||||||
|
tvMsgLowRingtone_value = v.findViewById(R.id.tvMsgLowRingtone_value);
|
||||||
|
prevMsgLowRingtone = v.findViewById(R.id.prevMsgLowRingtone);
|
||||||
|
prefMsgLowRepeatSound = v.findViewById(R.id.prefMsgLowRepeatSound);
|
||||||
|
prefMsgLowEnableLED = v.findViewById(R.id.prefMsgLowEnableLED);
|
||||||
|
tvMsgLowLedColor = v.findViewById(R.id.tvMsgLowLedColor);
|
||||||
|
prefMsgLowLedColor = v.findViewById(R.id.prefMsgLowLedColor);
|
||||||
|
prefMsgLowEnableVibrations = v.findViewById(R.id.prefMsgLowEnableVibrations);
|
||||||
|
|
||||||
|
prefMsgNormEnableSound = v.findViewById(R.id.prefMsgNormEnableSound);
|
||||||
|
tvMsgNormRingtone_value = v.findViewById(R.id.tvMsgNormRingtone_value);
|
||||||
|
prevMsgNormRingtone = v.findViewById(R.id.prevMsgNormRingtone);
|
||||||
|
prefMsgNormRepeatSound = v.findViewById(R.id.prefMsgNormRepeatSound);
|
||||||
|
prefMsgNormEnableLED = v.findViewById(R.id.prefMsgNormEnableLED);
|
||||||
|
tvMsgNormLedColor = v.findViewById(R.id.tvMsgNormLedColor);
|
||||||
|
prefMsgNormLedColor = v.findViewById(R.id.prefMsgNormLedColor);
|
||||||
|
prefMsgNormEnableVibrations = v.findViewById(R.id.prefMsgNormEnableVibrations);
|
||||||
|
|
||||||
|
prefMsgHighEnableSound = v.findViewById(R.id.prefMsgHighEnableSound);
|
||||||
|
tvMsgHighRingtone_value = v.findViewById(R.id.tvMsgHighRingtone_value);
|
||||||
|
prevMsgHighRingtone = v.findViewById(R.id.prevMsgHighRingtone);
|
||||||
|
prefMsgHighRepeatSound = v.findViewById(R.id.prefMsgHighRepeatSound);
|
||||||
|
prefMsgHighEnableLED = v.findViewById(R.id.prefMsgHighEnableLED);
|
||||||
|
tvMsgHighLedColor = v.findViewById(R.id.tvMsgHighLedColor);
|
||||||
|
prefMsgHighLedColor = v.findViewById(R.id.prefMsgHighLedColor);
|
||||||
|
prefMsgHighEnableVibrations = v.findViewById(R.id.prefMsgHighEnableVibrations);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
SCNSettings s = SCNSettings.inst();
|
||||||
|
|
||||||
|
prefAppEnabled.setChecked(s.Enabled);
|
||||||
|
prefAppEnabled.setOnCheckedChangeListener((a,b) -> onUpdate());
|
||||||
|
|
||||||
|
prefLocalCacheSize.setAdapter(new ArrayAdapter<>(v.getContext(), android.R.layout.simple_spinner_item, SCNSettings.CHOOSABLE_CACHE_SIZES));
|
||||||
|
prefLocalCacheSize.setSelection(getCacheSizeIndex(s.LocalCacheSize));
|
||||||
|
prefLocalCacheSize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
|
||||||
|
{
|
||||||
|
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { onUpdate(); }
|
||||||
|
@Override public void onNothingSelected(AdapterView<?> parent) { onUpdate(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
//TODO ...
|
||||||
|
|
||||||
|
prevMsgLowRingtone.setOnClickListener((a) -> chooseRingtoneLow());
|
||||||
|
}
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onUpdate()
|
||||||
|
{
|
||||||
|
SCNSettings s = SCNSettings.inst();
|
||||||
|
|
||||||
|
s.Enabled = prefAppEnabled.isChecked();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getCacheSizeIndex(int value)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < SCNSettings.CHOOSABLE_CACHE_SIZES.length; i++)
|
||||||
|
{
|
||||||
|
if (SCNSettings.CHOOSABLE_CACHE_SIZES[i] == value) return i;
|
||||||
|
}
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void chooseRingtoneLow()
|
||||||
|
{
|
||||||
|
new UltimateMusicPicker()
|
||||||
|
.windowTitle("Choose notification sound")
|
||||||
|
.removeSilent()
|
||||||
|
.streamType(AudioManager.STREAM_ALARM)
|
||||||
|
.ringtone()
|
||||||
|
.notification()
|
||||||
|
.alarm()
|
||||||
|
.music()
|
||||||
|
.goWithActivity(this, 0, MainActivity.class);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package com.blackforestbytes.simplecloudnotifier.view;
|
package com.blackforestbytes.simplecloudnotifier.view;
|
||||||
|
|
||||||
import android.support.v4.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||||
|
|
||||||
public class TabAdapter extends FragmentStatePagerAdapter {
|
public class TabAdapter extends FragmentStatePagerAdapter {
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
|
||||||
<android.support.constraint.ConstraintLayout
|
<android.support.constraint.ConstraintLayout
|
||||||
android:layout_marginStart="4dp"
|
android:layout_marginStart="4dp"
|
||||||
android:layout_marginEnd="4dp"
|
android:layout_marginEnd="4dp"
|
||||||
@ -143,6 +142,7 @@
|
|||||||
android:minHeight="48dp">
|
android:minHeight="48dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/prevMsgLowRingtone"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
@ -339,6 +339,7 @@
|
|||||||
android:minHeight="48dp">
|
android:minHeight="48dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/prevMsgNormRingtone"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
@ -535,6 +536,7 @@
|
|||||||
android:minHeight="48dp">
|
android:minHeight="48dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/prevMsgHighRingtone"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="AppTheme" parent="@style/PreferenceFixTheme.Light.NoActionBar">
|
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||||
<!-- your app branding color for the app bar -->
|
<!-- your app branding color for the app bar -->
|
||||||
<item name="colorPrimary">#3F51B5</item>
|
<item name="colorPrimary">#3F51B5</item>
|
||||||
<!-- darker variant for the status bar and contextual app bars -->
|
<!-- darker variant for the status bar and contextual app bars -->
|
||||||
|
@ -9,8 +9,6 @@ buildscript {
|
|||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||||
classpath 'com.google.gms:google-services:4.0.1'
|
classpath 'com.google.gms:google-services:4.0.1'
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
|
||||||
// in the individual module build.gradle files
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,3 +11,6 @@ org.gradle.jvmargs=-Xmx1536m
|
|||||||
# This option should only be used with decoupled projects. More details, visit
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
# org.gradle.parallel=true
|
# org.gradle.parallel=true
|
||||||
|
|
||||||
|
android.useAndroidX=true
|
||||||
|
android.enableJetifier=true
|
||||||
|
Loading…
Reference in New Issue
Block a user