Giter VIP home page Giter VIP logo

androidui's Introduction

This library has 6 modules to aid Android development, speeding up the completion of the application

Features

Gradle Setup

Add Maven Central to the project's build.gradle :

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
		maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases' }
	}
}

Add the following dependency into your module's build.gradle:

TAG =

 defaultConfig {
        multiDexEnabled true
 }
    
dependencies {
	implementation 'com.github.Concyline:Androidui:TAG'
}

You can add below lines into your gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true

Componentes

Simples

 <siac.com.componentes.EditTextTitle
            android:id="@+id/editTextTitle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:colorTitle="@color/colorAccent"
            app:requerido="false"
            app:enabled="true"
            app:focusable="true"
            app:requestfocus="true"
            app:tag="edittext"
            app:text="texto"
            app:title="Componente simples" />

Mascara

    <!-- Is free to create any mask just edit the app:mascara="" -->

    <siac.com.componentes.EditTextTitle
            android:id="@+id/editTextTitle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:title="Mascara"
            app:mascara="  .   .   /    -  "
            app:enabled="true"
            app:focusable="true"
            app:requestfocus="false"
            app:tag="edittext"
            app:text="texto"
            app:requerido="true"
	    app:titleRequerido="Digite um CNPJ válido!"/>

Requerido

    <siac.com.componentes.EditTextTitle
            android:id="@+id/editTextTitle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:title="Enail"
            app:enabled="true"
            app:focusable="true"
            app:requestfocus="false"
            app:tag="edittext"
            app:text="texto"
            app:requerido="true"
	    app:titleRequerido="Digite um email válido!"/>

Só data

    <!-- the calendar listener is already implemented within the component -->

     <siac.com.componentes.EditTextCalendar
            android:id="@+id/editTextTitle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:title="Só data" />

Spinner

         <siac.com.componentes.SpinnerTitle
            android:id="@+id/spinnerTitle"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:entries="@array/tipo"
            app:title="Spinner" />

or add programaticaly adapter

ArrayAdapter<Object> adapter = new ArrayAdapter<Object>(getBaseContext(), 
	siac.com.componentes.R.layout.view_spinner_item_ui, new String[]{"aureo", "ana", "davi"});
	
spinnerTitle.setAdapter(adapter);

Dara e Hora

          <siac.com.componentes.EditTextCalendar
            android:id="@+id/editTextCalendar"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:hora="true"
            app:inicializa="false"
            app:title="EditTextCalendar" />

Icon direita

      <siac.com.componentes.EditTextTitle
            android:id="@+id/cadastroEditTextTitle"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:coricon="#D6C"
            app:iconRigth="@drawable/icons_coroa_48"
            app:inputType="number"
            app:title="Nome do cliente"
            app:tamTitle="@dimen/tamLegendaEditTextUi" />

TextViewTitle

    <siac.com.componentes.TextViewTitle
            android:id="@+id/textViewTitle"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="9dp"
            app:corDescricao="@color/colorPrimaryDark"
            app:colorTitle="@color/colorAccent"
	    app:tamTitle="13sp"
	    app:layout_constraintWidth_percent="0.2"
            app:tamDescricao="16sp"
	    app:singleLine="false"
            app:descricao="Goiânia  adsdasdadsdasdsdasdsadsadsadasdsadadsdaszdsadasdsadasdasda"
            app:title="Cidade" />
textViewTitle.setFont("fonts/Lobster-Regular.ttf");

EditTextSearch

   <siac.com.componentes.EditTextSearch
            android:id="@+id/editTextSearch"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:hint="sua pesquisa"
            app:inputType="none"
            app:coricon="@color/colorAccent"
            app:title="EditTextSearch" />
editTextSearch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ...
            }
        });
	
// Custom inputType programmatically
searchLegenda.setInputTypeSearch(Constantes.textPassword);

Multiline

    <siac.com.componentes.EditTextTitle
            android:id="@+id/multilineEditTextTitle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            app:coricon="@color/colorAccent"
            app:inputType="textMultiLine"
            app:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s"
            app:title="Multiline"
            app:lines="4"
            app:tamTitle="@dimen/tamLegendaEditTextUi" />

PassWord

      <siac.com.componentes.EditTextTitle
            android:id="@+id/senhaEditTextTitle"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:coricon="@color/colorAccent"
            app:iconRigth="@drawable/round_visibility_black_48dp"
            app:inputType="textPassword"
            app:title="Senha"
            app:tamTitle="@dimen/tamLegendaEditTextUi" />
