mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
cleanup: use import more for new class
This commit is contained in:
parent
497567ac2d
commit
531f30aae8
5 changed files with 24 additions and 25 deletions
|
@ -54,6 +54,7 @@ import junit.framework.Assert;
|
||||||
import org.eehouse.android.xw4.DBUtils.SentInvitesInfo;
|
import org.eehouse.android.xw4.DBUtils.SentInvitesInfo;
|
||||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||||
import org.eehouse.android.xw4.DlgDelegate.ActionPair;
|
import org.eehouse.android.xw4.DlgDelegate.ActionPair;
|
||||||
|
import org.eehouse.android.xw4.Perms23.Perm;
|
||||||
import org.eehouse.android.xw4.Toolbar.Buttons;
|
import org.eehouse.android.xw4.Toolbar.Buttons;
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||||
|
@ -725,12 +726,12 @@ public class BoardDelegate extends DelegateBase
|
||||||
boolean showRationale )
|
boolean showRationale )
|
||||||
{
|
{
|
||||||
Perms23.Builder builder =
|
Perms23.Builder builder =
|
||||||
new Perms23.Builder( Perms23.Perm.READ_PHONE_STATE );
|
new Perms23.Builder( Perm.READ_PHONE_STATE );
|
||||||
|
|
||||||
if ( showRationale ) {
|
if ( showRationale ) {
|
||||||
builder.setOnShowRationale( new Perms23.OnShowRationale() {
|
builder.setOnShowRationale( new Perms23.OnShowRationale() {
|
||||||
@Override
|
@Override
|
||||||
public void onShouldShowRationale( Set<Perms23.Perm> perms )
|
public void onShouldShowRationale( Set<Perm> perms )
|
||||||
{
|
{
|
||||||
makeOkOnlyBuilder( R.string.phone_state_rationale )
|
makeOkOnlyBuilder( R.string.phone_state_rationale )
|
||||||
.setAction( Action.RETRY_PHONE_STATE_ACTION )
|
.setAction( Action.RETRY_PHONE_STATE_ACTION )
|
||||||
|
@ -742,7 +743,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
|
|
||||||
builder.asyncQuery( m_activity, new Perms23.PermCbck() {
|
builder.asyncQuery( m_activity, new Perms23.PermCbck() {
|
||||||
@Override
|
@Override
|
||||||
public void onPermissionResult( Map<Perms23.Perm,
|
public void onPermissionResult( Map<Perm,
|
||||||
Boolean> perms )
|
Boolean> perms )
|
||||||
{
|
{
|
||||||
// Do the work regardless of result; just won't have
|
// Do the work regardless of result; just won't have
|
||||||
|
@ -2229,13 +2230,13 @@ public class BoardDelegate extends DelegateBase
|
||||||
&& null == m_permCbck ) { // already asked?
|
&& null == m_permCbck ) { // already asked?
|
||||||
m_permCbck = new Perms23.PermCbck() {
|
m_permCbck = new Perms23.PermCbck() {
|
||||||
@Override
|
@Override
|
||||||
public void onPermissionResult( Map<Perms23.Perm,
|
public void onPermissionResult( Map<Perm,
|
||||||
Boolean> perms )
|
Boolean> perms )
|
||||||
{
|
{
|
||||||
ActionPair pair = new ActionPair( Action.DROP_SMS_ACTION,
|
ActionPair pair = new ActionPair( Action.DROP_SMS_ACTION,
|
||||||
R.string.remove_sms );
|
R.string.remove_sms );
|
||||||
|
|
||||||
if ( ! perms.get(Perms23.Perm.SEND_SMS) ) {
|
if ( ! perms.get(Perm.SEND_SMS) ) {
|
||||||
makeNotAgainBuilder( R.string.not_again_missing_perms,
|
makeNotAgainBuilder( R.string.not_again_missing_perms,
|
||||||
R.string.key_notagain_missing_perms )
|
R.string.key_notagain_missing_perms )
|
||||||
.setActionPair( pair )
|
.setActionPair( pair )
|
||||||
|
@ -2243,7 +2244,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new Perms23.Builder(Perms23.Perm.SEND_SMS)
|
new Perms23.Builder(Perm.SEND_SMS)
|
||||||
.asyncQuery( m_activity, m_permCbck );
|
.asyncQuery( m_activity, m_permCbck );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ import org.eehouse.android.xw4.DlgDelegate.ActionPair;
|
||||||
import org.eehouse.android.xw4.DlgDelegate.NAKey;
|
import org.eehouse.android.xw4.DlgDelegate.NAKey;
|
||||||
import org.eehouse.android.xw4.DwnldDelegate.DownloadFinishedListener;
|
import org.eehouse.android.xw4.DwnldDelegate.DownloadFinishedListener;
|
||||||
import org.eehouse.android.xw4.DwnldDelegate.OnGotLcDictListener;
|
import org.eehouse.android.xw4.DwnldDelegate.OnGotLcDictListener;
|
||||||
|
import org.eehouse.android.xw4.Perms23.Perm;
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
||||||
|
@ -1560,14 +1561,14 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.games_menu_loaddb:
|
case R.id.games_menu_loaddb:
|
||||||
new Perms23.Builder( Perms23.Perm.STORAGE )
|
new Perms23.Builder( Perm.STORAGE )
|
||||||
.asyncQuery( m_activity, new Perms23.PermCbck() {
|
.asyncQuery( m_activity, new Perms23.PermCbck() {
|
||||||
@Override
|
@Override
|
||||||
public void onPermissionResult( Map<Perms23.Perm,
|
public void onPermissionResult( Map<Perm,
|
||||||
Boolean> granted )
|
Boolean> granted )
|
||||||
{
|
{
|
||||||
Assert.assertTrue( granted.containsKey(Perms23.Perm.STORAGE) );
|
Assert.assertTrue( granted.containsKey(Perm.STORAGE) );
|
||||||
if ( granted.get(Perms23.Perm.STORAGE) ) {
|
if ( granted.get(Perm.STORAGE) ) {
|
||||||
DBUtils.loadDB( m_activity );
|
DBUtils.loadDB( m_activity );
|
||||||
XWPrefs.clearGroupPositions( m_activity );
|
XWPrefs.clearGroupPositions( m_activity );
|
||||||
mkListAdapter();
|
mkListAdapter();
|
||||||
|
@ -1576,13 +1577,13 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
} );
|
} );
|
||||||
break;
|
break;
|
||||||
case R.id.games_menu_storedb:
|
case R.id.games_menu_storedb:
|
||||||
new Perms23.Builder( Perms23.Perm.STORAGE )
|
new Perms23.Builder( Perm.STORAGE )
|
||||||
.asyncQuery( m_activity, new Perms23.PermCbck() {
|
.asyncQuery( m_activity, new Perms23.PermCbck() {
|
||||||
@Override
|
@Override
|
||||||
public void onPermissionResult( Map<Perms23.Perm, Boolean> granted )
|
public void onPermissionResult( Map<Perm, Boolean> granted )
|
||||||
{
|
{
|
||||||
Assert.assertTrue( granted.containsKey( Perms23.Perm.STORAGE ) );
|
Assert.assertTrue( granted.containsKey( Perm.STORAGE ) );
|
||||||
if ( granted.get( Perms23.Perm.STORAGE ) ) {
|
if ( granted.get( Perm.STORAGE ) ) {
|
||||||
DBUtils.saveDB( m_activity );
|
DBUtils.saveDB( m_activity );
|
||||||
showToast( R.string.db_store_done );
|
showToast( R.string.db_store_done );
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class Perms23 {
|
||||||
void onPermissionResult( Map<Perm, Boolean> perms );
|
void onPermissionResult( Map<Perm, Boolean> perms );
|
||||||
}
|
}
|
||||||
public interface OnShowRationale {
|
public interface OnShowRationale {
|
||||||
void onShouldShowRationale( Set<Perms23.Perm> perms );
|
void onShouldShowRationale( Set<Perm> perms );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
|
@ -39,6 +39,7 @@ import junit.framework.Assert;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.DBUtils.SentInvitesInfo;
|
import org.eehouse.android.xw4.DBUtils.SentInvitesInfo;
|
||||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||||
|
import org.eehouse.android.xw4.Perms23.Perm;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -57,9 +58,6 @@ public class SMSInviteDelegate extends InviteDelegate {
|
||||||
R.id.button_clear,
|
R.id.button_clear,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final String SAVE_NAME = "SAVE_NAME";
|
|
||||||
private static final String SAVE_NUMBER = "SAVE_NUMBER";
|
|
||||||
|
|
||||||
private ArrayList<PhoneRec> m_phoneRecs;
|
private ArrayList<PhoneRec> m_phoneRecs;
|
||||||
private boolean m_immobileConfirmed;
|
private boolean m_immobileConfirmed;
|
||||||
private Activity m_activity;
|
private Activity m_activity;
|
||||||
|
@ -91,8 +89,6 @@ public class SMSInviteDelegate extends InviteDelegate {
|
||||||
super.init( msg, R.string.empty_sms_inviter );
|
super.init( msg, R.string.empty_sms_inviter );
|
||||||
addButtonBar( R.layout.sms_buttons, BUTTONIDS );
|
addButtonBar( R.layout.sms_buttons, BUTTONIDS );
|
||||||
|
|
||||||
// getBundledData( savedInstanceState );
|
|
||||||
|
|
||||||
getSavedState();
|
getSavedState();
|
||||||
rebuildList( true );
|
rebuildList( true );
|
||||||
|
|
||||||
|
@ -339,11 +335,11 @@ public class SMSInviteDelegate extends InviteDelegate {
|
||||||
|
|
||||||
private void askContactsPermission( boolean showRationale )
|
private void askContactsPermission( boolean showRationale )
|
||||||
{
|
{
|
||||||
Perms23.Builder builder = new Perms23.Builder( Perms23.Perm.READ_CONTACTS );
|
Perms23.Builder builder = new Perms23.Builder( Perm.READ_CONTACTS );
|
||||||
if ( showRationale ) {
|
if ( showRationale ) {
|
||||||
builder.setOnShowRationale( new Perms23.OnShowRationale() {
|
builder.setOnShowRationale( new Perms23.OnShowRationale() {
|
||||||
@Override
|
@Override
|
||||||
public void onShouldShowRationale( Set<Perms23.Perm> perms )
|
public void onShouldShowRationale( Set<Perm> perms )
|
||||||
{
|
{
|
||||||
makeOkOnlyBuilder( R.string.contacts_rationale )
|
makeOkOnlyBuilder( R.string.contacts_rationale )
|
||||||
.setAction( Action.RETRY_CONTACTS_ACTION )
|
.setAction( Action.RETRY_CONTACTS_ACTION )
|
||||||
|
|
|
@ -63,6 +63,7 @@ import java.util.Random;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.Perms23.Perm;
|
||||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||||
import org.eehouse.android.xw4.loc.LocUtils;
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
|
@ -113,7 +114,7 @@ public class Utils {
|
||||||
public static boolean isGSMPhone( Context context )
|
public static boolean isGSMPhone( Context context )
|
||||||
{
|
{
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if ( Perms23.havePermission( Perms23.Perm.READ_PHONE_STATE ) ) {
|
if ( Perms23.havePermission( Perm.READ_PHONE_STATE ) ) {
|
||||||
SMSService.SMSPhoneInfo info = SMSService.getPhoneInfo( context );
|
SMSService.SMSPhoneInfo info = SMSService.getPhoneInfo( context );
|
||||||
result = info.isPhone && info.isGSM;
|
result = info.isPhone && info.isGSM;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +130,7 @@ public class Utils {
|
||||||
public static boolean deviceSupportsSMS( Context context )
|
public static boolean deviceSupportsSMS( Context context )
|
||||||
{
|
{
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if ( Perms23.havePermission( Perms23.Perm.READ_PHONE_STATE ) ) {
|
if ( Perms23.havePermission( Perm.READ_PHONE_STATE ) ) {
|
||||||
TelephonyManager tm = (TelephonyManager)
|
TelephonyManager tm = (TelephonyManager)
|
||||||
context.getSystemService( Context.TELEPHONY_SERVICE );
|
context.getSystemService( Context.TELEPHONY_SERVICE );
|
||||||
result = null != tm;
|
result = null != tm;
|
||||||
|
@ -283,7 +284,7 @@ public class Utils {
|
||||||
synchronized ( s_phonesHash ) {
|
synchronized ( s_phonesHash ) {
|
||||||
if ( s_phonesHash.containsKey( phone ) ) {
|
if ( s_phonesHash.containsKey( phone ) ) {
|
||||||
name = s_phonesHash.get( phone );
|
name = s_phonesHash.get( phone );
|
||||||
} else if ( Perms23.havePermission( Perms23.Perm.READ_CONTACTS ) ) {
|
} else if ( Perms23.havePermission( Perm.READ_CONTACTS ) ) {
|
||||||
try {
|
try {
|
||||||
ContentResolver contentResolver = context
|
ContentResolver contentResolver = context
|
||||||
.getContentResolver();
|
.getContentResolver();
|
||||||
|
|
Loading…
Add table
Reference in a new issue