mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-22 07:57:30 +00:00
Localize ok/cancel
This commit is contained in:
parent
471ef16a5b
commit
2277dbd572
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2011 Whisper Systems
|
* Copyright (C) 2011 Whisper Systems
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
@ -10,15 +10,12 @@
|
|||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.preferences;
|
package org.thoughtcrime.securesms.preferences;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
|
||||||
import org.thoughtcrime.securesms.R;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.preference.DialogPreference;
|
import android.preference.DialogPreference;
|
||||||
@ -29,9 +26,12 @@ import android.widget.SeekBar;
|
|||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||||
|
import org.thoughtcrime.securesms.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog preference for encryption passphrase timeout.
|
* Dialog preference for encryption passphrase timeout.
|
||||||
*
|
*
|
||||||
* @author Moxie Marlinspike
|
* @author Moxie Marlinspike
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -40,14 +40,14 @@ public class PassphraseTimeoutPreference extends DialogPreference {
|
|||||||
private Spinner scaleSpinner;
|
private Spinner scaleSpinner;
|
||||||
private SeekBar seekBar;
|
private SeekBar seekBar;
|
||||||
private TextView timeoutText;
|
private TextView timeoutText;
|
||||||
|
|
||||||
public PassphraseTimeoutPreference(Context context, AttributeSet attrs) {
|
public PassphraseTimeoutPreference(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
this.setDialogLayoutResource(R.layout.passphrase_timeout_dialog);
|
this.setDialogLayoutResource(R.layout.passphrase_timeout_dialog);
|
||||||
this.setPositiveButtonText("Ok");
|
this.setPositiveButtonText(android.R.string.ok);
|
||||||
this.setNegativeButtonText("Cancel");
|
this.setNegativeButtonText(android.R.string.cancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected View onCreateDialogView() {
|
protected View onCreateDialogView() {
|
||||||
View dialog = super.onCreateDialogView();
|
View dialog = super.onCreateDialogView();
|
||||||
@ -57,30 +57,30 @@ public class PassphraseTimeoutPreference extends DialogPreference {
|
|||||||
|
|
||||||
initializeDefaults();
|
initializeDefaults();
|
||||||
initializeListeners();
|
initializeListeners();
|
||||||
|
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||||
int interval;
|
int interval;
|
||||||
|
|
||||||
if (scaleSpinner.getSelectedItemPosition() == 0) {
|
if (scaleSpinner.getSelectedItemPosition() == 0) {
|
||||||
interval = Math.max(seekBar.getProgress(), 1);
|
interval = Math.max(seekBar.getProgress(), 1);
|
||||||
} else {
|
} else {
|
||||||
interval = Math.max(seekBar.getProgress(), 1) * 60;
|
interval = Math.max(seekBar.getProgress(), 1) * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getSharedPreferences().edit().putInt(ApplicationPreferencesActivity.PASSPHRASE_TIMEOUT_INTERVAL_PREF, interval).commit();
|
this.getSharedPreferences().edit().putInt(ApplicationPreferencesActivity.PASSPHRASE_TIMEOUT_INTERVAL_PREF, interval).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onClick(dialog, which);
|
super.onClick(dialog, which);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeDefaults() {
|
private void initializeDefaults() {
|
||||||
int timeout = this.getSharedPreferences().getInt(ApplicationPreferencesActivity.PASSPHRASE_TIMEOUT_INTERVAL_PREF, 60 * 5);
|
int timeout = this.getSharedPreferences().getInt(ApplicationPreferencesActivity.PASSPHRASE_TIMEOUT_INTERVAL_PREF, 60 * 5);
|
||||||
|
|
||||||
if (timeout > 60) {
|
if (timeout > 60) {
|
||||||
scaleSpinner.setSelection(1);
|
scaleSpinner.setSelection(1);
|
||||||
seekBar.setMax(24);
|
seekBar.setMax(24);
|
||||||
@ -96,10 +96,11 @@ public class PassphraseTimeoutPreference extends DialogPreference {
|
|||||||
|
|
||||||
private void initializeListeners() {
|
private void initializeListeners() {
|
||||||
this.seekBar.setOnSeekBarChangeListener(new SeekbarChangedListener());
|
this.seekBar.setOnSeekBarChangeListener(new SeekbarChangedListener());
|
||||||
this.scaleSpinner.setOnItemSelectedListener(new ScaleSelectedListener());
|
this.scaleSpinner.setOnItemSelectedListener(new ScaleSelectedListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ScaleSelectedListener implements AdapterView.OnItemSelectedListener {
|
private class ScaleSelectedListener implements AdapterView.OnItemSelectedListener {
|
||||||
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long selected) {
|
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long selected) {
|
||||||
if (selected == 0) {
|
if (selected == 0) {
|
||||||
seekBar.setMax(60);
|
seekBar.setMax(60);
|
||||||
@ -108,25 +109,29 @@ public class PassphraseTimeoutPreference extends DialogPreference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onNothingSelected(AdapterView<?> arg0) {
|
public void onNothingSelected(AdapterView<?> arg0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SeekbarChangedListener implements SeekBar.OnSeekBarChangeListener {
|
private class SeekbarChangedListener implements SeekBar.OnSeekBarChangeListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
if (progress < 1)
|
if (progress < 1)
|
||||||
progress = 1;
|
progress = 1;
|
||||||
|
|
||||||
timeoutText.setText(progress +"");
|
timeoutText.setText(progress +"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user