-
Notifications
You must be signed in to change notification settings - Fork 46
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
8f6be29
commit 9c44f8d
Showing
25 changed files
with
455 additions
and
80 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
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
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
100 changes: 100 additions & 0 deletions
100
app/src/main/java/org/openobservatory/ooniprobe/activity/ResultActivity.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,100 @@ | ||
package org.openobservatory.ooniprobe.activity; | ||
|
||
import android.content.Intent; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v4.app.FragmentManager; | ||
import android.support.v4.app.FragmentTransaction; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.view.Menu; | ||
import org.openobservatory.ooniprobe.R; | ||
import org.openobservatory.ooniprobe.fragment.ResultFragment; | ||
import org.openobservatory.ooniprobe.fragment.ResultListFragment; | ||
import org.openobservatory.ooniprobe.utils.LogUtils; | ||
|
||
public class ResultActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_result); | ||
Intent intent = getIntent(); | ||
if(intent.getExtras() != null) { | ||
String json_file = intent.getStringExtra("json_file"); | ||
final String[] parts = LogUtils.getLogParts(this, json_file); | ||
if (parts.length == 1){ | ||
Fragment fragment = new ResultFragment(); | ||
FragmentManager fm= getSupportFragmentManager(); | ||
FragmentTransaction ft=fm.beginTransaction(); | ||
Bundle bundle = new Bundle(); | ||
bundle.putInt("position", 0); | ||
fragment.setArguments(bundle); | ||
//ft.remove(fragment); | ||
ft.add(R.id.fragment,fragment); | ||
//ft.replace(R.id.fragment, fragment); | ||
//ft.addToBackStack(null); | ||
ft.commit(); | ||
} | ||
else { | ||
Fragment fragment = new ResultListFragment(); | ||
FragmentManager fm= getSupportFragmentManager(); | ||
FragmentTransaction ft=fm.beginTransaction(); | ||
//ft.remove(fragment); | ||
ft.add(R.id.fragment,fragment); | ||
//ft.replace(R.id.fragment, fragment); | ||
//ft.addToBackStack(null); | ||
ft.commit(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
// Inflate the menu; this adds items to the action bar if it is present. | ||
//getMenuInflater().inflate(R.menu.menu_main, menu); | ||
return true; | ||
} | ||
/* | ||
@Override | ||
public void onBackPressed() { | ||
Fragment fragment=new Fragment1(); | ||
FragmentManager fm= getFragmentManager(); | ||
FragmentTransaction ft=fm.beginTransaction(); | ||
ft.replace(R.id.fragment,fragment); | ||
ft.commit(); | ||
} | ||
*/ | ||
/* | ||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle action bar item clicks here. The action bar will | ||
// automatically handle clicks on the Home/Up button, so long | ||
// as you specify a parent activity in AndroidManifest.xml. | ||
int id = item.getItemId(); | ||
//noinspection SimplifiableIfStatement | ||
if (id == R.id.action_settings) { | ||
Fragment fragment=new ResultListFragment(); | ||
FragmentManager fm= getSupportFragmentManager(); | ||
FragmentTransaction ft=fm.beginTransaction(); | ||
//ft.remove(fragment); | ||
ft.add(R.id.fragment,fragment); | ||
//ft.replace(R.id.fragment,fragment); | ||
ft.addToBackStack(null); | ||
ft.commit(); | ||
return true; | ||
} | ||
if(id == R.id.action_exit) | ||
{ | ||
android.os.Process.killProcess(android.os.Process.myPid()); | ||
System.exit(1); | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
*/ | ||
} |
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
123 changes: 123 additions & 0 deletions
123
app/src/main/java/org/openobservatory/ooniprobe/adapter/TestResultListAdapter.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,123 @@ | ||
package org.openobservatory.ooniprobe.adapter; | ||
|
||
import android.graphics.Typeface; | ||
import android.os.Bundle; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v4.app.FragmentActivity; | ||
import android.support.v4.app.FragmentManager; | ||
import android.support.v4.app.FragmentTransaction; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageButton; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
import org.openobservatory.ooniprobe.R; | ||
import org.openobservatory.ooniprobe.fragment.ResultFragment; | ||
import org.openobservatory.ooniprobe.fragment.ResultListFragment; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class TestResultListAdapter extends RecyclerView.Adapter<TestResultListAdapter.ViewHolder> { | ||
|
||
|
||
private static final String TAG = TestResultListAdapter.class.toString(); | ||
|
||
private FragmentActivity mActivity; | ||
private ArrayList<JSONObject> values; | ||
private int context; | ||
TestResultListAdapter.OnItemClickListener mItemClickListener; | ||
|
||
public TestResultListAdapter(FragmentActivity context, ArrayList<JSONObject> values) { | ||
this.mActivity = context; | ||
this.values = values; | ||
} | ||
|
||
@Override | ||
public TestResultListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_result_test, parent, false); | ||
TestResultListAdapter.ViewHolder vh = new ViewHolder(v); | ||
return vh; | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(TestResultListAdapter.ViewHolder holder, final int position) { | ||
final JSONObject i = values.get(position); | ||
Typeface font = Typeface.createFromAsset(mActivity.getAssets(), "fonts/HelveticaNeue-Roman.otf"); | ||
holder.txtTitle.setTypeface(font); | ||
System.out.println(i); | ||
try { | ||
holder.txtTitle.setText("input " + i.getString("input")); | ||
} catch (JSONException e) { | ||
holder.txtTitle.setText("input " + position); | ||
} | ||
try { | ||
if (!i.getJSONObject("test_keys").getBoolean("blocking")) | ||
holder.testStatus.setImageResource(R.drawable.censorship_no); | ||
else | ||
holder.testStatus.setImageResource(R.drawable.censorship_yes); | ||
} catch (JSONException e) { | ||
holder.testStatus.setImageResource(R.drawable.censorship_yes); | ||
} | ||
|
||
holder.itemView.setOnClickListener( | ||
new ImageButton.OnClickListener() { | ||
public void onClick(View v) { | ||
Fragment fragment = new ResultFragment(); | ||
Bundle bundle = new Bundle(); | ||
bundle.putInt("position", position); | ||
fragment.setArguments(bundle); | ||
FragmentManager fm = mActivity.getSupportFragmentManager(); | ||
FragmentTransaction ft=fm.beginTransaction(); | ||
ft.replace(R.id.fragment,fragment); | ||
ft.addToBackStack(null); | ||
ft.commit(); | ||
} | ||
} | ||
); | ||
|
||
|
||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return values.size(); | ||
} | ||
|
||
public void setData(ArrayList<JSONObject> data) { | ||
values = data; | ||
notifyDataSetChanged(); | ||
|
||
} | ||
|
||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { | ||
public TextView txtTitle; | ||
public ImageView testStatus; | ||
public ViewHolder(View itemView) { | ||
super(itemView); | ||
itemView.setOnClickListener(this); | ||
txtTitle = (TextView) itemView.findViewById(R.id.test_title); | ||
testStatus = (ImageView) itemView.findViewById(R.id.status_image); | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
if (mItemClickListener != null) { | ||
mItemClickListener.onItemClick(v, getAdapterPosition()); | ||
} | ||
} | ||
} | ||
|
||
public void setOnItemClickListener(final TestResultListAdapter.OnItemClickListener mItemClickListener) { | ||
this.mItemClickListener = mItemClickListener; | ||
} | ||
|
||
public interface OnItemClickListener { | ||
void onItemClick(View view, int position); | ||
} | ||
|
||
} | ||
|
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
Oops, something went wrong.