final EditTextTitle senhaEditTextTitle = findViewById(R.id.senhaEditTextTitle);
        senhaEditTextTitle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                senhaEditTextTitle.mostraSenha();
            }
        });

EditTexCurrency

         <siac.com.componentes.EditTexCurrency
            android:id="@+id/editTexCurrency"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:enabled="true"
            app:focusable="true"
            app:title="Valor"
            app:requerido="false"
            app:requestfocus="false"
            app:locale="pt_BR"
            app:showSymbol="true"
            app:tag="Valor"
            app:text="" />

RecyclerViewParallax

    <siac.com.componentes.RecyclerViewParallax
         android:id="@+id/rv"
         android:layout_width="match_parent"
         android:layout_height="match_parent"/>


RecyclerViewButton

XML file

   <siac.com.componentes.RecyclerViewButton
        android:id="@+id/recyclerViewButton"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:horizontalDivider="true"
        app:locationButton="right"
        app:numberOfColumns="2"
        app:basic="false"
        app:refresh="true"
        app:verticalDivider="true" />

Set Listener

recyclerViewButton.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                new Async().execute();
            }
});

recyclerViewButton.addOnItemTouchListener(new RecyclerViewButton.ItemClickListener(new RecyclerViewButton.Listener() {
            @Override
            public void onItemClick(View view, int position) {
                System.out.println("aqui");
            }

            @Override
            public void onLongItemClick(View view, int position) {
                System.out.println("aqui");
            }

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                System.out.println("aqui");
            }
}));

AsyncTask

   public class Async extends AsyncTask<Void, Void, List<Cidade>> {

        @Override
        protected List<Cidade> doInBackground(Void... voids) {
            List<Cidade> list = helper.CidadeController().getAll();
            return list;
        }

        @Override
        protected void onPostExecute(List<Cidade> cidade) {
            super.onPostExecute(cidade);

            if (adapter == null) {
                adapter = new Adapter(cidade);
                recyclerViewButton.setAdapter(this, adapter);
            } else {
                adapter.notifyDataSetChanged();
            }

            recyclerViewButton.scrollToPosition(0);
            recyclerViewButton.setRefreshing(false);
        }
}

Adapter

 public class Adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

        private LayoutInflater mInflater;
	private List<Cidade> lCidade;

        Adapter(List<Cidade> lCidade) {
            this.mInflater = LayoutInflater.from(getBaseContext());
	    this.lCidade = lCidade;
        }

        @Override
        @NonNull
        public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View view = mInflater.inflate(R.layout.cidade_item, parent, false);
            return new ViewHolder(view);
        }

        @Override
        public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {

            final ViewHolder viewHolder = (ViewHolder) holder;

            Cidade cidade = lCidade.get(position);

            viewHolder.nomeTextView.setText(cidade.getNome());
            viewHolder.ufTextView.setText(cidade.getUf());
        }

        @Override
        public int getItemCount() {
            return lCidade.size();
        }

        public class ViewHolder extends RecyclerView.ViewHolder {
            TextView nomeTextView;
            TextView ufTextView;

            ViewHolder(View itemView) {
                super(itemView);
                nomeTextView = itemView.findViewById(R.id.nomeTextView);
                ufTextView = itemView.findViewById(R.id.ufTextView);
            }
        }

        Cidade getItem(int id) {
            return lCidade.get(id);
        }
}

ProgressImageView

    <siac.com.componentes.ProgressImageView
        android:id="@+id/progressImageView"
        android:layout_width="50dp"
        android:layout_height="50dp"
        app:progressSize="150dp"
        app:src="@drawable/lupa"
        app:progressColor="#2DB200" />
 final ProgressImageView progressImageView = findViewById(R.id.progressImageView);
        progressImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                progressImageView.setProgres();

                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        progressImageView.removeProgres();
                    }
                }, 2000);
            }
        });

ProgressButton

    <siac.com.componentes.ProgressButton
        android:id="@+id/progressButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:progressColor="#2DB200"
        app:progressSize="100dp"
        app:text="Ok Big Guy" />
final ProgressButton progressButtonOk = findViewById(R.id.progressButtonOk);
        progressButtonOk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                progressButtonOk.setProgres();

                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        progressButtonOk.removeProgres();
                    }
                }, 2000);
            }
        });

