Android Open Source - ACM_Pi_Cloud Own Cloud Version






From Project

Back to project page ACM_Pi_Cloud.

License

The source code is released under:

MIT License

If you think the Android project ACM_Pi_Cloud listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/* ownCloud Android Library is available under MIT license
 *   Copyright (C) 2014 ownCloud Inc. /*from  ww  w. j a  va2 s  . c  o  m*/
 *   Copyright (C) 2012  Bartek Przybylski
 *   
 *   Permission is hereby granted, free of charge, to any person obtaining a copy
 *   of this software and associated documentation files (the "Software"), to deal
 *   in the Software without restriction, including without limitation the rights
 *   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *   copies of the Software, and to permit persons to whom the Software is
 *   furnished to do so, subject to the following conditions:
 *   
 *   The above copyright notice and this permission notice shall be included in
 *   all copies or substantial portions of the Software.
 *   
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
 *   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
 *   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
 *   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 *   THE SOFTWARE.
 *
 */

package com.owncloud.android.lib.resources.status;

public class OwnCloudVersion implements Comparable<OwnCloudVersion> {
    public static final OwnCloudVersion owncloud_v1 = new OwnCloudVersion(
            0x01000000);
    public static final OwnCloudVersion owncloud_v2 = new OwnCloudVersion(
            0x02000000);
    public static final OwnCloudVersion owncloud_v3 = new OwnCloudVersion(
            0x03000000);
    public static final OwnCloudVersion owncloud_v4 = new OwnCloudVersion(
            0x04000000);
    public static final OwnCloudVersion owncloud_v4_5 = new OwnCloudVersion(
            0x04050000);
    
    public static final int MINIMUM_VERSION_FOR_SHARING_API = 0x05001B00; // 5.0.27
    
    private static final int MAX_DOTS = 3;
    
    // format is in version
    // 0xAABBCCDD
    // for version AA.BB.CC.DD
    // ie version 2.0.3 will be stored as 0x02000300
    private int mVersion;
    private boolean mIsValid;

    protected OwnCloudVersion(int version) {
        mVersion = version;
        mIsValid = true;
    }
    
    public OwnCloudVersion(String version){
       mVersion = 0;
         mIsValid = false;
         int countDots = version.length() - version.replace(".", "").length();

         // Complete the version. Version must have 3 dots
         for (int i = countDots; i < MAX_DOTS; i++) {
           version = version + ".0";
         }
         
         parseVersion(version);

    }
    
    public String toString() {
      String versionToString = String.valueOf((mVersion >> (8*MAX_DOTS)) % 256);
      for (int i = MAX_DOTS - 1; i >= 0; i-- ) {
        versionToString = versionToString + "." + String.valueOf((mVersion >> (8*i)) % 256);
      }
        return versionToString;
    }
    
    public String getVersion() {
      return toString();
    }
    
    public boolean isVersionValid() {
        return mIsValid;
    }

    @Override
    public int compareTo(OwnCloudVersion another) {
        return another.mVersion == mVersion ? 0
                : another.mVersion < mVersion ? 1 : -1;
    }

    private void parseVersion(String version) {
      try {
        mVersion = getParsedVersion(version);
        mIsValid = true;
        
      } catch (Exception e) {
        mIsValid = false;
        }
    }
    
    private int getParsedVersion(String version) throws NumberFormatException {
      int versionValue = 0;

      // get only numeric part 
      version = version.replaceAll("[^\\d.]", "");

      String[] nums = version.split("\\.");
      for (int i = 0; i < nums.length && i <= MAX_DOTS; i++) {
        versionValue += Integer.parseInt(nums[i]);
        if (i < nums.length - 1) {
          versionValue = versionValue << 8;
        }
      }

      return versionValue; 
    }
    
    
    public boolean isSharedSupported() {
      return (mVersion >= MINIMUM_VERSION_FOR_SHARING_API);
    }
    
    
}




Java Source Code List

