private void openFolderPicker() {
    mGalleryQueryParameter.mUseLatLon = false;

    int dirQueryID = this.mGalleryQueryParameter.getDirQueryID();

    /** if wrong datatype was saved: gallery is not allowed for dirPicker */
    if (FotoSql.QUERY_TYPE_GALLERY == dirQueryID) {
      dirQueryID = FotoSql.QUERY_TYPE_GROUP_ALBUM;
    }

    if (mDirectoryRoot == null) {
      // not loaded yet. load directoryRoot in background
      final QueryParameterParcelable currentDirContentQuery =
          new QueryParameterParcelable(FotoSql.getQuery(dirQueryID));
      FotoSql.setWhereFilter(currentDirContentQuery, this.mGalleryQueryParameter.mFilter);

      this.mGalleryQueryParameter.mDirQueryID =
          (currentDirContentQuery != null)
              ? currentDirContentQuery.getID()
              : FotoSql.QUERY_TYPE_UNDEFINED;

      if (currentDirContentQuery != null) {
        this.mMustShowNavigator = true;
        DirectoryLoaderTask loader =
            new DirectoryLoaderTask(this, debugPrefix) {
              @Override
              protected void onPostExecute(IDirectory directoryRoot) {
                onDirectoryDataLoadComplete(directoryRoot);
              }
            };
        loader.execute(currentDirContentQuery);
      } else {
        Log.e(
            Global.LOG_CONTEXT,
            debugPrefix + " this.mDirQueryID undefined " + this.mGalleryQueryParameter.mDirQueryID);
      }
    } else {
      this.mMustShowNavigator = false;
      final FragmentManager manager = getFragmentManager();
      DirectoryPickerFragment dirDialog =
          new DirectoryPickerFragment(); // (DirectoryPickerFragment)
                                         // manager.findFragmentByTag(DLG_NAVIGATOR_TAG);
      dirDialog.defineDirectoryNavigation(
          mDirectoryRoot, dirQueryID, this.mGalleryQueryParameter.mCurrentPath);

      dirDialog.show(manager, DLG_NAVIGATOR_TAG);
    }
  }