HelpButton

  <siac.com.componentes.HelpButton
    android:id="@+id/helpButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:color="@color/colorError"
    app:helpMsg="Lorem Ipsum is simply dummy text of the printing and typesetting industry."/>
 HelpButton helpButton = findViewById(R.id.helpButton);
 helpButton.setActivity(this);
 
 // In XML file or programmatically
 helpButton.setHelpMsg("Lorem Ipsum is simply dummy text of the printing and typesetting industry.");

RoundishImageView

     <siac.com.componentes.RoundishImageView
            android:id="@+id/roundishImageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:src="@drawable/cidade"
            app:cornerRadius="10dp"
            app:roundedCorners="topLeft|bottomRight" />

RoundImageView

     <siac.com.componentes.RoundImageView
        android:id="@+id/roundImageView"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:src="@drawable/cidade"
        app:borderColor="@color/colorAccent"
        app:borderWidth="5dp" />

Custon Dialog

new CDialog(ComponentesDoisActivity.this)
                        .createAlert("WARNING! custon mensagem",
                                WindowFormat.BACKGROUND_RECTANGLE,
                                getBitmapFromAsset(),
                                TypeDialog.WARNING,
                                SizeDialog.XLARGE)
                        .setAnimation(AnimateDialog.SCALE_FROM_BOTTOM_TO_TOP)
                        .setDuration(3000)  // in milliseconds
                        .setTextSize(SizeText.XLARGE)
                        .setPosition(PositionDialog.POSITION_CENTER)
                        .setBackDimness(0.9f) // less Than One
                        .setBackgroundColor(R.color.pink)
                        .show();

Or Listener, when you finish the task

new CDialog(ParametrosActivity.this)
                .createAlertSneckBar("Salvo com sucesso!",
                        TypeDialog.INFO,
                        SizeDialog.MEDIUM)
                .setDuration(2000)
                .show(new CDialog.CDialogListener() {
                    @Override
                    public void onDismiss() {
                	...
                    }
                });

Get Image resources

 public Bitmap getBitmapFromAsset() {
      InputStream imageStream = getResources().openRawResource(R.raw.lamp);
      Bitmap bitmap = BitmapFactory.decodeStream(imageStream);
      return bitmap;
  }

  public Drawable getDrawable() {
      Drawable myDrawable = getResources().getDrawable(R.drawable.checked_1);
      return myDrawable;
  }

SnackBar

 new CDialog(ComponentesDoisActivity.this)
                        .createAlertSneckBar("Info SnackBar",
                            TypeDialog.INFO,
                            SizeDialog.MEDIUM)
                        .show();

Manipulador de texto

Usage

@Override
protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_manipula_texto);
  
  //anywhere in the system
  
   StorageSD
             .init(this)
             .setFolderAndFileName("Manipula","Log.txt")
  	.setLog(new Log() {
                  @Override
                  public void onLog(String message) {
                      // 
                  }
              })
              .build();

	// METHODS
	//StorageSD.info("");
	//StorageSD.erro("");
	//StorageSD.processaException("class", Exception error);
	//StorageSD.delete()
	//String all = StorageSD.getAll();
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="siac.com.androidui">

  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

  <application
      android:allowBackup="true"
      android:icon="@mipmap/icon_teste"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/icon_teste"
      android:supportsRtl="true"
  android:requestLegacyExternalStorage="true" <!--VERY IMPORTANT API > 26-->
      android:theme="@style/AppTheme">
      <activity android:name=".ManipulaTextoActivity"></activity>
      <activity android:name=".MainActivity">
          <intent-filter>
              <action android:name="android.intent.action.MAIN" />

              <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
      </activity>
     
  </application>

</manifest>

CustomDialog

in res/layout/cadastro.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp"
    android:background="#FFF">
	
	...

        <Button
            android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="OK"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName2" />
</androidx.constraintlayout.widget.ConstraintLayout>

in res/menu/menu_bar.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/miCompose"
        android:icon="@drawable/round_alarm_white_48dp"
        app:showAsAction="ifRoom"
        android:title="Compose">
    </item>
    <item
        android:id="@+id/miProfile"
        android:icon="@drawable/round_backup_white_48dp"
        app:showAsAction="ifRoom|withText"
        android:title="Profile">
    </item>
</menu>

