-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32f6125
commit c79df9e
Showing
60 changed files
with
922 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
dependencies { | ||
compile 'com.squareup.picasso:picasso:2.5.2' | ||
compile 'com.squareup.retrofit2:converter-gson:2.1.0' | ||
} | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "25.0.2" | ||
|
||
defaultConfig { | ||
minSdkVersion 15 | ||
targetSdkVersion 25 | ||
applicationId "com.commonsware.android.netseccfg" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="com.commonsware.android.picasso" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:allowBackup="false" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:networkSecurityConfig="@xml/net_security_config" | ||
android:theme="@style/Theme.Apptheme"> | ||
<activity | ||
android:name="com.commonsware.android.picasso.MainActivity" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
26 changes: 26 additions & 0 deletions
26
SSL/NetSecCfg/app/src/main/java/com/commonsware/android/picasso/Item.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/*** | ||
Copyright (c) 2013 CommonsWare, LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required | ||
by applicable law or agreed to in writing, software distributed under the | ||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
OF ANY KIND, either express or implied. See the License for the specific | ||
language governing permissions and limitations under the License. | ||
Covered in detail in the book _The Busy Coder's Guide to Android Development_ | ||
https://commonsware.com/Android | ||
*/ | ||
|
||
package com.commonsware.android.picasso; | ||
|
||
public class Item { | ||
String title; | ||
Owner owner; | ||
String link; | ||
|
||
@Override | ||
public String toString() { | ||
return(title); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
SSL/NetSecCfg/app/src/main/java/com/commonsware/android/picasso/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*** | ||
Copyright (c) 2013-2014 CommonsWare, LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required | ||
by applicable law or agreed to in writing, software distributed under the | ||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
OF ANY KIND, either express or implied. See the License for the specific | ||
language governing permissions and limitations under the License. | ||
Covered in detail in the book _The Busy Coder's Guide to Android Development_ | ||
https://commonsware.com/Android | ||
*/ | ||
|
||
package com.commonsware.android.picasso; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
|
||
public class MainActivity extends Activity | ||
implements QuestionsFragment.Contract { | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
if (getFragmentManager().findFragmentById(android.R.id.content) == null) { | ||
getFragmentManager().beginTransaction() | ||
.add(android.R.id.content, | ||
new QuestionsFragment()).commit(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onQuestion(Item question) { | ||
startActivity(new Intent(Intent.ACTION_VIEW, | ||
Uri.parse(question.link))); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
SSL/NetSecCfg/app/src/main/java/com/commonsware/android/picasso/Owner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/*** | ||
Copyright (c) 2013 CommonsWare, LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required | ||
by applicable law or agreed to in writing, software distributed under the | ||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
OF ANY KIND, either express or implied. See the License for the specific | ||
language governing permissions and limitations under the License. | ||
Covered in detail in the book _The Busy Coder's Guide to Android Development_ | ||
https://commonsware.com/Android | ||
*/ | ||
|
||
package com.commonsware.android.picasso; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
public class Owner { | ||
@SerializedName("profile_image") String profileImage; | ||
} |
109 changes: 109 additions & 0 deletions
109
SSL/NetSecCfg/app/src/main/java/com/commonsware/android/picasso/QuestionsFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/*** | ||
Copyright (c) 2013-2014 CommonsWare, LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required | ||
by applicable law or agreed to in writing, software distributed under the | ||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
OF ANY KIND, either express or implied. See the License for the specific | ||
language governing permissions and limitations under the License. | ||
Covered in detail in the book _The Busy Coder's Guide to Android Development_ | ||
https://commonsware.com/Android | ||
*/ | ||
|
||
package com.commonsware.android.picasso; | ||
|
||
import android.app.ListFragment; | ||
import android.os.Bundle; | ||
import android.text.Html; | ||
import android.util.Log; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.ImageView; | ||
import android.widget.ListView; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
import com.squareup.picasso.Picasso; | ||
import java.util.List; | ||
import retrofit2.Call; | ||
import retrofit2.Callback; | ||
import retrofit2.Response; | ||
import retrofit2.Retrofit; | ||
import retrofit2.converter.gson.GsonConverterFactory; | ||
|
||
public class QuestionsFragment extends ListFragment implements | ||
Callback<SOQuestions> { | ||
public interface Contract { | ||
void onQuestion(Item question); | ||
} | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, | ||
ViewGroup container, | ||
Bundle savedInstanceState) { | ||
View result= | ||
super.onCreateView(inflater, container, savedInstanceState); | ||
|
||
setRetainInstance(true); | ||
|
||
Retrofit retrofit= | ||
new Retrofit.Builder() | ||
.baseUrl("https://api.stackexchange.com") | ||
.addConverterFactory(GsonConverterFactory.create()) | ||
.build(); | ||
StackOverflowInterface so= | ||
retrofit.create(StackOverflowInterface.class); | ||
|
||
so.questions("android").enqueue(this); | ||
|
||
return(result); | ||
} | ||
|
||
@Override | ||
public void onListItemClick(ListView l, View v, int position, long id) { | ||
Item item=((ItemsAdapter)getListAdapter()).getItem(position); | ||
|
||
((Contract)getActivity()).onQuestion(item); | ||
} | ||
|
||
@Override | ||
public void onResponse(Call<SOQuestions> call, | ||
Response<SOQuestions> response) { | ||
setListAdapter(new ItemsAdapter(response.body().items)); | ||
} | ||
|
||
@Override | ||
public void onFailure(Call<SOQuestions> call, Throwable t) { | ||
Toast.makeText(getActivity(), t.getMessage(), | ||
Toast.LENGTH_LONG).show(); | ||
Log.e(getClass().getSimpleName(), | ||
"Exception from Retrofit request to StackOverflow", t); | ||
} | ||
|
||
class ItemsAdapter extends ArrayAdapter<Item> { | ||
ItemsAdapter(List<Item> items) { | ||
super(getActivity(), R.layout.row, R.id.title, items); | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
View row=super.getView(position, convertView, parent); | ||
Item item=getItem(position); | ||
ImageView icon=(ImageView)row.findViewById(R.id.icon); | ||
|
||
Picasso.with(getActivity()).load(item.owner.profileImage) | ||
.fit().centerCrop() | ||
.placeholder(R.drawable.owner_placeholder) | ||
.error(R.drawable.owner_error).into(icon); | ||
|
||
TextView title=(TextView)row.findViewById(R.id.title); | ||
|
||
title.setText(Html.fromHtml(getItem(position).title)); | ||
|
||
return(row); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
SSL/NetSecCfg/app/src/main/java/com/commonsware/android/picasso/SOQuestions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/*** | ||
Copyright (c) 2013 CommonsWare, LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required | ||
by applicable law or agreed to in writing, software distributed under the | ||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
OF ANY KIND, either express or implied. See the License for the specific | ||
language governing permissions and limitations under the License. | ||
Covered in detail in the book _The Busy Coder's Guide to Android Development_ | ||
https://commonsware.com/Android | ||
*/ | ||
|
||
package com.commonsware.android.picasso; | ||
|
||
import java.util.List; | ||
|
||
public class SOQuestions { | ||
List<Item> items; | ||
} |
24 changes: 24 additions & 0 deletions
24
SSL/NetSecCfg/app/src/main/java/com/commonsware/android/picasso/StackOverflowInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/*** | ||
Copyright (c) 2013-2016 CommonsWare, LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required | ||
by applicable law or agreed to in writing, software distributed under the | ||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
OF ANY KIND, either express or implied. See the License for the specific | ||
language governing permissions and limitations under the License. | ||
Covered in detail in the book _The Busy Coder's Guide to Android Development_ | ||
https://commonsware.com/Android | ||
*/ | ||
|
||
package com.commonsware.android.picasso; | ||
|
||
import retrofit2.Call; | ||
import retrofit2.http.GET; | ||
import retrofit2.http.Query; | ||
|
||
public interface StackOverflowInterface { | ||
@GET("/2.1/questions?order=desc&sort=creation&site=stackoverflow") | ||
Call<SOQuestions> questions(@Query("tagged") String tags); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal"> | ||
|
||
<ImageView | ||
android:id="@+id/icon" | ||
android:layout_width="@dimen/icon" | ||
android:layout_height="@dimen/icon" | ||
android:layout_gravity="center_vertical" | ||
android:contentDescription="@string/icon" | ||
android:padding="8dip"/> | ||
|
||
<TextView | ||
android:id="@+id/title" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textSize="20sp" | ||
android:layout_gravity="left|center_vertical"/> | ||
|
||
</LinearLayout> |
Binary file added
BIN
+969 Bytes
SSL/NetSecCfg/app/src/main/res/raw/digicert_high_assurance_ev_root_ca.crt
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx | ||
EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R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J6raBKZV8aPEjoJpL1E/QYVN8Gb5DKj7Tjo | ||
2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO | ||
LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI | ||
4uJEvlz36hz1 | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="primary">#3f51b5</color> | ||
<color name="primary_dark">#1a237e</color> | ||
<color name="accent">#ffee58</color> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<style name="Theme.Apptheme" parent="android:Theme.Material.Light.DarkActionBar"> | ||
<item name="android:colorPrimary">@color/primary</item> | ||
<item name="android:colorPrimaryDark">@color/primary_dark</item> | ||
<item name="android:colorAccent">@color/accent</item> | ||
</style> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<dimen name="icon">48dp</dimen> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<string name="app_name">Picasso Demo</string> | ||
<string name="icon">Owner Icon</string> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<style name="Theme.Apptheme" parent="@android:style/Theme.Holo.Light.DarkActionBar"> | ||
</style> | ||
|
||
<style name="activated" parent="Theme.Apptheme"> | ||
<item name="android:background">?android:attr/activatedBackgroundIndicator</item> | ||
</style> | ||
|
||
</resources> |
14 changes: 14 additions & 0 deletions
14
SSL/NetSecCfg/app/src/main/res/xml/net_security_config.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<network-security-config> | ||
<domain-config> | ||
<domain includeSubdomains="false">api.stackexchange.com</domain> | ||
<trust-anchors> | ||
<certificates src="@raw/digicert_high_assurance_ev_root_ca" /> | ||
</trust-anchors> | ||
</domain-config> | ||
<base-config> | ||
<trust-anchors> | ||
<certificates src="system" /> | ||
</trust-anchors> | ||
</base-config> | ||
</network-security-config> |
Oops, something went wrong.