- Received sound setting done
This commit is contained in:
parent
032cc6fae5
commit
3ce3665546
4 changed files with 72 additions and 6 deletions
|
@ -67,4 +67,5 @@ dependencies {
|
||||||
compile 'com.squareup.picasso:picasso:2.5.2'
|
compile 'com.squareup.picasso:picasso:2.5.2'
|
||||||
implementation 'com.github.esafirm.android-image-picker:imagepicker:1.11.1'
|
implementation 'com.github.esafirm.android-image-picker:imagepicker:1.11.1'
|
||||||
compile 'id.zelory:compressor:2.1.0'
|
compile 'id.zelory:compressor:2.1.0'
|
||||||
|
compile 'com.vincent.filepicker:MultiTypeFilePicker:1.0.7'
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,15 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.vincent.filepicker.Constant;
|
||||||
|
import com.vincent.filepicker.activity.AudioPickActivity;
|
||||||
|
import com.vincent.filepicker.filter.entity.AudioFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -29,6 +36,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
import butterknife.OnItemSelected;
|
import butterknife.OnItemSelected;
|
||||||
import cy.agorise.crystalwallet.R;
|
import cy.agorise.crystalwallet.R;
|
||||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||||
|
@ -37,6 +45,10 @@ import cy.agorise.crystalwallet.models.GeneralSetting;
|
||||||
import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel;
|
import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel;
|
||||||
import cy.agorise.crystalwallet.views.TimeZoneAdapter;
|
import cy.agorise.crystalwallet.views.TimeZoneAdapter;
|
||||||
|
|
||||||
|
import static android.app.Activity.RESULT_OK;
|
||||||
|
import static android.content.Context.CONSUMER_IR_SERVICE;
|
||||||
|
import static com.vincent.filepicker.activity.AudioPickActivity.IS_NEED_RECORDER;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by xd on 12/28/17.
|
* Created by xd on 12/28/17.
|
||||||
|
@ -57,6 +69,8 @@ public class GeneralSettingsFragment extends Fragment {
|
||||||
Spinner spPreferredLanguage;
|
Spinner spPreferredLanguage;
|
||||||
@BindView (R.id.spDisplayDateTime)
|
@BindView (R.id.spDisplayDateTime)
|
||||||
Spinner spDisplayDateTime;
|
Spinner spDisplayDateTime;
|
||||||
|
@BindView (R.id.tvReceiveFundsSoundValue)
|
||||||
|
TextView tvReceiveFundsSound;
|
||||||
|
|
||||||
public GeneralSettingsFragment() {
|
public GeneralSettingsFragment() {
|
||||||
this.spPreferredLanguageInitialized = false;
|
this.spPreferredLanguageInitialized = false;
|
||||||
|
@ -152,6 +166,20 @@ public class GeneralSettingsFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void initReceiveFundsSound(GeneralSetting receiveFundsSoundSetting){
|
||||||
|
if (receiveFundsSoundSetting != null){
|
||||||
|
if (receiveFundsSoundSetting.getValue().equals("")){
|
||||||
|
tvReceiveFundsSound.setText("Woohoo");
|
||||||
|
} else {
|
||||||
|
File audioFile = new File(receiveFundsSoundSetting.getValue());
|
||||||
|
|
||||||
|
tvReceiveFundsSound.setText(audioFile.getName());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tvReceiveFundsSound.setText("Woohoo");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public GeneralSetting getSetting(String name){
|
public GeneralSetting getSetting(String name){
|
||||||
for (GeneralSetting generalSetting:this.generalSettingListLiveData.getValue()) {
|
for (GeneralSetting generalSetting:this.generalSettingListLiveData.getValue()) {
|
||||||
if (generalSetting.getName().equals(name)) {
|
if (generalSetting.getName().equals(name)) {
|
||||||
|
@ -162,6 +190,15 @@ public class GeneralSettingsFragment extends Fragment {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OnClick(R.id.tvReceiveFundsSoundValue)
|
||||||
|
void onReceiveFundsSoundSelected(){
|
||||||
|
Intent intent3 = new Intent(this.getContext(), AudioPickActivity.class);
|
||||||
|
intent3.putExtra(IS_NEED_RECORDER, true);
|
||||||
|
intent3.putExtra(Constant.MAX_NUMBER, 1);
|
||||||
|
startActivityForResult(intent3, Constant.REQUEST_CODE_PICK_AUDIO);
|
||||||
|
}
|
||||||
|
|
||||||
@OnItemSelected(R.id.spTaxableCountry)
|
@OnItemSelected(R.id.spTaxableCountry)
|
||||||
void onItemSelected(int position) {
|
void onItemSelected(int position) {
|
||||||
if (position != 0) {
|
if (position != 0) {
|
||||||
|
@ -246,5 +283,32 @@ public class GeneralSettingsFragment extends Fragment {
|
||||||
initPreferredCountry(getSetting(GeneralSetting.SETTING_NAME_PREFERRED_COUNTRY));
|
initPreferredCountry(getSetting(GeneralSetting.SETTING_NAME_PREFERRED_COUNTRY));
|
||||||
initPreferredLanguage(getSetting(GeneralSetting.SETTING_NAME_PREFERRED_LANGUAGE));
|
initPreferredLanguage(getSetting(GeneralSetting.SETTING_NAME_PREFERRED_LANGUAGE));
|
||||||
initDateTimeFormat(getSetting(GeneralSetting.SETTING_NAME_TIME_ZONE));
|
initDateTimeFormat(getSetting(GeneralSetting.SETTING_NAME_TIME_ZONE));
|
||||||
|
initReceiveFundsSound(getSetting(GeneralSetting.SETTING_NAME_RECEIVED_FUNDS_SOUND_PATH));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
|
if (requestCode == Constant.REQUEST_CODE_PICK_AUDIO){
|
||||||
|
if (resultCode == RESULT_OK) {
|
||||||
|
ArrayList<AudioFile> list = data.getParcelableArrayListExtra(Constant.RESULT_PICK_AUDIO);
|
||||||
|
if (list.size() > 0) {
|
||||||
|
AudioFile audioSelected = list.get(0);
|
||||||
|
String audioSelectedPath = audioSelected.getPath();
|
||||||
|
|
||||||
|
GeneralSetting generalSettingReceivedFundsSoundPath = this.getSetting(GeneralSetting.SETTING_NAME_RECEIVED_FUNDS_SOUND_PATH);
|
||||||
|
|
||||||
|
if (generalSettingReceivedFundsSoundPath == null){
|
||||||
|
generalSettingReceivedFundsSoundPath = new GeneralSetting();
|
||||||
|
generalSettingReceivedFundsSoundPath.setName(GeneralSetting.SETTING_NAME_RECEIVED_FUNDS_SOUND_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
generalSettingReceivedFundsSoundPath.setValue(audioSelectedPath);
|
||||||
|
this.generalSettingListViewModel.saveGeneralSettings(generalSettingReceivedFundsSoundPath);
|
||||||
|
tvReceiveFundsSound.setText(audioSelected.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class GeneralSetting {
|
||||||
public final static String SETTING_NAME_PREFERRED_LANGUAGE = "PREFERRED_LANGUAGE";
|
public final static String SETTING_NAME_PREFERRED_LANGUAGE = "PREFERRED_LANGUAGE";
|
||||||
public final static String SETTING_NAME_TIME_ZONE = "TIME_ZONE";
|
public final static String SETTING_NAME_TIME_ZONE = "TIME_ZONE";
|
||||||
public final static String SETTING_PASSWORD = "PASSWORD";
|
public final static String SETTING_PASSWORD = "PASSWORD";
|
||||||
|
public final static String SETTING_NAME_RECEIVED_FUNDS_SOUND_PATH = "RECEIVED_FUNDS_SOUND_PATH";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id on the database
|
* The id on the database
|
||||||
|
|
|
@ -127,7 +127,7 @@
|
||||||
app:layout_constraintEnd_toEndOf="@id/vPreferredLanguage"/>
|
app:layout_constraintEnd_toEndOf="@id/vPreferredLanguage"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvSound"
|
android:id="@+id/tvReceiveFundsSound"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
|
@ -135,12 +135,12 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/vDisplayDateTime"
|
app:layout_constraintTop_toBottomOf="@id/vDisplayDateTime"
|
||||||
app:layout_constraintStart_toStartOf="@id/tvDisplayDateTime" />
|
app:layout_constraintStart_toStartOf="@id/tvDisplayDateTime" />
|
||||||
|
|
||||||
<Spinner
|
<TextView
|
||||||
android:id="@+id/spSound"
|
android:id="@+id/tvReceiveFundsSoundValue"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvSound"
|
app:layout_constraintTop_toBottomOf="@id/tvReceiveFundsSound"
|
||||||
app:layout_constraintStart_toStartOf="@id/spDisplayDateTime"
|
app:layout_constraintStart_toStartOf="@id/spDisplayDateTime"
|
||||||
app:layout_constraintEnd_toEndOf="@id/spDisplayDateTime"/>
|
app:layout_constraintEnd_toEndOf="@id/spDisplayDateTime"/>
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:background="@color/gray"
|
android:background="@color/gray"
|
||||||
app:layout_constraintTop_toBottomOf="@id/spSound"
|
app:layout_constraintTop_toBottomOf="@id/tvReceiveFundsSoundValue"
|
||||||
app:layout_constraintStart_toStartOf="@id/vDisplayDateTime"
|
app:layout_constraintStart_toStartOf="@id/vDisplayDateTime"
|
||||||
app:layout_constraintEnd_toEndOf="@id/vDisplayDateTime"/>
|
app:layout_constraintEnd_toEndOf="@id/vDisplayDateTime"/>
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_constraintTop_toBottomOf="@id/vSound"
|
app:layout_constraintTop_toBottomOf="@id/vSound"
|
||||||
app:layout_constraintStart_toStartOf="@id/spSound" />
|
app:layout_constraintStart_toStartOf="@id/tvReceiveFundsSoundValue" />
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
android:id="@+id/sCloseWalletTimer"
|
android:id="@+id/sCloseWalletTimer"
|
||||||
|
|
Loading…
Reference in a new issue