in onCreate

   try {
            CustomDialog customDialog = new CustomDialog(MainActivity.this);
            customDialog.setContentView(R.layout.cadastro)
                    .setToolbarTitle("Log IN")
                    .setToolbarSubTitle("Enter the system")
                    .setMenuToolbar(R.menu.menu_bar)
                    .setBackgroundResource(CustomDialog.DWindow.ROUND)
                    .setHeight(CustomDialog.DLayoutParams.WRAP_CONTENT)
                    .setCancelable(true)
                    .create();

            customDialog.menu(R.id.miCompose).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    System.out.println("MENU");
                    return false;
                }
            });

            Dialog dialog = customDialog.dialog();

            Button button = dialog.findViewById(R.id.button);
            button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    System.out.println("BUTTON");
                }
            });
            
            customDialog.show();
        } catch (Exception e) {
            e.printStackTrace();
        }

GeometricProgress

 <siac.com.componentes.GeometricProgressView
    android:id="@+id/progressView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:gp_type="triangle"
    app:gp_number_of_angles="7"
    app:gp_color="@android:color/black"
    app:gp_duration="800"
    app:gp_figure_padding="3dp" />
GeometricProgressView progressView = (GeometricProgressView) findViewById(R.id.progressView);
progressView.setType(TYPE.KITE);
progressView.setNumberOfAngles(6);
progressView.setColor(Color.parseColor("#00897b"));
progressView.setDuration(1000);
progressView.setFigurePadding(getResources().getDimensionPixelOffset(R.dimen.figure_padding));

DotLoader

 <siac.com.componentes.DotLoader
    android:id="@+id/text_dot_loader"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:color_array="@array/dot_colors"
    app:dot_radius="4dp"
    app:number_of_dots="3"/>

color.xml

<array name="dot_colors">
    <item>#03A9F4</item>
    <item>#E65100</item>
    <item>#FFBB00</item>
</array>
dotLoader.postDelayed(new Runnable() {
    @Override
    public void run() {
        dotLoader.setNumberOfDots(5);
    }
}, 3000);

ProgressIndeterminate

ProgressIndeterminate progressDialog = new ProgressIndeterminate(ComponentesDoisActivity.this).
                        create("Atenção!")
                        .multColor(true)
                        .setTextSize(SizeText.MEDIUM)
                        .cancelable(false);

      progressDialog.show();
      
      //progressDialog.dismiss();
      //progressDialog.isShowing();
      //progressDialog.setMessage("Text");
      //progressDialog.setBackgroundColor(R.color.pink);
		
// or

ProgressIndeterminate progressDialog = ProgressIndeterminate.show(ComponentesDoisActivity.this, "OK");

SwipeLayout

<siac.com.componentes.SwipeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/swipe_layout"
    android:layout_width="match_parent"
    android:layout_height="90dp"
    android:layout_marginTop="3dp"
    app:draggedItem="@id/drag_item"
    app:swipeDirection="left|right"
    app:leftItem="@id/left_view"
    app:rightItem="@id/right_view">

    <ImageView
        android:id="@+id/left_view"
        android:layout_width="90dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#ff5722"
        android:gravity="center"
        android:paddingEnd="24dp"
        android:paddingStart="24dp"
        android:src="@drawable/ic_upload"/>

    <ImageView
        android:id="@+id/right_view"
        android:layout_width="90dp"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:background="#ff5722"
        android:gravity="center"
        android:paddingEnd="24dp"
        android:paddingStart="24dp"
        android:src="@drawable/ic_delete"/>

    <TextView
        android:id="@+id/drag_item"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#eeeeee"
        android:clickable="true"
        android:focusable="true"
        android:foreground="?selectableItemBackgroundBorderless"
        android:gravity="center_vertical"
        android:orientation="vertical"
        android:paddingEnd="10dp"
        android:paddingStart="20dp"
        android:textSize="20sp"/>

</siac.com.componentes.SwipeLayout>

In Holder

    leftView = itemView.findViewById(R.id.left_view);
                rightView = itemView.findViewById(R.id.right_view);

                rightView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (getAdapterPosition() != NO_POSITION) {
                            remove(itemView.getContext(), getAdapterPosition());
                        }
                    }
                });

                leftView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (getAdapterPosition() != NO_POSITION) {
                            upload(itemView.getContext(), getAdapterPosition());
                        }
                    }
                });

For all companions

