am f8014eea: Hide the correct button when pressing a new button.
* commit 'f8014eea341040f8d155e071e4e0c915a7ebd61d': Hide the correct button when pressing a new button.main
commit
6dc9933d83
|
@ -174,7 +174,7 @@ public final class ActionBatch {
|
||||||
final long downloadId = UpdateHandler.registerDownloadRequest(manager, request, db,
|
final long downloadId = UpdateHandler.registerDownloadRequest(manager, request, db,
|
||||||
mWordList.mId, mWordList.mVersion);
|
mWordList.mId, mWordList.mVersion);
|
||||||
Utils.l("Starting download of", uri, "with id", downloadId);
|
Utils.l("Starting download of", uri, "with id", downloadId);
|
||||||
PrivateLog.log("Starting download of " + uri + ", id : " + downloadId, context);
|
PrivateLog.log("Starting download of " + uri + ", id : " + downloadId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ public final class ActionBatch {
|
||||||
mWordList.mRemoteFilename, mWordList.mLastUpdate, mWordList.mChecksum,
|
mWordList.mRemoteFilename, mWordList.mLastUpdate, mWordList.mChecksum,
|
||||||
mWordList.mFileSize, mWordList.mVersion, mWordList.mFormatVersion);
|
mWordList.mFileSize, mWordList.mVersion, mWordList.mFormatVersion);
|
||||||
PrivateLog.log("Insert 'available' record for " + mWordList.mDescription
|
PrivateLog.log("Insert 'available' record for " + mWordList.mDescription
|
||||||
+ " and locale " + mWordList.mLocale, context);
|
+ " and locale " + mWordList.mLocale);
|
||||||
db.insert(MetadataDbHelper.METADATA_TABLE_NAME, null, values);
|
db.insert(MetadataDbHelper.METADATA_TABLE_NAME, null, values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,7 @@ public final class ActionBatch {
|
||||||
mWordList.mChecksum, mWordList.mFileSize, mWordList.mVersion,
|
mWordList.mChecksum, mWordList.mFileSize, mWordList.mVersion,
|
||||||
mWordList.mFormatVersion);
|
mWordList.mFormatVersion);
|
||||||
PrivateLog.log("Insert 'preinstalled' record for " + mWordList.mDescription
|
PrivateLog.log("Insert 'preinstalled' record for " + mWordList.mDescription
|
||||||
+ " and locale " + mWordList.mLocale, context);
|
+ " and locale " + mWordList.mLocale);
|
||||||
db.insert(MetadataDbHelper.METADATA_TABLE_NAME, null, values);
|
db.insert(MetadataDbHelper.METADATA_TABLE_NAME, null, values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -424,7 +424,7 @@ public final class ActionBatch {
|
||||||
mWordList.mRemoteFilename, mWordList.mLastUpdate, mWordList.mChecksum,
|
mWordList.mRemoteFilename, mWordList.mLastUpdate, mWordList.mChecksum,
|
||||||
mWordList.mFileSize, mWordList.mVersion, mWordList.mFormatVersion);
|
mWordList.mFileSize, mWordList.mVersion, mWordList.mFormatVersion);
|
||||||
PrivateLog.log("Updating record for " + mWordList.mDescription
|
PrivateLog.log("Updating record for " + mWordList.mDescription
|
||||||
+ " and locale " + mWordList.mLocale, context);
|
+ " and locale " + mWordList.mLocale);
|
||||||
db.update(MetadataDbHelper.METADATA_TABLE_NAME, values,
|
db.update(MetadataDbHelper.METADATA_TABLE_NAME, values,
|
||||||
MetadataDbHelper.WORDLISTID_COLUMN + " = ? AND "
|
MetadataDbHelper.WORDLISTID_COLUMN + " = ? AND "
|
||||||
+ MetadataDbHelper.VERSION_COLUMN + " = ?",
|
+ MetadataDbHelper.VERSION_COLUMN + " = ?",
|
||||||
|
|
|
@ -189,7 +189,7 @@ public final class DictionaryProvider extends ContentProvider {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getType(final Uri uri) {
|
public String getType(final Uri uri) {
|
||||||
PrivateLog.log("Asked for type of : " + uri, this);
|
PrivateLog.log("Asked for type of : " + uri);
|
||||||
final int match = matchUri(uri);
|
final int match = matchUri(uri);
|
||||||
switch (match) {
|
switch (match) {
|
||||||
case NO_MATCH: return null;
|
case NO_MATCH: return null;
|
||||||
|
@ -220,7 +220,7 @@ public final class DictionaryProvider extends ContentProvider {
|
||||||
public Cursor query(final Uri uri, final String[] projection, final String selection,
|
public Cursor query(final Uri uri, final String[] projection, final String selection,
|
||||||
final String[] selectionArgs, final String sortOrder) {
|
final String[] selectionArgs, final String sortOrder) {
|
||||||
Utils.l("Uri =", uri);
|
Utils.l("Uri =", uri);
|
||||||
PrivateLog.log("Query : " + uri, this);
|
PrivateLog.log("Query : " + uri);
|
||||||
final String clientId = getClientId(uri);
|
final String clientId = getClientId(uri);
|
||||||
final int match = matchUri(uri);
|
final int match = matchUri(uri);
|
||||||
switch (match) {
|
switch (match) {
|
||||||
|
@ -228,7 +228,7 @@ public final class DictionaryProvider extends ContentProvider {
|
||||||
case DICTIONARY_V2_WHOLE_LIST:
|
case DICTIONARY_V2_WHOLE_LIST:
|
||||||
final Cursor c = MetadataDbHelper.queryDictionaries(getContext(), clientId);
|
final Cursor c = MetadataDbHelper.queryDictionaries(getContext(), clientId);
|
||||||
Utils.l("List of dictionaries with count", c.getCount());
|
Utils.l("List of dictionaries with count", c.getCount());
|
||||||
PrivateLog.log("Returned a list of " + c.getCount() + " items", this);
|
PrivateLog.log("Returned a list of " + c.getCount() + " items");
|
||||||
return c;
|
return c;
|
||||||
case DICTIONARY_V2_DICT_INFO:
|
case DICTIONARY_V2_DICT_INFO:
|
||||||
// In protocol version 2, we return null if the client is unknown. Otherwise
|
// In protocol version 2, we return null if the client is unknown. Otherwise
|
||||||
|
@ -248,10 +248,10 @@ public final class DictionaryProvider extends ContentProvider {
|
||||||
// TODO: pass clientId to the following function
|
// TODO: pass clientId to the following function
|
||||||
DictionaryService.updateNowIfNotUpdatedInAVeryLongTime(getContext());
|
DictionaryService.updateNowIfNotUpdatedInAVeryLongTime(getContext());
|
||||||
if (null != dictFiles && dictFiles.size() > 0) {
|
if (null != dictFiles && dictFiles.size() > 0) {
|
||||||
PrivateLog.log("Returned " + dictFiles.size() + " files", this);
|
PrivateLog.log("Returned " + dictFiles.size() + " files");
|
||||||
return new ResourcePathCursor(dictFiles);
|
return new ResourcePathCursor(dictFiles);
|
||||||
} else {
|
} else {
|
||||||
PrivateLog.log("No dictionary files for this URL", this);
|
PrivateLog.log("No dictionary files for this URL");
|
||||||
return new ResourcePathCursor(Collections.<WordListInfo>emptyList());
|
return new ResourcePathCursor(Collections.<WordListInfo>emptyList());
|
||||||
}
|
}
|
||||||
// V2_METADATA and V2_DATAFILE are not supported for query()
|
// V2_METADATA and V2_DATAFILE are not supported for query()
|
||||||
|
@ -488,7 +488,7 @@ public final class DictionaryProvider extends ContentProvider {
|
||||||
public Uri insert(final Uri uri, final ContentValues values)
|
public Uri insert(final Uri uri, final ContentValues values)
|
||||||
throws UnsupportedOperationException {
|
throws UnsupportedOperationException {
|
||||||
if (null == uri || null == values) return null; // Should never happen but let's be safe
|
if (null == uri || null == values) return null; // Should never happen but let's be safe
|
||||||
PrivateLog.log("Insert, uri = " + uri.toString(), this);
|
PrivateLog.log("Insert, uri = " + uri.toString());
|
||||||
final String clientId = getClientId(uri);
|
final String clientId = getClientId(uri);
|
||||||
switch (matchUri(uri)) {
|
switch (matchUri(uri)) {
|
||||||
case DICTIONARY_V2_METADATA:
|
case DICTIONARY_V2_METADATA:
|
||||||
|
@ -517,7 +517,7 @@ public final class DictionaryProvider extends ContentProvider {
|
||||||
break;
|
break;
|
||||||
case DICTIONARY_V1_WHOLE_LIST:
|
case DICTIONARY_V1_WHOLE_LIST:
|
||||||
case DICTIONARY_V1_DICT_INFO:
|
case DICTIONARY_V1_DICT_INFO:
|
||||||
PrivateLog.log("Attempt to insert : " + uri, this);
|
PrivateLog.log("Attempt to insert : " + uri);
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"Insertion in the dictionary is not supported in this version");
|
"Insertion in the dictionary is not supported in this version");
|
||||||
}
|
}
|
||||||
|
@ -532,7 +532,7 @@ public final class DictionaryProvider extends ContentProvider {
|
||||||
@Override
|
@Override
|
||||||
public int update(final Uri uri, final ContentValues values, final String selection,
|
public int update(final Uri uri, final ContentValues values, final String selection,
|
||||||
final String[] selectionArgs) throws UnsupportedOperationException {
|
final String[] selectionArgs) throws UnsupportedOperationException {
|
||||||
PrivateLog.log("Attempt to update : " + uri, this);
|
PrivateLog.log("Attempt to update : " + uri);
|
||||||
throw new UnsupportedOperationException("Updating dictionary words is not supported");
|
throw new UnsupportedOperationException("Updating dictionary words is not supported");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -190,7 +189,7 @@ public final class DictionaryService extends Service {
|
||||||
// is still more recent than UPDATE_FREQUENCY, do nothing.
|
// is still more recent than UPDATE_FREQUENCY, do nothing.
|
||||||
if (!isLastUpdateAtLeastThisOld(context, UPDATE_FREQUENCY)) return;
|
if (!isLastUpdateAtLeastThisOld(context, UPDATE_FREQUENCY)) return;
|
||||||
|
|
||||||
PrivateLog.log("Date changed - registering alarm", context);
|
PrivateLog.log("Date changed - registering alarm");
|
||||||
AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
|
AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
|
||||||
|
|
||||||
// Best effort to wake between midnight and MAX_ALARM_DELAY in the morning.
|
// Best effort to wake between midnight and MAX_ALARM_DELAY in the morning.
|
||||||
|
@ -215,7 +214,7 @@ public final class DictionaryService extends Service {
|
||||||
private static boolean isLastUpdateAtLeastThisOld(final Context context, final long time) {
|
private static boolean isLastUpdateAtLeastThisOld(final Context context, final long time) {
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
final long lastUpdate = MetadataDbHelper.getOldestUpdateTime(context);
|
final long lastUpdate = MetadataDbHelper.getOldestUpdateTime(context);
|
||||||
PrivateLog.log("Last update was " + lastUpdate, context);
|
PrivateLog.log("Last update was " + lastUpdate);
|
||||||
return lastUpdate + time < now;
|
return lastUpdate + time < now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@ final class LogProblemReporter implements ProblemReporter {
|
||||||
TAG = tag;
|
TAG = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void report(final Exception e) {
|
public void report(final Exception e) {
|
||||||
Log.e(TAG, "Reporting problem : " + e);
|
Log.e(TAG, "Reporting problem", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,11 @@
|
||||||
|
|
||||||
package com.android.inputmethod.dictionarypack;
|
package com.android.inputmethod.dictionarypack;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
import android.provider.Settings;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
@ -309,8 +307,7 @@ public class MetadataDbHelper extends SQLiteOpenHelper {
|
||||||
* @param uri the metadata URI we just downloaded
|
* @param uri the metadata URI we just downloaded
|
||||||
*/
|
*/
|
||||||
public static void saveLastUpdateTimeOfUri(final Context context, final String uri) {
|
public static void saveLastUpdateTimeOfUri(final Context context, final String uri) {
|
||||||
PrivateLog.log("Save last update time of URI : " + uri + " " + System.currentTimeMillis(),
|
PrivateLog.log("Save last update time of URI : " + uri + " " + System.currentTimeMillis());
|
||||||
context);
|
|
||||||
final ContentValues values = new ContentValues();
|
final ContentValues values = new ContentValues();
|
||||||
values.put(CLIENT_LAST_UPDATE_DATE_COLUMN, System.currentTimeMillis());
|
values.put(CLIENT_LAST_UPDATE_DATE_COLUMN, System.currentTimeMillis());
|
||||||
final SQLiteDatabase defaultDb = getDb(context, null);
|
final SQLiteDatabase defaultDb = getDb(context, null);
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package com.android.inputmethod.dictionarypack;
|
package com.android.inputmethod.dictionarypack;
|
||||||
|
|
||||||
import android.content.ContentProvider;
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
@ -24,6 +23,7 @@ import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to keep long-term log. This is inactive in production, and is only for debug purposes.
|
* Class to keep long-term log. This is inactive in production, and is only for debug purposes.
|
||||||
|
@ -44,10 +44,10 @@ public class PrivateLog {
|
||||||
+ COLUMN_EVENT + " TEXT);";
|
+ COLUMN_EVENT + " TEXT);";
|
||||||
|
|
||||||
private static final SimpleDateFormat sDateFormat =
|
private static final SimpleDateFormat sDateFormat =
|
||||||
new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.US);
|
||||||
|
|
||||||
private static PrivateLog sInstance = new PrivateLog();
|
private static PrivateLog sInstance = new PrivateLog();
|
||||||
private static DebugHelper mDebugHelper = null;
|
private static DebugHelper sDebugHelper = null;
|
||||||
|
|
||||||
private PrivateLog() {
|
private PrivateLog() {
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ public class PrivateLog {
|
||||||
public static synchronized PrivateLog getInstance(final Context context) {
|
public static synchronized PrivateLog getInstance(final Context context) {
|
||||||
if (!DEBUG) return sInstance;
|
if (!DEBUG) return sInstance;
|
||||||
synchronized(PrivateLog.class) {
|
synchronized(PrivateLog.class) {
|
||||||
if (sInstance.mDebugHelper == null) {
|
if (sDebugHelper == null) {
|
||||||
sInstance.mDebugHelper = new DebugHelper(context);
|
sDebugHelper = new DebugHelper(context);
|
||||||
}
|
}
|
||||||
return sInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
@ -94,16 +94,9 @@ public class PrivateLog {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(String event, Context context) {
|
public static void log(String event) {
|
||||||
if (!DEBUG) return;
|
if (!DEBUG) return;
|
||||||
final SQLiteDatabase l = getInstance(context).mDebugHelper.getWritableDatabase();
|
final SQLiteDatabase l = sDebugHelper.getWritableDatabase();
|
||||||
mDebugHelper.insert(l, event);
|
DebugHelper.insert(l, event);
|
||||||
}
|
|
||||||
|
|
||||||
public static void log(String event, ContentProvider provider) {
|
|
||||||
if (!DEBUG) return;
|
|
||||||
final SQLiteDatabase l =
|
|
||||||
getInstance(provider.getContext()).mDebugHelper.getWritableDatabase();
|
|
||||||
mDebugHelper.insert(l, event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ public final class UpdateHandler {
|
||||||
final String clientId = cursor.getString(0);
|
final String clientId = cursor.getString(0);
|
||||||
final String metadataUri =
|
final String metadataUri =
|
||||||
MetadataDbHelper.getMetadataUriAsString(context, clientId);
|
MetadataDbHelper.getMetadataUriAsString(context, clientId);
|
||||||
PrivateLog.log("Update for clientId " + Utils.s(clientId), context);
|
PrivateLog.log("Update for clientId " + Utils.s(clientId));
|
||||||
Utils.l("Update for clientId", clientId, " which uses URI ", metadataUri);
|
Utils.l("Update for clientId", clientId, " which uses URI ", metadataUri);
|
||||||
uris.add(metadataUri);
|
uris.add(metadataUri);
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
|
@ -211,7 +211,7 @@ public final class UpdateHandler {
|
||||||
*/
|
*/
|
||||||
private static void updateClientsWithMetadataUri(final Context context,
|
private static void updateClientsWithMetadataUri(final Context context,
|
||||||
final boolean updateNow, final String metadataUri) {
|
final boolean updateNow, final String metadataUri) {
|
||||||
PrivateLog.log("Update for metadata URI " + Utils.s(metadataUri), context);
|
PrivateLog.log("Update for metadata URI " + Utils.s(metadataUri));
|
||||||
final Request metadataRequest = new Request(Uri.parse(metadataUri));
|
final Request metadataRequest = new Request(Uri.parse(metadataUri));
|
||||||
Utils.l("Request =", metadataRequest);
|
Utils.l("Request =", metadataRequest);
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ public final class UpdateHandler {
|
||||||
// method will ignore it.
|
// method will ignore it.
|
||||||
writeMetadataDownloadId(context, metadataUri, downloadId);
|
writeMetadataDownloadId(context, metadataUri, downloadId);
|
||||||
}
|
}
|
||||||
PrivateLog.log("Requested download with id " + downloadId, context);
|
PrivateLog.log("Requested download with id " + downloadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -404,7 +404,7 @@ public final class UpdateHandler {
|
||||||
/* package */ static void downloadFinished(final Context context, final Intent intent) {
|
/* package */ static void downloadFinished(final Context context, final Intent intent) {
|
||||||
// Get and check the ID of the file that was downloaded
|
// Get and check the ID of the file that was downloaded
|
||||||
final long fileId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, NOT_AN_ID);
|
final long fileId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, NOT_AN_ID);
|
||||||
PrivateLog.log("Download finished with id " + fileId, context);
|
PrivateLog.log("Download finished with id " + fileId);
|
||||||
Utils.l("DownloadFinished with id", fileId);
|
Utils.l("DownloadFinished with id", fileId);
|
||||||
if (NOT_AN_ID == fileId) return; // Spurious wake-up: ignore
|
if (NOT_AN_ID == fileId) return; // Spurious wake-up: ignore
|
||||||
|
|
||||||
|
@ -491,7 +491,7 @@ public final class UpdateHandler {
|
||||||
|
|
||||||
private static void publishUpdateCycleCompletedEvent(final Context context) {
|
private static void publishUpdateCycleCompletedEvent(final Context context) {
|
||||||
// Even if this is not successful, we have to publish the new state.
|
// Even if this is not successful, we have to publish the new state.
|
||||||
PrivateLog.log("Publishing update cycle completed event", context);
|
PrivateLog.log("Publishing update cycle completed event");
|
||||||
Utils.l("Publishing update cycle completed event");
|
Utils.l("Publishing update cycle completed event");
|
||||||
for (UpdateEventListener listener : linkedCopyOfList(sUpdateEventListeners)) {
|
for (UpdateEventListener listener : linkedCopyOfList(sUpdateEventListeners)) {
|
||||||
listener.updateCycleCompleted();
|
listener.updateCycleCompleted();
|
||||||
|
@ -582,7 +582,7 @@ public final class UpdateHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.l("Downloaded metadata :", newMetadata);
|
Utils.l("Downloaded metadata :", newMetadata);
|
||||||
PrivateLog.log("Downloaded metadata\n" + newMetadata, context);
|
PrivateLog.log("Downloaded metadata\n" + newMetadata);
|
||||||
|
|
||||||
final ActionBatch actions = computeUpgradeTo(context, clientId, newMetadata);
|
final ActionBatch actions = computeUpgradeTo(context, clientId, newMetadata);
|
||||||
// TODO: Check with UX how we should report to the user
|
// TODO: Check with UX how we should report to the user
|
||||||
|
@ -610,7 +610,7 @@ public final class UpdateHandler {
|
||||||
MetadataDbHelper.DESCRIPTION_COLUMN), "for", downloadRecord.mClientId);
|
MetadataDbHelper.DESCRIPTION_COLUMN), "for", downloadRecord.mClientId);
|
||||||
PrivateLog.log("Downloaded a new word list with description : "
|
PrivateLog.log("Downloaded a new word list with description : "
|
||||||
+ downloadRecord.mAttributes.getAsString(MetadataDbHelper.DESCRIPTION_COLUMN)
|
+ downloadRecord.mAttributes.getAsString(MetadataDbHelper.DESCRIPTION_COLUMN)
|
||||||
+ " for " + downloadRecord.mClientId, context);
|
+ " for " + downloadRecord.mClientId);
|
||||||
|
|
||||||
final String locale =
|
final String locale =
|
||||||
downloadRecord.mAttributes.getAsString(MetadataDbHelper.LOCALE_COLUMN);
|
downloadRecord.mAttributes.getAsString(MetadataDbHelper.LOCALE_COLUMN);
|
||||||
|
|
|
@ -23,7 +23,9 @@ import android.preference.DialogPreference;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewParent;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.ListView;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
|
|
||||||
|
@ -42,6 +44,7 @@ public final class WordListPreference extends DialogPreference {
|
||||||
// What to display in the "status" field when we receive unknown data as a status from
|
// What to display in the "status" field when we receive unknown data as a status from
|
||||||
// the content provider. Empty string sounds sensible.
|
// the content provider. Empty string sounds sensible.
|
||||||
static final private String NO_STATUS_MESSAGE = "";
|
static final private String NO_STATUS_MESSAGE = "";
|
||||||
|
static final private int NOT_AN_INDEX = -1;
|
||||||
|
|
||||||
/// Actions
|
/// Actions
|
||||||
static final private int ACTION_UNKNOWN = 0;
|
static final private int ACTION_UNKNOWN = 0;
|
||||||
|
@ -64,7 +67,7 @@ public final class WordListPreference extends DialogPreference {
|
||||||
static final private int ANIMATION_IN = 1;
|
static final private int ANIMATION_IN = 1;
|
||||||
static final private int ANIMATION_OUT = 2;
|
static final private int ANIMATION_OUT = 2;
|
||||||
|
|
||||||
private static Button sLastClickedActionButton = null;
|
private static int sLastClickedIndex = NOT_AN_INDEX;
|
||||||
private final OnWordListPreferenceClick mPreferenceClickHandler =
|
private final OnWordListPreferenceClick mPreferenceClickHandler =
|
||||||
new OnWordListPreferenceClick();
|
new OnWordListPreferenceClick();
|
||||||
private final OnActionButtonClick mActionButtonClickHandler =
|
private final OnActionButtonClick mActionButtonClickHandler =
|
||||||
|
@ -205,15 +208,30 @@ public final class WordListPreference extends DialogPreference {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(final View v) {
|
public void onClick(final View v) {
|
||||||
final Button button = (Button)v.findViewById(R.id.wordlist_button);
|
final Button button = (Button)v.findViewById(R.id.wordlist_button);
|
||||||
if (null != sLastClickedActionButton) {
|
|
||||||
animateButton(sLastClickedActionButton, ANIMATION_OUT);
|
|
||||||
}
|
|
||||||
animateButton(button, ANIMATION_IN);
|
animateButton(button, ANIMATION_IN);
|
||||||
sLastClickedActionButton = button;
|
final ViewParent parent = v.getParent();
|
||||||
|
// Just in case something changed in the framework, test for the concrete class
|
||||||
|
if (!(parent instanceof ListView)) return;
|
||||||
|
final ListView listView = (ListView)parent;
|
||||||
|
final int myIndex = listView.indexOfChild(v) + listView.getFirstVisiblePosition();
|
||||||
|
if (NOT_AN_INDEX != sLastClickedIndex) {
|
||||||
|
animateButton(getButtonForIndex(listView, sLastClickedIndex), ANIMATION_OUT);
|
||||||
|
}
|
||||||
|
sLastClickedIndex = myIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Button getButtonForIndex(final ListView listView, final int index) {
|
||||||
|
final int indexInChildren = index - listView.getFirstVisiblePosition();
|
||||||
|
if (indexInChildren < 0 || index > listView.getLastVisiblePosition()) {
|
||||||
|
// The view is offscreen.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (Button)listView.getChildAt(indexInChildren).findViewById(R.id.wordlist_button);
|
||||||
|
}
|
||||||
|
|
||||||
private void animateButton(final Button button, final int direction) {
|
private void animateButton(final Button button, final int direction) {
|
||||||
|
if (null == button) return;
|
||||||
final float outerX = ((View)button.getParent()).getWidth();
|
final float outerX = ((View)button.getParent()).getWidth();
|
||||||
final float innerX = button.getX() - button.getTranslationX();
|
final float innerX = button.getX() - button.getTranslationX();
|
||||||
if (View.INVISIBLE == button.getVisibility()) {
|
if (View.INVISIBLE == button.getVisibility()) {
|
||||||
|
|
Loading…
Reference in New Issue