diff options
author | Renard | 2016-04-07 18:58:48 -0300 |
---|---|---|
committer | Renard | 2016-04-07 18:58:48 -0300 |
commit | b9b2cd586c147ba9b08bbd809e7137ba3b6dacff (patch) | |
tree | 27604522330c9d7d88c61c946cf602f4b49ea5aa /app/src/main/java/org | |
parent | b80e7f3fd96d76d05734f3ba4221f1d7af97a57f (diff) | |
download | BaiApp-b9b2cd586c147ba9b08bbd809e7137ba3b6dacff.tar.gz BaiApp-b9b2cd586c147ba9b08bbd809e7137ba3b6dacff.tar.xz BaiApp-b9b2cd586c147ba9b08bbd809e7137ba3b6dacff.zip |
test
Diffstat (limited to 'app/src/main/java/org')
4 files changed, 26 insertions, 210 deletions
diff --git a/app/src/main/java/org/bienvenidoainternet/baiparser/MainActivity.java b/app/src/main/java/org/bienvenidoainternet/baiparser/MainActivity.java index bfe9db7..0a7d057 100644 --- a/app/src/main/java/org/bienvenidoainternet/baiparser/MainActivity.java +++ b/app/src/main/java/org/bienvenidoainternet/baiparser/MainActivity.java @@ -217,10 +217,8 @@ public class MainActivity extends AppCompatActivity refreshNavigator(); } - // TODO: Aplicar tema al navigator -// navigationView.setBackgroundColor(themeManager.getPrimaryDarkColor()); - // TODO: Arreglar el servidor -// checkForUpdates(); + //TODO: Aplicar tema al navigator + //navigationView.setBackgroundColor(themeManager.getPrimaryDarkColor()); } @Override @@ -293,10 +291,9 @@ public class MainActivity extends AppCompatActivity childFragment.scrollToTop(); } break; - case R.id.action_update: - Toast.makeText(getApplicationContext(), "nope", Toast.LENGTH_SHORT).show(); -// Intent updater = new Intent(getApplicationContext(), UpdaterActivity.class); -// startActivity(updater); + case R.id.action_about: + startActivity(new Intent(getApplicationContext(), LicensesActivity.class)); + break; } return super.onOptionsItemSelected(item); } @@ -441,40 +438,4 @@ public class MainActivity extends AppCompatActivity } return rnd; } - - public void checkForUpdates(){ - Ion.with(getApplicationContext()) - .load("http://ahri.xyz/bai/version.php") - .asString() - .setCallback(new FutureCallback<String>() { - @Override - public void onCompleted(Exception e, String result) { - if (e != null){ - e.printStackTrace(); - }else{ - try { - JSONObject version = new JSONObject(result); - float lastVersion = (float) version.getDouble("version"); - if (CURRENT_VERSION == lastVersion){ - Log.v("Updater", "Up to date"); - }else{ - Log.v("Updater", "New version available : " + lastVersion); - Snackbar.make(getCurrentFocus(), "Nueva versión disponible", Snackbar.LENGTH_LONG) - .setAction("Actualizar", new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent updater = new Intent(getApplicationContext(), UpdaterActivity.class); - startActivity(updater); - } - }) - .setActionTextColor(Color.rgb(255,127,0)) - .show(); - } - } catch (JSONException e1) { - e1.printStackTrace(); - } - } - } - }); - } } diff --git a/app/src/main/java/org/bienvenidoainternet/baiparser/ResponseActivity.java b/app/src/main/java/org/bienvenidoainternet/baiparser/ResponseActivity.java index b319426..e96868a 100644 --- a/app/src/main/java/org/bienvenidoainternet/baiparser/ResponseActivity.java +++ b/app/src/main/java/org/bienvenidoainternet/baiparser/ResponseActivity.java @@ -2,11 +2,15 @@ package org.bienvenidoainternet.baiparser; import android.content.Intent; import android.content.SharedPreferences; +import android.graphics.drawable.ColorDrawable; import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.EditText; @@ -27,12 +31,6 @@ import java.io.File; import utils.ContentProviderUtils; -//import org.apache.http.HttpEntity; -//import org.apache.http.entity.ContentType; -//import org.apache.http.entity.mime.HttpMultipartMode; -//import org.apache.http.entity.mime.MultipartEntityBuilder; -//import org.apache.http.entity.mime.content.FileBody; -//import org.apache.http.entity.mime.content.StringBody; public class ResponseActivity extends AppCompatActivity { @@ -67,17 +65,6 @@ public class ResponseActivity extends AppCompatActivity { LinearLayout layoutProcess = (LinearLayout)findViewById(R.id.layoutPostProcess); layoutProcess.setVisibility(View.GONE); filePath = (EditText) findViewById(R.id.txtFilePath); - Button send = (Button)findViewById(R.id.btnSend); - send.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - TextView txtName = (TextView) findViewById(R.id.txtPosterName); - TextView txtEmail = (TextView) findViewById(R.id.txtEmail); - TextView txtMessage = (TextView) findViewById(R.id.txtResponse); - makePost(txtName.getText().toString(), txtEmail.getText().toString(), txtMessage.getText().toString()); - - } - }); Button bBold = (Button) findViewById(R.id.buttonBold); bBold.setOnClickListener(new View.OnClickListener() { @@ -127,6 +114,23 @@ public class ResponseActivity extends AppCompatActivity { } @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_replyform, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == R.id.action_form_reply){ + TextView txtName = (TextView) findViewById(R.id.txtPosterName); + TextView txtEmail = (TextView) findViewById(R.id.txtEmail); + TextView txtMessage = (TextView) findViewById(R.id.txtResponse); + makePost(txtName.getText().toString(), txtEmail.getText().toString(), txtMessage.getText().toString()); + } + return super.onOptionsItemSelected(item); + } + + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE && resultCode == RESULT_OK && null != data) { diff --git a/app/src/main/java/org/bienvenidoainternet/baiparser/UpdaterActivity.java b/app/src/main/java/org/bienvenidoainternet/baiparser/UpdaterActivity.java deleted file mode 100644 index e98f303..0000000 --- a/app/src/main/java/org/bienvenidoainternet/baiparser/UpdaterActivity.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.bienvenidoainternet.baiparser; - -import android.content.Context; -import android.content.ContextWrapper; -import android.content.Intent; -import android.net.Uri; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.text.Html; -import android.util.Log; -import android.view.View; -import android.widget.Button; -import android.widget.ProgressBar; -import android.widget.TextView; -import android.widget.Toast; - -import com.koushikdutta.async.future.FutureCallback; -import com.koushikdutta.ion.Ion; - -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; - -public class UpdaterActivity extends AppCompatActivity { - private float lastVersion = 1.0F; - Button btnUpdate; - ProgressBar barUpdate; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_updater); - setTheme(R.style.AppTheme_Black_Activity); - btnUpdate = (Button) findViewById(R.id.btnDownloadLastVersion); - barUpdate = (ProgressBar) findViewById(R.id.barUpdateProgress); - TextView txtCurrentVersion = (TextView) findViewById(R.id.txtCurrentVersion); - btnUpdate.setEnabled(false); - txtCurrentVersion.setText("Versión actual: " + MainActivity.CURRENT_VERSION); - getVersionData(); - btnUpdate.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - downloadApk(); - } - }); - } - - private void getVersionData(){ - Ion.with(getApplicationContext()) - .load("http://ahri.xyz/bai/version.php") - .asString() - .setCallback(new FutureCallback<String>() { - @Override - public void onCompleted(Exception e, String result) { - if (e != null) { - e.printStackTrace(); - } else { - JSONObject version = null; - try { - version = new JSONObject(result); - lastVersion = (float) version.getDouble("version"); - TextView txtLastVersion = (TextView) findViewById(R.id.txtLastVersion); - txtLastVersion.setText("Última versión: " + lastVersion); - - if (lastVersion > MainActivity.CURRENT_VERSION) { - getChangelog(); - btnUpdate.setEnabled(true); - } - } catch (JSONException e1) { - e1.printStackTrace(); - } - } - } - }); - } - - private void getChangelog(){ - Ion.with(getApplicationContext()) - .load("http://ahri.xyz/bai/lastChangelog.txt") - .asString() - .setCallback(new FutureCallback<String>() { - @Override - public void onCompleted(Exception e, String result) { - if (e != null){ - e.printStackTrace(); - }else{ - TextView txtChangelog = (TextView) findViewById(R.id.txtChangelog); - txtChangelog.setText(Html.fromHtml(result)); - } - } - }); - } - - private void downloadApk(){ - ContextWrapper cw = new ContextWrapper(getApplicationContext()); - File directory = cw.getDir("src", Context.MODE_PRIVATE); - if (!directory.exists()) { - directory.mkdir(); - } - final File filePath = new File(directory, "last.apk"); - if (filePath.exists()) { - filePath.delete(); - } - Ion.with(getApplicationContext()) - .load("http://ahri.xyz/bai/" + lastVersion + "/last.apk") - .setLogging("Updater", Log.VERBOSE) - .progressBar(barUpdate) - .write(filePath) - .setCallback(new FutureCallback<File>() { - @Override - public void onCompleted(Exception e, File result) { - if (e != null) { - Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG).show(); - } else { - Intent promptInstall = new Intent(Intent.ACTION_VIEW) - .setDataAndType(Uri.fromFile(filePath), - "application/vnd.android.package-archive"); - startActivity(promptInstall); - } - } - }); - } -} - - diff --git a/app/src/main/java/org/bienvenidoainternet/baiparser/ViewerActivity.java b/app/src/main/java/org/bienvenidoainternet/baiparser/ViewerActivity.java index b113c2a..4501c0f 100644 --- a/app/src/main/java/org/bienvenidoainternet/baiparser/ViewerActivity.java +++ b/app/src/main/java/org/bienvenidoainternet/baiparser/ViewerActivity.java @@ -40,26 +40,6 @@ public class ViewerActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - -// SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); -// int themeId = Integer.valueOf(settings.getString("setting_theme", "1")), currentThemeId = R.style.AppTheme; -// switch (themeId) { -// case 1: -// currentThemeId = R.style.AppTheme_NoActionBar; -// break; -// case 2: -// currentThemeId = R.style.AppTheme_Dark; -// break; -// case 3: -// currentThemeId = R.style.AppTheme_HeadLine; -// break; -// case 4: -// currentThemeId = R.style.AppTheme_Black; -// break; -// } -// setTheme(currentThemeId); - - if (savedInstanceState != null){ bi = savedInstanceState.getParcelable("boardItem"); } @@ -70,8 +50,6 @@ public class ViewerActivity extends AppCompatActivity { imageView = (SubsamplingScaleImageView)findViewById(R.id.imageView); gifView = (GifImageView) findViewById(R.id.gifView); setTitle(bi.getFile()); -// imageView.setOnClickListener(new View.OnClickListener() { -// new TaskDownloadFile().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); downloadFile(); this.getSupportActionBar().setDisplayHomeAsUpEnabled(true); } |