Skip to content
This repository has been archived by the owner on Jan 1, 2020. It is now read-only.

Commit

Permalink
v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioars committed Jun 11, 2016
0 parents commit ec46272
Show file tree
Hide file tree
Showing 68 changed files with 1,378 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
27 changes: 27 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "br.com.developbox.favorites"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\fabio\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package br.com.developbox.favorites;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
32 changes: 32 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.com.developbox.favorites">

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

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name="br.com.developbox.favorites.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="br.com.developbox.favorites.AddActivity"
android:label="@string/add_title_activity" />
<activity
android:name="br.com.developbox.favorites.EditActivity"
android:label="@string/edit"/>
</application>

</manifest>
97 changes: 97 additions & 0 deletions app/src/main/java/br/com/developbox/favorites/AddActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package br.com.developbox.favorites;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import br.com.developbox.services.Favorite;
import br.com.developbox.services.FavoritesDatabase;

public class AddActivity extends AppCompatActivity {

private EditText addTitleField;
private EditText urlField;

Button clearButton;
Button addButton;
InputMethodManager keyboard;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

this.keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
this.addTitleField = (EditText) findViewById(R.id.addTitleField);
this.urlField = (EditText) findViewById(R.id.urlField);

this.clearButton = (Button) findViewById(R.id.clearButton);
this.addButton = (Button) findViewById(R.id.addButton);


this.clearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clearFields();
}
});
this.addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(addTitleField.getText().equals("")){
Toast.makeText(AddActivity.this, "O título não pode está limpo.", Toast.LENGTH_SHORT).show();
forceKeyBoard(addTitleField);
}
if(urlField.getText().equals("")){
Toast.makeText(AddActivity.this, "O campo de URL não pode está limpo.", Toast.LENGTH_SHORT).show();
forceKeyBoard(urlField);
}
if(!addTitleField.getText().equals("") && !urlField.getText().equals("")){
FavoritesDatabase db = new FavoritesDatabase(getBaseContext());
Favorite favorite = new Favorite(addTitleField.getText().toString(), urlField.getText().toString());
db.add(db.getWritableDatabase(), favorite);
clearFields();
finish();
}
}
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu){
getMenuInflater().inflate(R.menu.main, menu);

return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()){
case android.R.id.home:
this.keyboard.showSoftInput(this.addTitleField, InputMethodManager.HIDE_IMPLICIT_ONLY);
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
public void clearFields(){
this.addTitleField.setText("");
this.urlField.setText("");
this.addTitleField.requestFocus();

forceKeyBoard(addTitleField);

}
private void forceKeyBoard(View component){
InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
keyboard.showSoftInput(component, InputMethodManager.SHOW_FORCED);
}

}
Loading

0 comments on commit ec46272

Please sign in to comment.