all components have the following methods boolean validaPreenchido(), boolean validaCpfCnpj(), void setError(), void removeError(), void mostraSenha(), String getString() , String getStringUperCase() , Integer getInteger(), Double getDouble()

update color icon error

<color name="colorAccent">#F79D91</color>

public listeners

  public void setOnClickListener(OnClickListener onClickListener) {
        editText.setOnClickListener(onClickListener);
    }

    public void setOnClickListenerIconLeft(OnClickListener onClickListener) {
        iconLeftImageView.setOnClickListener(onClickListener);
    }

    public void setOnClickListenerIconRigth(OnClickListener onClickListener) {
        iconRigthImageView.setOnClickListener(onClickListener);
    }

Leitor Qr and CodeBar

Usage

@Override
protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_manipula_texto);

	retornoEditText = findViewById(R.id.retornoEditText);

      Button lerQrTesteButton = findViewById(R.id.lerQrTesteButton);
      lerQrTesteButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent = new Intent(getBaseContext(), LeitorActivity.class);
              String codigo = "C=7898958119652;L=50962;V=30/09/2019";
              intent.putExtra(LeitorActivity.CODE_TEST,codigo);
              startActivityForResult(intent, 123);
          }
      });

      Button lerQrButton = findViewById(R.id.lerQrButton);
      lerQrButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent = new Intent(getBaseContext(), LeitorActivity.class);
              startActivityForResult(intent, 123);
          }
      });
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      
   if(requestCode == 123) {
          retornoEditText.setText("");
          if (data != null) {
              retornoEditText.setText(data.getStringExtra("CODIGO"));
          }
      }
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="siac.com.androidui">

  <uses-permission android:name="android.permission.CAMERA" />

  <application
      android:allowBackup="true"
      android:icon="@mipmap/icon_teste"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/icon_teste"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".ManipulaTextoActivity"></activity>
      <activity android:name=".MainActivity">
          <intent-filter>
              <action android:name="android.intent.action.MAIN" />

              <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
      </activity>
      
      <activity android:name="siac.com.leitor.LeitorActivity" />

  </application>

</manifest>

ShortCut

Usage

ADD

ShortcutUtils shortcutUtils;
Shortcut dynamicShortcut;
   
shortcutUtils = new ShortcutUtils(this);

dynamicShortcut = new Shortcut.ShortcutBuilder()
     .setShortcutIcon(R.drawable.round_device_hub_white_48dp)
     .setShortcutId("dynamicShortcutId")
     .setShortcutLongLabel("ALL Devices")
     .setShortcutShortLabel("ALL Devices")
     .setIntentAction("dynamicShortcutIntentAction")
     .setIntentStringExtraKey("dynamicShortcutKey")
     .setIntentStringExtraValue("all")
.build();


 shortcutUtils.addDynamicShortCut(dynamicShortcut, new IReceiveStringExtra() {
      @Override
      public void onReceiveStringExtra(String stringExtraKey, String stringExtraValue) {
           String intent = getIntent().getStringExtra(stringExtraKey);
               if (intent != null) {
                   if (intent.equals("all")) {
                       System.out.println("OKOKOKOKOKOKO");
                   }
               }
           }
       });
   

REMOVE

shortcutUtils.removeDynamicShortCut(dynamicShortcut);

Permisions

Usage

in AndroidManifest.xml

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

in Activity

String[] permissions = {Manifest.permission.READ_EXTERNAL_STORAGE,
                Manifest.permission.WRITE_EXTERNAL_STORAGE};

Permissions.check(MainActivity.this, permissions, null, null, new PermissionHandler() {
       @Override
       public void onGranted() {
	    	...
       }

       @Override
       public void onDenied(Context context, ArrayList<String> deniedPermissions) {
        	...
       }
});

Util

Usage

// In Activity
import siac.com.util.Util;

// Usage in class
Util.setBar(UtilActivity.this, "Title", "Subtitle");

Util.abaixaTeclado(getBaseContext(), view);
                               
Util.fadeIn(getBaseContext(), view);
                               
Util.toastLong(getBaseContext(),"Long mesage Toasta");

Util.toastShort(getBaseContext(),"Short mesage Toasta");
                               
Util.alertOk(UtilActivity.this, "Atention mesage");
                               
Util.alertOk(UtilActivity.this, "mesage", new OnListnerOk() {
        @Override
        public void ok() {
                ...                       
        }
});
                               
