Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
p13i committed Jul 11, 2019
1 parent fc3dbd6 commit ad5208f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion glass/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "io.p13i.glassnotes.template"
applicationId "io.p13i.glassnotes"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,35 @@
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

import java.io.IOException;
import java.lang.reflect.Type;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.Map;

import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class ClientFactory {
public static OkHttpClient getOkHttpClient() {
public static OkHttpClient getOkHttpClientWithAuthorizationHeader(final String authorizationHeaderValue) {

OkHttpClient httpClient = new OkHttpClient();
try {
httpClient = new OkHttpClient.Builder()
.sslSocketFactory(new TLSSocketFactory())
.addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request()
.newBuilder()
.addHeader("Authorization", authorizationHeaderValue).build();
return chain.proceed(request);
}
})
.build();
} catch (KeyManagementException e) {
e.printStackTrace();
Expand Down Expand Up @@ -53,10 +66,10 @@ public JsonElement serialize(Gist src, Type typeOfSrc, JsonSerializationContext
.create();
}

public static GitHubClient getGitHubClient() {
public static GitHubClient getGitHubClient(String authorizationToken) {
return new Retrofit.Builder()
.baseUrl("https://api.github.com")
.client(getOkHttpClient())
.client(getOkHttpClientWithAuthorizationHeader("token " + authorizationToken))
.addConverterFactory(GsonConverterFactory.create(getGson()))
.build()
.create(GitHubClient.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@
import retrofit2.http.Path;

public interface GitHubClient {
@Headers(Preferences.GITHUB_OAUTH_AUTH_HEADER)
@GET("/gists")
Call<List<Gist>> getGists();

@Headers(Preferences.GITHUB_OAUTH_AUTH_HEADER)
@POST("/gists")
Call<Gist> postGist(@Body Gist gist);

@Headers(Preferences.GITHUB_OAUTH_AUTH_HEADER)
@GET("/gists/{gistId}")
Call<Gist> getGist(@Path("gistId") String gistId);

@Headers(Preferences.GITHUB_OAUTH_AUTH_HEADER)
@PATCH("/gists/{gistId}")
Call<Note> patchGist(@Path("gistId") String gistId, @Body Gist gist);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@
public class GlassNotesGitHubAPIClient implements GlassNotesDataStore {
public static final String TAG = GlassNotesGitHubAPIClient.class.getName();

GitHubClient mGitHubClient;

public GlassNotesGitHubAPIClient(String authorizationTokenValue) {
mGitHubClient = ClientFactory.getGitHubClient( authorizationTokenValue);
}

@Override
public String getShortName() {
return "GitHub";
}

@Override
public void createNote(Note note, final Promise<Note> promise) {
ClientFactory.getGitHubClient().postGist(note.asGist()).enqueue(new Callback<Gist>() {
mGitHubClient.postGist(note.asGist()).enqueue(new Callback<Gist>() {
@Override
public void onResponse(Call<Gist> call, Response<Gist> response) {
Gist gist = response.body();
Expand All @@ -35,8 +41,7 @@ public void onFailure(Call<Gist> call, Throwable t) {
}

public void getNotes(final Promise<List<Note>> promise) {
GitHubClient client = ClientFactory.getGitHubClient();
client.getGists().enqueue(new Callback<List<Gist>>() {
mGitHubClient.getGists().enqueue(new Callback<List<Gist>>() {
@Override
public void onResponse(Call<List<Gist>> call, Response<List<Gist>> response) {
List<Note> notes = new ArrayList<Note>();
Expand All @@ -57,8 +62,7 @@ public void onFailure(Call<List<Gist>> call, Throwable t) {
}

public void getNote(String id, final Promise<Note> promise) {
GitHubClient client = ClientFactory.getGitHubClient();
client.getGist(id).enqueue(new Callback<Gist>() {
mGitHubClient.getGist(id).enqueue(new Callback<Gist>() {
@Override
public void onResponse(Call<Gist> call, Response<Gist> response) {
Gist gist = response.body();
Expand All @@ -74,9 +78,7 @@ public void onFailure(Call<Gist> call, Throwable t) {
}

public void saveNote(Note note, final Promise<Note> promise) {
GitHubClient client = ClientFactory.getGitHubClient();

client.patchGist(note.getId(), note.asGist()).enqueue(new Callback<Note>() {
mGitHubClient.patchGist(note.getId(), note.asGist()).enqueue(new Callback<Note>() {
@Override
public void onResponse(Call<Note> call, Response<Note> response) {
promise.resolved(response.body());
Expand Down
3 changes: 3 additions & 0 deletions glass/src/main/java/io/p13i/glassnotes/ui/StatusTextView.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;

Expand Down Expand Up @@ -39,6 +40,8 @@ protected void onDraw(Canvas canvas) {

// EEE, MMM dd, yyyy @
String now = DateUtilities.nowAs("KK:mm:ss a");
setTypeface(Typeface.MONOSPACE);
setTextSize(16f);

setText(getShortPageTitle(mCurrentPageTitleStartingIndex) + " | " + now + " | " + mStatus);

Expand Down
3 changes: 3 additions & 0 deletions glass/src/main/res/layout/activity_edit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
android:inputType="textFilter|textMultiLine|textNoSuggestions"
android:padding="2dp"
android:layout_weight="10"
android:typeface="monospace"
android:textColor="@color/white"
android:textSize="12sp"
android:textCursorDrawable="@null"
tools:ignore="SmallSp"
android:layout_height="0dp" />
Expand Down
2 changes: 1 addition & 1 deletion glass/src/main/res/xml/voice_trigger.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<!-- For more information about voice trigger, check out: https://developers.google.com/glass/develop/gdk/starting-glassware -->
<trigger command="RUN_AN_EXPERIMENT" />
<trigger command="TAKE_A_NOTE" />

0 comments on commit ad5208f

Please sign in to comment.