com.owncloud.android.lib.common.OwnCloudAccount.java
com.owncloud.android.lib.common.OwnCloudBasicCredentials.java
com.owncloud.android.lib.common.OwnCloudBearerCredentials.java
com.owncloud.android.lib.common.OwnCloudClientFactory.java
com.owncloud.android.lib.common.OwnCloudClientManagerFactory.java
com.owncloud.android.lib.common.OwnCloudClientManager.java
com.owncloud.android.lib.common.OwnCloudClient.java
com.owncloud.android.lib.common.OwnCloudCredentialsFactory.java
com.owncloud.android.lib.common.OwnCloudCredentials.java
com.owncloud.android.lib.common.OwnCloudSamlSsoCredentials.java
com.owncloud.android.lib.common.SimpleFactoryManager.java
com.owncloud.android.lib.common.SingleSessionManager.java
com.owncloud.android.lib.common.accounts.AccountTypeUtils.java
com.owncloud.android.lib.common.accounts.AccountUtils.java
com.owncloud.android.lib.common.network.AdvancedSslSocketFactory.java
com.owncloud.android.lib.common.network.AdvancedX509TrustManager.java
com.owncloud.android.lib.common.network.BearerAuthScheme.java
com.owncloud.android.lib.common.network.BearerCredentials.java
com.owncloud.android.lib.common.network.CertificateCombinedException.java
com.owncloud.android.lib.common.network.ChunkFromFileChannelRequestEntity.java
com.owncloud.android.lib.common.network.FileRequestEntity.java
com.owncloud.android.lib.common.network.NetworkUtils.java
com.owncloud.android.lib.common.network.OnDatatransferProgressListener.java
com.owncloud.android.lib.common.network.ProgressiveDataTransferer.java
com.owncloud.android.lib.common.network.ServerNameIndicator.java
com.owncloud.android.lib.common.network.WebdavEntry.java
com.owncloud.android.lib.common.network.WebdavUtils.java
com.owncloud.android.lib.common.operations.OnRemoteOperationListener.java
com.owncloud.android.lib.common.operations.OperationCancelledException.java
com.owncloud.android.lib.common.operations.RemoteOperationResult.java
com.owncloud.android.lib.common.operations.RemoteOperation.java
com.owncloud.android.lib.resources.files.ChunkedUploadRemoteFileOperation.java
com.owncloud.android.lib.resources.files.CreateRemoteFolderOperation.java
com.owncloud.android.lib.resources.files.DownloadRemoteFileOperation.java
com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation.java
com.owncloud.android.lib.resources.files.FileUtils.java
com.owncloud.android.lib.resources.files.ReadRemoteFileOperation.java
com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation.java
com.owncloud.android.lib.resources.files.RemoteFile.java
com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation.java
com.owncloud.android.lib.resources.files.RenameRemoteFileOperation.java
com.owncloud.android.lib.resources.files.UploadRemoteFileOperation.java
com.owncloud.android.lib.resources.shares.CreateRemoteShareOperation.java
com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation.java
com.owncloud.android.lib.resources.shares.GetRemoteSharesOperation.java
com.owncloud.android.lib.resources.shares.OCShare.java
com.owncloud.android.lib.resources.shares.RemoveRemoteShareOperation.java
com.owncloud.android.lib.resources.shares.ShareType.java
com.owncloud.android.lib.resources.shares.ShareUtils.java
com.owncloud.android.lib.resources.shares.ShareXMLParser.java
com.owncloud.android.lib.resources.status.GetRemoteStatusOperation.java
com.owncloud.android.lib.resources.status.OwnCloudVersion.java
com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation.java
com.owncloud.android.lib.sampleclient.FilesArrayAdapter.java
com.owncloud.android.lib.sampleclient.MainActivity.java
com.owncloud.android.lib.test_project.SelfSignedConfidentSslSocketFactory.java
com.owncloud.android.lib.test_project.TestActivity.java