content: /*
   * Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     https://mindorks.com/license/apache-v2
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License
   */
  
  package <%= appPackage %>.utils;
  
  import android.annotation.SuppressLint;
  import android.app.ProgressDialog;
  import android.content.Context;
  import android.graphics.Color;
  import android.graphics.drawable.ColorDrawable;
  import android.provider.Settings;
  
  import <%= appPackage %>.R;
  
  import java.text.SimpleDateFormat;
  import java.util.Date;
  import java.util.Locale;
  import java.util.regex.Matcher;
  import java.util.regex.Pattern;
  
  /**
   * Created by janisharali on 27/01/17.
   */
  
  public final class CommonUtils {
  
      private static final String TAG = "CommonUtils";
  
      private CommonUtils() {
          // This utility class is not publicly instantiable
      }
  
      public static ProgressDialog showLoadingDialog(Context context) {
          ProgressDialog progressDialog = new ProgressDialog(context);
          progressDialog.show();
          if (progressDialog.getWindow() != null) {
              progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
          }
          progressDialog.setContentView(R.layout.progress_dialog);
          progressDialog.setIndeterminate(true);
          progressDialog.setCancelable(false);
          progressDialog.setCanceledOnTouchOutside(false);
          return progressDialog;
      }
  
      @SuppressLint("all")
      public static String getDeviceId(Context context) {
          return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
      }
  
      public static boolean isEmailValid(String email) {
          Pattern pattern;
          Matcher matcher;
          final String EMAIL_PATTERN =
                  "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
                          + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
          pattern = Pattern.compile(EMAIL_PATTERN);
          matcher = pattern.matcher(email);
          return matcher.matches();
      }
  
      public static String getTimeStamp() {
          return new SimpleDateFormat(AppConstants.TIMESTAMP_FORMAT, Locale.US).format(new Date());
      }
  }
  