Util.alertSimCancelar(UtilActivity.this, "mesage", new OnListnerAlertSimCancelar() {
         @Override
         public void sim() {
                 ...                      
         }

         @Override
         public void cancelar() {
     		  ...
         }
 });

BackgroundTask

BackgroundTask.with(this) // Activity|FragmentActivity(v4)|Fragment|Fragment(v4)
       .assign(new BackgroundTask.TaskDescription() {
           @Override
           public Object onBackground() {
               // Do what you want to do on background thread.
               // If you want to post something to MainThread,
               // just call BackgroundTask.post(YOUR_MESSAGE).

               // Return your finally result(Nullable).
               return null;
           }
       })
   .preExecute(new BackgroundTask.PreExecuteListener() {
            @Override
            public void onPreExecute() {
                // Run task before starting
            }
        })
       .handle(new BackgroundTask.MessageListener() {
           @Override
           public void handleMessage(@NonNull Message message) {
               // Receive message in MainThread which sent from WorkerThread,
               // update your UI just in time.
           }
       })
       .finish(new BackgroundTask.FinishListener() {
           @Override
           public void onFinish(@Nullable Object result) {
               // If WorkerThread finish without Exception and lifecycle safety,
               // deal with your WorkerThread result at here.
           }
       })
       .broken(new BackgroundTask.BrokenListener() {
           @Override
           public void onBroken(@NonNull Exception e) {
               // If WorkerThread finish with Exception and lifecycle safety,
               // deal with Exception at here.
           }
       })
       .execute();
   

Notice:

MUST: .with(), .assign(), .execute().

OPTION: .handle(), .finish(), broken(). Every method just call once, otherwise the newer with replace the older.

Use: BackgroundTask.post() To send message from WorkerThread to MainThread just in time.

EasyFonts

TextView tv_hello = (TextView) findViewById(R.id.tv_hello);
tv_hello.setTypeface(EasyFonts.robotoThin(this));

EasyLocation

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com">

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

</manifest>
     findViewById(R.id.button23).setOnClickListener(v -> {

            EditText editText = findViewById(R.id.editTextTextMultiLine2);
            GeoLocationModel geoLocationModel = new EasyLocationFetch(this).getLocationData();

            if(geoLocationModel == null){
                editText.setText("The system was unable to retrieve the location!");
                return;
            }

            StringBuilder builder = new StringBuilder();

            builder.append("Address:   "+geoLocationModel.getAddress() +"\r\n");
            builder.append("City:      "+geoLocationModel.getCity() +"\r\n");
            builder.append("Lattitude: "+geoLocationModel.getLattitude() +"\r\n");
            builder.append("Longitude: "+geoLocationModel.getLongitude() +"\r\n");

            editText.setText(builder.toString());

        });

ActionBarCuston

     ActionBarCuston actionBarCuston = new ActionBarCuston(this);
     actionBarCuston.setBarColor(R.color.colorPrimary);
     actionBarCuston.setTitleColor("#E60000");
     actionBarCuston.setSubTitleColor("#E60000");

     actionBarCuston.setBar("Teste", "Subtitle");

MeasureIcon


CamPix

Usage

AndroidManifest.xml

   <?xml version="1.0" encoding="utf-8"?>
   <manifest xmlns:android="http://schemas.android.com/apk/res/android"
   	package="...">

   		<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
   		<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
   		<uses-permission android:name="android.permission.CAMERA" />
   		<uses-permission android:name="android.permission.VIBRATE" />

   		<application>

   		...    

       		<activity android:name="br.com.campix.Pix"/>
   		</application>

   </manifest>
      findViewById(R.id.cliclButton).setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               options = Options.init()
                       .setRequestCode(requestCodePicker)
                       .setFrontfacing(false)
                       .setPath("pix/photo");
               //.setFileName("teste");

               Pix.start(CamPixActivity.this, options);
           }
       });
   
 @Override
  protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
      super.onActivityResult(requestCode, resultCode, data);

      if (requestCode == requestCodePicker) {
          if (resultCode == Activity.RESULT_OK) {

              String path = data.getStringExtra(Pix.IMAGE_PATH);
              File file = (File) data.getExtras().get(Pix.IMAGE_FILE);

              glide = Glide.with(CamPixActivity.this);
              glide.load(path).into(imageView);
          }
      }
  }

  @Override
  public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
      super.onRequestPermissionsResult(requestCode, permissions, grantResults);

      if (requestCode == PermUtil.REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS) {
          if (grantResults.length != 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
              Pix.start(this, options);
          } else {
              Toast.makeText(this, "Approve permissions to open Pix ImagePicker", Toast.LENGTH_LONG).show();
          }
      }
  }
  

