mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-15 23:33:07 +02:00
Code cleanup: Cleanup method order in AbstractSendToGoogleActivity.
This commit is contained in:
@@ -20,8 +20,8 @@ import com.google.android.apps.mytracks.fragments.CheckPermissionFragment;
|
|||||||
import com.google.android.apps.mytracks.fragments.CheckPermissionFragment.CheckPermissionCaller;
|
import com.google.android.apps.mytracks.fragments.CheckPermissionFragment.CheckPermissionCaller;
|
||||||
import com.google.android.apps.mytracks.fragments.ChooseAccountDialogFragment;
|
import com.google.android.apps.mytracks.fragments.ChooseAccountDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.ChooseAccountDialogFragment.ChooseAccountCaller;
|
import com.google.android.apps.mytracks.fragments.ChooseAccountDialogFragment.ChooseAccountCaller;
|
||||||
import com.google.android.apps.mytracks.fragments.ConfirmDialogFragment;
|
import com.google.android.apps.mytracks.fragments.ConfirmPlayDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.ConfirmDialogFragment.ConfirmCaller;
|
import com.google.android.apps.mytracks.fragments.ConfirmPlayDialogFragment.ConfirmPlayCaller;
|
||||||
import com.google.android.apps.mytracks.fragments.ConfirmSyncDialogFragment;
|
import com.google.android.apps.mytracks.fragments.ConfirmSyncDialogFragment;
|
||||||
import com.google.android.apps.mytracks.fragments.ConfirmSyncDialogFragment.ConfirmSyncCaller;
|
import com.google.android.apps.mytracks.fragments.ConfirmSyncDialogFragment.ConfirmSyncCaller;
|
||||||
import com.google.android.apps.mytracks.fragments.InstallEarthDialogFragment;
|
import com.google.android.apps.mytracks.fragments.InstallEarthDialogFragment;
|
||||||
@@ -67,19 +67,13 @@ import java.io.IOException;
|
|||||||
* @author Jimmy Shih
|
* @author Jimmy Shih
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSendToGoogleActivity extends AbstractMyTracksActivity implements
|
public abstract class AbstractSendToGoogleActivity extends AbstractMyTracksActivity implements
|
||||||
ChooseAccountCaller, ConfirmSyncCaller, CheckPermissionCaller, ShareTrackCaller, ConfirmCaller {
|
ChooseAccountCaller, ConfirmSyncCaller, CheckPermissionCaller, ShareTrackCaller, ConfirmPlayCaller {
|
||||||
|
|
||||||
private static final String TAG = AbstractMyTracksActivity.class.getSimpleName();
|
private static final String TAG = AbstractMyTracksActivity.class.getSimpleName();
|
||||||
private static final String SEND_REQUEST_KEY = "send_request_key";
|
private static final String SEND_REQUEST_KEY = "send_request_key";
|
||||||
|
|
||||||
private SendRequest sendRequest;
|
private SendRequest sendRequest;
|
||||||
|
|
||||||
public void sendToGoogle(SendRequest request) {
|
|
||||||
sendRequest = request;
|
|
||||||
new ChooseAccountDialogFragment().show(
|
|
||||||
getSupportFragmentManager(), ChooseAccountDialogFragment.CHOOSE_ACCOUNT_DIALOG_TAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -94,6 +88,100 @@ public abstract class AbstractSendToGoogleActivity extends AbstractMyTracksActiv
|
|||||||
outState.putParcelable(SEND_REQUEST_KEY, sendRequest);
|
outState.putParcelable(SEND_REQUEST_KEY, sendRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Share a track.
|
||||||
|
*
|
||||||
|
* @param trackId the track id
|
||||||
|
*/
|
||||||
|
protected void shareTrack(long trackId) {
|
||||||
|
AnalyticsUtils.sendPageViews(this, "/action/share_drive");
|
||||||
|
SendRequest newRequest;
|
||||||
|
newRequest = new SendRequest(trackId);
|
||||||
|
newRequest.setSendDrive(true);
|
||||||
|
newRequest.setDriveShare(true);
|
||||||
|
sendToGoogle(newRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a request to Google.
|
||||||
|
*
|
||||||
|
* @param request the request
|
||||||
|
*/
|
||||||
|
protected void sendToGoogle(SendRequest request) {
|
||||||
|
sendRequest = request;
|
||||||
|
new ChooseAccountDialogFragment().show(
|
||||||
|
getSupportFragmentManager(), ChooseAccountDialogFragment.CHOOSE_ACCOUNT_DIALOG_TAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChooseAccountDone() {
|
||||||
|
String googleAccount = PreferencesUtils.getString(
|
||||||
|
this, R.string.google_account_key, PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT);
|
||||||
|
if (googleAccount == null || googleAccount.equals(PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sendRequest.setAccount(new Account(googleAccount, Constants.ACCOUNT_TYPE));
|
||||||
|
|
||||||
|
if (sendRequest.isSendDrive() && sendRequest.isDriveSync() && sendRequest.isDriveSyncConfirm()) {
|
||||||
|
new ConfirmSyncDialogFragment().show(
|
||||||
|
getSupportFragmentManager(), ConfirmSyncDialogFragment.CONFIRM_SYNC_DIALOG_TAG);
|
||||||
|
} else {
|
||||||
|
onConfirmSyncDone(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfirmSyncDone(boolean enable) {
|
||||||
|
if (enable) {
|
||||||
|
// Check Drive permission
|
||||||
|
boolean needDrivePermission = sendRequest.isSendDrive();
|
||||||
|
if (!needDrivePermission && sendRequest.isSendFusionTables()) {
|
||||||
|
needDrivePermission = PreferencesUtils.getBoolean(this,
|
||||||
|
R.string.export_google_fusion_tables_public_key,
|
||||||
|
PreferencesUtils.EXPORT_GOOGLE_FUSION_TABLES_PUBLIC_DEFAULT);
|
||||||
|
}
|
||||||
|
if (!needDrivePermission) {
|
||||||
|
needDrivePermission = sendRequest.isSendSpreadsheets();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needDrivePermission) {
|
||||||
|
Fragment fragment = CheckPermissionFragment.newInstance(
|
||||||
|
sendRequest.getAccount().name, SendToGoogleUtils.DRIVE_SCOPE);
|
||||||
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
.add(fragment, CheckPermissionFragment.CHECK_PERMISSION_TAG).commit();
|
||||||
|
} else {
|
||||||
|
onDrivePermissionSuccess();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCheckPermissionDone(String scope, boolean success, Intent intent) {
|
||||||
|
if (success) {
|
||||||
|
if (scope.equals(SendToGoogleUtils.DRIVE_SCOPE)) {
|
||||||
|
onDrivePermissionSuccess();
|
||||||
|
} else if (scope.equals(SendToGoogleUtils.FUSION_TABLES_SCOPE)) {
|
||||||
|
onFusionTablesSuccess();
|
||||||
|
} else {
|
||||||
|
onSpreadsheetsPermissionSuccess();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (intent != null) {
|
||||||
|
int requestCode;
|
||||||
|
if (scope.equals(SendToGoogleUtils.DRIVE_SCOPE)) {
|
||||||
|
requestCode = SendToGoogleUtils.DRIVE_PERMISSION_REQUEST_CODE;
|
||||||
|
} else if (scope.equals(SendToGoogleUtils.FUSION_TABLES_SCOPE)) {
|
||||||
|
requestCode = SendToGoogleUtils.FUSION_TABLES_PERMISSION_REQUEST_CODE;
|
||||||
|
} else {
|
||||||
|
requestCode = SendToGoogleUtils.SPREADSHEET_PERMISSION_REQUEST_CODE;
|
||||||
|
}
|
||||||
|
startActivityForResult(intent, requestCode);
|
||||||
|
} else {
|
||||||
|
onPermissionFailure();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
@@ -126,83 +214,6 @@ public abstract class AbstractSendToGoogleActivity extends AbstractMyTracksActiv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onChooseAccountDone() {
|
|
||||||
String googleAccount = PreferencesUtils.getString(
|
|
||||||
this, R.string.google_account_key, PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT);
|
|
||||||
if (googleAccount == null || googleAccount.equals(PreferencesUtils.GOOGLE_ACCOUNT_DEFAULT)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sendRequest.setAccount(new Account(googleAccount, Constants.ACCOUNT_TYPE));
|
|
||||||
|
|
||||||
if (sendRequest.isSendDrive() && sendRequest.isDriveSync() && sendRequest.isDriveSyncConfirm()) {
|
|
||||||
new ConfirmSyncDialogFragment().show(
|
|
||||||
getSupportFragmentManager(), ConfirmSyncDialogFragment.CONFIRM_SYNC_DIALOG_TAG);
|
|
||||||
} else {
|
|
||||||
onConfirmSyncDone(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConfirmSyncDone(boolean enable) {
|
|
||||||
if (enable) {
|
|
||||||
// Check Drive permission
|
|
||||||
boolean needDrivePermission = sendRequest.isSendDrive();
|
|
||||||
if (!needDrivePermission && sendRequest.isSendFusionTables()) {
|
|
||||||
needDrivePermission = PreferencesUtils.getBoolean(this,
|
|
||||||
R.string.export_google_fusion_tables_public_key,
|
|
||||||
PreferencesUtils.EXPORT_GOOGLE_FUSION_TABLES_PUBLIC_DEFAULT);
|
|
||||||
}
|
|
||||||
if (!needDrivePermission) {
|
|
||||||
needDrivePermission = sendRequest.isSendSpreadsheets();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needDrivePermission) {
|
|
||||||
Fragment fragment = CheckPermissionFragment.newInstance(
|
|
||||||
sendRequest.getAccount().name, SendToGoogleUtils.DRIVE_SCOPE);
|
|
||||||
getSupportFragmentManager().beginTransaction()
|
|
||||||
.add(fragment, CheckPermissionFragment.CHECK_PERMISSION_TAG).commit();
|
|
||||||
} else {
|
|
||||||
onDrivePermissionSuccess();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCheckPermissionDone(String scope, boolean success, Intent intent) {
|
|
||||||
if (success) {
|
|
||||||
if (scope.equals(SendToGoogleUtils.DRIVE_SCOPE)) {
|
|
||||||
onDrivePermissionSuccess();
|
|
||||||
} else if (scope.equals(SendToGoogleUtils.FUSION_TABLES_SCOPE)) {
|
|
||||||
onFusionTablesSuccess();
|
|
||||||
} else {
|
|
||||||
onSpreadsheetsPermissionSuccess();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (intent != null) {
|
|
||||||
int requestCode;
|
|
||||||
if (scope.equals(SendToGoogleUtils.DRIVE_SCOPE)) {
|
|
||||||
requestCode = SendToGoogleUtils.DRIVE_PERMISSION_REQUEST_CODE;
|
|
||||||
} else if (scope.equals(SendToGoogleUtils.FUSION_TABLES_SCOPE)) {
|
|
||||||
requestCode = SendToGoogleUtils.FUSION_TABLES_PERMISSION_REQUEST_CODE;
|
|
||||||
} else {
|
|
||||||
requestCode = SendToGoogleUtils.SPREADSHEET_PERMISSION_REQUEST_CODE;
|
|
||||||
}
|
|
||||||
startActivityForResult(intent, requestCode);
|
|
||||||
} else {
|
|
||||||
onPermissionFailure();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onShareTrackDone(String emails, boolean makePublic) {
|
|
||||||
sendRequest.setDriveShareEmails(emails);
|
|
||||||
sendRequest.setDriveSharePublic(makePublic);
|
|
||||||
Intent intent = IntentUtils.newIntent(this, SendDriveActivity.class)
|
|
||||||
.putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onDrivePermissionSuccess() {
|
private void onDrivePermissionSuccess() {
|
||||||
// Check Maps permission
|
// Check Maps permission
|
||||||
if (sendRequest.isSendMaps()) {
|
if (sendRequest.isSendMaps()) {
|
||||||
@@ -327,6 +338,15 @@ public abstract class AbstractSendToGoogleActivity extends AbstractMyTracksActiv
|
|||||||
Toast.makeText(this, R.string.send_google_no_account_permission, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.send_google_no_account_permission, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onShareTrackDone(String emails, boolean makePublic) {
|
||||||
|
sendRequest.setDriveShareEmails(emails);
|
||||||
|
sendRequest.setDriveSharePublic(makePublic);
|
||||||
|
Intent intent = IntentUtils.newIntent(this, SendDriveActivity.class)
|
||||||
|
.putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Confirm playing tracks in Google Earth.
|
* Confirm playing tracks in Google Earth.
|
||||||
*
|
*
|
||||||
@@ -334,42 +354,26 @@ public abstract class AbstractSendToGoogleActivity extends AbstractMyTracksActiv
|
|||||||
*/
|
*/
|
||||||
protected void confirmPlay(long[] trackIds) {
|
protected void confirmPlay(long[] trackIds) {
|
||||||
if (GoogleEarthUtils.isEarthInstalled(this)) {
|
if (GoogleEarthUtils.isEarthInstalled(this)) {
|
||||||
ConfirmDialogFragment.newInstance(R.string.confirm_play_earth_key,
|
if (PreferencesUtils.getBoolean(
|
||||||
PreferencesUtils.CONFIRM_PLAY_EARTH_DEFAULT,
|
this, R.string.confirm_play_earth_key, PreferencesUtils.CONFIRM_PLAY_EARTH_DEFAULT)) {
|
||||||
getString(R.string.track_detail_play_confirm_message), trackIds)
|
ConfirmPlayDialogFragment.newInstance(trackIds)
|
||||||
.show(getSupportFragmentManager(), ConfirmDialogFragment.CONFIRM_DIALOG_TAG);
|
.show(getSupportFragmentManager(), ConfirmPlayDialogFragment.CONFIRM_PLAY_DIALOG_TAG);
|
||||||
|
} else {
|
||||||
|
onConfirmPlayDone(trackIds);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
new InstallEarthDialogFragment().show(
|
new InstallEarthDialogFragment().show(
|
||||||
getSupportFragmentManager(), InstallEarthDialogFragment.INSTALL_EARTH_DIALOG_TAG);
|
getSupportFragmentManager(), InstallEarthDialogFragment.INSTALL_EARTH_DIALOG_TAG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Confirm sharing a track.
|
|
||||||
*
|
|
||||||
* @param trackId the track id
|
|
||||||
*/
|
|
||||||
protected void shareTrack(long trackId) {
|
|
||||||
AnalyticsUtils.sendPageViews(this, "/action/share_drive");
|
|
||||||
SendRequest newRequest;
|
|
||||||
newRequest = new SendRequest(trackId);
|
|
||||||
newRequest.setSendDrive(true);
|
|
||||||
newRequest.setDriveShare(true);
|
|
||||||
sendToGoogle(newRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirmDone(int confirmId, long[] trackIds) {
|
public void onConfirmPlayDone(long[] trackIds) {
|
||||||
switch (confirmId) {
|
AnalyticsUtils.sendPageViews(this, "/action/play");
|
||||||
case R.string.confirm_play_earth_key:
|
|
||||||
AnalyticsUtils.sendPageViews(this, "/action/play");
|
|
||||||
Intent intent = IntentUtils.newIntent(this, SaveActivity.class)
|
Intent intent = IntentUtils.newIntent(this, SaveActivity.class)
|
||||||
.putExtra(SaveActivity.EXTRA_TRACK_IDS, trackIds)
|
.putExtra(SaveActivity.EXTRA_TRACK_IDS, trackIds)
|
||||||
.putExtra(SaveActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) TrackFileFormat.KML)
|
.putExtra(SaveActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) TrackFileFormat.KML)
|
||||||
.putExtra(SaveActivity.EXTRA_PLAY_TRACK, true);
|
.putExtra(SaveActivity.EXTRA_PLAY_TRACK, true);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-29
@@ -31,89 +31,75 @@ import android.widget.CheckBox;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DialogFragment to confirm an action.
|
* A DialogFragment to confirm playing a track.
|
||||||
*
|
*
|
||||||
* @author Jimmy Shih
|
* @author Jimmy Shih
|
||||||
*/
|
*/
|
||||||
public class ConfirmDialogFragment extends DialogFragment {
|
public class ConfirmPlayDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for caller of this dialog fragment.
|
* Interface for caller of this dialog fragment.
|
||||||
*
|
*
|
||||||
* @author Jimmy Shih
|
* @author Jimmy Shih
|
||||||
*/
|
*/
|
||||||
public interface ConfirmCaller {
|
public interface ConfirmPlayCaller {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when confirm is done.
|
* Called when confirm play is done.
|
||||||
*/
|
*/
|
||||||
public void onConfirmDone(int confirmId, long[] trackIds);
|
public void onConfirmPlayDone(long[] trackIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String CONFIRM_DIALOG_TAG = "confirmDialog";
|
public static final String CONFIRM_PLAY_DIALOG_TAG = "confirmPlayDialog";
|
||||||
|
|
||||||
private static final String KEY_CONFIRM_ID = "confirmId";
|
|
||||||
private static final String KEY_DEFAULT_VALUE = "defaultValue";
|
|
||||||
private static final String KEY_MESSAGE = "message";
|
|
||||||
private static final String KEY_TRACK_IDS = "trackIds";
|
private static final String KEY_TRACK_IDS = "trackIds";
|
||||||
|
|
||||||
private CheckBox checkBox;
|
private CheckBox checkBox;
|
||||||
|
|
||||||
public static ConfirmDialogFragment newInstance(
|
public static ConfirmPlayDialogFragment newInstance(long[] trackIds) {
|
||||||
int confirmId, boolean defaultValue, CharSequence message, long[] trackIds) {
|
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putInt(KEY_CONFIRM_ID, confirmId);
|
|
||||||
bundle.putBoolean(KEY_DEFAULT_VALUE, defaultValue);
|
|
||||||
bundle.putCharSequence(KEY_MESSAGE, message);
|
|
||||||
bundle.putLongArray(KEY_TRACK_IDS, trackIds);
|
bundle.putLongArray(KEY_TRACK_IDS, trackIds);
|
||||||
|
|
||||||
ConfirmDialogFragment confirmDialogFragment = new ConfirmDialogFragment();
|
ConfirmPlayDialogFragment confirmDialogFragment = new ConfirmPlayDialogFragment();
|
||||||
confirmDialogFragment.setArguments(bundle);
|
confirmDialogFragment.setArguments(bundle);
|
||||||
return confirmDialogFragment;
|
return confirmDialogFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConfirmCaller caller;
|
private ConfirmPlayCaller caller;
|
||||||
private FragmentActivity fragmentActivity;
|
private FragmentActivity fragmentActivity;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
try {
|
try {
|
||||||
caller = (ConfirmCaller) activity;
|
caller = (ConfirmPlayCaller) activity;
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
throw new ClassCastException(
|
throw new ClassCastException(
|
||||||
activity.toString() + " must implement " + ConfirmCaller.class.getSimpleName());
|
activity.toString() + " must implement " + ConfirmPlayCaller.class.getSimpleName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
int confirmId = getArguments().getInt(KEY_CONFIRM_ID);
|
|
||||||
boolean defaultValue = getArguments().getBoolean(KEY_DEFAULT_VALUE);
|
|
||||||
fragmentActivity = getActivity();
|
fragmentActivity = getActivity();
|
||||||
if (!PreferencesUtils.getBoolean(fragmentActivity, confirmId, defaultValue)) {
|
|
||||||
long[] trackIds = getArguments().getLongArray(KEY_TRACK_IDS);
|
|
||||||
dismiss();
|
|
||||||
caller.onConfirmDone(confirmId, trackIds);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
View view = fragmentActivity.getLayoutInflater().inflate(R.layout.confirm_dialog, null);
|
View view = fragmentActivity.getLayoutInflater().inflate(R.layout.confirm_dialog, null);
|
||||||
TextView textView = (TextView) view.findViewById(R.id.confirm_dialog_message);
|
TextView textView = (TextView) view.findViewById(R.id.confirm_dialog_message);
|
||||||
textView.setText(getArguments().getCharSequence(KEY_MESSAGE));
|
textView.setText(R.string.track_detail_play_confirm_message);
|
||||||
checkBox = (CheckBox) view.findViewById(R.id.confirm_dialog_check_box);
|
checkBox = (CheckBox) view.findViewById(R.id.confirm_dialog_check_box);
|
||||||
|
|
||||||
return new AlertDialog.Builder(fragmentActivity).setNegativeButton(R.string.generic_no, null)
|
return new AlertDialog.Builder(fragmentActivity).setNegativeButton(R.string.generic_no, null)
|
||||||
.setPositiveButton(R.string.generic_yes, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.generic_yes, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int confirmId = getArguments().getInt(KEY_CONFIRM_ID);
|
|
||||||
long[] trackIds = getArguments().getLongArray(KEY_TRACK_IDS);
|
long[] trackIds = getArguments().getLongArray(KEY_TRACK_IDS);
|
||||||
PreferencesUtils.setBoolean(fragmentActivity, confirmId, !checkBox.isChecked());
|
PreferencesUtils.setBoolean(
|
||||||
caller.onConfirmDone(confirmId, trackIds);
|
fragmentActivity, R.string.confirm_play_earth_key, !checkBox.isChecked());
|
||||||
|
caller.onConfirmPlayDone(trackIds);
|
||||||
}
|
}
|
||||||
}).setTitle(R.string.generic_confirm_title).setView(view).create();
|
}).setTitle(R.string.generic_confirm_title).setView(view).create();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user