Ejemplo n.º 2
0
 private QueryParameter getAsQuery() {
   IGalleryFilter filter = new GalleryFilterParameter();
   fromGui(filter);
   QueryParameter query = new QueryParameter(mRootQuery);
   FotoSql.setWhereFilter(query, filter, true);
   return query;
 }
  public static void showActivity(Activity context, SelectedItems selectedItems) {
    Uri initalUri = null;
    final Intent intent = new Intent().setClass(context, MapGeoPickerActivity.class);

    if ((selectedItems != null) && (selectedItems.size() > 0)) {
      intent.putExtra(EXTRA_SELECTED_ITEMS, selectedItems.toString());

      IGeoPoint initialPoint = FotoSql.execGetPosition(context, selectedItems.first().intValue());
      if (initialPoint != null) {
        GeoUri PARSER = new GeoUri(GeoUri.OPT_PARSE_INFER_MISSING);

        initalUri =
            Uri.parse(
                PARSER.toUriString(
                    initialPoint.getLatitude(),
                    initialPoint.getLongitude(),
                    IGeoPointInfo.NO_ZOOM));
        intent.setData(initalUri);
      }
      GalleryFilterParameter filter = new GalleryFilterParameter();
      filter.setNonGeoOnly(true);
      intent.putExtra(EXTRA_FILTER, filter.toString());
    }

    intent.setAction(Intent.ACTION_VIEW);
    if (Global.debugEnabled) {
      Log.d(
          Global.LOG_CONTEXT,
          context.getClass().getSimpleName() + " > MapGeoPickerActivity.showActivity@" + initalUri);
    }

    context.startActivity(intent);
  }
    // load from settings/instanceState
    private void loadSettingsAndInstanceState(Activity context, Bundle savedInstanceState) {
      SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
      this.mCurrentPath = sharedPref.getString(STATE_CurrentPath, this.mCurrentPath);
      this.mDirQueryID = sharedPref.getInt(STATE_DirQueryID, this.getDirQueryID());
      this.mSortID = sharedPref.getInt(STATE_SortID, this.mSortID);
      this.mSortAscending = sharedPref.getBoolean(STATE_SortAscending, this.mSortAscending);
      this.mCurrentLatLon.get(
          DirectoryFormatter.parseLatLon(sharedPref.getString(STATE_LAT_LON, null)));

      // instance state overrides settings
      if (savedInstanceState != null) {
        this.mCurrentPath = savedInstanceState.getString(STATE_CurrentPath, this.mCurrentPath);
        this.mDirQueryID = savedInstanceState.getInt(STATE_DirQueryID, this.getDirQueryID());
        this.mSortID = savedInstanceState.getInt(STATE_SortID, this.mSortID);
        this.mSortAscending =
            savedInstanceState.getBoolean(STATE_SortAscending, this.mSortAscending);
        this.mFilter = savedInstanceState.getParcelable(STATE_Filter);
        this.mCurrentLatLon.get(
            DirectoryFormatter.parseLatLon(savedInstanceState.getString(STATE_LAT_LON)));

        this.mUseLatLon = savedInstanceState.getBoolean(STATE_LAT_LON_ACTIVE, this.mUseLatLon);
      }

      if (this.mFilter == null) {
        this.mFilter = new GalleryFilterParameterParcelable();
        mFilter.loadSettings(sharedPref);
      }
      // extra parameter
      this.mGalleryContentQuery = context.getIntent().getParcelableExtra(EXTRA_QUERY);
      if (this.mGalleryContentQuery == null)
        this.mGalleryContentQuery = FotoSql.getQuery(FotoSql.QUERY_TYPE_DEFAULT);
    }
    /** combine root-query plus current selected directoryRoot */
    private QueryParameterParcelable calculateEffectiveGalleryContentQuery() {
      if (this.mGalleryContentQuery == null) return null;
      QueryParameterParcelable result = new QueryParameterParcelable(this.mGalleryContentQuery);

      FotoSql.setWhereFilter(result, this.mFilter);
      if (result == null) return null;

      if (mUseLatLon) {
        FotoSql.addWhereFilteLatLon(result, mCurrentLatLon);
      } else if (this.mCurrentPath != null) {
        FotoSql.addPathWhere(result, this.mCurrentPath, this.getDirQueryID());
      }

      FotoSql.setSort(result, mSortID, mSortAscending);
      return result;
    }
Ejemplo n.º 6
0
  /** called when user picks a new directory */
  @Override
  public void onDirectoryPick(String selectedAbsolutePath, int queryTypeId) {
    DirInfo dirInfo = getOrCreateDirInfo(queryTypeId);
    dirInfo.currentPath = selectedAbsolutePath;

    FotoSql.set(mFilter, selectedAbsolutePath, queryTypeId);
    toGui(mFilter);
  }
  private void setTitle() {
    String title = getIntent().getStringExtra(EXTRA_TITLE);

    if (title == null) {
      if (mGalleryQueryParameter.mUseLatLon) {
        title = getString(R.string.gallery_foto);
      } else if (this.mGalleryQueryParameter.mCurrentPath != null) {
        title =
            FotoSql.getName(this, this.mGalleryQueryParameter.getDirQueryID())
                + " - "
                + this.mGalleryQueryParameter.mCurrentPath;
      }
    }
    if (title != null) {
      this.setTitle(title + mTitleResultCount);
    }
  }
  private void onDirectoryDataLoadComplete(IDirectory directoryRoot) {
    if (directoryRoot == null) {
      final String message =
          getString(
              R.string.err_load_folder_failed,
              FotoSql.getName(this, this.mGalleryQueryParameter.getDirQueryID()));
      Toast.makeText(this, message, Toast.LENGTH_LONG).show();
    } else {
      mDirectoryRoot = directoryRoot;
      if ((mDirGui != null) && (this.mGalleryQueryParameter.mCurrentPath != null)) {
        mDirGui.defineDirectoryNavigation(
            directoryRoot,
            this.mGalleryQueryParameter.getDirQueryID(),
            this.mGalleryQueryParameter.mCurrentPath);
      }
      Global.debugMemory(debugPrefix, "onDirectoryDataLoadComplete");

      if ((mDirectoryRoot != null) && (this.mMustShowNavigator)) {
        openFolderPicker();
      }
    }
  }
 public String getSortDisplayName(Context context) {
   return FotoSql.getName(context, this.mSortID) + ((mSortAscending) ? " ^" : " V");
 }