PhotoView

Usage

  <br.com.campix.photoView.PhotoView
        android:id="@+id/imagemImageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"
        app:srcCompat="@drawable/button" />
PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);
photoView.setImageResource(R.drawable.image);

Zoom Frame

Usage

  <siac.com.componentes.ZoomFrameImageView
       android:id="@+id/fragmentloginKenBurnsView1"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:src="@drawable/image_3" />

Hawk

Usage

Initialize
Hawk.init(context).build();

Usage
Save any type (Any object, primitives, lists, sets, maps ...)

Hawk.put(key, T);
Get the original value with the original type

T value = Hawk.get(key);
Delete any entry

Hawk.delete(key);
Check if any key exists

Hawk.contains(key);
Check total entry count

Hawk.count();

Get crazy and delete everything
Hawk.deleteAll();

CalculatorDialog

Usage

new CalculatorDialog(this) {
               @Override
               public void onResult(Double result) {
                   editText.setText(result + "");
               }
}.setValue(Double.parseDouble(editText.getText().toString().trim())).showDIalog();

KeyBoardDialog

Usage

KeyBoardDialog customDialog = new KeyBoardDialog(ComponentesDoisActivity.this);
                   customDialog.setBackgroundResource(KeyBoardDialog.DWindow.ROUND)
                           .setCancelable(true)
                           .setJustNumber(false)
   		    .setBackgroundColor(R.color.background)
                           .create();

                   customDialog.show(editTextNumber.getText().toString(), new KeyBoardDialog.OnDismissListener() {
                       @Override
                       public void dismiss(String value) {
                           editTextNumber.setText(value);
                       }
                   });

HttpAgent

Usage

  String content = gson.toJson(new LoginBody("12247272000170", "API", "123456"));

       new HttpAgent(MainActivity.this, "https://viacep.com.br/ws/01001000/json/", HTTP.GET)
               //new HttpAgent(MainActivity.this,"http://10.0.2.2:8080/SiacAPI/Login", HTTP.POST)
               //new HttpAgent(MainActivity.this,"http://10.0.2.2:8080/SiacAPI/Minutas", HTTP.GET)
               //.headers("Authorization", "Bearer " + token, "Content-Type", "application/json")
               .headers("Content-Type", "application/json")
               //.setTokenBearer(token)
   	//.queryParams("key_1","value_1","key_2","value_2","key_N","value_N")
               //.withBody("{name:popapp ,age:27}")
               //.withBody(content)
               .goString(new StringCallback() {
                   @Override
                   protected void onDone(boolean success, String stringResults) {
                       if (success) {
                           System.out.println(stringResults);
                       } else {
                           System.out.println(getErrorMessage());
                       }
                   }
               });
   	

//Get no results, Just send the request
go(new SuccessCallback() {
                       @Override
                       protected void onDone(boolean success) {
                           getErrorMessage(); //returns error message if exists.
                           getResponseCode(); // well, it's obvious...
                           getStringResults(); // returns results as as string.
                       }
                   })

//Get a string results
goString(new StringCallback() {
                       @Override
                       protected void onDone(boolean success, String results) {
                           getErrorMessage(); //returns error message if exists.
                           getResponseCode(); // well, it's obvious...
                           getStringResults(); // returns results as as string.
                       }
                   })

//Get Json results
goJson(new JsonCallback() {
                       @Override
                       protected void onDone(boolean success, JSONObject jsonObject) {
                           getErrorMessage(); //returns error message if exists.
                           getResponseCode(); // well, it's obvious...
                           getStringResults(); // returns results as as string.
                       }
                   })

//Get JsonArray results
goJsonArray(new JsonArrayCallback() {
                       @Override
                       protected void onDone(boolean success, JSONArray jsonArray) {
			    getErrorMessage(); //returns error message if exists.
                           getResponseCode(); // well, it's obvious...
                           getStringResults(); // returns results as as string.
                       }
                   });

SOAPManager

SOAP has been losing ground to REST services in mobile the last years, thus losing attention. But SOAP isn't gone and many still use it. The thing is that it usually requires a lot of work from the dev to create and parse all the messages.

