-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
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 |
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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' | ||
} |
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); | ||
} | ||
} |
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> |
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); | ||
} | ||
|
||
} |