use of org.fairphone.launcher.ApplicationInfo in project Fairphone by Kwamecorp.
the class AllAppsListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
if (rowView == null) {
LayoutInflater inflater = context.getLayoutInflater();
rowView = inflater.inflate(R.layout.fp_favorites_all_apps_list_item, null);
ViewHolder viewHolder = new ViewHolder();
viewHolder.appName = (TextView) rowView.findViewById(R.id.appText);
viewHolder.appImage = (ImageView) rowView.findViewById(R.id.appPicture);
rowView.setTag(viewHolder);
}
ViewHolder holder = (ViewHolder) rowView.getTag();
ApplicationInfo applicationInfo = allApps.get(position);
holder.appName.setText(applicationInfo.getApplicationTitle());
holder.appImage.setImageDrawable(new BitmapDrawable(context.getResources(), applicationInfo.iconBitmap));
return rowView;
}
use of org.fairphone.launcher.ApplicationInfo in project Fairphone by Kwamecorp.
the class EditFavoritesActivity method startDraggingIcon.
private void startDraggingIcon(View view, int position) {
// display a circle around the possible destinations
toggleFavoriteCircleSelection(-1, true);
View mainView = this.getWindow().getDecorView();
ApplicationInfo applicationInfo = mAllApps.get(position);
// set the item with the origin of the drag and the index of the dragged
// view
mDragOrigin = EditFavoritesActivity.ALL_APPS_DRAG;
String selectedItem = serializeItem(mDragOrigin, position);
ClipData.Item item = new ClipData.Item(selectedItem);
ClipData dragData = ClipData.newPlainText(applicationInfo.getApplicationTitle(), applicationInfo.getApplicationTitle());
dragData.addItem(item);
mainView.startDrag(dragData, new IconDragShadowBuilder(view, new BitmapDrawable(getResources(), applicationInfo.iconBitmap)), view, 0);
mainView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
use of org.fairphone.launcher.ApplicationInfo in project Fairphone by Kwamecorp.
the class FavoritesStorageHelper method storeSelectedApps.
/**
* Store the selected apps in the shared preferences as strings which is the
* package names of the apps. The package name of an app serves as the
* unique identifier of the app.
*/
public static void storeSelectedApps(Context context, ApplicationInfo[] mSelectedApps) {
if ((mSelectedApps != null) && (mSelectedApps.length > 0)) {
ArrayList<ComponentName> componentNamesArray = new ArrayList<ComponentName>();
for (int i = 0; i < mSelectedApps.length; i++) {
ApplicationInfo applicationInfo = mSelectedApps[i];
if (applicationInfo != null) {
componentNamesArray.add(applicationInfo.componentName);
} else {
componentNamesArray.add(null);
}
}
String componentNamesString = FavoritesStorageHelper.componentNamesArrayToString(componentNamesArray);
SharedPreferences sharedPreferences = context.getSharedPreferences(FAVORITES_APPS_SHARED_PREFERENCES_FILE_NAME, Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(FAVORITES_APPS_KEY, componentNamesString);
editor.commit();
}
}
use of org.fairphone.launcher.ApplicationInfo in project Fairphone by Kwamecorp.
the class FavoritesStorageHelper method loadSelectedApps.
/**
* Load the favorites apps from the shared preferences and get the Android
* application info from each, so we can get the app name and icon.
*/
public static ApplicationInfo[] loadSelectedApps(Context context, int maxApps) {
ApplicationInfo[] selectedAppArray = new ApplicationInfo[maxApps];
SharedPreferences sharedPreferences = context.getSharedPreferences(FAVORITES_APPS_SHARED_PREFERENCES_FILE_NAME, Activity.MODE_PRIVATE);
String componentNamesString = sharedPreferences.getString(FAVORITES_APPS_KEY, null);
if (componentNamesString == null || componentNamesString.length() == 0) {
componentNamesString = getDefaultEdgeSwipeApps(context);
}
if (componentNamesString != null) {
// Log.d(TAG, "loading selected apps - {" + componentNamesString + "}");
ArrayList<ComponentName> componentNames = FavoritesStorageHelper.stringToComponentNameArray(componentNamesString);
final PackageManager packageManager = context.getApplicationContext().getPackageManager();
for (int i = 0; i < Math.min(componentNames.size(), selectedAppArray.length); i++) {
ApplicationInfo applicationInfo = null;
ComponentName currentComponentName = componentNames.get(i);
if (currentComponentName != null) {
applicationInfo = AppDiscoverer.getInstance().getApplicationFromComponentName(currentComponentName);
}
selectedAppArray[i] = applicationInfo;
}
}
return selectedAppArray;
}
use of org.fairphone.launcher.ApplicationInfo in project Fairphone by Kwamecorp.
the class FavoritesStorageHelper method updateFavorites.
public static void updateFavorites(Context context, ComponentName componentName) {
ApplicationInfo[] currentApps = loadSelectedApps(context, MAX_FAVORITE_APPS);
for (ApplicationInfo appInfo : currentApps) {
if (appInfo != null) {
if (appInfo.componentName != null && appInfo.componentName.equals(componentName)) {
appInfo = null;
}
}
}
storeSelectedApps(context, currentApps);
}
Aggregations