Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
wiiaam committed Jul 9, 2015
1 parent 8be2f98 commit 61e4326
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 12 deletions.
14 changes: 12 additions & 2 deletions app/src/main/java/io/github/wiiam/srhtapp/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
package io.github.wiiam.srhtapp;

import android.net.Uri;
import android.os.StrictMode;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.util.Linkify;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import org.json.JSONException;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;

import io.github.wiiam.srhtapp.config.Config;


Expand All @@ -33,11 +38,16 @@ protected void onCreate(Bundle savedInstanceState) {
} catch (IOException e) {
e.printStackTrace();
}
Toast.makeText(getApplicationContext(),"test",Toast.LENGTH_LONG).show();
//Toast.makeText(getApplicationContext(),"test",Toast.LENGTH_LONG).show();
ImageView bgimage = (ImageView)findViewById(R.id.bgimage);
int imageNumber = (int)Math.ceil(Math.random()*9)+1;
Log.d("IMAGEID","" + imageNumber);
//bgimage.setImageResource(R.drawable.2);


TextView getApiKey = (TextView) findViewById(R.id.getApiKey);
final EditText apiKey = (EditText) findViewById(R.id.apiKey);
apiKey.setText(Config.getApiKey());
getApiKey.setText("Your API key can be found at https://sr.ht under API Info");
Linkify.addLinks(getApiKey, Linkify.ALL);
Button set = (Button)findViewById(R.id.set);
set.setOnClickListener(new View.OnClickListener() {
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/java/io/github/wiiam/srhtapp/Share.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.github.wiiam.srhtapp;

import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
Expand Down Expand Up @@ -54,6 +56,10 @@ protected void onCreate(Bundle savedInstanceState) {
Toast.makeText(getApplicationContext(),"Uploading file...",Toast.LENGTH_SHORT).show();
String path = parseUriToFilename(uri);
String hostedurl = upload(path);
if(hostedurl != null) {
ClipData cd = ClipData.newPlainText("sr.ht link", hostedurl);
((ClipboardManager) getSystemService(CLIPBOARD_SERVICE)).setPrimaryClip(cd);
}
}
}
}
Expand Down Expand Up @@ -99,7 +105,7 @@ private String sendRequest(String url, String apikey, File file, String fileFiel
String lineEnd = "\r\n";
FileInputStream fileInputStream = new FileInputStream(file);


int fileSize = (int)file.length();
byte[] fileContent = new byte[fileSize];
fileInputStream.read(fileContent);//, 0, fileSize);
Expand Down
55 changes: 46 additions & 9 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,81 @@
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
android:id="@+id/mainactivity">
android:id="@+id/mainactivity"
android:background="#eee">

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/apiKey"
android:singleLine="true"
android:inputType="textNoSuggestions"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:singleLine="true"
android:inputType="textNoSuggestions"
android:layout_alignParentEnd="true" />
android:layout_toLeftOf="@+id/button"
android:layout_toStartOf="@+id/button" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Set"
android:id="@+id/set"
android:layout_below="@+id/apiKey"
android:layout_below="@+id/button"
android:layout_centerHorizontal="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text=""
android:text="Your API key can be found at https://sr.ht under API Info"
android:id="@+id/getApiKey"
android:gravity="center"
android:linksClickable="true"
android:longClickable="false"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Your API Key"
android:id="@+id/ApiKeyTitle"
android:layout_above="@+id/apiKey"
android:layout_marginTop="36dp"
android:layout_below="@+id/title"
android:layout_centerHorizontal="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="sr.ht"
android:id="@+id/title"
android:textSize="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="clear"
android:id="@+id/button"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/bgimage"
android:layout_alignRight="@+id/getApiKey"
android:layout_alignEnd="@+id/getApiKey"
android:layout_alignTop="@+id/title"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />

</RelativeLayout>

0 comments on commit 61e4326

Please sign in to comment.