JSoap is an Android library which allows automatic handling of SOAP requests and resposes, making the process effortless to the user. It works on top of the well-known library KSOAP2.

Usage

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="br.com.androidui">

    <application
 	...
        android:usesCleartextTraffic="true">
     
    </application>

</manifest>
@JSoapClass(namespace = "http://tempuri.org/")
public class Cidade {

   @JSoapResField(name = "CidadeId")
   public int CidadeId;

   @JSoapResField(name = "EstadoId")
   public String EstadoId;

   @JSoapResField(name = "Nome")
   public String Nome;

   //very important
   public Cidade() {
   }
}

@JSoapClass(namespace = "http://tempuri.org/")
public class Parametros {

   @JSoapReqField(order = 0, fieldName = "DataHora")
   private String DataHora;

   public Parametros(String DataHora) {
       this.DataHora = DataHora;
   }
}

@JSoapClass(namespace = "http://tempuri.org/")
public class Response {

   @JSoapResField(name = "GetCidadesResult")
   public Cidade[] result;

}

private void get() {
       String url = "http://10.0.2.2:2193/Integracao.asmx";
       String namespace = "http://tempuri.org/";
       String method = "GetCidades";
       String soap_action = "http://tempuri.org/GetCidades";

       SOAPManager.get(namespace, url, method, soap_action, new Parametros("01/01/1000"), Response.class, new JSoapCallback() {

           @Override
           public void onSuccess(Object result) {
               Response res = (Response) result;
               setAdapter(res.result);
           }

           @Override
           public void onError(int error) {
               switch (error) {
                   case JsoapError.NETWORK_ERROR:
                       Log.v("JSoapExample", "Network error");
                       break;
                   case JsoapError.PARSE_ERROR:
                       Log.v("JSoapExample", "Parsing error");
                       break;
                   default:
                       Log.v("JSoapExample", "Unknown error");
                       break;
               }
           }

       });
   }

SignaturePad

Usage

        <br.com.signature.SignaturePad
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            signature:penColor="#000"
            signature:clearOnDoubleClick="true"
            signature:velocityFilterWeight="2000"
            android:id="@+id/signature_pad" />
 mSignaturePad.setOnSignedListener(new SignaturePad.OnSignedListener() {
           @Override
           public void onStartSigning() {
               ...
           }

           @Override
           public void onSigned() {
               ...
           }

           @Override
           public void onClear() {
              ...
           }
       });
   
//// Clear
mSignaturePad.clear();

//// Save
mSaveButton.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View view) {
               Bitmap signatureBitmap = mSignaturePad.getSignatureBitmap();
               if (addJpgSignatureToGallery(signatureBitmap)) {
                   Toast("Signature saved into the Gallery");
               } else {
                   Toast("Unable to store the signature");
               }
               if (addSvgSignatureToGallery(mSignaturePad.getSignatureSvg())) {
                   Toast("SVG Signature saved into the Gallery");
               } else {
                   Toast("Unable to store the SVG signature");
               }
           }
       });

UnCaughtException

Tracking down all exceptions is the crucial part of the development. We could just expect that we have handled all exceptions. But whatever we do, we come across it with the so-called pop-up saying “Unfortunately, App has stopped”, that is why it is called uncaught-exceptions.

In AndroidManifest.xml

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


<activity android:name="br.com.error.uce.DefaultActivity"></activity>
@Override
protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_error);

      new UnCaughtException.Builder(this)
                .setMailSuport("[email protected]", "[email protected]")
                .setTrackActivitiesEnabled(true)
                .setBackgroundModeEnabled(true)
                .build();

}

Optional Parameters

.setUCEHEnabled(true/false) // default 'true' => Enable/Disable UCE_Handler.

.setTrackActivitiesEnabled(true/false) // default 'false' => Choose whether you want to track the flow of activities the user/tester has taken or not.

.setBackgroundModeEnabled(true/false) // default 'true' => Choose if you want to catch exceptions while app is in background.

'Save Error Log' will work only if your app already has storage permission as library does not ask for it.


Resources

Anim Description
shake Balance the components
Drawable Description Image
shadow Composes with edges like a cardboard
shadow_selected Composes with edges like a cardboard selected
edit_selector skin for custom Edittext
spinner_selector skin for custom Spinner

Contact

androidui's People

Contributors

concyline avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ets-android5

androidui's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.